babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166
  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. readonly 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 readonly 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 LogLevels: 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/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/webRequest" {
  410. /**
  411. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  412. */
  413. export class WebRequest {
  414. private _xhr;
  415. /**
  416. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  417. * i.e. when loading files, where the server/service expects an Authorization header
  418. */
  419. static CustomRequestHeaders: {
  420. [key: string]: string;
  421. };
  422. /**
  423. * Add callback functions in this array to update all the requests before they get sent to the network
  424. */
  425. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  426. private _injectCustomRequestHeaders;
  427. /**
  428. * Gets or sets a function to be called when loading progress changes
  429. */
  430. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  431. /**
  432. * Returns client's state
  433. */
  434. readonly readyState: number;
  435. /**
  436. * Returns client's status
  437. */
  438. readonly status: number;
  439. /**
  440. * Returns client's status as a text
  441. */
  442. readonly statusText: string;
  443. /**
  444. * Returns client's response
  445. */
  446. readonly response: any;
  447. /**
  448. * Returns client's response url
  449. */
  450. readonly responseURL: string;
  451. /**
  452. * Returns client's response as text
  453. */
  454. readonly responseText: string;
  455. /**
  456. * Gets or sets the expected response type
  457. */
  458. responseType: XMLHttpRequestResponseType;
  459. /** @hidden */
  460. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  461. /** @hidden */
  462. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  463. /**
  464. * Cancels any network activity
  465. */
  466. abort(): void;
  467. /**
  468. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  469. * @param body defines an optional request body
  470. */
  471. send(body?: Document | BodyInit | null): void;
  472. /**
  473. * Sets the request method, request URL
  474. * @param method defines the method to use (GET, POST, etc..)
  475. * @param url defines the url to connect with
  476. */
  477. open(method: string, url: string): void;
  478. }
  479. }
  480. declare module "babylonjs/Misc/fileRequest" {
  481. import { Observable } from "babylonjs/Misc/observable";
  482. /**
  483. * File request interface
  484. */
  485. export interface IFileRequest {
  486. /**
  487. * Raised when the request is complete (success or error).
  488. */
  489. onCompleteObservable: Observable<IFileRequest>;
  490. /**
  491. * Aborts the request for a file.
  492. */
  493. abort: () => void;
  494. }
  495. }
  496. declare module "babylonjs/Maths/math.scalar" {
  497. /**
  498. * Scalar computation library
  499. */
  500. export class Scalar {
  501. /**
  502. * Two pi constants convenient for computation.
  503. */
  504. static TwoPi: number;
  505. /**
  506. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  507. * @param a number
  508. * @param b number
  509. * @param epsilon (default = 1.401298E-45)
  510. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  511. */
  512. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  513. /**
  514. * Returns a string : the upper case translation of the number i to hexadecimal.
  515. * @param i number
  516. * @returns the upper case translation of the number i to hexadecimal.
  517. */
  518. static ToHex(i: number): string;
  519. /**
  520. * Returns -1 if value is negative and +1 is value is positive.
  521. * @param value the value
  522. * @returns the value itself if it's equal to zero.
  523. */
  524. static Sign(value: number): number;
  525. /**
  526. * Returns the value itself if it's between min and max.
  527. * Returns min if the value is lower than min.
  528. * Returns max if the value is greater than max.
  529. * @param value the value to clmap
  530. * @param min the min value to clamp to (default: 0)
  531. * @param max the max value to clamp to (default: 1)
  532. * @returns the clamped value
  533. */
  534. static Clamp(value: number, min?: number, max?: number): number;
  535. /**
  536. * the log2 of value.
  537. * @param value the value to compute log2 of
  538. * @returns the log2 of value.
  539. */
  540. static Log2(value: number): number;
  541. /**
  542. * Loops the value, so that it is never larger than length and never smaller than 0.
  543. *
  544. * This is similar to the modulo operator but it works with floating point numbers.
  545. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  546. * With t = 5 and length = 2.5, the result would be 0.0.
  547. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  548. * @param value the value
  549. * @param length the length
  550. * @returns the looped value
  551. */
  552. static Repeat(value: number, length: number): number;
  553. /**
  554. * Normalize the value between 0.0 and 1.0 using min and max values
  555. * @param value value to normalize
  556. * @param min max to normalize between
  557. * @param max min to normalize between
  558. * @returns the normalized value
  559. */
  560. static Normalize(value: number, min: number, max: number): number;
  561. /**
  562. * Denormalize the value from 0.0 and 1.0 using min and max values
  563. * @param normalized value to denormalize
  564. * @param min max to denormalize between
  565. * @param max min to denormalize between
  566. * @returns the denormalized value
  567. */
  568. static Denormalize(normalized: number, min: number, max: number): number;
  569. /**
  570. * Calculates the shortest difference between two given angles given in degrees.
  571. * @param current current angle in degrees
  572. * @param target target angle in degrees
  573. * @returns the delta
  574. */
  575. static DeltaAngle(current: number, target: number): number;
  576. /**
  577. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  578. * @param tx value
  579. * @param length length
  580. * @returns The returned value will move back and forth between 0 and length
  581. */
  582. static PingPong(tx: number, length: number): number;
  583. /**
  584. * Interpolates between min and max with smoothing at the limits.
  585. *
  586. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  587. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  588. * @param from from
  589. * @param to to
  590. * @param tx value
  591. * @returns the smooth stepped value
  592. */
  593. static SmoothStep(from: number, to: number, tx: number): number;
  594. /**
  595. * Moves a value current towards target.
  596. *
  597. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  598. * Negative values of maxDelta pushes the value away from target.
  599. * @param current current value
  600. * @param target target value
  601. * @param maxDelta max distance to move
  602. * @returns resulting value
  603. */
  604. static MoveTowards(current: number, target: number, maxDelta: number): number;
  605. /**
  606. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  607. *
  608. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  609. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  610. * @param current current value
  611. * @param target target value
  612. * @param maxDelta max distance to move
  613. * @returns resulting angle
  614. */
  615. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  616. /**
  617. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  618. * @param start start value
  619. * @param end target value
  620. * @param amount amount to lerp between
  621. * @returns the lerped value
  622. */
  623. static Lerp(start: number, end: number, amount: number): number;
  624. /**
  625. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  626. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  627. * @param start start value
  628. * @param end target value
  629. * @param amount amount to lerp between
  630. * @returns the lerped value
  631. */
  632. static LerpAngle(start: number, end: number, amount: number): number;
  633. /**
  634. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  635. * @param a start value
  636. * @param b target value
  637. * @param value value between a and b
  638. * @returns the inverseLerp value
  639. */
  640. static InverseLerp(a: number, b: number, value: number): number;
  641. /**
  642. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  643. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  644. * @param value1 spline value
  645. * @param tangent1 spline value
  646. * @param value2 spline value
  647. * @param tangent2 spline value
  648. * @param amount input value
  649. * @returns hermite result
  650. */
  651. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  652. /**
  653. * Returns a random float number between and min and max values
  654. * @param min min value of random
  655. * @param max max value of random
  656. * @returns random value
  657. */
  658. static RandomRange(min: number, max: number): number;
  659. /**
  660. * This function returns percentage of a number in a given range.
  661. *
  662. * RangeToPercent(40,20,60) will return 0.5 (50%)
  663. * RangeToPercent(34,0,100) will return 0.34 (34%)
  664. * @param number to convert to percentage
  665. * @param min min range
  666. * @param max max range
  667. * @returns the percentage
  668. */
  669. static RangeToPercent(number: number, min: number, max: number): number;
  670. /**
  671. * This function returns number that corresponds to the percentage in a given range.
  672. *
  673. * PercentToRange(0.34,0,100) will return 34.
  674. * @param percent to convert to number
  675. * @param min min range
  676. * @param max max range
  677. * @returns the number
  678. */
  679. static PercentToRange(percent: number, min: number, max: number): number;
  680. /**
  681. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  682. * @param angle The angle to normalize in radian.
  683. * @return The converted angle.
  684. */
  685. static NormalizeRadians(angle: number): number;
  686. }
  687. }
  688. declare module "babylonjs/Maths/math.constants" {
  689. /**
  690. * Constant used to convert a value to gamma space
  691. * @ignorenaming
  692. */
  693. export const ToGammaSpace: number;
  694. /**
  695. * Constant used to convert a value to linear space
  696. * @ignorenaming
  697. */
  698. export const ToLinearSpace = 2.2;
  699. /**
  700. * Constant used to define the minimal number value in Babylon.js
  701. * @ignorenaming
  702. */
  703. let Epsilon: number;
  704. export { Epsilon };
  705. }
  706. declare module "babylonjs/Maths/math.viewport" {
  707. /**
  708. * Class used to represent a viewport on screen
  709. */
  710. export class Viewport {
  711. /** viewport left coordinate */
  712. x: number;
  713. /** viewport top coordinate */
  714. y: number;
  715. /**viewport width */
  716. width: number;
  717. /** viewport height */
  718. height: number;
  719. /**
  720. * Creates a Viewport object located at (x, y) and sized (width, height)
  721. * @param x defines viewport left coordinate
  722. * @param y defines viewport top coordinate
  723. * @param width defines the viewport width
  724. * @param height defines the viewport height
  725. */
  726. constructor(
  727. /** viewport left coordinate */
  728. x: number,
  729. /** viewport top coordinate */
  730. y: number,
  731. /**viewport width */
  732. width: number,
  733. /** viewport height */
  734. height: number);
  735. /**
  736. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  737. * @param renderWidth defines the rendering width
  738. * @param renderHeight defines the rendering height
  739. * @returns a new Viewport
  740. */
  741. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  742. /**
  743. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  744. * @param renderWidth defines the rendering width
  745. * @param renderHeight defines the rendering height
  746. * @param ref defines the target viewport
  747. * @returns the current viewport
  748. */
  749. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  750. /**
  751. * Returns a new Viewport copied from the current one
  752. * @returns a new Viewport
  753. */
  754. clone(): Viewport;
  755. }
  756. }
  757. declare module "babylonjs/Misc/arrayTools" {
  758. /**
  759. * Class containing a set of static utilities functions for arrays.
  760. */
  761. export class ArrayTools {
  762. /**
  763. * Returns an array of the given size filled with element built from the given constructor and the paramters
  764. * @param size the number of element to construct and put in the array
  765. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  766. * @returns a new array filled with new objects
  767. */
  768. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  769. }
  770. }
  771. declare module "babylonjs/Maths/math.like" {
  772. import { float, int, DeepImmutable } from "babylonjs/types";
  773. /**
  774. * @hidden
  775. */
  776. export interface IColor4Like {
  777. r: float;
  778. g: float;
  779. b: float;
  780. a: float;
  781. }
  782. /**
  783. * @hidden
  784. */
  785. export interface IColor3Like {
  786. r: float;
  787. g: float;
  788. b: float;
  789. }
  790. /**
  791. * @hidden
  792. */
  793. export interface IVector4Like {
  794. x: float;
  795. y: float;
  796. z: float;
  797. w: float;
  798. }
  799. /**
  800. * @hidden
  801. */
  802. export interface IVector3Like {
  803. x: float;
  804. y: float;
  805. z: float;
  806. }
  807. /**
  808. * @hidden
  809. */
  810. export interface IVector2Like {
  811. x: float;
  812. y: float;
  813. }
  814. /**
  815. * @hidden
  816. */
  817. export interface IMatrixLike {
  818. toArray(): DeepImmutable<Float32Array>;
  819. updateFlag: int;
  820. }
  821. /**
  822. * @hidden
  823. */
  824. export interface IViewportLike {
  825. x: float;
  826. y: float;
  827. width: float;
  828. height: float;
  829. }
  830. /**
  831. * @hidden
  832. */
  833. export interface IPlaneLike {
  834. normal: IVector3Like;
  835. d: float;
  836. normalize(): void;
  837. }
  838. }
  839. declare module "babylonjs/Maths/math.vector" {
  840. import { Viewport } from "babylonjs/Maths/math.viewport";
  841. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  842. import { IPlaneLike } from "babylonjs/Maths/math.like";
  843. /**
  844. * Class representing a vector containing 2 coordinates
  845. */
  846. export class Vector2 {
  847. /** defines the first coordinate */
  848. x: number;
  849. /** defines the second coordinate */
  850. y: number;
  851. /**
  852. * Creates a new Vector2 from the given x and y coordinates
  853. * @param x defines the first coordinate
  854. * @param y defines the second coordinate
  855. */
  856. constructor(
  857. /** defines the first coordinate */
  858. x?: number,
  859. /** defines the second coordinate */
  860. y?: number);
  861. /**
  862. * Gets a string with the Vector2 coordinates
  863. * @returns a string with the Vector2 coordinates
  864. */
  865. toString(): string;
  866. /**
  867. * Gets class name
  868. * @returns the string "Vector2"
  869. */
  870. getClassName(): string;
  871. /**
  872. * Gets current vector hash code
  873. * @returns the Vector2 hash code as a number
  874. */
  875. getHashCode(): number;
  876. /**
  877. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  878. * @param array defines the source array
  879. * @param index defines the offset in source array
  880. * @returns the current Vector2
  881. */
  882. toArray(array: FloatArray, index?: number): Vector2;
  883. /**
  884. * Copy the current vector to an array
  885. * @returns a new array with 2 elements: the Vector2 coordinates.
  886. */
  887. asArray(): number[];
  888. /**
  889. * Sets the Vector2 coordinates with the given Vector2 coordinates
  890. * @param source defines the source Vector2
  891. * @returns the current updated Vector2
  892. */
  893. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. copyFromFloats(x: number, y: number): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. set(x: number, y: number): Vector2;
  908. /**
  909. * Add another vector with the current one
  910. * @param otherVector defines the other vector
  911. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  912. */
  913. add(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  916. * @param otherVector defines the other vector
  917. * @param result defines the target vector
  918. * @returns the unmodified current Vector2
  919. */
  920. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  921. /**
  922. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  923. * @param otherVector defines the other vector
  924. * @returns the current updated Vector2
  925. */
  926. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  927. /**
  928. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  929. * @param otherVector defines the other vector
  930. * @returns a new Vector2
  931. */
  932. addVector3(otherVector: Vector3): Vector2;
  933. /**
  934. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  935. * @param otherVector defines the other vector
  936. * @returns a new Vector2
  937. */
  938. subtract(otherVector: Vector2): Vector2;
  939. /**
  940. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  941. * @param otherVector defines the other vector
  942. * @param result defines the target vector
  943. * @returns the unmodified current Vector2
  944. */
  945. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  946. /**
  947. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns the current updated Vector2
  950. */
  951. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Multiplies in place the current Vector2 coordinates by the given ones
  954. * @param otherVector defines the other vector
  955. * @returns the current updated Vector2
  956. */
  957. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  958. /**
  959. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  960. * @param otherVector defines the other vector
  961. * @returns a new Vector2
  962. */
  963. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  964. /**
  965. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  966. * @param otherVector defines the other vector
  967. * @param result defines the target vector
  968. * @returns the unmodified current Vector2
  969. */
  970. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  971. /**
  972. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  973. * @param x defines the first coordinate
  974. * @param y defines the second coordinate
  975. * @returns a new Vector2
  976. */
  977. multiplyByFloats(x: number, y: number): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. divide(otherVector: Vector2): Vector2;
  984. /**
  985. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  986. * @param otherVector defines the other vector
  987. * @param result defines the target vector
  988. * @returns the unmodified current Vector2
  989. */
  990. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Divides the current Vector2 coordinates by the given ones
  993. * @param otherVector defines the other vector
  994. * @returns the current updated Vector2
  995. */
  996. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  997. /**
  998. * Gets a new Vector2 with current Vector2 negated coordinates
  999. * @returns a new Vector2
  1000. */
  1001. negate(): Vector2;
  1002. /**
  1003. * Multiply the Vector2 coordinates by scale
  1004. * @param scale defines the scaling factor
  1005. * @returns the current updated Vector2
  1006. */
  1007. scaleInPlace(scale: number): Vector2;
  1008. /**
  1009. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1010. * @param scale defines the scaling factor
  1011. * @returns a new Vector2
  1012. */
  1013. scale(scale: number): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Gets a boolean if two vectors are equals
  1030. * @param otherVector defines the other vector
  1031. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1032. */
  1033. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1034. /**
  1035. * Gets a boolean if two vectors are equals (using an epsilon value)
  1036. * @param otherVector defines the other vector
  1037. * @param epsilon defines the minimal distance to consider equality
  1038. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1039. */
  1040. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1041. /**
  1042. * Gets a new Vector2 from current Vector2 floored values
  1043. * @returns a new Vector2
  1044. */
  1045. floor(): Vector2;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. fract(): Vector2;
  1051. /**
  1052. * Gets the length of the vector
  1053. * @returns the vector length (float)
  1054. */
  1055. length(): number;
  1056. /**
  1057. * Gets the vector squared length
  1058. * @returns the vector squared length (float)
  1059. */
  1060. lengthSquared(): number;
  1061. /**
  1062. * Normalize the vector
  1063. * @returns the current updated Vector2
  1064. */
  1065. normalize(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 copied from the Vector2
  1068. * @returns a new Vector2
  1069. */
  1070. clone(): Vector2;
  1071. /**
  1072. * Gets a new Vector2(0, 0)
  1073. * @returns a new Vector2
  1074. */
  1075. static Zero(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(1, 1)
  1078. * @returns a new Vector2
  1079. */
  1080. static One(): Vector2;
  1081. /**
  1082. * Gets a new Vector2 set from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @returns a new Vector2
  1086. */
  1087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1088. /**
  1089. * Sets "result" from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @param result defines the target vector
  1093. */
  1094. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1095. /**
  1096. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1097. * @param value1 defines 1st point of control
  1098. * @param value2 defines 2nd point of control
  1099. * @param value3 defines 3rd point of control
  1100. * @param value4 defines 4th point of control
  1101. * @param amount defines the interpolation factor
  1102. * @returns a new Vector2
  1103. */
  1104. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1105. /**
  1106. * 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".
  1107. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1108. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1109. * @param value defines the value to clamp
  1110. * @param min defines the lower limit
  1111. * @param max defines the upper limit
  1112. * @returns a new Vector2
  1113. */
  1114. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1115. /**
  1116. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1117. * @param value1 defines the 1st control point
  1118. * @param tangent1 defines the outgoing tangent
  1119. * @param value2 defines the 2nd control point
  1120. * @param tangent2 defines the incoming tangent
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1127. * @param start defines the start vector
  1128. * @param end defines the end vector
  1129. * @param amount defines the interpolation factor
  1130. * @returns a new Vector2
  1131. */
  1132. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1133. /**
  1134. * Gets the dot product of the vector "left" and the vector "right"
  1135. * @param left defines first vector
  1136. * @param right defines second vector
  1137. * @returns the dot product (float)
  1138. */
  1139. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1140. /**
  1141. * Returns a new Vector2 equal to the normalized given vector
  1142. * @param vector defines the vector to normalize
  1143. * @returns a new Vector2
  1144. */
  1145. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @returns a new Vector2
  1165. */
  1166. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1167. /**
  1168. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @param result defines the target vector
  1172. */
  1173. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1174. /**
  1175. * Determines if a given vector is included in a triangle
  1176. * @param p defines the vector to test
  1177. * @param p0 defines 1st triangle point
  1178. * @param p1 defines 2nd triangle point
  1179. * @param p2 defines 3rd triangle point
  1180. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1181. */
  1182. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1183. /**
  1184. * Gets the distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the distance between vectors
  1188. */
  1189. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Returns the squared distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the squared distance between vectors
  1195. */
  1196. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns a new Vector2
  1202. */
  1203. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1204. /**
  1205. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1206. * @param p defines the middle point
  1207. * @param segA defines one point of the segment
  1208. * @param segB defines the other point of the segment
  1209. * @returns the shortest distance
  1210. */
  1211. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1212. }
  1213. /**
  1214. * Classed used to store (x,y,z) vector representation
  1215. * A Vector3 is the main object used in 3D geometry
  1216. * It can represent etiher the coordinates of a point the space, either a direction
  1217. * Reminder: js uses a left handed forward facing system
  1218. */
  1219. export class Vector3 {
  1220. /**
  1221. * Defines the first coordinates (on X axis)
  1222. */
  1223. x: number;
  1224. /**
  1225. * Defines the second coordinates (on Y axis)
  1226. */
  1227. y: number;
  1228. /**
  1229. * Defines the third coordinates (on Z axis)
  1230. */
  1231. z: number;
  1232. private static _UpReadOnly;
  1233. private static _ZeroReadOnly;
  1234. /**
  1235. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1236. * @param x defines the first coordinates (on X axis)
  1237. * @param y defines the second coordinates (on Y axis)
  1238. * @param z defines the third coordinates (on Z axis)
  1239. */
  1240. constructor(
  1241. /**
  1242. * Defines the first coordinates (on X axis)
  1243. */
  1244. x?: number,
  1245. /**
  1246. * Defines the second coordinates (on Y axis)
  1247. */
  1248. y?: number,
  1249. /**
  1250. * Defines the third coordinates (on Z axis)
  1251. */
  1252. z?: number);
  1253. /**
  1254. * Creates a string representation of the Vector3
  1255. * @returns a string with the Vector3 coordinates.
  1256. */
  1257. toString(): string;
  1258. /**
  1259. * Gets the class name
  1260. * @returns the string "Vector3"
  1261. */
  1262. getClassName(): string;
  1263. /**
  1264. * Creates the Vector3 hash code
  1265. * @returns a number which tends to be unique between Vector3 instances
  1266. */
  1267. getHashCode(): number;
  1268. /**
  1269. * Creates an array containing three elements : the coordinates of the Vector3
  1270. * @returns a new array of numbers
  1271. */
  1272. asArray(): number[];
  1273. /**
  1274. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1275. * @param array defines the destination array
  1276. * @param index defines the offset in the destination array
  1277. * @returns the current Vector3
  1278. */
  1279. toArray(array: FloatArray, index?: number): Vector3;
  1280. /**
  1281. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1282. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1283. */
  1284. toQuaternion(): Quaternion;
  1285. /**
  1286. * Adds the given vector to the current Vector3
  1287. * @param otherVector defines the second operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the given coordinates to the current Vector3
  1293. * @param x defines the x coordinate of the operand
  1294. * @param y defines the y coordinate of the operand
  1295. * @param z defines the z coordinate of the operand
  1296. * @returns the current updated Vector3
  1297. */
  1298. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1299. /**
  1300. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1301. * @param otherVector defines the second operand
  1302. * @returns the resulting Vector3
  1303. */
  1304. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1307. * @param otherVector defines the second operand
  1308. * @param result defines the Vector3 object where to store the result
  1309. * @returns the current Vector3
  1310. */
  1311. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1312. /**
  1313. * Subtract the given vector from the current Vector3
  1314. * @param otherVector defines the second operand
  1315. * @returns the current updated Vector3
  1316. */
  1317. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1318. /**
  1319. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1320. * @param otherVector defines the second operand
  1321. * @returns the resulting Vector3
  1322. */
  1323. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1324. /**
  1325. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1326. * @param otherVector defines the second operand
  1327. * @param result defines the Vector3 object where to store the result
  1328. * @returns the current Vector3
  1329. */
  1330. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1331. /**
  1332. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @returns the resulting Vector3
  1337. */
  1338. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1339. /**
  1340. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1341. * @param x defines the x coordinate of the operand
  1342. * @param y defines the y coordinate of the operand
  1343. * @param z defines the z coordinate of the operand
  1344. * @param result defines the Vector3 object where to store the result
  1345. * @returns the current Vector3
  1346. */
  1347. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1348. /**
  1349. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1350. * @returns a new Vector3
  1351. */
  1352. negate(): Vector3;
  1353. /**
  1354. * Multiplies the Vector3 coordinates by the float "scale"
  1355. * @param scale defines the multiplier factor
  1356. * @returns the current updated Vector3
  1357. */
  1358. scaleInPlace(scale: number): Vector3;
  1359. /**
  1360. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1361. * @param scale defines the multiplier factor
  1362. * @returns a new Vector3
  1363. */
  1364. scale(scale: number): Vector3;
  1365. /**
  1366. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1367. * @param scale defines the multiplier factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the current Vector3
  1370. */
  1371. scaleToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1374. * @param scale defines the scale factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the unmodified current Vector3
  1377. */
  1378. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1381. * @param otherVector defines the second operand
  1382. * @returns true if both vectors are equals
  1383. */
  1384. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1387. * @param otherVector defines the second operand
  1388. * @param epsilon defines the minimal distance to define values as equals
  1389. * @returns true if both vectors are distant less than epsilon
  1390. */
  1391. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 coordinates equals the given floats
  1394. * @param x defines the x coordinate of the operand
  1395. * @param y defines the y coordinate of the operand
  1396. * @param z defines the z coordinate of the operand
  1397. * @returns true if both vectors are equals
  1398. */
  1399. equalsToFloats(x: number, y: number, z: number): boolean;
  1400. /**
  1401. * Multiplies the current Vector3 coordinates by the given ones
  1402. * @param otherVector defines the second operand
  1403. * @returns the current updated Vector3
  1404. */
  1405. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1406. /**
  1407. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1408. * @param otherVector defines the second operand
  1409. * @returns the new Vector3
  1410. */
  1411. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1412. /**
  1413. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1414. * @param otherVector defines the second operand
  1415. * @param result defines the Vector3 object where to store the result
  1416. * @returns the current Vector3
  1417. */
  1418. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1421. * @param x defines the x coordinate of the operand
  1422. * @param y defines the y coordinate of the operand
  1423. * @param z defines the z coordinate of the operand
  1424. * @returns the new Vector3
  1425. */
  1426. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1427. /**
  1428. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1429. * @param otherVector defines the second operand
  1430. * @returns the new Vector3
  1431. */
  1432. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1435. * @param otherVector defines the second operand
  1436. * @param result defines the Vector3 object where to store the result
  1437. * @returns the current Vector3
  1438. */
  1439. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones.
  1442. * @param otherVector defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. divideInPlace(otherVector: Vector3): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1448. * @param other defines the second operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1454. * @param other defines the second operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1468. * @param x defines the x coordinate of the operand
  1469. * @param y defines the y coordinate of the operand
  1470. * @param z defines the z coordinate of the operand
  1471. * @returns the current updated Vector3
  1472. */
  1473. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1474. /**
  1475. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1476. * Check if is non uniform within a certain amount of decimal places to account for this
  1477. * @param epsilon the amount the values can differ
  1478. * @returns if the the vector is non uniform to a certain number of decimal places
  1479. */
  1480. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1481. /**
  1482. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1483. */
  1484. readonly isNonUniform: boolean;
  1485. /**
  1486. * Gets a new Vector3 from current Vector3 floored values
  1487. * @returns a new Vector3
  1488. */
  1489. floor(): Vector3;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. fract(): Vector3;
  1495. /**
  1496. * Gets the length of the Vector3
  1497. * @returns the length of the Vector3
  1498. */
  1499. length(): number;
  1500. /**
  1501. * Gets the squared length of the Vector3
  1502. * @returns squared length of the Vector3
  1503. */
  1504. lengthSquared(): number;
  1505. /**
  1506. * Normalize the current Vector3.
  1507. * Please note that this is an in place operation.
  1508. * @returns the current updated Vector3
  1509. */
  1510. normalize(): Vector3;
  1511. /**
  1512. * Reorders the x y z properties of the vector in place
  1513. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1514. * @returns the current updated vector
  1515. */
  1516. reorderInPlace(order: string): this;
  1517. /**
  1518. * Rotates the vector around 0,0,0 by a quaternion
  1519. * @param quaternion the rotation quaternion
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1524. /**
  1525. * Rotates a vector around a given point
  1526. * @param quaternion the rotation quaternion
  1527. * @param point the point to rotate around
  1528. * @param result vector to store the result
  1529. * @returns the resulting vector
  1530. */
  1531. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1532. /**
  1533. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1534. * The cross product is then orthogonal to both current and "other"
  1535. * @param other defines the right operand
  1536. * @returns the cross product
  1537. */
  1538. cross(other: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Checks if a given vector is inside a specific range
  1777. * @param v defines the vector to test
  1778. * @param min defines the minimum range
  1779. * @param max defines the maximum range
  1780. */
  1781. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1782. /**
  1783. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1784. * @param value1 defines the first control point
  1785. * @param tangent1 defines the first tangent vector
  1786. * @param value2 defines the second control point
  1787. * @param tangent2 defines the second tangent vector
  1788. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @returns the new Vector3
  1798. */
  1799. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1800. /**
  1801. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1802. * @param start defines the start value
  1803. * @param end defines the end value
  1804. * @param amount max defines amount between both (between 0 and 1)
  1805. * @param result defines the Vector3 where to store the result
  1806. */
  1807. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1808. /**
  1809. * Returns the dot product (float) between the vectors "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the dot product
  1813. */
  1814. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1815. /**
  1816. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @returns the cross product
  1821. */
  1822. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1823. /**
  1824. * Sets the given vector "result" with the cross product of "left" and "right"
  1825. * The cross product is then orthogonal to both "left" and "right"
  1826. * @param left defines the left operand
  1827. * @param right defines the right operand
  1828. * @param result defines the Vector3 where to store the result
  1829. */
  1830. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1831. /**
  1832. * Returns a new Vector3 as the normalization of the given vector
  1833. * @param vector defines the Vector3 to normalize
  1834. * @returns the new Vector3
  1835. */
  1836. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1837. /**
  1838. * Sets the given vector "result" with the normalization of the given first vector
  1839. * @param vector defines the Vector3 to normalize
  1840. * @param result defines the Vector3 where to store the result
  1841. */
  1842. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1843. /**
  1844. * Project a Vector3 onto screen space
  1845. * @param vector defines the Vector3 to project
  1846. * @param world defines the world matrix to use
  1847. * @param transform defines the transform (view x projection) matrix to use
  1848. * @param viewport defines the screen viewport to use
  1849. * @returns the new Vector3
  1850. */
  1851. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1852. /** @hidden */
  1853. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param transform defines the transform (view x projection) matrix to use
  1861. * @returns the new Vector3
  1862. */
  1863. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1864. /**
  1865. * Unproject from screen space to object space
  1866. * @param source defines the screen space Vector3 to use
  1867. * @param viewportWidth defines the current width of the viewport
  1868. * @param viewportHeight defines the current height of the viewport
  1869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1870. * @param view defines the view matrix to use
  1871. * @param projection defines the projection matrix to use
  1872. * @returns the new Vector3
  1873. */
  1874. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1875. /**
  1876. * Unproject from screen space to object space
  1877. * @param source defines the screen space Vector3 to use
  1878. * @param viewportWidth defines the current width of the viewport
  1879. * @param viewportHeight defines the current height of the viewport
  1880. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1881. * @param view defines the view matrix to use
  1882. * @param projection defines the projection matrix to use
  1883. * @param result defines the Vector3 where to store the result
  1884. */
  1885. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1886. /**
  1887. * Unproject from screen space to object space
  1888. * @param sourceX defines the screen space x coordinate to use
  1889. * @param sourceY defines the screen space y coordinate to use
  1890. * @param sourceZ defines the screen space z coordinate to use
  1891. * @param viewportWidth defines the current width of the viewport
  1892. * @param viewportHeight defines the current height of the viewport
  1893. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1894. * @param view defines the view matrix to use
  1895. * @param projection defines the projection matrix to use
  1896. * @param result defines the Vector3 where to store the result
  1897. */
  1898. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1899. /**
  1900. * Gets the minimal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Gets the maximal coordinate values between two Vector3
  1908. * @param left defines the first operand
  1909. * @param right defines the second operand
  1910. * @returns the new Vector3
  1911. */
  1912. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * Returns the distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the distance
  1918. */
  1919. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns the squared distance between the vectors "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the squared distance
  1925. */
  1926. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1927. /**
  1928. * Returns a new Vector3 located at the center between "value1" and "value2"
  1929. * @param value1 defines the first operand
  1930. * @param value2 defines the second operand
  1931. * @returns the new Vector3
  1932. */
  1933. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1936. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1937. * to something in order to rotate it from its local system to the given target system
  1938. * Note: axis1, axis2 and axis3 are normalized during this operation
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @returns a new Vector3
  1943. */
  1944. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1947. * @param axis1 defines the first axis
  1948. * @param axis2 defines the second axis
  1949. * @param axis3 defines the third axis
  1950. * @param ref defines the Vector3 where to store the result
  1951. */
  1952. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1953. }
  1954. /**
  1955. * Vector4 class created for EulerAngle class conversion to Quaternion
  1956. */
  1957. export class Vector4 {
  1958. /** x value of the vector */
  1959. x: number;
  1960. /** y value of the vector */
  1961. y: number;
  1962. /** z value of the vector */
  1963. z: number;
  1964. /** w value of the vector */
  1965. w: number;
  1966. /**
  1967. * Creates a Vector4 object from the given floats.
  1968. * @param x x value of the vector
  1969. * @param y y value of the vector
  1970. * @param z z value of the vector
  1971. * @param w w value of the vector
  1972. */
  1973. constructor(
  1974. /** x value of the vector */
  1975. x: number,
  1976. /** y value of the vector */
  1977. y: number,
  1978. /** z value of the vector */
  1979. z: number,
  1980. /** w value of the vector */
  1981. w: number);
  1982. /**
  1983. * Returns the string with the Vector4 coordinates.
  1984. * @returns a string containing all the vector values
  1985. */
  1986. toString(): string;
  1987. /**
  1988. * Returns the string "Vector4".
  1989. * @returns "Vector4"
  1990. */
  1991. getClassName(): string;
  1992. /**
  1993. * Returns the Vector4 hash code.
  1994. * @returns a unique hash code
  1995. */
  1996. getHashCode(): number;
  1997. /**
  1998. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1999. * @returns the resulting array
  2000. */
  2001. asArray(): number[];
  2002. /**
  2003. * Populates the given array from the given index with the Vector4 coordinates.
  2004. * @param array array to populate
  2005. * @param index index of the array to start at (default: 0)
  2006. * @returns the Vector4.
  2007. */
  2008. toArray(array: FloatArray, index?: number): Vector4;
  2009. /**
  2010. * Adds the given vector to the current Vector4.
  2011. * @param otherVector the vector to add
  2012. * @returns the updated Vector4.
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2015. /**
  2016. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2017. * @param otherVector the vector to add
  2018. * @returns the resulting vector
  2019. */
  2020. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2021. /**
  2022. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2023. * @param otherVector the vector to add
  2024. * @param result the vector to store the result
  2025. * @returns the current Vector4.
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2028. /**
  2029. * Subtract in place the given vector from the current Vector4.
  2030. * @param otherVector the vector to subtract
  2031. * @returns the updated Vector4.
  2032. */
  2033. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2034. /**
  2035. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2036. * @param otherVector the vector to add
  2037. * @returns the new vector with the result
  2038. */
  2039. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2040. /**
  2041. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2042. * @param otherVector the vector to subtract
  2043. * @param result the vector to store the result
  2044. * @returns the current Vector4.
  2045. */
  2046. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2049. */
  2050. /**
  2051. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @returns new vector containing the result
  2057. */
  2058. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2059. /**
  2060. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2061. * @param x value to subtract
  2062. * @param y value to subtract
  2063. * @param z value to subtract
  2064. * @param w value to subtract
  2065. * @param result the vector to store the result in
  2066. * @returns the current Vector4.
  2067. */
  2068. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2069. /**
  2070. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2071. * @returns a new vector with the negated values
  2072. */
  2073. negate(): Vector4;
  2074. /**
  2075. * Multiplies the current Vector4 coordinates by scale (float).
  2076. * @param scale the number to scale with
  2077. * @returns the updated Vector4.
  2078. */
  2079. scaleInPlace(scale: number): Vector4;
  2080. /**
  2081. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2082. * @param scale the number to scale with
  2083. * @returns a new vector with the result
  2084. */
  2085. scale(scale: number): Vector4;
  2086. /**
  2087. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2088. * @param scale the number to scale with
  2089. * @param result a vector to store the result in
  2090. * @returns the current Vector4.
  2091. */
  2092. scaleToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2095. * @param scale defines the scale factor
  2096. * @param result defines the Vector4 object where to store the result
  2097. * @returns the unmodified current Vector4
  2098. */
  2099. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2100. /**
  2101. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2102. * @param otherVector the vector to compare against
  2103. * @returns true if they are equal
  2104. */
  2105. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2106. /**
  2107. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2108. * @param otherVector vector to compare against
  2109. * @param epsilon (Default: very small number)
  2110. * @returns true if they are equal
  2111. */
  2112. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2113. /**
  2114. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2115. * @param x x value to compare against
  2116. * @param y y value to compare against
  2117. * @param z z value to compare against
  2118. * @param w w value to compare against
  2119. * @returns true if equal
  2120. */
  2121. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2122. /**
  2123. * Multiplies in place the current Vector4 by the given one.
  2124. * @param otherVector vector to multiple with
  2125. * @returns the updated Vector4.
  2126. */
  2127. multiplyInPlace(otherVector: Vector4): Vector4;
  2128. /**
  2129. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2130. * @param otherVector vector to multiple with
  2131. * @returns resulting new vector
  2132. */
  2133. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2134. /**
  2135. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2136. * @param otherVector vector to multiple with
  2137. * @param result vector to store the result
  2138. * @returns the current Vector4.
  2139. */
  2140. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2143. * @param x x value multiply with
  2144. * @param y y value multiply with
  2145. * @param z z value multiply with
  2146. * @param w w value multiply with
  2147. * @returns resulting new vector
  2148. */
  2149. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2150. /**
  2151. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2152. * @param otherVector vector to devide with
  2153. * @returns resulting new vector
  2154. */
  2155. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2156. /**
  2157. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2158. * @param otherVector vector to devide with
  2159. * @param result vector to store the result
  2160. * @returns the current Vector4.
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2163. /**
  2164. * Divides the current Vector3 coordinates by the given ones.
  2165. * @param otherVector vector to devide with
  2166. * @returns the updated Vector3.
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2169. /**
  2170. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2171. * @param other defines the second operand
  2172. * @returns the current updated Vector4
  2173. */
  2174. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2175. /**
  2176. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2177. * @param other defines the second operand
  2178. * @returns the current updated Vector4
  2179. */
  2180. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2181. /**
  2182. * Gets a new Vector4 from current Vector4 floored values
  2183. * @returns a new Vector4
  2184. */
  2185. floor(): Vector4;
  2186. /**
  2187. * Gets a new Vector4 from current Vector3 floored values
  2188. * @returns a new Vector4
  2189. */
  2190. fract(): Vector4;
  2191. /**
  2192. * Returns the Vector4 length (float).
  2193. * @returns the length
  2194. */
  2195. length(): number;
  2196. /**
  2197. * Returns the Vector4 squared length (float).
  2198. * @returns the length squared
  2199. */
  2200. lengthSquared(): number;
  2201. /**
  2202. * Normalizes in place the Vector4.
  2203. * @returns the updated Vector4.
  2204. */
  2205. normalize(): Vector4;
  2206. /**
  2207. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2208. * @returns this converted to a new vector3
  2209. */
  2210. toVector3(): Vector3;
  2211. /**
  2212. * Returns a new Vector4 copied from the current one.
  2213. * @returns the new cloned vector
  2214. */
  2215. clone(): Vector4;
  2216. /**
  2217. * Updates the current Vector4 with the given one coordinates.
  2218. * @param source the source vector to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to copy from
  2225. * @param y float to copy from
  2226. * @param z float to copy from
  2227. * @param w float to copy from
  2228. * @returns the updated Vector4.
  2229. */
  2230. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Updates the current Vector4 coordinates with the given floats.
  2233. * @param x float to set from
  2234. * @param y float to set from
  2235. * @param z float to set from
  2236. * @param w float to set from
  2237. * @returns the updated Vector4.
  2238. */
  2239. set(x: number, y: number, z: number, w: number): Vector4;
  2240. /**
  2241. * Copies the given float to the current Vector3 coordinates
  2242. * @param v defines the x, y, z and w coordinates of the operand
  2243. * @returns the current updated Vector3
  2244. */
  2245. setAll(v: number): Vector4;
  2246. /**
  2247. * Returns a new Vector4 set from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @returns the new vector
  2251. */
  2252. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" from the starting index of the given Float32Array.
  2262. * @param array the array to pull values from
  2263. * @param offset the offset into the array to start at
  2264. * @param result the vector to store the result in
  2265. */
  2266. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2267. /**
  2268. * Updates the given vector "result" coordinates from the given floats.
  2269. * @param x float to set from
  2270. * @param y float to set from
  2271. * @param z float to set from
  2272. * @param w float to set from
  2273. * @param result the vector to the floats in
  2274. */
  2275. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2276. /**
  2277. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2278. * @returns the new vector
  2279. */
  2280. static Zero(): Vector4;
  2281. /**
  2282. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2283. * @returns the new vector
  2284. */
  2285. static One(): Vector4;
  2286. /**
  2287. * Returns a new normalized Vector4 from the given one.
  2288. * @param vector the vector to normalize
  2289. * @returns the vector
  2290. */
  2291. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2292. /**
  2293. * Updates the given vector "result" from the normalization of the given one.
  2294. * @param vector the vector to normalize
  2295. * @param result the vector to store the result in
  2296. */
  2297. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2298. /**
  2299. * Returns a vector with the minimum values from the left and right vectors
  2300. * @param left left vector to minimize
  2301. * @param right right vector to minimize
  2302. * @returns a new vector with the minimum of the left and right vector values
  2303. */
  2304. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns a vector with the maximum values from the left and right vectors
  2307. * @param left left vector to maximize
  2308. * @param right right vector to maximize
  2309. * @returns a new vector with the maximum of the left and right vector values
  2310. */
  2311. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Returns the distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors
  2317. */
  2318. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the distance between
  2322. * @param value2 value to calulate the distance between
  2323. * @return the distance between the two vectors squared
  2324. */
  2325. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2326. /**
  2327. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2328. * @param value1 value to calulate the center between
  2329. * @param value2 value to calulate the center between
  2330. * @return the center between the two vectors
  2331. */
  2332. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2333. /**
  2334. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @returns the new vector
  2339. */
  2340. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param vector the vector to transform
  2345. * @param transformation the transformation matrix to apply
  2346. * @param result the vector to store the result in
  2347. */
  2348. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2349. /**
  2350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2351. * This methods computes transformed normalized direction vectors only.
  2352. * @param x value to transform
  2353. * @param y value to transform
  2354. * @param z value to transform
  2355. * @param w value to transform
  2356. * @param transformation the transformation matrix to apply
  2357. * @param result the vector to store the results in
  2358. */
  2359. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2360. /**
  2361. * Creates a new Vector4 from a Vector3
  2362. * @param source defines the source data
  2363. * @param w defines the 4th component (default is 0)
  2364. * @returns a new Vector4
  2365. */
  2366. static FromVector3(source: Vector3, w?: number): Vector4;
  2367. }
  2368. /**
  2369. * Class used to store quaternion data
  2370. * @see https://en.wikipedia.org/wiki/Quaternion
  2371. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2372. */
  2373. export class Quaternion {
  2374. /** defines the first component (0 by default) */
  2375. x: number;
  2376. /** defines the second component (0 by default) */
  2377. y: number;
  2378. /** defines the third component (0 by default) */
  2379. z: number;
  2380. /** defines the fourth component (1.0 by default) */
  2381. w: number;
  2382. /**
  2383. * Creates a new Quaternion from the given floats
  2384. * @param x defines the first component (0 by default)
  2385. * @param y defines the second component (0 by default)
  2386. * @param z defines the third component (0 by default)
  2387. * @param w defines the fourth component (1.0 by default)
  2388. */
  2389. constructor(
  2390. /** defines the first component (0 by default) */
  2391. x?: number,
  2392. /** defines the second component (0 by default) */
  2393. y?: number,
  2394. /** defines the third component (0 by default) */
  2395. z?: number,
  2396. /** defines the fourth component (1.0 by default) */
  2397. w?: number);
  2398. /**
  2399. * Gets a string representation for the current quaternion
  2400. * @returns a string with the Quaternion coordinates
  2401. */
  2402. toString(): string;
  2403. /**
  2404. * Gets the class name of the quaternion
  2405. * @returns the string "Quaternion"
  2406. */
  2407. getClassName(): string;
  2408. /**
  2409. * Gets a hash code for this quaternion
  2410. * @returns the quaternion hash code
  2411. */
  2412. getHashCode(): number;
  2413. /**
  2414. * Copy the quaternion to an array
  2415. * @returns a new array populated with 4 elements from the quaternion coordinates
  2416. */
  2417. asArray(): number[];
  2418. /**
  2419. * Check if two quaternions are equals
  2420. * @param otherQuaternion defines the second operand
  2421. * @return true if the current quaternion and the given one coordinates are strictly equals
  2422. */
  2423. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2424. /**
  2425. * Clone the current quaternion
  2426. * @returns a new quaternion copied from the current one
  2427. */
  2428. clone(): Quaternion;
  2429. /**
  2430. * Copy a quaternion to the current one
  2431. * @param other defines the other quaternion
  2432. * @returns the updated current quaternion
  2433. */
  2434. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2435. /**
  2436. * Updates the current quaternion with the given float coordinates
  2437. * @param x defines the x coordinate
  2438. * @param y defines the y coordinate
  2439. * @param z defines the z coordinate
  2440. * @param w defines the w coordinate
  2441. * @returns the updated current quaternion
  2442. */
  2443. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2444. /**
  2445. * Updates the current quaternion from the given float coordinates
  2446. * @param x defines the x coordinate
  2447. * @param y defines the y coordinate
  2448. * @param z defines the z coordinate
  2449. * @param w defines the w coordinate
  2450. * @returns the updated current quaternion
  2451. */
  2452. set(x: number, y: number, z: number, w: number): Quaternion;
  2453. /**
  2454. * Adds two quaternions
  2455. * @param other defines the second operand
  2456. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2457. */
  2458. add(other: DeepImmutable<Quaternion>): Quaternion;
  2459. /**
  2460. * Add a quaternion to the current one
  2461. * @param other defines the quaternion to add
  2462. * @returns the current quaternion
  2463. */
  2464. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2465. /**
  2466. * Subtract two quaternions
  2467. * @param other defines the second operand
  2468. * @returns a new quaternion as the subtraction result of the given one from the current one
  2469. */
  2470. subtract(other: Quaternion): Quaternion;
  2471. /**
  2472. * Multiplies the current quaternion by a scale factor
  2473. * @param value defines the scale factor
  2474. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2475. */
  2476. scale(value: number): Quaternion;
  2477. /**
  2478. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2479. * @param scale defines the scale factor
  2480. * @param result defines the Quaternion object where to store the result
  2481. * @returns the unmodified current quaternion
  2482. */
  2483. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2484. /**
  2485. * Multiplies in place the current quaternion by a scale factor
  2486. * @param value defines the scale factor
  2487. * @returns the current modified quaternion
  2488. */
  2489. scaleInPlace(value: number): Quaternion;
  2490. /**
  2491. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2492. * @param scale defines the scale factor
  2493. * @param result defines the Quaternion object where to store the result
  2494. * @returns the unmodified current quaternion
  2495. */
  2496. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2497. /**
  2498. * Multiplies two quaternions
  2499. * @param q1 defines the second operand
  2500. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2501. */
  2502. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2503. /**
  2504. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @param result defines the target quaternion
  2507. * @returns the current quaternion
  2508. */
  2509. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2510. /**
  2511. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2512. * @param q1 defines the second operand
  2513. * @returns the currentupdated quaternion
  2514. */
  2515. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2518. * @param ref defines the target quaternion
  2519. * @returns the current quaternion
  2520. */
  2521. conjugateToRef(ref: Quaternion): Quaternion;
  2522. /**
  2523. * Conjugates in place (1-q) the current quaternion
  2524. * @returns the current updated quaternion
  2525. */
  2526. conjugateInPlace(): Quaternion;
  2527. /**
  2528. * Conjugates in place (1-q) the current quaternion
  2529. * @returns a new quaternion
  2530. */
  2531. conjugate(): Quaternion;
  2532. /**
  2533. * Gets length of current quaternion
  2534. * @returns the quaternion length (float)
  2535. */
  2536. length(): number;
  2537. /**
  2538. * Normalize in place the current quaternion
  2539. * @returns the current updated quaternion
  2540. */
  2541. normalize(): Quaternion;
  2542. /**
  2543. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns a new Vector3 containing the Euler angles
  2546. */
  2547. toEulerAngles(order?: string): Vector3;
  2548. /**
  2549. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2550. * @param result defines the vector which will be filled with the Euler angles
  2551. * @param order is a reserved parameter and is ignore for now
  2552. * @returns the current unchanged quaternion
  2553. */
  2554. toEulerAnglesToRef(result: Vector3): Quaternion;
  2555. /**
  2556. * Updates the given rotation matrix with the current quaternion values
  2557. * @param result defines the target matrix
  2558. * @returns the current unchanged quaternion
  2559. */
  2560. toRotationMatrix(result: Matrix): Quaternion;
  2561. /**
  2562. * Updates the current quaternion from the given rotation matrix values
  2563. * @param matrix defines the source matrix
  2564. * @returns the current updated quaternion
  2565. */
  2566. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2567. /**
  2568. * Creates a new quaternion from a rotation matrix
  2569. * @param matrix defines the source matrix
  2570. * @returns a new quaternion created from the given rotation matrix values
  2571. */
  2572. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2573. /**
  2574. * Updates the given quaternion with the given rotation matrix values
  2575. * @param matrix defines the source matrix
  2576. * @param result defines the target quaternion
  2577. */
  2578. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2579. /**
  2580. * Returns the dot product (float) between the quaternions "left" and "right"
  2581. * @param left defines the left operand
  2582. * @param right defines the right operand
  2583. * @returns the dot product
  2584. */
  2585. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2586. /**
  2587. * Checks if the two quaternions are close to each other
  2588. * @param quat0 defines the first quaternion to check
  2589. * @param quat1 defines the second quaternion to check
  2590. * @returns true if the two quaternions are close to each other
  2591. */
  2592. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2593. /**
  2594. * Creates an empty quaternion
  2595. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2596. */
  2597. static Zero(): Quaternion;
  2598. /**
  2599. * Inverse a given quaternion
  2600. * @param q defines the source quaternion
  2601. * @returns a new quaternion as the inverted current quaternion
  2602. */
  2603. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2604. /**
  2605. * Inverse a given quaternion
  2606. * @param q defines the source quaternion
  2607. * @param result the quaternion the result will be stored in
  2608. * @returns the result quaternion
  2609. */
  2610. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2611. /**
  2612. * Creates an identity quaternion
  2613. * @returns the identity quaternion
  2614. */
  2615. static Identity(): Quaternion;
  2616. /**
  2617. * Gets a boolean indicating if the given quaternion is identity
  2618. * @param quaternion defines the quaternion to check
  2619. * @returns true if the quaternion is identity
  2620. */
  2621. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2622. /**
  2623. * Creates a quaternion from a rotation around an axis
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2627. */
  2628. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2629. /**
  2630. * Creates a rotation around an axis and stores it into the given quaternion
  2631. * @param axis defines the axis to use
  2632. * @param angle defines the angle to use
  2633. * @param result defines the target quaternion
  2634. * @returns the target quaternion
  2635. */
  2636. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2637. /**
  2638. * Creates a new quaternion from data stored into an array
  2639. * @param array defines the data source
  2640. * @param offset defines the offset in the source array where the data starts
  2641. * @returns a new quaternion
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2644. /**
  2645. * Create a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @returns the new Quaternion
  2650. */
  2651. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2652. /**
  2653. * Updates a quaternion from Euler rotation angles
  2654. * @param x Pitch
  2655. * @param y Yaw
  2656. * @param z Roll
  2657. * @param result the quaternion to store the result
  2658. * @returns the updated quaternion
  2659. */
  2660. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2661. /**
  2662. * Create a quaternion from Euler rotation vector
  2663. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2664. * @returns the new Quaternion
  2665. */
  2666. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2667. /**
  2668. * Updates a quaternion from Euler rotation vector
  2669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2670. * @param result the quaternion to store the result
  2671. * @returns the updated quaternion
  2672. */
  2673. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2674. /**
  2675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @returns the new quaternion
  2680. */
  2681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2682. /**
  2683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2684. * @param yaw defines the rotation around Y axis
  2685. * @param pitch defines the rotation around X axis
  2686. * @param roll defines the rotation around Z axis
  2687. * @param result defines the target quaternion
  2688. */
  2689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @returns the new quaternion
  2696. */
  2697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2698. /**
  2699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2700. * @param alpha defines the rotation around first axis
  2701. * @param beta defines the rotation around second axis
  2702. * @param gamma defines the rotation around third axis
  2703. * @param result defines the target quaternion
  2704. */
  2705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2706. /**
  2707. * 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)
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @returns the new quaternion
  2712. */
  2713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2714. /**
  2715. * 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
  2716. * @param axis1 defines the first axis
  2717. * @param axis2 defines the second axis
  2718. * @param axis3 defines the third axis
  2719. * @param ref defines the target quaternion
  2720. */
  2721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2722. /**
  2723. * Interpolates between two quaternions
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @returns the new interpolated quaternion
  2728. */
  2729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2730. /**
  2731. * Interpolates between two quaternions and stores it into a target quaternion
  2732. * @param left defines first quaternion
  2733. * @param right defines second quaternion
  2734. * @param amount defines the gradient to use
  2735. * @param result defines the target quaternion
  2736. */
  2737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2738. /**
  2739. * Interpolate between two quaternions using Hermite interpolation
  2740. * @param value1 defines first quaternion
  2741. * @param tangent1 defines the incoming tangent
  2742. * @param value2 defines second quaternion
  2743. * @param tangent2 defines the outgoing tangent
  2744. * @param amount defines the target quaternion
  2745. * @returns the new interpolated quaternion
  2746. */
  2747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2748. }
  2749. /**
  2750. * Class used to store matrix data (4x4)
  2751. */
  2752. export class Matrix {
  2753. private static _updateFlagSeed;
  2754. private static _identityReadOnly;
  2755. private _isIdentity;
  2756. private _isIdentityDirty;
  2757. private _isIdentity3x2;
  2758. private _isIdentity3x2Dirty;
  2759. /**
  2760. * Gets the update flag of the matrix which is an unique number for the matrix.
  2761. * It will be incremented every time the matrix data change.
  2762. * You can use it to speed the comparison between two versions of the same matrix.
  2763. */
  2764. updateFlag: number;
  2765. private readonly _m;
  2766. /**
  2767. * Gets the internal data of the matrix
  2768. */
  2769. readonly m: DeepImmutable<Float32Array>;
  2770. /** @hidden */
  2771. _markAsUpdated(): void;
  2772. /** @hidden */
  2773. private _updateIdentityStatus;
  2774. /**
  2775. * Creates an empty matrix (filled with zeros)
  2776. */
  2777. constructor();
  2778. /**
  2779. * Check if the current matrix is identity
  2780. * @returns true is the matrix is the identity matrix
  2781. */
  2782. isIdentity(): boolean;
  2783. /**
  2784. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2785. * @returns true is the matrix is the identity matrix
  2786. */
  2787. isIdentityAs3x2(): boolean;
  2788. /**
  2789. * Gets the determinant of the matrix
  2790. * @returns the matrix determinant
  2791. */
  2792. determinant(): number;
  2793. /**
  2794. * Returns the matrix as a Float32Array
  2795. * @returns the matrix underlying array
  2796. */
  2797. toArray(): DeepImmutable<Float32Array>;
  2798. /**
  2799. * Returns the matrix as a Float32Array
  2800. * @returns the matrix underlying array.
  2801. */
  2802. asArray(): DeepImmutable<Float32Array>;
  2803. /**
  2804. * Inverts the current matrix in place
  2805. * @returns the current inverted matrix
  2806. */
  2807. invert(): Matrix;
  2808. /**
  2809. * Sets all the matrix elements to zero
  2810. * @returns the current matrix
  2811. */
  2812. reset(): Matrix;
  2813. /**
  2814. * Adds the current matrix with a second one
  2815. * @param other defines the matrix to add
  2816. * @returns a new matrix as the addition of the current matrix and the given one
  2817. */
  2818. add(other: DeepImmutable<Matrix>): Matrix;
  2819. /**
  2820. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2821. * @param other defines the matrix to add
  2822. * @param result defines the target matrix
  2823. * @returns the current matrix
  2824. */
  2825. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2826. /**
  2827. * Adds in place the given matrix to the current matrix
  2828. * @param other defines the second operand
  2829. * @returns the current updated matrix
  2830. */
  2831. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2832. /**
  2833. * Sets the given matrix to the current inverted Matrix
  2834. * @param other defines the target matrix
  2835. * @returns the unmodified current matrix
  2836. */
  2837. invertToRef(other: Matrix): Matrix;
  2838. /**
  2839. * add a value at the specified position in the current Matrix
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. addAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * mutiply the specified position in the current Matrix by a value
  2847. * @param index the index of the value within the matrix. between 0 and 15.
  2848. * @param value the value to be added
  2849. * @returns the current updated matrix
  2850. */
  2851. multiplyAtIndex(index: number, value: number): Matrix;
  2852. /**
  2853. * Inserts the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Adds the translation vector (using 3 floats) in the current matrix
  2862. * @param x defines the 1st component of the translation
  2863. * @param y defines the 2nd component of the translation
  2864. * @param z defines the 3rd component of the translation
  2865. * @returns the current updated matrix
  2866. */
  2867. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2868. /**
  2869. * Inserts the translation vector in the current matrix
  2870. * @param vector3 defines the translation to insert
  2871. * @returns the current updated matrix
  2872. */
  2873. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2874. /**
  2875. * Gets the translation value of the current matrix
  2876. * @returns a new Vector3 as the extracted translation from the matrix
  2877. */
  2878. getTranslation(): Vector3;
  2879. /**
  2880. * Fill a Vector3 with the extracted translation from the matrix
  2881. * @param result defines the Vector3 where to store the translation
  2882. * @returns the current matrix
  2883. */
  2884. getTranslationToRef(result: Vector3): Matrix;
  2885. /**
  2886. * Remove rotation and scaling part from the matrix
  2887. * @returns the updated matrix
  2888. */
  2889. removeRotationAndScaling(): Matrix;
  2890. /**
  2891. * Multiply two matrices
  2892. * @param other defines the second operand
  2893. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2894. */
  2895. multiply(other: DeepImmutable<Matrix>): Matrix;
  2896. /**
  2897. * Copy the current matrix from the given one
  2898. * @param other defines the source matrix
  2899. * @returns the current updated matrix
  2900. */
  2901. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Populates the given array from the starting index with the current matrix values
  2904. * @param array defines the target array
  2905. * @param offset defines the offset in the target array where to start storing values
  2906. * @returns the current matrix
  2907. */
  2908. copyToArray(array: Float32Array, offset?: number): Matrix;
  2909. /**
  2910. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the matrix where to store the multiplication
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2916. /**
  2917. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2918. * @param other defines the second operand
  2919. * @param result defines the array where to store the multiplication
  2920. * @param offset defines the offset in the target array where to start storing values
  2921. * @returns the current matrix
  2922. */
  2923. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2924. /**
  2925. * Check equality between this matrix and a second one
  2926. * @param value defines the second matrix to compare
  2927. * @returns true is the current matrix and the given one values are strictly equal
  2928. */
  2929. equals(value: DeepImmutable<Matrix>): boolean;
  2930. /**
  2931. * Clone the current matrix
  2932. * @returns a new matrix from the current matrix
  2933. */
  2934. clone(): Matrix;
  2935. /**
  2936. * Returns the name of the current matrix class
  2937. * @returns the string "Matrix"
  2938. */
  2939. getClassName(): string;
  2940. /**
  2941. * Gets the hash code of the current matrix
  2942. * @returns the hash code
  2943. */
  2944. getHashCode(): number;
  2945. /**
  2946. * Decomposes the current Matrix into a translation, rotation and scaling components
  2947. * @param scale defines the scale vector3 given as a reference to update
  2948. * @param rotation defines the rotation quaternion given as a reference to update
  2949. * @param translation defines the translation vector3 given as a reference to update
  2950. * @returns true if operation was successful
  2951. */
  2952. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2953. /**
  2954. * Gets specific row of the matrix
  2955. * @param index defines the number of the row to get
  2956. * @returns the index-th row of the current matrix as a new Vector4
  2957. */
  2958. getRow(index: number): Nullable<Vector4>;
  2959. /**
  2960. * Sets the index-th row of the current matrix to the vector4 values
  2961. * @param index defines the number of the row to set
  2962. * @param row defines the target vector4
  2963. * @returns the updated current matrix
  2964. */
  2965. setRow(index: number, row: Vector4): Matrix;
  2966. /**
  2967. * Compute the transpose of the matrix
  2968. * @returns the new transposed matrix
  2969. */
  2970. transpose(): Matrix;
  2971. /**
  2972. * Compute the transpose of the matrix and store it in a given matrix
  2973. * @param result defines the target matrix
  2974. * @returns the current matrix
  2975. */
  2976. transposeToRef(result: Matrix): Matrix;
  2977. /**
  2978. * Sets the index-th row of the current matrix with the given 4 x float values
  2979. * @param index defines the row index
  2980. * @param x defines the x component to set
  2981. * @param y defines the y component to set
  2982. * @param z defines the z component to set
  2983. * @param w defines the w component to set
  2984. * @returns the updated current matrix
  2985. */
  2986. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2987. /**
  2988. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2989. * @param scale defines the scale factor
  2990. * @returns a new matrix
  2991. */
  2992. scale(scale: number): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor to a given result matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Scale the current matrix values by a factor and add the result to a given matrix
  3002. * @param scale defines the scale factor
  3003. * @param result defines the Matrix to store the result
  3004. * @returns the current matrix
  3005. */
  3006. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3007. /**
  3008. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3009. * @param ref matrix to store the result
  3010. */
  3011. toNormalMatrix(ref: Matrix): void;
  3012. /**
  3013. * Gets only rotation part of the current matrix
  3014. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3015. */
  3016. getRotationMatrix(): Matrix;
  3017. /**
  3018. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3019. * @param result defines the target matrix to store data to
  3020. * @returns the current matrix
  3021. */
  3022. getRotationMatrixToRef(result: Matrix): Matrix;
  3023. /**
  3024. * Toggles model matrix from being right handed to left handed in place and vice versa
  3025. */
  3026. toggleModelMatrixHandInPlace(): void;
  3027. /**
  3028. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3029. */
  3030. toggleProjectionMatrixHandInPlace(): void;
  3031. /**
  3032. * Creates a matrix from an array
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @returns a new Matrix set from the starting index of the given array
  3036. */
  3037. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3038. /**
  3039. * Copy the content of an array into a given matrix
  3040. * @param array defines the source array
  3041. * @param offset defines an offset in the source array
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3045. /**
  3046. * Stores an array into a matrix after having multiplied each component by a given factor
  3047. * @param array defines the source array
  3048. * @param offset defines the offset in the source array
  3049. * @param scale defines the scaling factor
  3050. * @param result defines the target matrix
  3051. */
  3052. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3053. /**
  3054. * Gets an identity matrix that must not be updated
  3055. */
  3056. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3057. /**
  3058. * Stores a list of values (16) inside a given matrix
  3059. * @param initialM11 defines 1st value of 1st row
  3060. * @param initialM12 defines 2nd value of 1st row
  3061. * @param initialM13 defines 3rd value of 1st row
  3062. * @param initialM14 defines 4th value of 1st row
  3063. * @param initialM21 defines 1st value of 2nd row
  3064. * @param initialM22 defines 2nd value of 2nd row
  3065. * @param initialM23 defines 3rd value of 2nd row
  3066. * @param initialM24 defines 4th value of 2nd row
  3067. * @param initialM31 defines 1st value of 3rd row
  3068. * @param initialM32 defines 2nd value of 3rd row
  3069. * @param initialM33 defines 3rd value of 3rd row
  3070. * @param initialM34 defines 4th value of 3rd row
  3071. * @param initialM41 defines 1st value of 4th row
  3072. * @param initialM42 defines 2nd value of 4th row
  3073. * @param initialM43 defines 3rd value of 4th row
  3074. * @param initialM44 defines 4th value of 4th row
  3075. * @param result defines the target matrix
  3076. */
  3077. 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;
  3078. /**
  3079. * Creates new matrix from a list of values (16)
  3080. * @param initialM11 defines 1st value of 1st row
  3081. * @param initialM12 defines 2nd value of 1st row
  3082. * @param initialM13 defines 3rd value of 1st row
  3083. * @param initialM14 defines 4th value of 1st row
  3084. * @param initialM21 defines 1st value of 2nd row
  3085. * @param initialM22 defines 2nd value of 2nd row
  3086. * @param initialM23 defines 3rd value of 2nd row
  3087. * @param initialM24 defines 4th value of 2nd row
  3088. * @param initialM31 defines 1st value of 3rd row
  3089. * @param initialM32 defines 2nd value of 3rd row
  3090. * @param initialM33 defines 3rd value of 3rd row
  3091. * @param initialM34 defines 4th value of 3rd row
  3092. * @param initialM41 defines 1st value of 4th row
  3093. * @param initialM42 defines 2nd value of 4th row
  3094. * @param initialM43 defines 3rd value of 4th row
  3095. * @param initialM44 defines 4th value of 4th row
  3096. * @returns the new matrix
  3097. */
  3098. 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;
  3099. /**
  3100. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @returns a new matrix
  3105. */
  3106. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3107. /**
  3108. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3109. * @param scale defines the scale vector3
  3110. * @param rotation defines the rotation quaternion
  3111. * @param translation defines the translation vector3
  3112. * @param result defines the target matrix
  3113. */
  3114. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3115. /**
  3116. * Creates a new identity matrix
  3117. * @returns a new identity matrix
  3118. */
  3119. static Identity(): Matrix;
  3120. /**
  3121. * Creates a new identity matrix and stores the result in a given matrix
  3122. * @param result defines the target matrix
  3123. */
  3124. static IdentityToRef(result: Matrix): void;
  3125. /**
  3126. * Creates a new zero matrix
  3127. * @returns a new zero matrix
  3128. */
  3129. static Zero(): Matrix;
  3130. /**
  3131. * Creates a new rotation matrix for "angle" radians around the X axis
  3132. * @param angle defines the angle (in radians) to use
  3133. * @return the new matrix
  3134. */
  3135. static RotationX(angle: number): Matrix;
  3136. /**
  3137. * Creates a new matrix as the invert of a given matrix
  3138. * @param source defines the source matrix
  3139. * @returns the new matrix
  3140. */
  3141. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3142. /**
  3143. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3144. * @param angle defines the angle (in radians) to use
  3145. * @param result defines the target matrix
  3146. */
  3147. static RotationXToRef(angle: number, result: Matrix): void;
  3148. /**
  3149. * Creates a new rotation matrix for "angle" radians around the Y axis
  3150. * @param angle defines the angle (in radians) to use
  3151. * @return the new matrix
  3152. */
  3153. static RotationY(angle: number): Matrix;
  3154. /**
  3155. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3156. * @param angle defines the angle (in radians) to use
  3157. * @param result defines the target matrix
  3158. */
  3159. static RotationYToRef(angle: number, result: Matrix): void;
  3160. /**
  3161. * Creates a new rotation matrix for "angle" radians around the Z axis
  3162. * @param angle defines the angle (in radians) to use
  3163. * @return the new matrix
  3164. */
  3165. static RotationZ(angle: number): Matrix;
  3166. /**
  3167. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3168. * @param angle defines the angle (in radians) to use
  3169. * @param result defines the target matrix
  3170. */
  3171. static RotationZToRef(angle: number, result: Matrix): void;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @return the new matrix
  3177. */
  3178. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3179. /**
  3180. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3181. * @param axis defines the axis to use
  3182. * @param angle defines the angle (in radians) to use
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3186. /**
  3187. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3188. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3189. * @param from defines the vector to align
  3190. * @param to defines the vector to align to
  3191. * @param result defines the target matrix
  3192. */
  3193. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a rotation matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @returns the new rotation matrix
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3202. /**
  3203. * Creates a rotation matrix and stores it in a given matrix
  3204. * @param yaw defines the yaw angle in radians (Y axis)
  3205. * @param pitch defines the pitch angle in radians (X axis)
  3206. * @param roll defines the roll angle in radians (X axis)
  3207. * @param result defines the target matrix
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3210. /**
  3211. * Creates a scaling matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @returns the new matrix
  3216. */
  3217. static Scaling(x: number, y: number, z: number): Matrix;
  3218. /**
  3219. * Creates a scaling matrix and stores it in a given matrix
  3220. * @param x defines the scale factor on X axis
  3221. * @param y defines the scale factor on Y axis
  3222. * @param z defines the scale factor on Z axis
  3223. * @param result defines the target matrix
  3224. */
  3225. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3226. /**
  3227. * Creates a translation matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @returns the new matrix
  3232. */
  3233. static Translation(x: number, y: number, z: number): Matrix;
  3234. /**
  3235. * Creates a translation matrix and stores it in a given matrix
  3236. * @param x defines the translation on X axis
  3237. * @param y defines the translation on Y axis
  3238. * @param z defines the translationon Z axis
  3239. * @param result defines the target matrix
  3240. */
  3241. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3242. /**
  3243. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @returns the new matrix
  3248. */
  3249. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3250. /**
  3251. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3252. * @param startValue defines the start value
  3253. * @param endValue defines the end value
  3254. * @param gradient defines the gradient factor
  3255. * @param result defines the Matrix object where to store data
  3256. */
  3257. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3258. /**
  3259. * Builds a new matrix whose values are computed by:
  3260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3263. * @param startValue defines the first matrix
  3264. * @param endValue defines the second matrix
  3265. * @param gradient defines the gradient between the two matrices
  3266. * @returns the new matrix
  3267. */
  3268. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3269. /**
  3270. * Update a matrix to values which are computed by:
  3271. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3272. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3273. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3274. * @param startValue defines the first matrix
  3275. * @param endValue defines the second matrix
  3276. * @param gradient defines the gradient between the two matrices
  3277. * @param result defines the target matrix
  3278. */
  3279. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3280. /**
  3281. * 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"
  3282. * This function works in left handed mode
  3283. * @param eye defines the final position of the entity
  3284. * @param target defines where the entity should look at
  3285. * @param up defines the up vector for the entity
  3286. * @returns the new matrix
  3287. */
  3288. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3289. /**
  3290. * 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".
  3291. * This function works in left handed mode
  3292. * @param eye defines the final position of the entity
  3293. * @param target defines where the entity should look at
  3294. * @param up defines the up vector for the entity
  3295. * @param result defines the target matrix
  3296. */
  3297. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * 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"
  3300. * This function works in right handed mode
  3301. * @param eye defines the final position of the entity
  3302. * @param target defines where the entity should look at
  3303. * @param up defines the up vector for the entity
  3304. * @returns the new matrix
  3305. */
  3306. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3307. /**
  3308. * 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".
  3309. * This function works in right handed mode
  3310. * @param eye defines the final position of the entity
  3311. * @param target defines where the entity should look at
  3312. * @param up defines the up vector for the entity
  3313. * @param result defines the target matrix
  3314. */
  3315. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3316. /**
  3317. * Create a left-handed orthographic projection matrix
  3318. * @param width defines the viewport width
  3319. * @param height defines the viewport height
  3320. * @param znear defines the near clip plane
  3321. * @param zfar defines the far clip plane
  3322. * @returns a new matrix as a left-handed orthographic projection matrix
  3323. */
  3324. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3325. /**
  3326. * Store a left-handed orthographic projection to a given matrix
  3327. * @param width defines the viewport width
  3328. * @param height defines the viewport height
  3329. * @param znear defines the near clip plane
  3330. * @param zfar defines the far clip plane
  3331. * @param result defines the target matrix
  3332. */
  3333. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3334. /**
  3335. * Create a left-handed orthographic projection matrix
  3336. * @param left defines the viewport left coordinate
  3337. * @param right defines the viewport right coordinate
  3338. * @param bottom defines the viewport bottom coordinate
  3339. * @param top defines the viewport top coordinate
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @returns a new matrix as a left-handed orthographic projection matrix
  3343. */
  3344. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Stores a left-handed orthographic projection into a given matrix
  3347. * @param left defines the viewport left coordinate
  3348. * @param right defines the viewport right coordinate
  3349. * @param bottom defines the viewport bottom coordinate
  3350. * @param top defines the viewport top coordinate
  3351. * @param znear defines the near clip plane
  3352. * @param zfar defines the far clip plane
  3353. * @param result defines the target matrix
  3354. */
  3355. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3356. /**
  3357. * Creates a right-handed orthographic projection matrix
  3358. * @param left defines the viewport left coordinate
  3359. * @param right defines the viewport right coordinate
  3360. * @param bottom defines the viewport bottom coordinate
  3361. * @param top defines the viewport top coordinate
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @returns a new matrix as a right-handed orthographic projection matrix
  3365. */
  3366. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3367. /**
  3368. * Stores a right-handed orthographic projection into a given matrix
  3369. * @param left defines the viewport left coordinate
  3370. * @param right defines the viewport right coordinate
  3371. * @param bottom defines the viewport bottom coordinate
  3372. * @param top defines the viewport top coordinate
  3373. * @param znear defines the near clip plane
  3374. * @param zfar defines the far clip plane
  3375. * @param result defines the target matrix
  3376. */
  3377. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3378. /**
  3379. * Creates a left-handed perspective projection matrix
  3380. * @param width defines the viewport width
  3381. * @param height defines the viewport height
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a left-handed perspective projection matrix
  3385. */
  3386. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Creates a left-handed perspective projection matrix
  3389. * @param fov defines the horizontal field of view
  3390. * @param aspect defines the aspect ratio
  3391. * @param znear defines the near clip plane
  3392. * @param zfar defines the far clip plane
  3393. * @returns a new matrix as a left-handed perspective projection matrix
  3394. */
  3395. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3396. /**
  3397. * Stores a left-handed perspective projection into a given matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @param result defines the target matrix
  3403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3404. */
  3405. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3406. /**
  3407. * Creates a right-handed perspective projection matrix
  3408. * @param fov defines the horizontal field of view
  3409. * @param aspect defines the aspect ratio
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @returns a new matrix as a right-handed perspective projection matrix
  3413. */
  3414. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3415. /**
  3416. * Stores a right-handed perspective projection into a given matrix
  3417. * @param fov defines the horizontal field of view
  3418. * @param aspect defines the aspect ratio
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @param result defines the target matrix
  3422. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3423. */
  3424. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3425. /**
  3426. * Stores a perspective projection for WebVR info a given matrix
  3427. * @param fov defines the field of view
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3432. */
  3433. static PerspectiveFovWebVRToRef(fov: {
  3434. upDegrees: number;
  3435. downDegrees: number;
  3436. leftDegrees: number;
  3437. rightDegrees: number;
  3438. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3439. /**
  3440. * Computes a complete transformation matrix
  3441. * @param viewport defines the viewport to use
  3442. * @param world defines the world matrix
  3443. * @param view defines the view matrix
  3444. * @param projection defines the projection matrix
  3445. * @param zmin defines the near clip plane
  3446. * @param zmax defines the far clip plane
  3447. * @returns the transformation matrix
  3448. */
  3449. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3450. /**
  3451. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3452. * @param matrix defines the matrix to use
  3453. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3454. */
  3455. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3456. /**
  3457. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3458. * @param matrix defines the matrix to use
  3459. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3460. */
  3461. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3462. /**
  3463. * Compute the transpose of a given matrix
  3464. * @param matrix defines the matrix to transpose
  3465. * @returns the new matrix
  3466. */
  3467. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3468. /**
  3469. * Compute the transpose of a matrix and store it in a target matrix
  3470. * @param matrix defines the matrix to transpose
  3471. * @param result defines the target matrix
  3472. */
  3473. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3474. /**
  3475. * Computes a reflection matrix from a plane
  3476. * @param plane defines the reflection plane
  3477. * @returns a new matrix
  3478. */
  3479. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3480. /**
  3481. * Computes a reflection matrix from a plane
  3482. * @param plane defines the reflection plane
  3483. * @param result defines the target matrix
  3484. */
  3485. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3486. /**
  3487. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3488. * @param xaxis defines the value of the 1st axis
  3489. * @param yaxis defines the value of the 2nd axis
  3490. * @param zaxis defines the value of the 3rd axis
  3491. * @param result defines the target matrix
  3492. */
  3493. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3494. /**
  3495. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3496. * @param quat defines the quaternion to use
  3497. * @param result defines the target matrix
  3498. */
  3499. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3500. }
  3501. /**
  3502. * @hidden
  3503. */
  3504. export class TmpVectors {
  3505. static Vector2: Vector2[];
  3506. static Vector3: Vector3[];
  3507. static Vector4: Vector4[];
  3508. static Quaternion: Quaternion[];
  3509. static Matrix: Matrix[];
  3510. }
  3511. }
  3512. declare module "babylonjs/Maths/math.color" {
  3513. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3514. /**
  3515. * Class used to hold a RBG color
  3516. */
  3517. export class Color3 {
  3518. /**
  3519. * Defines the red component (between 0 and 1, default is 0)
  3520. */
  3521. r: number;
  3522. /**
  3523. * Defines the green component (between 0 and 1, default is 0)
  3524. */
  3525. g: number;
  3526. /**
  3527. * Defines the blue component (between 0 and 1, default is 0)
  3528. */
  3529. b: number;
  3530. /**
  3531. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3532. * @param r defines the red component (between 0 and 1, default is 0)
  3533. * @param g defines the green component (between 0 and 1, default is 0)
  3534. * @param b defines the blue component (between 0 and 1, default is 0)
  3535. */
  3536. constructor(
  3537. /**
  3538. * Defines the red component (between 0 and 1, default is 0)
  3539. */
  3540. r?: number,
  3541. /**
  3542. * Defines the green component (between 0 and 1, default is 0)
  3543. */
  3544. g?: number,
  3545. /**
  3546. * Defines the blue component (between 0 and 1, default is 0)
  3547. */
  3548. b?: number);
  3549. /**
  3550. * Creates a string with the Color3 current values
  3551. * @returns the string representation of the Color3 object
  3552. */
  3553. toString(): string;
  3554. /**
  3555. * Returns the string "Color3"
  3556. * @returns "Color3"
  3557. */
  3558. getClassName(): string;
  3559. /**
  3560. * Compute the Color3 hash code
  3561. * @returns an unique number that can be used to hash Color3 objects
  3562. */
  3563. getHashCode(): number;
  3564. /**
  3565. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3566. * @param array defines the array where to store the r,g,b components
  3567. * @param index defines an optional index in the target array to define where to start storing values
  3568. * @returns the current Color3 object
  3569. */
  3570. toArray(array: FloatArray, index?: number): Color3;
  3571. /**
  3572. * Returns a new Color4 object from the current Color3 and the given alpha
  3573. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3574. * @returns a new Color4 object
  3575. */
  3576. toColor4(alpha?: number): Color4;
  3577. /**
  3578. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3579. * @returns the new array
  3580. */
  3581. asArray(): number[];
  3582. /**
  3583. * Returns the luminance value
  3584. * @returns a float value
  3585. */
  3586. toLuminance(): number;
  3587. /**
  3588. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3589. * @param otherColor defines the second operand
  3590. * @returns the new Color3 object
  3591. */
  3592. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3593. /**
  3594. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3595. * @param otherColor defines the second operand
  3596. * @param result defines the Color3 object where to store the result
  3597. * @returns the current Color3
  3598. */
  3599. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3600. /**
  3601. * Determines equality between Color3 objects
  3602. * @param otherColor defines the second operand
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equals(otherColor: DeepImmutable<Color3>): boolean;
  3606. /**
  3607. * Determines equality between the current Color3 object and a set of r,b,g values
  3608. * @param r defines the red component to check
  3609. * @param g defines the green component to check
  3610. * @param b defines the blue component to check
  3611. * @returns true if the rgb values are equal to the given ones
  3612. */
  3613. equalsFloats(r: number, g: number, b: number): boolean;
  3614. /**
  3615. * Multiplies in place each rgb value by scale
  3616. * @param scale defines the scaling factor
  3617. * @returns the updated Color3
  3618. */
  3619. scale(scale: number): Color3;
  3620. /**
  3621. * Multiplies the rgb values by scale and stores the result into "result"
  3622. * @param scale defines the scaling factor
  3623. * @param result defines the Color3 object where to store the result
  3624. * @returns the unmodified current Color3
  3625. */
  3626. scaleToRef(scale: number, result: Color3): Color3;
  3627. /**
  3628. * Scale the current Color3 values by a factor and add the result to a given Color3
  3629. * @param scale defines the scale factor
  3630. * @param result defines color to store the result into
  3631. * @returns the unmodified current Color3
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3634. /**
  3635. * Clamps the rgb values by the min and max values and stores the result into "result"
  3636. * @param min defines minimum clamping value (default is 0)
  3637. * @param max defines maximum clamping value (default is 1)
  3638. * @param result defines color to store the result into
  3639. * @returns the original Color3
  3640. */
  3641. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3642. /**
  3643. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3644. * @param otherColor defines the second operand
  3645. * @returns the new Color3
  3646. */
  3647. add(otherColor: DeepImmutable<Color3>): Color3;
  3648. /**
  3649. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3650. * @param otherColor defines the second operand
  3651. * @param result defines Color3 object to store the result into
  3652. * @returns the unmodified current Color3
  3653. */
  3654. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3655. /**
  3656. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3657. * @param otherColor defines the second operand
  3658. * @returns the new Color3
  3659. */
  3660. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3661. /**
  3662. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3663. * @param otherColor defines the second operand
  3664. * @param result defines Color3 object to store the result into
  3665. * @returns the unmodified current Color3
  3666. */
  3667. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3668. /**
  3669. * Copy the current object
  3670. * @returns a new Color3 copied the current one
  3671. */
  3672. clone(): Color3;
  3673. /**
  3674. * Copies the rgb values from the source in the current Color3
  3675. * @param source defines the source Color3 object
  3676. * @returns the updated Color3 object
  3677. */
  3678. copyFrom(source: DeepImmutable<Color3>): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. copyFromFloats(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Updates the Color3 rgb values from the given floats
  3689. * @param r defines the red component to read from
  3690. * @param g defines the green component to read from
  3691. * @param b defines the blue component to read from
  3692. * @returns the current Color3 object
  3693. */
  3694. set(r: number, g: number, b: number): Color3;
  3695. /**
  3696. * Compute the Color3 hexadecimal code as a string
  3697. * @returns a string containing the hexadecimal representation of the Color3 object
  3698. */
  3699. toHexString(): string;
  3700. /**
  3701. * Computes a new Color3 converted from the current one to linear space
  3702. * @returns a new Color3 object
  3703. */
  3704. toLinearSpace(): Color3;
  3705. /**
  3706. * Converts current color in rgb space to HSV values
  3707. * @returns a new color3 representing the HSV values
  3708. */
  3709. toHSV(): Color3;
  3710. /**
  3711. * Converts current color in rgb space to HSV values
  3712. * @param result defines the Color3 where to store the HSV values
  3713. */
  3714. toHSVToRef(result: Color3): void;
  3715. /**
  3716. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3717. * @param convertedColor defines the Color3 object where to store the linear space version
  3718. * @returns the unmodified Color3
  3719. */
  3720. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3721. /**
  3722. * Computes a new Color3 converted from the current one to gamma space
  3723. * @returns a new Color3 object
  3724. */
  3725. toGammaSpace(): Color3;
  3726. /**
  3727. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3728. * @param convertedColor defines the Color3 object where to store the gamma space version
  3729. * @returns the unmodified Color3
  3730. */
  3731. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3732. private static _BlackReadOnly;
  3733. /**
  3734. * Convert Hue, saturation and value to a Color3 (RGB)
  3735. * @param hue defines the hue
  3736. * @param saturation defines the saturation
  3737. * @param value defines the value
  3738. * @param result defines the Color3 where to store the RGB values
  3739. */
  3740. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3741. /**
  3742. * Creates a new Color3 from the string containing valid hexadecimal values
  3743. * @param hex defines a string containing valid hexadecimal values
  3744. * @returns a new Color3 object
  3745. */
  3746. static FromHexString(hex: string): Color3;
  3747. /**
  3748. * Creates a new Color3 from the starting index of the given array
  3749. * @param array defines the source array
  3750. * @param offset defines an offset in the source array
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3754. /**
  3755. * Creates a new Color3 from integer values (< 256)
  3756. * @param r defines the red component to read from (value between 0 and 255)
  3757. * @param g defines the green component to read from (value between 0 and 255)
  3758. * @param b defines the blue component to read from (value between 0 and 255)
  3759. * @returns a new Color3 object
  3760. */
  3761. static FromInts(r: number, g: number, b: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param start defines the start Color3 value
  3765. * @param end defines the end Color3 value
  3766. * @param amount defines the gradient value between start and end
  3767. * @returns a new Color3 object
  3768. */
  3769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3770. /**
  3771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3772. * @param left defines the start value
  3773. * @param right defines the end value
  3774. * @param amount defines the gradient factor
  3775. * @param result defines the Color3 object where to store the result
  3776. */
  3777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3778. /**
  3779. * Returns a Color3 value containing a red color
  3780. * @returns a new Color3 object
  3781. */
  3782. static Red(): Color3;
  3783. /**
  3784. * Returns a Color3 value containing a green color
  3785. * @returns a new Color3 object
  3786. */
  3787. static Green(): Color3;
  3788. /**
  3789. * Returns a Color3 value containing a blue color
  3790. * @returns a new Color3 object
  3791. */
  3792. static Blue(): Color3;
  3793. /**
  3794. * Returns a Color3 value containing a black color
  3795. * @returns a new Color3 object
  3796. */
  3797. static Black(): Color3;
  3798. /**
  3799. * Gets a Color3 value containing a black color that must not be updated
  3800. */
  3801. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3802. /**
  3803. * Returns a Color3 value containing a white color
  3804. * @returns a new Color3 object
  3805. */
  3806. static White(): Color3;
  3807. /**
  3808. * Returns a Color3 value containing a purple color
  3809. * @returns a new Color3 object
  3810. */
  3811. static Purple(): Color3;
  3812. /**
  3813. * Returns a Color3 value containing a magenta color
  3814. * @returns a new Color3 object
  3815. */
  3816. static Magenta(): Color3;
  3817. /**
  3818. * Returns a Color3 value containing a yellow color
  3819. * @returns a new Color3 object
  3820. */
  3821. static Yellow(): Color3;
  3822. /**
  3823. * Returns a Color3 value containing a gray color
  3824. * @returns a new Color3 object
  3825. */
  3826. static Gray(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a teal color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Teal(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a random color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Random(): Color3;
  3837. }
  3838. /**
  3839. * Class used to hold a RBGA color
  3840. */
  3841. export class Color4 {
  3842. /**
  3843. * Defines the red component (between 0 and 1, default is 0)
  3844. */
  3845. r: number;
  3846. /**
  3847. * Defines the green component (between 0 and 1, default is 0)
  3848. */
  3849. g: number;
  3850. /**
  3851. * Defines the blue component (between 0 and 1, default is 0)
  3852. */
  3853. b: number;
  3854. /**
  3855. * Defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. a: number;
  3858. /**
  3859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3860. * @param r defines the red component (between 0 and 1, default is 0)
  3861. * @param g defines the green component (between 0 and 1, default is 0)
  3862. * @param b defines the blue component (between 0 and 1, default is 0)
  3863. * @param a defines the alpha component (between 0 and 1, default is 1)
  3864. */
  3865. constructor(
  3866. /**
  3867. * Defines the red component (between 0 and 1, default is 0)
  3868. */
  3869. r?: number,
  3870. /**
  3871. * Defines the green component (between 0 and 1, default is 0)
  3872. */
  3873. g?: number,
  3874. /**
  3875. * Defines the blue component (between 0 and 1, default is 0)
  3876. */
  3877. b?: number,
  3878. /**
  3879. * Defines the alpha component (between 0 and 1, default is 1)
  3880. */
  3881. a?: number);
  3882. /**
  3883. * Adds in place the given Color4 values to the current Color4 object
  3884. * @param right defines the second operand
  3885. * @returns the current updated Color4 object
  3886. */
  3887. addInPlace(right: DeepImmutable<Color4>): Color4;
  3888. /**
  3889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3890. * @returns the new array
  3891. */
  3892. asArray(): number[];
  3893. /**
  3894. * Stores from the starting index in the given array the Color4 successive values
  3895. * @param array defines the array where to store the r,g,b components
  3896. * @param index defines an optional index in the target array to define where to start storing values
  3897. * @returns the current Color4 object
  3898. */
  3899. toArray(array: number[], index?: number): Color4;
  3900. /**
  3901. * Determines equality between Color4 objects
  3902. * @param otherColor defines the second operand
  3903. * @returns true if the rgba values are equal to the given ones
  3904. */
  3905. equals(otherColor: DeepImmutable<Color4>): boolean;
  3906. /**
  3907. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3908. * @param right defines the second operand
  3909. * @returns a new Color4 object
  3910. */
  3911. add(right: DeepImmutable<Color4>): Color4;
  3912. /**
  3913. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3914. * @param right defines the second operand
  3915. * @returns a new Color4 object
  3916. */
  3917. subtract(right: DeepImmutable<Color4>): Color4;
  3918. /**
  3919. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3920. * @param right defines the second operand
  3921. * @param result defines the Color4 object where to store the result
  3922. * @returns the current Color4 object
  3923. */
  3924. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3925. /**
  3926. * Creates a new Color4 with the current Color4 values multiplied by scale
  3927. * @param scale defines the scaling factor to apply
  3928. * @returns a new Color4 object
  3929. */
  3930. scale(scale: number): Color4;
  3931. /**
  3932. * Multiplies the current Color4 values by scale and stores the result in "result"
  3933. * @param scale defines the scaling factor to apply
  3934. * @param result defines the Color4 object where to store the result
  3935. * @returns the current unmodified Color4
  3936. */
  3937. scaleToRef(scale: number, result: Color4): Color4;
  3938. /**
  3939. * Scale the current Color4 values by a factor and add the result to a given Color4
  3940. * @param scale defines the scale factor
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the unmodified current Color4
  3943. */
  3944. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3945. /**
  3946. * Clamps the rgb values by the min and max values and stores the result into "result"
  3947. * @param min defines minimum clamping value (default is 0)
  3948. * @param max defines maximum clamping value (default is 1)
  3949. * @param result defines color to store the result into.
  3950. * @returns the cuurent Color4
  3951. */
  3952. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3953. /**
  3954. * Multipy an Color4 value by another and return a new Color4 object
  3955. * @param color defines the Color4 value to multiply by
  3956. * @returns a new Color4 object
  3957. */
  3958. multiply(color: Color4): Color4;
  3959. /**
  3960. * Multipy a Color4 value by another and push the result in a reference value
  3961. * @param color defines the Color4 value to multiply by
  3962. * @param result defines the Color4 to fill the result in
  3963. * @returns the result Color4
  3964. */
  3965. multiplyToRef(color: Color4, result: Color4): Color4;
  3966. /**
  3967. * Creates a string with the Color4 current values
  3968. * @returns the string representation of the Color4 object
  3969. */
  3970. toString(): string;
  3971. /**
  3972. * Returns the string "Color4"
  3973. * @returns "Color4"
  3974. */
  3975. getClassName(): string;
  3976. /**
  3977. * Compute the Color4 hash code
  3978. * @returns an unique number that can be used to hash Color4 objects
  3979. */
  3980. getHashCode(): number;
  3981. /**
  3982. * Creates a new Color4 copied from the current one
  3983. * @returns a new Color4 object
  3984. */
  3985. clone(): Color4;
  3986. /**
  3987. * Copies the given Color4 values into the current one
  3988. * @param source defines the source Color4 object
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFrom(source: Color4): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Copies the given float values into the current one
  4003. * @param r defines the red component to read from
  4004. * @param g defines the green component to read from
  4005. * @param b defines the blue component to read from
  4006. * @param a defines the alpha component to read from
  4007. * @returns the current updated Color4 object
  4008. */
  4009. set(r: number, g: number, b: number, a: number): Color4;
  4010. /**
  4011. * Compute the Color4 hexadecimal code as a string
  4012. * @returns a string containing the hexadecimal representation of the Color4 object
  4013. */
  4014. toHexString(): string;
  4015. /**
  4016. * Computes a new Color4 converted from the current one to linear space
  4017. * @returns a new Color4 object
  4018. */
  4019. toLinearSpace(): Color4;
  4020. /**
  4021. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4022. * @param convertedColor defines the Color4 object where to store the linear space version
  4023. * @returns the unmodified Color4
  4024. */
  4025. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4026. /**
  4027. * Computes a new Color4 converted from the current one to gamma space
  4028. * @returns a new Color4 object
  4029. */
  4030. toGammaSpace(): Color4;
  4031. /**
  4032. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4033. * @param convertedColor defines the Color4 object where to store the gamma space version
  4034. * @returns the unmodified Color4
  4035. */
  4036. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4037. /**
  4038. * Creates a new Color4 from the string containing valid hexadecimal values
  4039. * @param hex defines a string containing valid hexadecimal values
  4040. * @returns a new Color4 object
  4041. */
  4042. static FromHexString(hex: string): Color4;
  4043. /**
  4044. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @returns a new Color4 object
  4049. */
  4050. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4051. /**
  4052. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4053. * @param left defines the start value
  4054. * @param right defines the end value
  4055. * @param amount defines the gradient factor
  4056. * @param result defines the Color4 object where to store data
  4057. */
  4058. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4059. /**
  4060. * Creates a new Color4 from a Color3 and an alpha value
  4061. * @param color3 defines the source Color3 to read from
  4062. * @param alpha defines the alpha component (1.0 by default)
  4063. * @returns a new Color4 object
  4064. */
  4065. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4066. /**
  4067. * Creates a new Color4 from the starting index element of the given array
  4068. * @param array defines the source array to read from
  4069. * @param offset defines the offset in the source array
  4070. * @returns a new Color4 object
  4071. */
  4072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4073. /**
  4074. * Creates a new Color3 from integer values (< 256)
  4075. * @param r defines the red component to read from (value between 0 and 255)
  4076. * @param g defines the green component to read from (value between 0 and 255)
  4077. * @param b defines the blue component to read from (value between 0 and 255)
  4078. * @param a defines the alpha component to read from (value between 0 and 255)
  4079. * @returns a new Color3 object
  4080. */
  4081. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4082. /**
  4083. * Check the content of a given array and convert it to an array containing RGBA data
  4084. * If the original array was already containing count * 4 values then it is returned directly
  4085. * @param colors defines the array to check
  4086. * @param count defines the number of RGBA data to expect
  4087. * @returns an array containing count * 4 values (RGBA)
  4088. */
  4089. static CheckColors4(colors: number[], count: number): number[];
  4090. }
  4091. /**
  4092. * @hidden
  4093. */
  4094. export class TmpColors {
  4095. static Color3: Color3[];
  4096. static Color4: Color4[];
  4097. }
  4098. }
  4099. declare module "babylonjs/Maths/sphericalPolynomial" {
  4100. import { Vector3 } from "babylonjs/Maths/math.vector";
  4101. import { Color3 } from "babylonjs/Maths/math.color";
  4102. /**
  4103. * Class representing spherical harmonics coefficients to the 3rd degree
  4104. */
  4105. export class SphericalHarmonics {
  4106. /**
  4107. * Defines whether or not the harmonics have been prescaled for rendering.
  4108. */
  4109. preScaled: boolean;
  4110. /**
  4111. * The l0,0 coefficients of the spherical harmonics
  4112. */
  4113. l00: Vector3;
  4114. /**
  4115. * The l1,-1 coefficients of the spherical harmonics
  4116. */
  4117. l1_1: Vector3;
  4118. /**
  4119. * The l1,0 coefficients of the spherical harmonics
  4120. */
  4121. l10: Vector3;
  4122. /**
  4123. * The l1,1 coefficients of the spherical harmonics
  4124. */
  4125. l11: Vector3;
  4126. /**
  4127. * The l2,-2 coefficients of the spherical harmonics
  4128. */
  4129. l2_2: Vector3;
  4130. /**
  4131. * The l2,-1 coefficients of the spherical harmonics
  4132. */
  4133. l2_1: Vector3;
  4134. /**
  4135. * The l2,0 coefficients of the spherical harmonics
  4136. */
  4137. l20: Vector3;
  4138. /**
  4139. * The l2,1 coefficients of the spherical harmonics
  4140. */
  4141. l21: Vector3;
  4142. /**
  4143. * The l2,2 coefficients of the spherical harmonics
  4144. */
  4145. l22: Vector3;
  4146. /**
  4147. * Adds a light to the spherical harmonics
  4148. * @param direction the direction of the light
  4149. * @param color the color of the light
  4150. * @param deltaSolidAngle the delta solid angle of the light
  4151. */
  4152. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4153. /**
  4154. * Scales the spherical harmonics by the given amount
  4155. * @param scale the amount to scale
  4156. */
  4157. scaleInPlace(scale: number): void;
  4158. /**
  4159. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4160. *
  4161. * ```
  4162. * E_lm = A_l * L_lm
  4163. * ```
  4164. *
  4165. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4166. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4167. * the scaling factors are given in equation 9.
  4168. */
  4169. convertIncidentRadianceToIrradiance(): void;
  4170. /**
  4171. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4172. *
  4173. * ```
  4174. * L = (1/pi) * E * rho
  4175. * ```
  4176. *
  4177. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4178. */
  4179. convertIrradianceToLambertianRadiance(): void;
  4180. /**
  4181. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4182. * required operations at run time.
  4183. *
  4184. * This is simply done by scaling back the SH with Ylm constants parameter.
  4185. * The trigonometric part being applied by the shader at run time.
  4186. */
  4187. preScaleForRendering(): void;
  4188. /**
  4189. * Constructs a spherical harmonics from an array.
  4190. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4191. * @returns the spherical harmonics
  4192. */
  4193. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4194. /**
  4195. * Gets the spherical harmonics from polynomial
  4196. * @param polynomial the spherical polynomial
  4197. * @returns the spherical harmonics
  4198. */
  4199. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4200. }
  4201. /**
  4202. * Class representing spherical polynomial coefficients to the 3rd degree
  4203. */
  4204. export class SphericalPolynomial {
  4205. private _harmonics;
  4206. /**
  4207. * The spherical harmonics used to create the polynomials.
  4208. */
  4209. readonly preScaledHarmonics: SphericalHarmonics;
  4210. /**
  4211. * The x coefficients of the spherical polynomial
  4212. */
  4213. x: Vector3;
  4214. /**
  4215. * The y coefficients of the spherical polynomial
  4216. */
  4217. y: Vector3;
  4218. /**
  4219. * The z coefficients of the spherical polynomial
  4220. */
  4221. z: Vector3;
  4222. /**
  4223. * The xx coefficients of the spherical polynomial
  4224. */
  4225. xx: Vector3;
  4226. /**
  4227. * The yy coefficients of the spherical polynomial
  4228. */
  4229. yy: Vector3;
  4230. /**
  4231. * The zz coefficients of the spherical polynomial
  4232. */
  4233. zz: Vector3;
  4234. /**
  4235. * The xy coefficients of the spherical polynomial
  4236. */
  4237. xy: Vector3;
  4238. /**
  4239. * The yz coefficients of the spherical polynomial
  4240. */
  4241. yz: Vector3;
  4242. /**
  4243. * The zx coefficients of the spherical polynomial
  4244. */
  4245. zx: Vector3;
  4246. /**
  4247. * Adds an ambient color to the spherical polynomial
  4248. * @param color the color to add
  4249. */
  4250. addAmbient(color: Color3): void;
  4251. /**
  4252. * Scales the spherical polynomial by the given amount
  4253. * @param scale the amount to scale
  4254. */
  4255. scaleInPlace(scale: number): void;
  4256. /**
  4257. * Gets the spherical polynomial from harmonics
  4258. * @param harmonics the spherical harmonics
  4259. * @returns the spherical polynomial
  4260. */
  4261. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4262. /**
  4263. * Constructs a spherical polynomial from an array.
  4264. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4265. * @returns the spherical polynomial
  4266. */
  4267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4268. }
  4269. }
  4270. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4271. /**
  4272. * Define options used to create a render target texture
  4273. */
  4274. export class RenderTargetCreationOptions {
  4275. /**
  4276. * Specifies is mipmaps must be generated
  4277. */
  4278. generateMipMaps?: boolean;
  4279. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4280. generateDepthBuffer?: boolean;
  4281. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4282. generateStencilBuffer?: boolean;
  4283. /** Defines texture type (int by default) */
  4284. type?: number;
  4285. /** Defines sampling mode (trilinear by default) */
  4286. samplingMode?: number;
  4287. /** Defines format (RGBA by default) */
  4288. format?: number;
  4289. }
  4290. }
  4291. declare module "babylonjs/Instrumentation/timeToken" {
  4292. import { Nullable } from "babylonjs/types";
  4293. /**
  4294. * @hidden
  4295. **/
  4296. export class _TimeToken {
  4297. _startTimeQuery: Nullable<WebGLQuery>;
  4298. _endTimeQuery: Nullable<WebGLQuery>;
  4299. _timeElapsedQuery: Nullable<WebGLQuery>;
  4300. _timeElapsedQueryEnded: boolean;
  4301. }
  4302. }
  4303. declare module "babylonjs/Engines/constants" {
  4304. /** Defines the cross module used constants to avoid circular dependncies */
  4305. export class Constants {
  4306. /** Defines that alpha blending is disabled */
  4307. static readonly ALPHA_DISABLE: number;
  4308. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4309. static readonly ALPHA_ADD: number;
  4310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4311. static readonly ALPHA_COMBINE: number;
  4312. /** Defines that alpha blending to DEST - SRC * DEST */
  4313. static readonly ALPHA_SUBTRACT: number;
  4314. /** Defines that alpha blending to SRC * DEST */
  4315. static readonly ALPHA_MULTIPLY: number;
  4316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4317. static readonly ALPHA_MAXIMIZED: number;
  4318. /** Defines that alpha blending to SRC + DEST */
  4319. static readonly ALPHA_ONEONE: number;
  4320. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4321. static readonly ALPHA_PREMULTIPLIED: number;
  4322. /**
  4323. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4325. */
  4326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4327. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4328. static readonly ALPHA_INTERPOLATE: number;
  4329. /**
  4330. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4332. */
  4333. static readonly ALPHA_SCREENMODE: number;
  4334. /**
  4335. * Defines that alpha blending to SRC + DST
  4336. * Alpha will be set to SRC ALPHA + DST ALPHA
  4337. */
  4338. static readonly ALPHA_ONEONE_ONEONE: number;
  4339. /**
  4340. * Defines that alpha blending to SRC * DST ALPHA + DST
  4341. * Alpha will be set to 0
  4342. */
  4343. static readonly ALPHA_ALPHATOCOLOR: number;
  4344. /**
  4345. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4346. */
  4347. static readonly ALPHA_REVERSEONEMINUS: number;
  4348. /**
  4349. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4351. */
  4352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4353. /**
  4354. * Defines that alpha blending to SRC + DST
  4355. * Alpha will be set to SRC ALPHA
  4356. */
  4357. static readonly ALPHA_ONEONE_ONEZERO: number;
  4358. /** Defines that alpha blending equation a SUM */
  4359. static readonly ALPHA_EQUATION_ADD: number;
  4360. /** Defines that alpha blending equation a SUBSTRACTION */
  4361. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4362. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4363. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4364. /** Defines that alpha blending equation a MAX operation */
  4365. static readonly ALPHA_EQUATION_MAX: number;
  4366. /** Defines that alpha blending equation a MIN operation */
  4367. static readonly ALPHA_EQUATION_MIN: number;
  4368. /**
  4369. * Defines that alpha blending equation a DARKEN operation:
  4370. * It takes the min of the src and sums the alpha channels.
  4371. */
  4372. static readonly ALPHA_EQUATION_DARKEN: number;
  4373. /** Defines that the ressource is not delayed*/
  4374. static readonly DELAYLOADSTATE_NONE: number;
  4375. /** Defines that the ressource was successfully delay loaded */
  4376. static readonly DELAYLOADSTATE_LOADED: number;
  4377. /** Defines that the ressource is currently delay loading */
  4378. static readonly DELAYLOADSTATE_LOADING: number;
  4379. /** Defines that the ressource is delayed and has not started loading */
  4380. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4382. static readonly NEVER: number;
  4383. /** 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 */
  4384. static readonly ALWAYS: number;
  4385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4386. static readonly LESS: number;
  4387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4388. static readonly EQUAL: number;
  4389. /** 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 */
  4390. static readonly LEQUAL: number;
  4391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4392. static readonly GREATER: number;
  4393. /** 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 */
  4394. static readonly GEQUAL: number;
  4395. /** 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 */
  4396. static readonly NOTEQUAL: number;
  4397. /** Passed to stencilOperation to specify that stencil value must be kept */
  4398. static readonly KEEP: number;
  4399. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4400. static readonly REPLACE: number;
  4401. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4402. static readonly INCR: number;
  4403. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4404. static readonly DECR: number;
  4405. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4406. static readonly INVERT: number;
  4407. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4408. static readonly INCR_WRAP: number;
  4409. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4410. static readonly DECR_WRAP: number;
  4411. /** Texture is not repeating outside of 0..1 UVs */
  4412. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4413. /** Texture is repeating outside of 0..1 UVs */
  4414. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4415. /** Texture is repeating and mirrored */
  4416. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4417. /** ALPHA */
  4418. static readonly TEXTUREFORMAT_ALPHA: number;
  4419. /** LUMINANCE */
  4420. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4421. /** LUMINANCE_ALPHA */
  4422. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4423. /** RGB */
  4424. static readonly TEXTUREFORMAT_RGB: number;
  4425. /** RGBA */
  4426. static readonly TEXTUREFORMAT_RGBA: number;
  4427. /** RED */
  4428. static readonly TEXTUREFORMAT_RED: number;
  4429. /** RED (2nd reference) */
  4430. static readonly TEXTUREFORMAT_R: number;
  4431. /** RG */
  4432. static readonly TEXTUREFORMAT_RG: number;
  4433. /** RED_INTEGER */
  4434. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4435. /** RED_INTEGER (2nd reference) */
  4436. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4437. /** RG_INTEGER */
  4438. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4439. /** RGB_INTEGER */
  4440. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4441. /** RGBA_INTEGER */
  4442. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4443. /** UNSIGNED_BYTE */
  4444. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4445. /** UNSIGNED_BYTE (2nd reference) */
  4446. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4447. /** FLOAT */
  4448. static readonly TEXTURETYPE_FLOAT: number;
  4449. /** HALF_FLOAT */
  4450. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4451. /** BYTE */
  4452. static readonly TEXTURETYPE_BYTE: number;
  4453. /** SHORT */
  4454. static readonly TEXTURETYPE_SHORT: number;
  4455. /** UNSIGNED_SHORT */
  4456. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4457. /** INT */
  4458. static readonly TEXTURETYPE_INT: number;
  4459. /** UNSIGNED_INT */
  4460. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4461. /** UNSIGNED_SHORT_4_4_4_4 */
  4462. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4463. /** UNSIGNED_SHORT_5_5_5_1 */
  4464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4465. /** UNSIGNED_SHORT_5_6_5 */
  4466. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4467. /** UNSIGNED_INT_2_10_10_10_REV */
  4468. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4469. /** UNSIGNED_INT_24_8 */
  4470. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4471. /** UNSIGNED_INT_10F_11F_11F_REV */
  4472. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4473. /** UNSIGNED_INT_5_9_9_9_REV */
  4474. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4475. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4476. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4477. /** nearest is mag = nearest and min = nearest and mip = linear */
  4478. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4479. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4480. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4481. /** Trilinear is mag = linear and min = linear and mip = linear */
  4482. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4483. /** nearest is mag = nearest and min = nearest and mip = linear */
  4484. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4486. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4487. /** Trilinear is mag = linear and min = linear and mip = linear */
  4488. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4489. /** mag = nearest and min = nearest and mip = nearest */
  4490. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4491. /** mag = nearest and min = linear and mip = nearest */
  4492. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4493. /** mag = nearest and min = linear and mip = linear */
  4494. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4495. /** mag = nearest and min = linear and mip = none */
  4496. static readonly TEXTURE_NEAREST_LINEAR: number;
  4497. /** mag = nearest and min = nearest and mip = none */
  4498. static readonly TEXTURE_NEAREST_NEAREST: number;
  4499. /** mag = linear and min = nearest and mip = nearest */
  4500. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4501. /** mag = linear and min = nearest and mip = linear */
  4502. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4503. /** mag = linear and min = linear and mip = none */
  4504. static readonly TEXTURE_LINEAR_LINEAR: number;
  4505. /** mag = linear and min = nearest and mip = none */
  4506. static readonly TEXTURE_LINEAR_NEAREST: number;
  4507. /** Explicit coordinates mode */
  4508. static readonly TEXTURE_EXPLICIT_MODE: number;
  4509. /** Spherical coordinates mode */
  4510. static readonly TEXTURE_SPHERICAL_MODE: number;
  4511. /** Planar coordinates mode */
  4512. static readonly TEXTURE_PLANAR_MODE: number;
  4513. /** Cubic coordinates mode */
  4514. static readonly TEXTURE_CUBIC_MODE: number;
  4515. /** Projection coordinates mode */
  4516. static readonly TEXTURE_PROJECTION_MODE: number;
  4517. /** Skybox coordinates mode */
  4518. static readonly TEXTURE_SKYBOX_MODE: number;
  4519. /** Inverse Cubic coordinates mode */
  4520. static readonly TEXTURE_INVCUBIC_MODE: number;
  4521. /** Equirectangular coordinates mode */
  4522. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4523. /** Equirectangular Fixed coordinates mode */
  4524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4525. /** Equirectangular Fixed Mirrored coordinates mode */
  4526. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4527. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4528. static readonly SCALEMODE_FLOOR: number;
  4529. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4530. static readonly SCALEMODE_NEAREST: number;
  4531. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4532. static readonly SCALEMODE_CEILING: number;
  4533. /**
  4534. * The dirty texture flag value
  4535. */
  4536. static readonly MATERIAL_TextureDirtyFlag: number;
  4537. /**
  4538. * The dirty light flag value
  4539. */
  4540. static readonly MATERIAL_LightDirtyFlag: number;
  4541. /**
  4542. * The dirty fresnel flag value
  4543. */
  4544. static readonly MATERIAL_FresnelDirtyFlag: number;
  4545. /**
  4546. * The dirty attribute flag value
  4547. */
  4548. static readonly MATERIAL_AttributesDirtyFlag: number;
  4549. /**
  4550. * The dirty misc flag value
  4551. */
  4552. static readonly MATERIAL_MiscDirtyFlag: number;
  4553. /**
  4554. * The all dirty flag value
  4555. */
  4556. static readonly MATERIAL_AllDirtyFlag: number;
  4557. /**
  4558. * Returns the triangle fill mode
  4559. */
  4560. static readonly MATERIAL_TriangleFillMode: number;
  4561. /**
  4562. * Returns the wireframe mode
  4563. */
  4564. static readonly MATERIAL_WireFrameFillMode: number;
  4565. /**
  4566. * Returns the point fill mode
  4567. */
  4568. static readonly MATERIAL_PointFillMode: number;
  4569. /**
  4570. * Returns the point list draw mode
  4571. */
  4572. static readonly MATERIAL_PointListDrawMode: number;
  4573. /**
  4574. * Returns the line list draw mode
  4575. */
  4576. static readonly MATERIAL_LineListDrawMode: number;
  4577. /**
  4578. * Returns the line loop draw mode
  4579. */
  4580. static readonly MATERIAL_LineLoopDrawMode: number;
  4581. /**
  4582. * Returns the line strip draw mode
  4583. */
  4584. static readonly MATERIAL_LineStripDrawMode: number;
  4585. /**
  4586. * Returns the triangle strip draw mode
  4587. */
  4588. static readonly MATERIAL_TriangleStripDrawMode: number;
  4589. /**
  4590. * Returns the triangle fan draw mode
  4591. */
  4592. static readonly MATERIAL_TriangleFanDrawMode: number;
  4593. /**
  4594. * Stores the clock-wise side orientation
  4595. */
  4596. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4597. /**
  4598. * Stores the counter clock-wise side orientation
  4599. */
  4600. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4601. /**
  4602. * Nothing
  4603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4604. */
  4605. static readonly ACTION_NothingTrigger: number;
  4606. /**
  4607. * On pick
  4608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4609. */
  4610. static readonly ACTION_OnPickTrigger: number;
  4611. /**
  4612. * On left pick
  4613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4614. */
  4615. static readonly ACTION_OnLeftPickTrigger: number;
  4616. /**
  4617. * On right pick
  4618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4619. */
  4620. static readonly ACTION_OnRightPickTrigger: number;
  4621. /**
  4622. * On center pick
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_OnCenterPickTrigger: number;
  4626. /**
  4627. * On pick down
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickDownTrigger: number;
  4631. /**
  4632. * On double pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnDoublePickTrigger: number;
  4636. /**
  4637. * On pick up
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnPickUpTrigger: number;
  4641. /**
  4642. * On pick out.
  4643. * This trigger will only be raised if you also declared a OnPickDown
  4644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4645. */
  4646. static readonly ACTION_OnPickOutTrigger: number;
  4647. /**
  4648. * On long press
  4649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4650. */
  4651. static readonly ACTION_OnLongPressTrigger: number;
  4652. /**
  4653. * On pointer over
  4654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4655. */
  4656. static readonly ACTION_OnPointerOverTrigger: number;
  4657. /**
  4658. * On pointer out
  4659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4660. */
  4661. static readonly ACTION_OnPointerOutTrigger: number;
  4662. /**
  4663. * On every frame
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnEveryFrameTrigger: number;
  4667. /**
  4668. * On intersection enter
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4672. /**
  4673. * On intersection exit
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnIntersectionExitTrigger: number;
  4677. /**
  4678. * On key down
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnKeyDownTrigger: number;
  4682. /**
  4683. * On key up
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnKeyUpTrigger: number;
  4687. /**
  4688. * Billboard mode will only apply to Y axis
  4689. */
  4690. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4691. /**
  4692. * Billboard mode will apply to all axes
  4693. */
  4694. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4695. /**
  4696. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4697. */
  4698. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4699. /**
  4700. * Gets or sets base Assets URL
  4701. */
  4702. static PARTICLES_BaseAssetsUrl: string;
  4703. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4704. * Test order :
  4705. * Is the bounding sphere outside the frustum ?
  4706. * If not, are the bounding box vertices outside the frustum ?
  4707. * It not, then the cullable object is in the frustum.
  4708. */
  4709. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4710. /** Culling strategy : Bounding Sphere Only.
  4711. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4712. * It's also less accurate than the standard because some not visible objects can still be selected.
  4713. * Test : is the bounding sphere outside the frustum ?
  4714. * If not, then the cullable object is in the frustum.
  4715. */
  4716. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4717. /** Culling strategy : Optimistic Inclusion.
  4718. * This in an inclusion test first, then the standard exclusion test.
  4719. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4720. * 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.
  4721. * Anyway, it's as accurate as the standard strategy.
  4722. * Test :
  4723. * Is the cullable object bounding sphere center in the frustum ?
  4724. * If not, apply the default culling strategy.
  4725. */
  4726. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4727. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4728. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4729. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4730. * 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.
  4731. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4732. * Test :
  4733. * Is the cullable object bounding sphere center in the frustum ?
  4734. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4737. /**
  4738. * No logging while loading
  4739. */
  4740. static readonly SCENELOADER_NO_LOGGING: number;
  4741. /**
  4742. * Minimal logging while loading
  4743. */
  4744. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4745. /**
  4746. * Summary logging while loading
  4747. */
  4748. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4749. /**
  4750. * Detailled logging while loading
  4751. */
  4752. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4753. }
  4754. }
  4755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4756. import { Nullable } from "babylonjs/types";
  4757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4758. /**
  4759. * This represents the required contract to create a new type of texture loader.
  4760. */
  4761. export interface IInternalTextureLoader {
  4762. /**
  4763. * Defines wether the loader supports cascade loading the different faces.
  4764. */
  4765. supportCascades: boolean;
  4766. /**
  4767. * This returns if the loader support the current file information.
  4768. * @param extension defines the file extension of the file being loaded
  4769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4770. * @param fallback defines the fallback internal texture if any
  4771. * @param isBase64 defines whether the texture is encoded as a base64
  4772. * @param isBuffer defines whether the texture data are stored as a buffer
  4773. * @returns true if the loader can load the specified file
  4774. */
  4775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4776. /**
  4777. * Transform the url before loading if required.
  4778. * @param rootUrl the url of the texture
  4779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4780. * @returns the transformed texture
  4781. */
  4782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4783. /**
  4784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4785. * @param rootUrl the url of the texture
  4786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4787. * @returns the fallback texture
  4788. */
  4789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4790. /**
  4791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4792. * @param data contains the texture data
  4793. * @param texture defines the BabylonJS internal texture
  4794. * @param createPolynomials will be true if polynomials have been requested
  4795. * @param onLoad defines the callback to trigger once the texture is ready
  4796. * @param onError defines the callback to trigger in case of error
  4797. */
  4798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4799. /**
  4800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4801. * @param data contains the texture data
  4802. * @param texture defines the BabylonJS internal texture
  4803. * @param callback defines the method to call once ready to upload
  4804. */
  4805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/IPipelineContext" {
  4809. /**
  4810. * Class used to store and describe the pipeline context associated with an effect
  4811. */
  4812. export interface IPipelineContext {
  4813. /**
  4814. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4815. */
  4816. isAsync: boolean;
  4817. /**
  4818. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4819. */
  4820. isReady: boolean;
  4821. /** @hidden */
  4822. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4823. }
  4824. }
  4825. declare module "babylonjs/Meshes/dataBuffer" {
  4826. /**
  4827. * Class used to store gfx data (like WebGLBuffer)
  4828. */
  4829. export class DataBuffer {
  4830. /**
  4831. * Gets or sets the number of objects referencing this buffer
  4832. */
  4833. references: number;
  4834. /** Gets or sets the size of the underlying buffer */
  4835. capacity: number;
  4836. /**
  4837. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4838. */
  4839. is32Bits: boolean;
  4840. /**
  4841. * Gets the underlying buffer
  4842. */
  4843. readonly underlyingResource: any;
  4844. }
  4845. }
  4846. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4847. /** @hidden */
  4848. export interface IShaderProcessor {
  4849. attributeProcessor?: (attribute: string) => string;
  4850. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4851. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4852. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4853. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4854. lineProcessor?: (line: string, isFragment: boolean) => string;
  4855. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4856. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4857. }
  4858. }
  4859. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4860. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4861. /** @hidden */
  4862. export interface ProcessingOptions {
  4863. defines: string[];
  4864. indexParameters: any;
  4865. isFragment: boolean;
  4866. shouldUseHighPrecisionShader: boolean;
  4867. supportsUniformBuffers: boolean;
  4868. shadersRepository: string;
  4869. includesShadersStore: {
  4870. [key: string]: string;
  4871. };
  4872. processor?: IShaderProcessor;
  4873. version: string;
  4874. platformName: string;
  4875. lookForClosingBracketForUniformBuffer?: boolean;
  4876. }
  4877. }
  4878. declare module "babylonjs/Misc/stringTools" {
  4879. /**
  4880. * Helper to manipulate strings
  4881. */
  4882. export class StringTools {
  4883. /**
  4884. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4885. * @param str Source string
  4886. * @param suffix Suffix to search for in the source string
  4887. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4888. */
  4889. static EndsWith(str: string, suffix: string): boolean;
  4890. /**
  4891. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4892. * @param str Source string
  4893. * @param suffix Suffix to search for in the source string
  4894. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4895. */
  4896. static StartsWith(str: string, suffix: string): boolean;
  4897. }
  4898. }
  4899. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4900. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4901. /** @hidden */
  4902. export class ShaderCodeNode {
  4903. line: string;
  4904. children: ShaderCodeNode[];
  4905. additionalDefineKey?: string;
  4906. additionalDefineValue?: string;
  4907. isValid(preprocessors: {
  4908. [key: string]: string;
  4909. }): boolean;
  4910. process(preprocessors: {
  4911. [key: string]: string;
  4912. }, options: ProcessingOptions): string;
  4913. }
  4914. }
  4915. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4916. /** @hidden */
  4917. export class ShaderCodeCursor {
  4918. private _lines;
  4919. lineIndex: number;
  4920. readonly currentLine: string;
  4921. readonly canRead: boolean;
  4922. lines: string[];
  4923. }
  4924. }
  4925. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4926. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4927. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4928. /** @hidden */
  4929. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4936. /** @hidden */
  4937. export class ShaderDefineExpression {
  4938. isTrue(preprocessors: {
  4939. [key: string]: string;
  4940. }): boolean;
  4941. }
  4942. }
  4943. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4944. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4945. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4946. /** @hidden */
  4947. export class ShaderCodeTestNode extends ShaderCodeNode {
  4948. testExpression: ShaderDefineExpression;
  4949. isValid(preprocessors: {
  4950. [key: string]: string;
  4951. }): boolean;
  4952. }
  4953. }
  4954. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4955. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4956. /** @hidden */
  4957. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4958. define: string;
  4959. not: boolean;
  4960. constructor(define: string, not?: boolean);
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4967. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4968. /** @hidden */
  4969. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4970. leftOperand: ShaderDefineExpression;
  4971. rightOperand: ShaderDefineExpression;
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4978. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4979. /** @hidden */
  4980. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4981. leftOperand: ShaderDefineExpression;
  4982. rightOperand: ShaderDefineExpression;
  4983. isTrue(preprocessors: {
  4984. [key: string]: string;
  4985. }): boolean;
  4986. }
  4987. }
  4988. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4989. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4990. /** @hidden */
  4991. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4992. define: string;
  4993. operand: string;
  4994. testValue: string;
  4995. constructor(define: string, operand: string, testValue: string);
  4996. isTrue(preprocessors: {
  4997. [key: string]: string;
  4998. }): boolean;
  4999. }
  5000. }
  5001. declare module "babylonjs/Misc/loadFileError" {
  5002. import { WebRequest } from "babylonjs/Misc/webRequest";
  5003. /**
  5004. * @ignore
  5005. * Application error to support additional information when loading a file
  5006. */
  5007. export class LoadFileError extends Error {
  5008. /** defines the optional web request */
  5009. request?: WebRequest | undefined;
  5010. private static _setPrototypeOf;
  5011. /**
  5012. * Creates a new LoadFileError
  5013. * @param message defines the message of the error
  5014. * @param request defines the optional web request
  5015. */
  5016. constructor(message: string,
  5017. /** defines the optional web request */
  5018. request?: WebRequest | undefined);
  5019. }
  5020. }
  5021. declare module "babylonjs/Offline/IOfflineProvider" {
  5022. /**
  5023. * Class used to enable access to offline support
  5024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5025. */
  5026. export interface IOfflineProvider {
  5027. /**
  5028. * Gets a boolean indicating if scene must be saved in the database
  5029. */
  5030. enableSceneOffline: boolean;
  5031. /**
  5032. * Gets a boolean indicating if textures must be saved in the database
  5033. */
  5034. enableTexturesOffline: boolean;
  5035. /**
  5036. * Open the offline support and make it available
  5037. * @param successCallback defines the callback to call on success
  5038. * @param errorCallback defines the callback to call on error
  5039. */
  5040. open(successCallback: () => void, errorCallback: () => void): void;
  5041. /**
  5042. * Loads an image from the offline support
  5043. * @param url defines the url to load from
  5044. * @param image defines the target DOM image
  5045. */
  5046. loadImage(url: string, image: HTMLImageElement): void;
  5047. /**
  5048. * Loads a file from offline support
  5049. * @param url defines the URL to load from
  5050. * @param sceneLoaded defines a callback to call on success
  5051. * @param progressCallBack defines a callback to call when progress changed
  5052. * @param errorCallback defines a callback to call on error
  5053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5054. */
  5055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5056. }
  5057. }
  5058. declare module "babylonjs/Misc/filesInputStore" {
  5059. /**
  5060. * Class used to help managing file picking and drag'n'drop
  5061. * File Storage
  5062. */
  5063. export class FilesInputStore {
  5064. /**
  5065. * List of files ready to be loaded
  5066. */
  5067. static FilesToLoad: {
  5068. [key: string]: File;
  5069. };
  5070. }
  5071. }
  5072. declare module "babylonjs/Misc/retryStrategy" {
  5073. import { WebRequest } from "babylonjs/Misc/webRequest";
  5074. /**
  5075. * Class used to define a retry strategy when error happens while loading assets
  5076. */
  5077. export class RetryStrategy {
  5078. /**
  5079. * Function used to defines an exponential back off strategy
  5080. * @param maxRetries defines the maximum number of retries (3 by default)
  5081. * @param baseInterval defines the interval between retries
  5082. * @returns the strategy function to use
  5083. */
  5084. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/fileTools" {
  5088. import { WebRequest } from "babylonjs/Misc/webRequest";
  5089. import { Nullable } from "babylonjs/types";
  5090. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5091. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5092. /**
  5093. * @hidden
  5094. */
  5095. export class FileTools {
  5096. /**
  5097. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5098. */
  5099. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5100. /**
  5101. * Gets or sets the base URL to use to load assets
  5102. */
  5103. static BaseUrl: string;
  5104. /**
  5105. * Default behaviour for cors in the application.
  5106. * It can be a string if the expected behavior is identical in the entire app.
  5107. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5108. */
  5109. static CorsBehavior: string | ((url: string | string[]) => string);
  5110. /**
  5111. * Gets or sets a function used to pre-process url before using them to load assets
  5112. */
  5113. static PreprocessUrl: (url: string) => string;
  5114. /**
  5115. * Removes unwanted characters from an url
  5116. * @param url defines the url to clean
  5117. * @returns the cleaned url
  5118. */
  5119. private static _CleanUrl;
  5120. /**
  5121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5122. * @param url define the url we are trying
  5123. * @param element define the dom element where to configure the cors policy
  5124. */
  5125. static SetCorsBehavior(url: string | string[], element: {
  5126. crossOrigin: string | null;
  5127. }): void;
  5128. /**
  5129. * Loads an image as an HTMLImageElement.
  5130. * @param input url string, ArrayBuffer, or Blob to load
  5131. * @param onLoad callback called when the image successfully loads
  5132. * @param onError callback called when the image fails to load
  5133. * @param offlineProvider offline provider for caching
  5134. * @returns the HTMLImageElement of the loaded image
  5135. */
  5136. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5137. /**
  5138. * Loads a file
  5139. * @param fileToLoad defines the file to load
  5140. * @param callback defines the callback to call when data is loaded
  5141. * @param progressCallBack defines the callback to call during loading process
  5142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5143. * @returns a file request object
  5144. */
  5145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5146. /**
  5147. * Loads a file
  5148. * @param url url string, ArrayBuffer, or Blob to load
  5149. * @param onSuccess callback called when the file successfully loads
  5150. * @param onProgress callback called while file is loading (if the server supports this mode)
  5151. * @param offlineProvider defines the offline provider for caching
  5152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5153. * @param onError callback called when the file fails to load
  5154. * @returns a file request object
  5155. */
  5156. 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;
  5157. /**
  5158. * Checks if the loaded document was accessed via `file:`-Protocol.
  5159. * @returns boolean
  5160. */
  5161. static IsFileURL(): boolean;
  5162. }
  5163. }
  5164. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5165. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5166. /** @hidden */
  5167. export class ShaderProcessor {
  5168. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5169. private static _ProcessPrecision;
  5170. private static _ExtractOperation;
  5171. private static _BuildSubExpression;
  5172. private static _BuildExpression;
  5173. private static _MoveCursorWithinIf;
  5174. private static _MoveCursor;
  5175. private static _EvaluatePreProcessors;
  5176. private static _PreparePreProcessors;
  5177. private static _ProcessShaderConversion;
  5178. private static _ProcessIncludes;
  5179. }
  5180. }
  5181. declare module "babylonjs/Materials/iEffectFallbacks" {
  5182. import { Effect } from "babylonjs/Materials/effect";
  5183. /**
  5184. * Interface used to define common properties for effect fallbacks
  5185. */
  5186. export interface IEffectFallbacks {
  5187. /**
  5188. * Removes the defines that should be removed when falling back.
  5189. * @param currentDefines defines the current define statements for the shader.
  5190. * @param effect defines the current effect we try to compile
  5191. * @returns The resulting defines with defines of the current rank removed.
  5192. */
  5193. reduce(currentDefines: string, effect: Effect): string;
  5194. /**
  5195. * Removes the fallback from the bound mesh.
  5196. */
  5197. unBindMesh(): void;
  5198. /**
  5199. * Checks to see if more fallbacks are still availible.
  5200. */
  5201. hasMoreFallbacks: boolean;
  5202. }
  5203. }
  5204. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5205. /**
  5206. * Class used to evalaute queries containing `and` and `or` operators
  5207. */
  5208. export class AndOrNotEvaluator {
  5209. /**
  5210. * Evaluate a query
  5211. * @param query defines the query to evaluate
  5212. * @param evaluateCallback defines the callback used to filter result
  5213. * @returns true if the query matches
  5214. */
  5215. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5216. private static _HandleParenthesisContent;
  5217. private static _SimplifyNegation;
  5218. }
  5219. }
  5220. declare module "babylonjs/Misc/tags" {
  5221. /**
  5222. * Class used to store custom tags
  5223. */
  5224. export class Tags {
  5225. /**
  5226. * Adds support for tags on the given object
  5227. * @param obj defines the object to use
  5228. */
  5229. static EnableFor(obj: any): void;
  5230. /**
  5231. * Removes tags support
  5232. * @param obj defines the object to use
  5233. */
  5234. static DisableFor(obj: any): void;
  5235. /**
  5236. * Gets a boolean indicating if the given object has tags
  5237. * @param obj defines the object to use
  5238. * @returns a boolean
  5239. */
  5240. static HasTags(obj: any): boolean;
  5241. /**
  5242. * Gets the tags available on a given object
  5243. * @param obj defines the object to use
  5244. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5245. * @returns the tags
  5246. */
  5247. static GetTags(obj: any, asString?: boolean): any;
  5248. /**
  5249. * Adds tags to an object
  5250. * @param obj defines the object to use
  5251. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5252. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5253. */
  5254. static AddTagsTo(obj: any, tagsString: string): void;
  5255. /**
  5256. * @hidden
  5257. */
  5258. static _AddTagTo(obj: any, tag: string): void;
  5259. /**
  5260. * Removes specific tags from a specific object
  5261. * @param obj defines the object to use
  5262. * @param tagsString defines the tags to remove
  5263. */
  5264. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5265. /**
  5266. * @hidden
  5267. */
  5268. static _RemoveTagFrom(obj: any, tag: string): void;
  5269. /**
  5270. * Defines if tags hosted on an object match a given query
  5271. * @param obj defines the object to use
  5272. * @param tagsQuery defines the tag query
  5273. * @returns a boolean
  5274. */
  5275. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5327. * @param a defines first vector
  5328. * @param b defines second vector
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. /**
  5466. * new Path3D(path, normal, raw)
  5467. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5468. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5469. * @param path an array of Vector3, the curve axis of the Path3D
  5470. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5471. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns an array populated with tangent vectors on each Path3D curve point.
  5485. * @returns an array populated with tangent vectors on each Path3D curve point.
  5486. */
  5487. getTangents(): Vector3[];
  5488. /**
  5489. * Returns an array populated with normal vectors on each Path3D curve point.
  5490. * @returns an array populated with normal vectors on each Path3D curve point.
  5491. */
  5492. getNormals(): Vector3[];
  5493. /**
  5494. * Returns an array populated with binormal vectors on each Path3D curve point.
  5495. * @returns an array populated with binormal vectors on each Path3D curve point.
  5496. */
  5497. getBinormals(): Vector3[];
  5498. /**
  5499. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5500. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5501. */
  5502. getDistances(): number[];
  5503. /**
  5504. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5505. * @param path path which all values are copied into the curves points
  5506. * @param firstNormal which should be projected onto the curve
  5507. * @returns the same object updated.
  5508. */
  5509. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5510. private _compute;
  5511. private _getFirstNonNullVector;
  5512. private _getLastNonNullVector;
  5513. private _normalVector;
  5514. }
  5515. /**
  5516. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5517. * A Curve3 is designed from a series of successive Vector3.
  5518. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5519. */
  5520. export class Curve3 {
  5521. private _points;
  5522. private _length;
  5523. /**
  5524. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5526. * @param v1 (Vector3) the control point
  5527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5528. * @param nbPoints (integer) the wanted number of points in the curve
  5529. * @returns the created Curve3
  5530. */
  5531. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5532. /**
  5533. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5534. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5535. * @param v1 (Vector3) the first control point
  5536. * @param v2 (Vector3) the second control point
  5537. * @param v3 (Vector3) the end point of the Cubic Bezier
  5538. * @param nbPoints (integer) the wanted number of points in the curve
  5539. * @returns the created Curve3
  5540. */
  5541. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5542. /**
  5543. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5544. * @param p1 (Vector3) the origin point of the Hermite Spline
  5545. * @param t1 (Vector3) the tangent vector at the origin point
  5546. * @param p2 (Vector3) the end point of the Hermite Spline
  5547. * @param t2 (Vector3) the tangent vector at the end point
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a CatmullRom Spline curve :
  5554. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5555. * @param nbPoints (integer) the wanted number of points between each curve control points
  5556. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5557. * @returns the created Curve3
  5558. */
  5559. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5564. * @param points points which make up the curve
  5565. */
  5566. constructor(points: Vector3[]);
  5567. /**
  5568. * @returns the Curve3 stored array of successive Vector3
  5569. */
  5570. getPoints(): Vector3[];
  5571. /**
  5572. * @returns the computed length (float) of the curve.
  5573. */
  5574. length(): number;
  5575. /**
  5576. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5577. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5578. * curveA and curveB keep unchanged.
  5579. * @param curve the curve to continue from this curve
  5580. * @returns the newly constructed curve
  5581. */
  5582. continue(curve: DeepImmutable<Curve3>): Curve3;
  5583. private _computeLength;
  5584. }
  5585. }
  5586. declare module "babylonjs/Animations/easing" {
  5587. /**
  5588. * This represents the main contract an easing function should follow.
  5589. * Easing functions are used throughout the animation system.
  5590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5591. */
  5592. export interface IEasingFunction {
  5593. /**
  5594. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5595. * of the easing function.
  5596. * The link below provides some of the most common examples of easing functions.
  5597. * @see https://easings.net/
  5598. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5599. * @returns the corresponding value on the curve defined by the easing function
  5600. */
  5601. ease(gradient: number): number;
  5602. }
  5603. /**
  5604. * Base class used for every default easing function.
  5605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5606. */
  5607. export class EasingFunction implements IEasingFunction {
  5608. /**
  5609. * Interpolation follows the mathematical formula associated with the easing function.
  5610. */
  5611. static readonly EASINGMODE_EASEIN: number;
  5612. /**
  5613. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5614. */
  5615. static readonly EASINGMODE_EASEOUT: number;
  5616. /**
  5617. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5618. */
  5619. static readonly EASINGMODE_EASEINOUT: number;
  5620. private _easingMode;
  5621. /**
  5622. * Sets the easing mode of the current function.
  5623. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5624. */
  5625. setEasingMode(easingMode: number): void;
  5626. /**
  5627. * Gets the current easing mode.
  5628. * @returns the easing mode
  5629. */
  5630. getEasingMode(): number;
  5631. /**
  5632. * @hidden
  5633. */
  5634. easeInCore(gradient: number): number;
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corresponding value
  5637. * of the easing function.
  5638. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5639. * @returns the corresponding value on the curve defined by the easing function
  5640. */
  5641. ease(gradient: number): number;
  5642. }
  5643. /**
  5644. * Easing function with a circle shape (see link below).
  5645. * @see https://easings.net/#easeInCirc
  5646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5647. */
  5648. export class CircleEase extends EasingFunction implements IEasingFunction {
  5649. /** @hidden */
  5650. easeInCore(gradient: number): number;
  5651. }
  5652. /**
  5653. * Easing function with a ease back shape (see link below).
  5654. * @see https://easings.net/#easeInBack
  5655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5656. */
  5657. export class BackEase extends EasingFunction implements IEasingFunction {
  5658. /** Defines the amplitude of the function */
  5659. amplitude: number;
  5660. /**
  5661. * Instantiates a back ease easing
  5662. * @see https://easings.net/#easeInBack
  5663. * @param amplitude Defines the amplitude of the function
  5664. */
  5665. constructor(
  5666. /** Defines the amplitude of the function */
  5667. amplitude?: number);
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with a bouncing shape (see link below).
  5673. * @see https://easings.net/#easeInBounce
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class BounceEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of bounces */
  5678. bounces: number;
  5679. /** Defines the amplitude of the bounce */
  5680. bounciness: number;
  5681. /**
  5682. * Instantiates a bounce easing
  5683. * @see https://easings.net/#easeInBounce
  5684. * @param bounces Defines the number of bounces
  5685. * @param bounciness Defines the amplitude of the bounce
  5686. */
  5687. constructor(
  5688. /** Defines the number of bounces */
  5689. bounces?: number,
  5690. /** Defines the amplitude of the bounce */
  5691. bounciness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with a power of 3 shape (see link below).
  5697. * @see https://easings.net/#easeInCubic
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class CubicEase extends EasingFunction implements IEasingFunction {
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with an elastic shape (see link below).
  5706. * @see https://easings.net/#easeInElastic
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the number of oscillations*/
  5711. oscillations: number;
  5712. /** Defines the amplitude of the oscillations*/
  5713. springiness: number;
  5714. /**
  5715. * Instantiates an elastic easing function
  5716. * @see https://easings.net/#easeInElastic
  5717. * @param oscillations Defines the number of oscillations
  5718. * @param springiness Defines the amplitude of the oscillations
  5719. */
  5720. constructor(
  5721. /** Defines the number of oscillations*/
  5722. oscillations?: number,
  5723. /** Defines the amplitude of the oscillations*/
  5724. springiness?: number);
  5725. /** @hidden */
  5726. easeInCore(gradient: number): number;
  5727. }
  5728. /**
  5729. * Easing function with an exponential shape (see link below).
  5730. * @see https://easings.net/#easeInExpo
  5731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5732. */
  5733. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5734. /** Defines the exponent of the function */
  5735. exponent: number;
  5736. /**
  5737. * Instantiates an exponential easing function
  5738. * @see https://easings.net/#easeInExpo
  5739. * @param exponent Defines the exponent of the function
  5740. */
  5741. constructor(
  5742. /** Defines the exponent of the function */
  5743. exponent?: number);
  5744. /** @hidden */
  5745. easeInCore(gradient: number): number;
  5746. }
  5747. /**
  5748. * Easing function with a power shape (see link below).
  5749. * @see https://easings.net/#easeInQuad
  5750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5751. */
  5752. export class PowerEase extends EasingFunction implements IEasingFunction {
  5753. /** Defines the power of the function */
  5754. power: number;
  5755. /**
  5756. * Instantiates an power base easing function
  5757. * @see https://easings.net/#easeInQuad
  5758. * @param power Defines the power of the function
  5759. */
  5760. constructor(
  5761. /** Defines the power of the function */
  5762. power?: number);
  5763. /** @hidden */
  5764. easeInCore(gradient: number): number;
  5765. }
  5766. /**
  5767. * Easing function with a power of 2 shape (see link below).
  5768. * @see https://easings.net/#easeInQuad
  5769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5770. */
  5771. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5772. /** @hidden */
  5773. easeInCore(gradient: number): number;
  5774. }
  5775. /**
  5776. * Easing function with a power of 4 shape (see link below).
  5777. * @see https://easings.net/#easeInQuart
  5778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5779. */
  5780. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 5 shape (see link below).
  5786. * @see https://easings.net/#easeInQuint
  5787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with a sin shape (see link below).
  5795. * @see https://easings.net/#easeInSine
  5796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class SineEase extends EasingFunction implements IEasingFunction {
  5799. /** @hidden */
  5800. easeInCore(gradient: number): number;
  5801. }
  5802. /**
  5803. * Easing function with a bezier shape (see link below).
  5804. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5806. */
  5807. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5808. /** Defines the x component of the start tangent in the bezier curve */
  5809. x1: number;
  5810. /** Defines the y component of the start tangent in the bezier curve */
  5811. y1: number;
  5812. /** Defines the x component of the end tangent in the bezier curve */
  5813. x2: number;
  5814. /** Defines the y component of the end tangent in the bezier curve */
  5815. y2: number;
  5816. /**
  5817. * Instantiates a bezier function
  5818. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5819. * @param x1 Defines the x component of the start tangent in the bezier curve
  5820. * @param y1 Defines the y component of the start tangent in the bezier curve
  5821. * @param x2 Defines the x component of the end tangent in the bezier curve
  5822. * @param y2 Defines the y component of the end tangent in the bezier curve
  5823. */
  5824. constructor(
  5825. /** Defines the x component of the start tangent in the bezier curve */
  5826. x1?: number,
  5827. /** Defines the y component of the start tangent in the bezier curve */
  5828. y1?: number,
  5829. /** Defines the x component of the end tangent in the bezier curve */
  5830. x2?: number,
  5831. /** Defines the y component of the end tangent in the bezier curve */
  5832. y2?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. }
  5837. declare module "babylonjs/Animations/animationKey" {
  5838. /**
  5839. * Defines an interface which represents an animation key frame
  5840. */
  5841. export interface IAnimationKey {
  5842. /**
  5843. * Frame of the key frame
  5844. */
  5845. frame: number;
  5846. /**
  5847. * Value at the specifies key frame
  5848. */
  5849. value: any;
  5850. /**
  5851. * The input tangent for the cubic hermite spline
  5852. */
  5853. inTangent?: any;
  5854. /**
  5855. * The output tangent for the cubic hermite spline
  5856. */
  5857. outTangent?: any;
  5858. /**
  5859. * The animation interpolation type
  5860. */
  5861. interpolation?: AnimationKeyInterpolation;
  5862. }
  5863. /**
  5864. * Enum for the animation key frame interpolation type
  5865. */
  5866. export enum AnimationKeyInterpolation {
  5867. /**
  5868. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5869. */
  5870. STEP = 1
  5871. }
  5872. }
  5873. declare module "babylonjs/Animations/animationRange" {
  5874. /**
  5875. * Represents the range of an animation
  5876. */
  5877. export class AnimationRange {
  5878. /**The name of the animation range**/
  5879. name: string;
  5880. /**The starting frame of the animation */
  5881. from: number;
  5882. /**The ending frame of the animation*/
  5883. to: number;
  5884. /**
  5885. * Initializes the range of an animation
  5886. * @param name The name of the animation range
  5887. * @param from The starting frame of the animation
  5888. * @param to The ending frame of the animation
  5889. */
  5890. constructor(
  5891. /**The name of the animation range**/
  5892. name: string,
  5893. /**The starting frame of the animation */
  5894. from: number,
  5895. /**The ending frame of the animation*/
  5896. to: number);
  5897. /**
  5898. * Makes a copy of the animation range
  5899. * @returns A copy of the animation range
  5900. */
  5901. clone(): AnimationRange;
  5902. }
  5903. }
  5904. declare module "babylonjs/Animations/animationEvent" {
  5905. /**
  5906. * Composed of a frame, and an action function
  5907. */
  5908. export class AnimationEvent {
  5909. /** The frame for which the event is triggered **/
  5910. frame: number;
  5911. /** The event to perform when triggered **/
  5912. action: (currentFrame: number) => void;
  5913. /** Specifies if the event should be triggered only once**/
  5914. onlyOnce?: boolean | undefined;
  5915. /**
  5916. * Specifies if the animation event is done
  5917. */
  5918. isDone: boolean;
  5919. /**
  5920. * Initializes the animation event
  5921. * @param frame The frame for which the event is triggered
  5922. * @param action The event to perform when triggered
  5923. * @param onlyOnce Specifies if the event should be triggered only once
  5924. */
  5925. constructor(
  5926. /** The frame for which the event is triggered **/
  5927. frame: number,
  5928. /** The event to perform when triggered **/
  5929. action: (currentFrame: number) => void,
  5930. /** Specifies if the event should be triggered only once**/
  5931. onlyOnce?: boolean | undefined);
  5932. /** @hidden */
  5933. _clone(): AnimationEvent;
  5934. }
  5935. }
  5936. declare module "babylonjs/Behaviors/behavior" {
  5937. import { Nullable } from "babylonjs/types";
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. export interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. export interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/smartArray" {
  5983. /**
  5984. * Defines an array and its length.
  5985. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5986. */
  5987. export interface ISmartArrayLike<T> {
  5988. /**
  5989. * The data of the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. }
  5997. /**
  5998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5999. */
  6000. export class SmartArray<T> implements ISmartArrayLike<T> {
  6001. /**
  6002. * The full set of data from the array.
  6003. */
  6004. data: Array<T>;
  6005. /**
  6006. * The active length of the array.
  6007. */
  6008. length: number;
  6009. protected _id: number;
  6010. /**
  6011. * Instantiates a Smart Array.
  6012. * @param capacity defines the default capacity of the array.
  6013. */
  6014. constructor(capacity: number);
  6015. /**
  6016. * Pushes a value at the end of the active data.
  6017. * @param value defines the object to push in the array.
  6018. */
  6019. push(value: T): void;
  6020. /**
  6021. * Iterates over the active data and apply the lambda to them.
  6022. * @param func defines the action to apply on each value.
  6023. */
  6024. forEach(func: (content: T) => void): void;
  6025. /**
  6026. * Sorts the full sets of data.
  6027. * @param compareFn defines the comparison function to apply.
  6028. */
  6029. sort(compareFn: (a: T, b: T) => number): void;
  6030. /**
  6031. * Resets the active data to an empty array.
  6032. */
  6033. reset(): void;
  6034. /**
  6035. * Releases all the data from the array as well as the array.
  6036. */
  6037. dispose(): void;
  6038. /**
  6039. * Concats the active data with a given array.
  6040. * @param array defines the data to concatenate with.
  6041. */
  6042. concat(array: any): void;
  6043. /**
  6044. * Returns the position of a value in the active data.
  6045. * @param value defines the value to find the index for
  6046. * @returns the index if found in the active data otherwise -1
  6047. */
  6048. indexOf(value: T): number;
  6049. /**
  6050. * Returns whether an element is part of the active data.
  6051. * @param value defines the value to look for
  6052. * @returns true if found in the active data otherwise false
  6053. */
  6054. contains(value: T): boolean;
  6055. private static _GlobalId;
  6056. }
  6057. /**
  6058. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6059. * The data in this array can only be present once
  6060. */
  6061. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6062. private _duplicateId;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Pushes a value at the end of the active data.
  6071. * If the data is already present, it won t be added again
  6072. * @param value defines the object to push in the array.
  6073. * @returns true if added false if it was already present
  6074. */
  6075. pushNoDuplicate(value: T): boolean;
  6076. /**
  6077. * Resets the active data to an empty array.
  6078. */
  6079. reset(): void;
  6080. /**
  6081. * Concats the active data with a given array.
  6082. * This ensures no dupplicate will be present in the result.
  6083. * @param array defines the data to concatenate with.
  6084. */
  6085. concatWithNoDuplicate(array: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Cameras/cameraInputsManager" {
  6089. import { Nullable } from "babylonjs/types";
  6090. import { Camera } from "babylonjs/Cameras/camera";
  6091. /**
  6092. * @ignore
  6093. * This is a list of all the different input types that are available in the application.
  6094. * Fo instance: ArcRotateCameraGamepadInput...
  6095. */
  6096. export var CameraInputTypes: {};
  6097. /**
  6098. * This is the contract to implement in order to create a new input class.
  6099. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6100. */
  6101. export interface ICameraInput<TCamera extends Camera> {
  6102. /**
  6103. * Defines the camera the input is attached to.
  6104. */
  6105. camera: Nullable<TCamera>;
  6106. /**
  6107. * Gets the class name of the current intput.
  6108. * @returns the class name
  6109. */
  6110. getClassName(): string;
  6111. /**
  6112. * Get the friendly name associated with the input class.
  6113. * @returns the input friendly name
  6114. */
  6115. getSimpleName(): string;
  6116. /**
  6117. * Attach the input controls to a specific dom element to get the input from.
  6118. * @param element Defines the element the controls should be listened from
  6119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6120. */
  6121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6122. /**
  6123. * Detach the current controls from the specified dom element.
  6124. * @param element Defines the element to stop listening the inputs from
  6125. */
  6126. detachControl(element: Nullable<HTMLElement>): void;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs?: () => void;
  6132. }
  6133. /**
  6134. * Represents a map of input types to input instance or input index to input instance.
  6135. */
  6136. export interface CameraInputsMap<TCamera extends Camera> {
  6137. /**
  6138. * Accessor to the input by input type.
  6139. */
  6140. [name: string]: ICameraInput<TCamera>;
  6141. /**
  6142. * Accessor to the input by input index.
  6143. */
  6144. [idx: number]: ICameraInput<TCamera>;
  6145. }
  6146. /**
  6147. * This represents the input manager used within a camera.
  6148. * It helps dealing with all the different kind of input attached to a camera.
  6149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6150. */
  6151. export class CameraInputsManager<TCamera extends Camera> {
  6152. /**
  6153. * Defines the list of inputs attahed to the camera.
  6154. */
  6155. attached: CameraInputsMap<TCamera>;
  6156. /**
  6157. * Defines the dom element the camera is collecting inputs from.
  6158. * This is null if the controls have not been attached.
  6159. */
  6160. attachedElement: Nullable<HTMLElement>;
  6161. /**
  6162. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6163. */
  6164. noPreventDefault: boolean;
  6165. /**
  6166. * Defined the camera the input manager belongs to.
  6167. */
  6168. camera: TCamera;
  6169. /**
  6170. * Update the current camera state depending on the inputs that have been used this frame.
  6171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6172. */
  6173. checkInputs: () => void;
  6174. /**
  6175. * Instantiate a new Camera Input Manager.
  6176. * @param camera Defines the camera the input manager blongs to
  6177. */
  6178. constructor(camera: TCamera);
  6179. /**
  6180. * Add an input method to a camera
  6181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6182. * @param input camera input method
  6183. */
  6184. add(input: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input method from a camera
  6187. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6188. * @param inputToRemove camera input method
  6189. */
  6190. remove(inputToRemove: ICameraInput<TCamera>): void;
  6191. /**
  6192. * Remove a specific input type from a camera
  6193. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6194. * @param inputType the type of the input to remove
  6195. */
  6196. removeByType(inputType: string): void;
  6197. private _addCheckInputs;
  6198. /**
  6199. * Attach the input controls to the currently attached dom element to listen the events from.
  6200. * @param input Defines the input to attach
  6201. */
  6202. attachInput(input: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6207. */
  6208. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6209. /**
  6210. * Detach the current manager inputs controls from a specific dom element.
  6211. * @param element Defines the dom element to collect the events from
  6212. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6213. */
  6214. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6215. /**
  6216. * Rebuild the dynamic inputCheck function from the current list of
  6217. * defined inputs in the manager.
  6218. */
  6219. rebuildInputCheck(): void;
  6220. /**
  6221. * Remove all attached input methods from a camera
  6222. */
  6223. clear(): void;
  6224. /**
  6225. * Serialize the current input manager attached to a camera.
  6226. * This ensures than once parsed,
  6227. * the input associated to the camera will be identical to the current ones
  6228. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6229. */
  6230. serialize(serializedCamera: any): void;
  6231. /**
  6232. * Parses an input manager serialized JSON to restore the previous list of inputs
  6233. * and states associated to a camera.
  6234. * @param parsedCamera Defines the JSON to parse
  6235. */
  6236. parse(parsedCamera: any): void;
  6237. }
  6238. }
  6239. declare module "babylonjs/Meshes/buffer" {
  6240. import { Nullable, DataArray } from "babylonjs/types";
  6241. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6242. /**
  6243. * Class used to store data that will be store in GPU memory
  6244. */
  6245. export class Buffer {
  6246. private _engine;
  6247. private _buffer;
  6248. /** @hidden */
  6249. _data: Nullable<DataArray>;
  6250. private _updatable;
  6251. private _instanced;
  6252. /**
  6253. * Gets the byte stride.
  6254. */
  6255. readonly byteStride: number;
  6256. /**
  6257. * Constructor
  6258. * @param engine the engine
  6259. * @param data the data to use for this buffer
  6260. * @param updatable whether the data is updatable
  6261. * @param stride the stride (optional)
  6262. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6263. * @param instanced whether the buffer is instanced (optional)
  6264. * @param useBytes set to true if the stride in in bytes (optional)
  6265. */
  6266. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6267. /**
  6268. * Create a new VertexBuffer based on the current buffer
  6269. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6270. * @param offset defines offset in the buffer (0 by default)
  6271. * @param size defines the size in floats of attributes (position is 3 for instance)
  6272. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6273. * @param instanced defines if the vertex buffer contains indexed data
  6274. * @param useBytes defines if the offset and stride are in bytes
  6275. * @returns the new vertex buffer
  6276. */
  6277. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6278. /**
  6279. * Gets a boolean indicating if the Buffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6302. * @param data defines the data to store
  6303. */
  6304. create(data?: Nullable<DataArray>): void;
  6305. /** @hidden */
  6306. _rebuild(): void;
  6307. /**
  6308. * Update current buffer data
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates the data directly.
  6314. * @param data the new data
  6315. * @param offset the new offset
  6316. * @param vertexCount the vertex count (optional)
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6320. /**
  6321. * Release all resources
  6322. */
  6323. dispose(): void;
  6324. }
  6325. /**
  6326. * Specialized buffer used to store vertex data
  6327. */
  6328. export class VertexBuffer {
  6329. /** @hidden */
  6330. _buffer: Buffer;
  6331. private _kind;
  6332. private _size;
  6333. private _ownsBuffer;
  6334. private _instanced;
  6335. private _instanceDivisor;
  6336. /**
  6337. * The byte type.
  6338. */
  6339. static readonly BYTE: number;
  6340. /**
  6341. * The unsigned byte type.
  6342. */
  6343. static readonly UNSIGNED_BYTE: number;
  6344. /**
  6345. * The short type.
  6346. */
  6347. static readonly SHORT: number;
  6348. /**
  6349. * The unsigned short type.
  6350. */
  6351. static readonly UNSIGNED_SHORT: number;
  6352. /**
  6353. * The integer type.
  6354. */
  6355. static readonly INT: number;
  6356. /**
  6357. * The unsigned integer type.
  6358. */
  6359. static readonly UNSIGNED_INT: number;
  6360. /**
  6361. * The float type.
  6362. */
  6363. static readonly FLOAT: number;
  6364. /**
  6365. * Gets or sets the instance divisor when in instanced mode
  6366. */
  6367. instanceDivisor: number;
  6368. /**
  6369. * Gets the byte stride.
  6370. */
  6371. readonly byteStride: number;
  6372. /**
  6373. * Gets the byte offset.
  6374. */
  6375. readonly byteOffset: number;
  6376. /**
  6377. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6378. */
  6379. readonly normalized: boolean;
  6380. /**
  6381. * Gets the data type of each component in the array.
  6382. */
  6383. readonly type: number;
  6384. /**
  6385. * Constructor
  6386. * @param engine the engine
  6387. * @param data the data to use for this vertex buffer
  6388. * @param kind the vertex buffer kind
  6389. * @param updatable whether the data is updatable
  6390. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6391. * @param stride the stride (optional)
  6392. * @param instanced whether the buffer is instanced (optional)
  6393. * @param offset the offset of the data (optional)
  6394. * @param size the number of components (optional)
  6395. * @param type the type of the component (optional)
  6396. * @param normalized whether the data contains normalized data (optional)
  6397. * @param useBytes set to true if stride and offset are in bytes (optional)
  6398. */
  6399. 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);
  6400. /** @hidden */
  6401. _rebuild(): void;
  6402. /**
  6403. * Returns the kind of the VertexBuffer (string)
  6404. * @returns a string
  6405. */
  6406. getKind(): string;
  6407. /**
  6408. * Gets a boolean indicating if the VertexBuffer is updatable?
  6409. * @returns true if the buffer is updatable
  6410. */
  6411. isUpdatable(): boolean;
  6412. /**
  6413. * Gets current buffer's data
  6414. * @returns a DataArray or null
  6415. */
  6416. getData(): Nullable<DataArray>;
  6417. /**
  6418. * Gets underlying native buffer
  6419. * @returns underlying native buffer
  6420. */
  6421. getBuffer(): Nullable<DataBuffer>;
  6422. /**
  6423. * Gets the stride in float32 units (i.e. byte stride / 4).
  6424. * May not be an integer if the byte stride is not divisible by 4.
  6425. * DEPRECATED. Use byteStride instead.
  6426. * @returns the stride in float32 units
  6427. */
  6428. getStrideSize(): number;
  6429. /**
  6430. * Returns the offset as a multiple of the type byte length.
  6431. * DEPRECATED. Use byteOffset instead.
  6432. * @returns the offset in bytes
  6433. */
  6434. getOffset(): number;
  6435. /**
  6436. * Returns the number of components per vertex attribute (integer)
  6437. * @returns the size in float
  6438. */
  6439. getSize(): number;
  6440. /**
  6441. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6442. * @returns true if this buffer is instanced
  6443. */
  6444. getIsInstanced(): boolean;
  6445. /**
  6446. * Returns the instancing divisor, zero for non-instanced (integer).
  6447. * @returns a number
  6448. */
  6449. getInstanceDivisor(): number;
  6450. /**
  6451. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6452. * @param data defines the data to store
  6453. */
  6454. create(data?: DataArray): void;
  6455. /**
  6456. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6457. * This function will create a new buffer if the current one is not updatable
  6458. * @param data defines the data to store
  6459. */
  6460. update(data: DataArray): void;
  6461. /**
  6462. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6463. * Returns the directly updated WebGLBuffer.
  6464. * @param data the new data
  6465. * @param offset the new offset
  6466. * @param useBytes set to true if the offset is in bytes
  6467. */
  6468. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6469. /**
  6470. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6471. */
  6472. dispose(): void;
  6473. /**
  6474. * Enumerates each value of this vertex buffer as numbers.
  6475. * @param count the number of values to enumerate
  6476. * @param callback the callback function called for each value
  6477. */
  6478. forEach(count: number, callback: (value: number, index: number) => void): void;
  6479. /**
  6480. * Positions
  6481. */
  6482. static readonly PositionKind: string;
  6483. /**
  6484. * Normals
  6485. */
  6486. static readonly NormalKind: string;
  6487. /**
  6488. * Tangents
  6489. */
  6490. static readonly TangentKind: string;
  6491. /**
  6492. * Texture coordinates
  6493. */
  6494. static readonly UVKind: string;
  6495. /**
  6496. * Texture coordinates 2
  6497. */
  6498. static readonly UV2Kind: string;
  6499. /**
  6500. * Texture coordinates 3
  6501. */
  6502. static readonly UV3Kind: string;
  6503. /**
  6504. * Texture coordinates 4
  6505. */
  6506. static readonly UV4Kind: string;
  6507. /**
  6508. * Texture coordinates 5
  6509. */
  6510. static readonly UV5Kind: string;
  6511. /**
  6512. * Texture coordinates 6
  6513. */
  6514. static readonly UV6Kind: string;
  6515. /**
  6516. * Colors
  6517. */
  6518. static readonly ColorKind: string;
  6519. /**
  6520. * Matrix indices (for bones)
  6521. */
  6522. static readonly MatricesIndicesKind: string;
  6523. /**
  6524. * Matrix weights (for bones)
  6525. */
  6526. static readonly MatricesWeightsKind: string;
  6527. /**
  6528. * Additional matrix indices (for bones)
  6529. */
  6530. static readonly MatricesIndicesExtraKind: string;
  6531. /**
  6532. * Additional matrix weights (for bones)
  6533. */
  6534. static readonly MatricesWeightsExtraKind: string;
  6535. /**
  6536. * Deduces the stride given a kind.
  6537. * @param kind The kind string to deduce
  6538. * @returns The deduced stride
  6539. */
  6540. static DeduceStride(kind: string): number;
  6541. /**
  6542. * Gets the byte length of the given type.
  6543. * @param type the type
  6544. * @returns the number of bytes
  6545. */
  6546. static GetTypeByteLength(type: number): number;
  6547. /**
  6548. * Enumerates each value of the given parameters as numbers.
  6549. * @param data the data to enumerate
  6550. * @param byteOffset the byte offset of the data
  6551. * @param byteStride the byte stride of the data
  6552. * @param componentCount the number of components per element
  6553. * @param componentType the type of the component
  6554. * @param count the number of values to enumerate
  6555. * @param normalized whether the data is normalized
  6556. * @param callback the callback function called for each value
  6557. */
  6558. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6559. private static _GetFloatValue;
  6560. }
  6561. }
  6562. declare module "babylonjs/Collisions/intersectionInfo" {
  6563. import { Nullable } from "babylonjs/types";
  6564. /**
  6565. * @hidden
  6566. */
  6567. export class IntersectionInfo {
  6568. bu: Nullable<number>;
  6569. bv: Nullable<number>;
  6570. distance: number;
  6571. faceId: number;
  6572. subMeshId: number;
  6573. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6574. }
  6575. }
  6576. declare module "babylonjs/Maths/math.plane" {
  6577. import { DeepImmutable } from "babylonjs/types";
  6578. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6579. /**
  6580. * Represens a plane by the equation ax + by + cz + d = 0
  6581. */
  6582. export class Plane {
  6583. private static _TmpMatrix;
  6584. /**
  6585. * Normal of the plane (a,b,c)
  6586. */
  6587. normal: Vector3;
  6588. /**
  6589. * d component of the plane
  6590. */
  6591. d: number;
  6592. /**
  6593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6594. * @param a a component of the plane
  6595. * @param b b component of the plane
  6596. * @param c c component of the plane
  6597. * @param d d component of the plane
  6598. */
  6599. constructor(a: number, b: number, c: number, d: number);
  6600. /**
  6601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6602. */
  6603. asArray(): number[];
  6604. /**
  6605. * @returns a new plane copied from the current Plane.
  6606. */
  6607. clone(): Plane;
  6608. /**
  6609. * @returns the string "Plane".
  6610. */
  6611. getClassName(): string;
  6612. /**
  6613. * @returns the Plane hash code.
  6614. */
  6615. getHashCode(): number;
  6616. /**
  6617. * Normalize the current Plane in place.
  6618. * @returns the updated Plane.
  6619. */
  6620. normalize(): Plane;
  6621. /**
  6622. * Applies a transformation the plane and returns the result
  6623. * @param transformation the transformation matrix to be applied to the plane
  6624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6625. */
  6626. transform(transformation: DeepImmutable<Matrix>): Plane;
  6627. /**
  6628. * Calcualtte the dot product between the point and the plane normal
  6629. * @param point point to calculate the dot product with
  6630. * @returns the dot product (float) of the point coordinates and the plane normal.
  6631. */
  6632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6633. /**
  6634. * Updates the current Plane from the plane defined by the three given points.
  6635. * @param point1 one of the points used to contruct the plane
  6636. * @param point2 one of the points used to contruct the plane
  6637. * @param point3 one of the points used to contruct the plane
  6638. * @returns the updated Plane.
  6639. */
  6640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6641. /**
  6642. * Checks if the plane is facing a given direction
  6643. * @param direction the direction to check if the plane is facing
  6644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6645. * @returns True is the vector "direction" is the same side than the plane normal.
  6646. */
  6647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6648. /**
  6649. * Calculates the distance to a point
  6650. * @param point point to calculate distance to
  6651. * @returns the signed distance (float) from the given point to the Plane.
  6652. */
  6653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6654. /**
  6655. * Creates a plane from an array
  6656. * @param array the array to create a plane from
  6657. * @returns a new Plane from the given array.
  6658. */
  6659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6660. /**
  6661. * Creates a plane from three points
  6662. * @param point1 point used to create the plane
  6663. * @param point2 point used to create the plane
  6664. * @param point3 point used to create the plane
  6665. * @returns a new Plane defined by the three given points.
  6666. */
  6667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Creates a plane from an origin point and a normal
  6670. * @param origin origin of the plane to be constructed
  6671. * @param normal normal of the plane to be constructed
  6672. * @returns a new Plane the normal vector to this plane at the given origin point.
  6673. * Note : the vector "normal" is updated because normalized.
  6674. */
  6675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Calculates the distance from a plane and a point
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @param point point to calculate distance to
  6681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6682. */
  6683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6684. }
  6685. }
  6686. declare module "babylonjs/Culling/boundingSphere" {
  6687. import { DeepImmutable } from "babylonjs/types";
  6688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding sphere information
  6692. */
  6693. export class BoundingSphere {
  6694. /**
  6695. * Gets the center of the bounding sphere in local space
  6696. */
  6697. readonly center: Vector3;
  6698. /**
  6699. * Radius of the bounding sphere in local space
  6700. */
  6701. radius: number;
  6702. /**
  6703. * Gets the center of the bounding sphere in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Radius of the bounding sphere in world space
  6708. */
  6709. radiusWorld: number;
  6710. /**
  6711. * Gets the minimum vector in local space
  6712. */
  6713. readonly minimum: Vector3;
  6714. /**
  6715. * Gets the maximum vector in local space
  6716. */
  6717. readonly maximum: Vector3;
  6718. private _worldMatrix;
  6719. private static readonly TmpVector3;
  6720. /**
  6721. * Creates a new bounding sphere
  6722. * @param min defines the minimum vector (in local space)
  6723. * @param max defines the maximum vector (in local space)
  6724. * @param worldMatrix defines the new world matrix
  6725. */
  6726. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6727. /**
  6728. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6729. * @param min defines the new minimum vector (in local space)
  6730. * @param max defines the new maximum vector (in local space)
  6731. * @param worldMatrix defines the new world matrix
  6732. */
  6733. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6734. /**
  6735. * Scale the current bounding sphere by applying a scale factor
  6736. * @param factor defines the scale factor to apply
  6737. * @returns the current bounding box
  6738. */
  6739. scale(factor: number): BoundingSphere;
  6740. /**
  6741. * Gets the world matrix of the bounding box
  6742. * @returns a matrix
  6743. */
  6744. getWorldMatrix(): DeepImmutable<Matrix>;
  6745. /** @hidden */
  6746. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6747. /**
  6748. * Tests if the bounding sphere is intersecting the frustum planes
  6749. * @param frustumPlanes defines the frustum planes to test
  6750. * @returns true if there is an intersection
  6751. */
  6752. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6753. /**
  6754. * Tests if the bounding sphere center is in between the frustum planes.
  6755. * Used for optimistic fast inclusion.
  6756. * @param frustumPlanes defines the frustum planes to test
  6757. * @returns true if the sphere center is in between the frustum planes
  6758. */
  6759. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6760. /**
  6761. * Tests if a point is inside the bounding sphere
  6762. * @param point defines the point to test
  6763. * @returns true if the point is inside the bounding sphere
  6764. */
  6765. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6766. /**
  6767. * Checks if two sphere intersct
  6768. * @param sphere0 sphere 0
  6769. * @param sphere1 sphere 1
  6770. * @returns true if the speres intersect
  6771. */
  6772. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6773. }
  6774. }
  6775. declare module "babylonjs/Culling/boundingBox" {
  6776. import { DeepImmutable } from "babylonjs/types";
  6777. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6778. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6779. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/collider" {
  6926. import { Nullable, IndicesArray } from "babylonjs/types";
  6927. import { Vector3 } from "babylonjs/Maths/math.vector";
  6928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6929. import { Plane } from "babylonjs/Maths/math.plane";
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. collisionMask: number;
  6973. /**
  6974. * Gets the plane normal used to compute the sliding response (in local space)
  6975. */
  6976. readonly slidePlaneNormal: Vector3;
  6977. /** @hidden */
  6978. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6979. /** @hidden */
  6980. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6981. /** @hidden */
  6982. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6983. /** @hidden */
  6984. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6987. /** @hidden */
  6988. _getResponse(pos: Vector3, vel: Vector3): void;
  6989. }
  6990. }
  6991. declare module "babylonjs/Culling/boundingInfo" {
  6992. import { DeepImmutable } from "babylonjs/types";
  6993. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6994. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6995. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6996. import { Plane } from "babylonjs/Maths/math.plane";
  6997. import { Collider } from "babylonjs/Collisions/collider";
  6998. /**
  6999. * Interface for cullable objects
  7000. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7001. */
  7002. export interface ICullable {
  7003. /**
  7004. * Checks if the object or part of the object is in the frustum
  7005. * @param frustumPlanes Camera near/planes
  7006. * @returns true if the object is in frustum otherwise false
  7007. */
  7008. isInFrustum(frustumPlanes: Plane[]): boolean;
  7009. /**
  7010. * Checks if a cullable object (mesh...) is in the camera frustum
  7011. * Unlike isInFrustum this cheks the full bounding box
  7012. * @param frustumPlanes Camera near/planes
  7013. * @returns true if the object is in frustum otherwise false
  7014. */
  7015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7016. }
  7017. /**
  7018. * Info for a bounding data of a mesh
  7019. */
  7020. export class BoundingInfo implements ICullable {
  7021. /**
  7022. * Bounding box for the mesh
  7023. */
  7024. readonly boundingBox: BoundingBox;
  7025. /**
  7026. * Bounding sphere for the mesh
  7027. */
  7028. readonly boundingSphere: BoundingSphere;
  7029. private _isLocked;
  7030. private static readonly TmpVector3;
  7031. /**
  7032. * Constructs bounding info
  7033. * @param minimum min vector of the bounding box/sphere
  7034. * @param maximum max vector of the bounding box/sphere
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7038. /**
  7039. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7040. * @param min defines the new minimum vector (in local space)
  7041. * @param max defines the new maximum vector (in local space)
  7042. * @param worldMatrix defines the new world matrix
  7043. */
  7044. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * min vector of the bounding box/sphere
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * max vector of the bounding box/sphere
  7051. */
  7052. readonly maximum: Vector3;
  7053. /**
  7054. * If the info is locked and won't be updated to avoid perf overhead
  7055. */
  7056. isLocked: boolean;
  7057. /**
  7058. * Updates the bounding sphere and box
  7059. * @param world world matrix to be used to update
  7060. */
  7061. update(world: DeepImmutable<Matrix>): void;
  7062. /**
  7063. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7064. * @param center New center of the bounding info
  7065. * @param extend New extend of the bounding info
  7066. * @returns the current bounding info
  7067. */
  7068. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7069. /**
  7070. * Scale the current bounding info by applying a scale factor
  7071. * @param factor defines the scale factor to apply
  7072. * @returns the current bounding info
  7073. */
  7074. scale(factor: number): BoundingInfo;
  7075. /**
  7076. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7077. * @param frustumPlanes defines the frustum to test
  7078. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7079. * @returns true if the bounding info is in the frustum planes
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7082. /**
  7083. * Gets the world distance between the min and max points of the bounding box
  7084. */
  7085. readonly diagonalLength: number;
  7086. /**
  7087. * Checks if a cullable object (mesh...) is in the camera frustum
  7088. * Unlike isInFrustum this cheks the full bounding box
  7089. * @param frustumPlanes Camera near/planes
  7090. * @returns true if the object is in frustum otherwise false
  7091. */
  7092. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /** @hidden */
  7094. _checkCollision(collider: Collider): boolean;
  7095. /**
  7096. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param point the point to check intersection with
  7099. * @returns if the point intersects
  7100. */
  7101. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7102. /**
  7103. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7104. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7105. * @param boundingInfo the bounding info to check intersection with
  7106. * @param precise if the intersection should be done using OBB
  7107. * @returns if the bounding info intersects
  7108. */
  7109. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7110. }
  7111. }
  7112. declare module "babylonjs/Maths/math.functions" {
  7113. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7114. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7115. /**
  7116. * Extracts minimum and maximum values from a list of indexed positions
  7117. * @param positions defines the positions to use
  7118. * @param indices defines the indices to the positions
  7119. * @param indexStart defines the start index
  7120. * @param indexCount defines the end index
  7121. * @param bias defines bias value to add to the result
  7122. * @return minimum and maximum values
  7123. */
  7124. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7125. minimum: Vector3;
  7126. maximum: Vector3;
  7127. };
  7128. /**
  7129. * Extracts minimum and maximum values from a list of positions
  7130. * @param positions defines the positions to use
  7131. * @param start defines the start index in the positions array
  7132. * @param count defines the number of positions to handle
  7133. * @param bias defines bias value to add to the result
  7134. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. }
  7142. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7143. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7144. /** @hidden */
  7145. export class WebGLDataBuffer extends DataBuffer {
  7146. private _buffer;
  7147. constructor(resource: WebGLBuffer);
  7148. readonly underlyingResource: any;
  7149. }
  7150. }
  7151. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7152. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7153. import { Nullable } from "babylonjs/types";
  7154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7155. /** @hidden */
  7156. export class WebGLPipelineContext implements IPipelineContext {
  7157. engine: ThinEngine;
  7158. program: Nullable<WebGLProgram>;
  7159. context?: WebGLRenderingContext;
  7160. vertexShader?: WebGLShader;
  7161. fragmentShader?: WebGLShader;
  7162. isParallelCompiled: boolean;
  7163. onCompiled?: () => void;
  7164. transformFeedback?: WebGLTransformFeedback | null;
  7165. readonly isAsync: boolean;
  7166. readonly isReady: boolean;
  7167. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7168. }
  7169. }
  7170. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7171. import { FloatArray, Nullable } from "babylonjs/types";
  7172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7173. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7174. module "babylonjs/Engines/thinEngine" {
  7175. interface ThinEngine {
  7176. /**
  7177. * Create an uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param elements defines the content of the uniform buffer
  7180. * @returns the webGL uniform buffer
  7181. */
  7182. createUniformBuffer(elements: FloatArray): DataBuffer;
  7183. /**
  7184. * Create a dynamic uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Update an existing uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param uniformBuffer defines the target uniform buffer
  7194. * @param elements defines the content to update
  7195. * @param offset defines the offset in the uniform buffer where update should start
  7196. * @param count defines the size of the data to update
  7197. */
  7198. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7199. /**
  7200. * Bind an uniform buffer to the current webGL context
  7201. * @param buffer defines the buffer to bind
  7202. */
  7203. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7204. /**
  7205. * Bind a buffer to the current webGL context at a given location
  7206. * @param buffer defines the buffer to bind
  7207. * @param location defines the index where to bind the buffer
  7208. */
  7209. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7210. /**
  7211. * Bind a specific block at a given index in a specific shader program
  7212. * @param pipelineContext defines the pipeline context to use
  7213. * @param blockName defines the block name
  7214. * @param index defines the index where to bind the block
  7215. */
  7216. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7217. }
  7218. }
  7219. }
  7220. declare module "babylonjs/Materials/uniformBuffer" {
  7221. import { Nullable, FloatArray } from "babylonjs/types";
  7222. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7223. import { Engine } from "babylonjs/Engines/engine";
  7224. import { Effect } from "babylonjs/Materials/effect";
  7225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7226. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7227. import { Color3 } from "babylonjs/Maths/math.color";
  7228. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7229. /**
  7230. * Uniform buffer objects.
  7231. *
  7232. * Handles blocks of uniform on the GPU.
  7233. *
  7234. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7235. *
  7236. * For more information, please refer to :
  7237. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7238. */
  7239. export class UniformBuffer {
  7240. private _engine;
  7241. private _buffer;
  7242. private _data;
  7243. private _bufferData;
  7244. private _dynamic?;
  7245. private _uniformLocations;
  7246. private _uniformSizes;
  7247. private _uniformLocationPointer;
  7248. private _needSync;
  7249. private _noUBO;
  7250. private _currentEffect;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. 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;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. 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;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7671. }
  7672. }
  7673. }
  7674. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7675. import { Nullable } from "babylonjs/types";
  7676. import { Scene } from "babylonjs/scene";
  7677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7679. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. boundingBoxSize: Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. /**
  7712. * Gets texture matrix rotation angle around Y axis radians.
  7713. */
  7714. rotationY: number;
  7715. /**
  7716. * Are mip maps generated for this texture or not.
  7717. */
  7718. readonly noMipmap: boolean;
  7719. private _noMipmap;
  7720. private _files;
  7721. private _extensions;
  7722. private _textureMatrix;
  7723. private _format;
  7724. private _createPolynomials;
  7725. /** @hidden */
  7726. _prefiltered: boolean;
  7727. /**
  7728. * Creates a cube texture from an array of image urls
  7729. * @param files defines an array of image urls
  7730. * @param scene defines the hosting scene
  7731. * @param noMipmap specifies if mip maps are not used
  7732. * @returns a cube texture
  7733. */
  7734. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7735. /**
  7736. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7737. * @param url defines the url of the prefiltered texture
  7738. * @param scene defines the scene the texture is attached to
  7739. * @param forcedExtension defines the extension of the file if different from the url
  7740. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7741. * @return the prefiltered texture
  7742. */
  7743. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7744. /**
  7745. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7746. * as prefiltered data.
  7747. * @param rootUrl defines the url of the texture or the root name of the six images
  7748. * @param scene defines the scene the texture is attached to
  7749. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7750. * @param noMipmap defines if mipmaps should be created or not
  7751. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7752. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7753. * @param onError defines a callback triggered in case of error during load
  7754. * @param format defines the internal format to use for the texture once loaded
  7755. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7756. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7757. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7758. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7759. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7760. * @return the cube texture
  7761. */
  7762. 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);
  7763. /**
  7764. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7765. */
  7766. readonly isPrefiltered: boolean;
  7767. /**
  7768. * Get the current class name of the texture useful for serialization or dynamic coding.
  7769. * @returns "CubeTexture"
  7770. */
  7771. getClassName(): string;
  7772. /**
  7773. * Update the url (and optional buffer) of this texture if url was null during construction.
  7774. * @param url the url of the texture
  7775. * @param forcedExtension defines the extension to use
  7776. * @param onLoad callback called when the texture is loaded (defaults to null)
  7777. */
  7778. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7779. /**
  7780. * Delays loading of the cube texture
  7781. * @param forcedExtension defines the extension to use
  7782. */
  7783. delayLoad(forcedExtension?: string): void;
  7784. /**
  7785. * Returns the reflection texture matrix
  7786. * @returns the reflection texture matrix
  7787. */
  7788. getReflectionTextureMatrix(): Matrix;
  7789. /**
  7790. * Sets the reflection texture matrix
  7791. * @param value Reflection texture matrix
  7792. */
  7793. setReflectionTextureMatrix(value: Matrix): void;
  7794. /**
  7795. * Parses text to create a cube texture
  7796. * @param parsedTexture define the serialized text to read from
  7797. * @param scene defines the hosting scene
  7798. * @param rootUrl defines the root url of the cube texture
  7799. * @returns a cube texture
  7800. */
  7801. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7802. /**
  7803. * Makes a clone, or deep copy, of the cube texture
  7804. * @returns a new cube texture
  7805. */
  7806. clone(): CubeTexture;
  7807. }
  7808. }
  7809. declare module "babylonjs/Materials/materialDefines" {
  7810. /**
  7811. * Manages the defines for the Material
  7812. */
  7813. export class MaterialDefines {
  7814. /** @hidden */
  7815. protected _keys: string[];
  7816. private _isDirty;
  7817. /** @hidden */
  7818. _renderId: number;
  7819. /** @hidden */
  7820. _areLightsDirty: boolean;
  7821. /** @hidden */
  7822. _areLightsDisposed: boolean;
  7823. /** @hidden */
  7824. _areAttributesDirty: boolean;
  7825. /** @hidden */
  7826. _areTexturesDirty: boolean;
  7827. /** @hidden */
  7828. _areFresnelDirty: boolean;
  7829. /** @hidden */
  7830. _areMiscDirty: boolean;
  7831. /** @hidden */
  7832. _areImageProcessingDirty: boolean;
  7833. /** @hidden */
  7834. _normals: boolean;
  7835. /** @hidden */
  7836. _uvs: boolean;
  7837. /** @hidden */
  7838. _needNormals: boolean;
  7839. /** @hidden */
  7840. _needUVs: boolean;
  7841. [id: string]: any;
  7842. /**
  7843. * Specifies if the material needs to be re-calculated
  7844. */
  7845. readonly isDirty: boolean;
  7846. /**
  7847. * Marks the material to indicate that it has been re-calculated
  7848. */
  7849. markAsProcessed(): void;
  7850. /**
  7851. * Marks the material to indicate that it needs to be re-calculated
  7852. */
  7853. markAsUnprocessed(): void;
  7854. /**
  7855. * Marks the material to indicate all of its defines need to be re-calculated
  7856. */
  7857. markAllAsDirty(): void;
  7858. /**
  7859. * Marks the material to indicate that image processing needs to be re-calculated
  7860. */
  7861. markAsImageProcessingDirty(): void;
  7862. /**
  7863. * Marks the material to indicate the lights need to be re-calculated
  7864. * @param disposed Defines whether the light is dirty due to dispose or not
  7865. */
  7866. markAsLightDirty(disposed?: boolean): void;
  7867. /**
  7868. * Marks the attribute state as changed
  7869. */
  7870. markAsAttributesDirty(): void;
  7871. /**
  7872. * Marks the texture state as changed
  7873. */
  7874. markAsTexturesDirty(): void;
  7875. /**
  7876. * Marks the fresnel state as changed
  7877. */
  7878. markAsFresnelDirty(): void;
  7879. /**
  7880. * Marks the misc state as changed
  7881. */
  7882. markAsMiscDirty(): void;
  7883. /**
  7884. * Rebuilds the material defines
  7885. */
  7886. rebuild(): void;
  7887. /**
  7888. * Specifies if two material defines are equal
  7889. * @param other - A material define instance to compare to
  7890. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7891. */
  7892. isEqual(other: MaterialDefines): boolean;
  7893. /**
  7894. * Clones this instance's defines to another instance
  7895. * @param other - material defines to clone values to
  7896. */
  7897. cloneTo(other: MaterialDefines): void;
  7898. /**
  7899. * Resets the material define values
  7900. */
  7901. reset(): void;
  7902. /**
  7903. * Converts the material define values to a string
  7904. * @returns - String of material define information
  7905. */
  7906. toString(): string;
  7907. }
  7908. }
  7909. declare module "babylonjs/Materials/colorCurves" {
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. /**
  7912. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7913. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7914. * 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;
  7915. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7916. */
  7917. export class ColorCurves {
  7918. private _dirty;
  7919. private _tempColor;
  7920. private _globalCurve;
  7921. private _highlightsCurve;
  7922. private _midtonesCurve;
  7923. private _shadowsCurve;
  7924. private _positiveCurve;
  7925. private _negativeCurve;
  7926. private _globalHue;
  7927. private _globalDensity;
  7928. private _globalSaturation;
  7929. private _globalExposure;
  7930. /**
  7931. * Gets the global Hue value.
  7932. * 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).
  7933. */
  7934. /**
  7935. * Sets the global Hue value.
  7936. * 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).
  7937. */
  7938. globalHue: number;
  7939. /**
  7940. * Gets the global Density value.
  7941. * 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.
  7942. * Values less than zero provide a filter of opposite hue.
  7943. */
  7944. /**
  7945. * Sets the global Density value.
  7946. * 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.
  7947. * Values less than zero provide a filter of opposite hue.
  7948. */
  7949. globalDensity: number;
  7950. /**
  7951. * Gets the global Saturation value.
  7952. * 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.
  7953. */
  7954. /**
  7955. * Sets the global Saturation value.
  7956. * 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.
  7957. */
  7958. globalSaturation: number;
  7959. /**
  7960. * Gets the global Exposure value.
  7961. * 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.
  7962. */
  7963. /**
  7964. * Sets the global Exposure value.
  7965. * 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.
  7966. */
  7967. globalExposure: number;
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * 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).
  7975. */
  7976. /**
  7977. * Sets the highlights 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. highlightsHue: number;
  7981. /**
  7982. * Gets the highlights 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. /**
  7987. * Sets the highlights Density value.
  7988. * 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.
  7989. * Values less than zero provide a filter of opposite hue.
  7990. */
  7991. highlightsDensity: number;
  7992. /**
  7993. * Gets the highlights Saturation value.
  7994. * 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.
  7995. */
  7996. /**
  7997. * Sets the highlights Saturation value.
  7998. * 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.
  7999. */
  8000. highlightsSaturation: number;
  8001. /**
  8002. * Gets the highlights Exposure value.
  8003. * 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.
  8004. */
  8005. /**
  8006. * Sets the highlights Exposure value.
  8007. * 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.
  8008. */
  8009. highlightsExposure: number;
  8010. private _midtonesHue;
  8011. private _midtonesDensity;
  8012. private _midtonesSaturation;
  8013. private _midtonesExposure;
  8014. /**
  8015. * Gets the midtones Hue value.
  8016. * 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).
  8017. */
  8018. /**
  8019. * Sets the midtones Hue value.
  8020. * 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).
  8021. */
  8022. midtonesHue: number;
  8023. /**
  8024. * Gets the midtones Density value.
  8025. * 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.
  8026. * Values less than zero provide a filter of opposite hue.
  8027. */
  8028. /**
  8029. * Sets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. midtonesDensity: number;
  8034. /**
  8035. * Gets the midtones Saturation value.
  8036. * 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.
  8037. */
  8038. /**
  8039. * Sets the midtones Saturation value.
  8040. * 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.
  8041. */
  8042. midtonesSaturation: number;
  8043. /**
  8044. * Gets the midtones Exposure value.
  8045. * 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.
  8046. */
  8047. /**
  8048. * Sets the midtones Exposure value.
  8049. * 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.
  8050. */
  8051. midtonesExposure: number;
  8052. private _shadowsHue;
  8053. private _shadowsDensity;
  8054. private _shadowsSaturation;
  8055. private _shadowsExposure;
  8056. /**
  8057. * Gets the shadows Hue value.
  8058. * 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).
  8059. */
  8060. /**
  8061. * Sets the shadows Hue value.
  8062. * 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).
  8063. */
  8064. shadowsHue: number;
  8065. /**
  8066. * Gets the shadows Density value.
  8067. * 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.
  8068. * Values less than zero provide a filter of opposite hue.
  8069. */
  8070. /**
  8071. * Sets the shadows Density value.
  8072. * 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.
  8073. * Values less than zero provide a filter of opposite hue.
  8074. */
  8075. shadowsDensity: number;
  8076. /**
  8077. * Gets the shadows Saturation value.
  8078. * 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.
  8079. */
  8080. /**
  8081. * Sets the shadows Saturation value.
  8082. * 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.
  8083. */
  8084. shadowsSaturation: number;
  8085. /**
  8086. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  8088. */
  8089. /**
  8090. * Sets the shadows Exposure value.
  8091. * 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.
  8092. */
  8093. shadowsExposure: number;
  8094. /**
  8095. * Returns the class name
  8096. * @returns The class name
  8097. */
  8098. getClassName(): string;
  8099. /**
  8100. * Binds the color curves to the shader.
  8101. * @param colorCurves The color curve to bind
  8102. * @param effect The effect to bind to
  8103. * @param positiveUniform The positive uniform shader parameter
  8104. * @param neutralUniform The neutral uniform shader parameter
  8105. * @param negativeUniform The negative uniform shader parameter
  8106. */
  8107. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8108. /**
  8109. * Prepare the list of uniforms associated with the ColorCurves effects.
  8110. * @param uniformsList The list of uniforms used in the effect
  8111. */
  8112. static PrepareUniforms(uniformsList: string[]): void;
  8113. /**
  8114. * Returns color grading data based on a hue, density, saturation and exposure value.
  8115. * @param filterHue The hue of the color filter.
  8116. * @param filterDensity The density of the color filter.
  8117. * @param saturation The saturation.
  8118. * @param exposure The exposure.
  8119. * @param result The result data container.
  8120. */
  8121. private getColorGradingDataToRef;
  8122. /**
  8123. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8124. * @param value The input slider value in range [-100,100].
  8125. * @returns Adjusted value.
  8126. */
  8127. private static applyColorGradingSliderNonlinear;
  8128. /**
  8129. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8130. * @param hue The hue (H) input.
  8131. * @param saturation The saturation (S) input.
  8132. * @param brightness The brightness (B) input.
  8133. * @result An RGBA color represented as Vector4.
  8134. */
  8135. private static fromHSBToRef;
  8136. /**
  8137. * Returns a value clamped between min and max
  8138. * @param value The value to clamp
  8139. * @param min The minimum of value
  8140. * @param max The maximum of value
  8141. * @returns The clamped value.
  8142. */
  8143. private static clamp;
  8144. /**
  8145. * Clones the current color curve instance.
  8146. * @return The cloned curves
  8147. */
  8148. clone(): ColorCurves;
  8149. /**
  8150. * Serializes the current color curve instance to a json representation.
  8151. * @return a JSON representation
  8152. */
  8153. serialize(): any;
  8154. /**
  8155. * Parses the color curve from a json representation.
  8156. * @param source the JSON source to parse
  8157. * @return The parsed curves
  8158. */
  8159. static Parse(source: any): ColorCurves;
  8160. }
  8161. }
  8162. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8163. import { Observable } from "babylonjs/Misc/observable";
  8164. import { Nullable } from "babylonjs/types";
  8165. import { Color4 } from "babylonjs/Maths/math.color";
  8166. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8167. import { Effect } from "babylonjs/Materials/effect";
  8168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8169. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8170. /**
  8171. * Interface to follow in your material defines to integrate easily the
  8172. * Image proccessing functions.
  8173. * @hidden
  8174. */
  8175. export interface IImageProcessingConfigurationDefines {
  8176. IMAGEPROCESSING: boolean;
  8177. VIGNETTE: boolean;
  8178. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8179. VIGNETTEBLENDMODEOPAQUE: boolean;
  8180. TONEMAPPING: boolean;
  8181. TONEMAPPING_ACES: boolean;
  8182. CONTRAST: boolean;
  8183. EXPOSURE: boolean;
  8184. COLORCURVES: boolean;
  8185. COLORGRADING: boolean;
  8186. COLORGRADING3D: boolean;
  8187. SAMPLER3DGREENDEPTH: boolean;
  8188. SAMPLER3DBGRMAP: boolean;
  8189. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8190. }
  8191. /**
  8192. * @hidden
  8193. */
  8194. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8195. IMAGEPROCESSING: boolean;
  8196. VIGNETTE: boolean;
  8197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8198. VIGNETTEBLENDMODEOPAQUE: boolean;
  8199. TONEMAPPING: boolean;
  8200. TONEMAPPING_ACES: boolean;
  8201. CONTRAST: boolean;
  8202. COLORCURVES: boolean;
  8203. COLORGRADING: boolean;
  8204. COLORGRADING3D: boolean;
  8205. SAMPLER3DGREENDEPTH: boolean;
  8206. SAMPLER3DBGRMAP: boolean;
  8207. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8208. EXPOSURE: boolean;
  8209. constructor();
  8210. }
  8211. /**
  8212. * This groups together the common properties used for image processing either in direct forward pass
  8213. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8214. * or not.
  8215. */
  8216. export class ImageProcessingConfiguration {
  8217. /**
  8218. * Default tone mapping applied in BabylonJS.
  8219. */
  8220. static readonly TONEMAPPING_STANDARD: number;
  8221. /**
  8222. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8223. * to other engines rendering to increase portability.
  8224. */
  8225. static readonly TONEMAPPING_ACES: number;
  8226. /**
  8227. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8228. */
  8229. colorCurves: Nullable<ColorCurves>;
  8230. private _colorCurvesEnabled;
  8231. /**
  8232. * Gets wether the color curves effect is enabled.
  8233. */
  8234. /**
  8235. * Sets wether the color curves effect is enabled.
  8236. */
  8237. colorCurvesEnabled: boolean;
  8238. private _colorGradingTexture;
  8239. /**
  8240. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8241. */
  8242. /**
  8243. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8244. */
  8245. colorGradingTexture: Nullable<BaseTexture>;
  8246. private _colorGradingEnabled;
  8247. /**
  8248. * Gets wether the color grading effect is enabled.
  8249. */
  8250. /**
  8251. * Sets wether the color grading effect is enabled.
  8252. */
  8253. colorGradingEnabled: boolean;
  8254. private _colorGradingWithGreenDepth;
  8255. /**
  8256. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8257. */
  8258. /**
  8259. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8260. */
  8261. colorGradingWithGreenDepth: boolean;
  8262. private _colorGradingBGR;
  8263. /**
  8264. * Gets wether the color grading texture contains BGR values.
  8265. */
  8266. /**
  8267. * Sets wether the color grading texture contains BGR values.
  8268. */
  8269. colorGradingBGR: boolean;
  8270. /** @hidden */
  8271. _exposure: number;
  8272. /**
  8273. * Gets the Exposure used in the effect.
  8274. */
  8275. /**
  8276. * Sets the Exposure used in the effect.
  8277. */
  8278. exposure: number;
  8279. private _toneMappingEnabled;
  8280. /**
  8281. * Gets wether the tone mapping effect is enabled.
  8282. */
  8283. /**
  8284. * Sets wether the tone mapping effect is enabled.
  8285. */
  8286. toneMappingEnabled: boolean;
  8287. private _toneMappingType;
  8288. /**
  8289. * Gets the type of tone mapping effect.
  8290. */
  8291. /**
  8292. * Sets the type of tone mapping effect used in BabylonJS.
  8293. */
  8294. toneMappingType: number;
  8295. protected _contrast: number;
  8296. /**
  8297. * Gets the contrast used in the effect.
  8298. */
  8299. /**
  8300. * Sets the contrast used in the effect.
  8301. */
  8302. contrast: number;
  8303. /**
  8304. * Vignette stretch size.
  8305. */
  8306. vignetteStretch: number;
  8307. /**
  8308. * Vignette centre X Offset.
  8309. */
  8310. vignetteCentreX: number;
  8311. /**
  8312. * Vignette centre Y Offset.
  8313. */
  8314. vignetteCentreY: number;
  8315. /**
  8316. * Vignette weight or intensity of the vignette effect.
  8317. */
  8318. vignetteWeight: number;
  8319. /**
  8320. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8321. * if vignetteEnabled is set to true.
  8322. */
  8323. vignetteColor: Color4;
  8324. /**
  8325. * Camera field of view used by the Vignette effect.
  8326. */
  8327. vignetteCameraFov: number;
  8328. private _vignetteBlendMode;
  8329. /**
  8330. * Gets the vignette blend mode allowing different kind of effect.
  8331. */
  8332. /**
  8333. * Sets the vignette blend mode allowing different kind of effect.
  8334. */
  8335. vignetteBlendMode: number;
  8336. private _vignetteEnabled;
  8337. /**
  8338. * Gets wether the vignette effect is enabled.
  8339. */
  8340. /**
  8341. * Sets wether the vignette effect is enabled.
  8342. */
  8343. vignetteEnabled: boolean;
  8344. private _applyByPostProcess;
  8345. /**
  8346. * Gets wether the image processing is applied through a post process or not.
  8347. */
  8348. /**
  8349. * Sets wether the image processing is applied through a post process or not.
  8350. */
  8351. applyByPostProcess: boolean;
  8352. private _isEnabled;
  8353. /**
  8354. * Gets wether the image processing is enabled or not.
  8355. */
  8356. /**
  8357. * Sets wether the image processing is enabled or not.
  8358. */
  8359. isEnabled: boolean;
  8360. /**
  8361. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8362. */
  8363. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8364. /**
  8365. * Method called each time the image processing information changes requires to recompile the effect.
  8366. */
  8367. protected _updateParameters(): void;
  8368. /**
  8369. * Gets the current class name.
  8370. * @return "ImageProcessingConfiguration"
  8371. */
  8372. getClassName(): string;
  8373. /**
  8374. * Prepare the list of uniforms associated with the Image Processing effects.
  8375. * @param uniforms The list of uniforms used in the effect
  8376. * @param defines the list of defines currently in use
  8377. */
  8378. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8379. /**
  8380. * Prepare the list of samplers associated with the Image Processing effects.
  8381. * @param samplersList The list of uniforms used in the effect
  8382. * @param defines the list of defines currently in use
  8383. */
  8384. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8385. /**
  8386. * Prepare the list of defines associated to the shader.
  8387. * @param defines the list of defines to complete
  8388. * @param forPostProcess Define if we are currently in post process mode or not
  8389. */
  8390. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8391. /**
  8392. * Returns true if all the image processing information are ready.
  8393. * @returns True if ready, otherwise, false
  8394. */
  8395. isReady(): boolean;
  8396. /**
  8397. * Binds the image processing to the shader.
  8398. * @param effect The effect to bind to
  8399. * @param aspectRatio Define the current aspect ratio of the effect
  8400. */
  8401. bind(effect: Effect, aspectRatio?: number): void;
  8402. /**
  8403. * Clones the current image processing instance.
  8404. * @return The cloned image processing
  8405. */
  8406. clone(): ImageProcessingConfiguration;
  8407. /**
  8408. * Serializes the current image processing instance to a json representation.
  8409. * @return a JSON representation
  8410. */
  8411. serialize(): any;
  8412. /**
  8413. * Parses the image processing from a json representation.
  8414. * @param source the JSON source to parse
  8415. * @return The parsed image processing
  8416. */
  8417. static Parse(source: any): ImageProcessingConfiguration;
  8418. private static _VIGNETTEMODE_MULTIPLY;
  8419. private static _VIGNETTEMODE_OPAQUE;
  8420. /**
  8421. * Used to apply the vignette as a mix with the pixel color.
  8422. */
  8423. static readonly VIGNETTEMODE_MULTIPLY: number;
  8424. /**
  8425. * Used to apply the vignette as a replacement of the pixel color.
  8426. */
  8427. static readonly VIGNETTEMODE_OPAQUE: number;
  8428. }
  8429. }
  8430. declare module "babylonjs/Shaders/postprocess.vertex" {
  8431. /** @hidden */
  8432. export var postprocessVertexShader: {
  8433. name: string;
  8434. shader: string;
  8435. };
  8436. }
  8437. declare module "babylonjs/Maths/math.axis" {
  8438. import { Vector3 } from "babylonjs/Maths/math.vector";
  8439. /** Defines supported spaces */
  8440. export enum Space {
  8441. /** Local (object) space */
  8442. LOCAL = 0,
  8443. /** World space */
  8444. WORLD = 1,
  8445. /** Bone space */
  8446. BONE = 2
  8447. }
  8448. /** Defines the 3 main axes */
  8449. export class Axis {
  8450. /** X axis */
  8451. static X: Vector3;
  8452. /** Y axis */
  8453. static Y: Vector3;
  8454. /** Z axis */
  8455. static Z: Vector3;
  8456. }
  8457. }
  8458. declare module "babylonjs/Cameras/targetCamera" {
  8459. import { Nullable } from "babylonjs/types";
  8460. import { Camera } from "babylonjs/Cameras/camera";
  8461. import { Scene } from "babylonjs/scene";
  8462. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8463. /**
  8464. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8465. * This is the base of the follow, arc rotate cameras and Free camera
  8466. * @see http://doc.babylonjs.com/features/cameras
  8467. */
  8468. export class TargetCamera extends Camera {
  8469. private static _RigCamTransformMatrix;
  8470. private static _TargetTransformMatrix;
  8471. private static _TargetFocalPoint;
  8472. /**
  8473. * Define the current direction the camera is moving to
  8474. */
  8475. cameraDirection: Vector3;
  8476. /**
  8477. * Define the current rotation the camera is rotating to
  8478. */
  8479. cameraRotation: Vector2;
  8480. /**
  8481. * When set, the up vector of the camera will be updated by the rotation of the camera
  8482. */
  8483. updateUpVectorFromRotation: boolean;
  8484. private _tmpQuaternion;
  8485. /**
  8486. * Define the current rotation of the camera
  8487. */
  8488. rotation: Vector3;
  8489. /**
  8490. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8491. */
  8492. rotationQuaternion: Quaternion;
  8493. /**
  8494. * Define the current speed of the camera
  8495. */
  8496. speed: number;
  8497. /**
  8498. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8499. * around all axis.
  8500. */
  8501. noRotationConstraint: boolean;
  8502. /**
  8503. * Define the current target of the camera as an object or a position.
  8504. */
  8505. lockedTarget: any;
  8506. /** @hidden */
  8507. _currentTarget: Vector3;
  8508. /** @hidden */
  8509. _initialFocalDistance: number;
  8510. /** @hidden */
  8511. _viewMatrix: Matrix;
  8512. /** @hidden */
  8513. _camMatrix: Matrix;
  8514. /** @hidden */
  8515. _cameraTransformMatrix: Matrix;
  8516. /** @hidden */
  8517. _cameraRotationMatrix: Matrix;
  8518. /** @hidden */
  8519. _referencePoint: Vector3;
  8520. /** @hidden */
  8521. _transformedReferencePoint: Vector3;
  8522. protected _globalCurrentTarget: Vector3;
  8523. protected _globalCurrentUpVector: Vector3;
  8524. /** @hidden */
  8525. _reset: () => void;
  8526. private _defaultUp;
  8527. /**
  8528. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. * @param name Defines the name of the camera in the scene
  8532. * @param position Defines the start position of the camera in the scene
  8533. * @param scene Defines the scene the camera belongs to
  8534. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8535. */
  8536. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8537. /**
  8538. * Gets the position in front of the camera at a given distance.
  8539. * @param distance The distance from the camera we want the position to be
  8540. * @returns the position
  8541. */
  8542. getFrontPosition(distance: number): Vector3;
  8543. /** @hidden */
  8544. _getLockedTargetPosition(): Nullable<Vector3>;
  8545. private _storedPosition;
  8546. private _storedRotation;
  8547. private _storedRotationQuaternion;
  8548. /**
  8549. * Store current camera state of the camera (fov, position, rotation, etc..)
  8550. * @returns the camera
  8551. */
  8552. storeState(): Camera;
  8553. /**
  8554. * Restored camera state. You must call storeState() first
  8555. * @returns whether it was successful or not
  8556. * @hidden
  8557. */
  8558. _restoreStateValues(): boolean;
  8559. /** @hidden */
  8560. _initCache(): void;
  8561. /** @hidden */
  8562. _updateCache(ignoreParentClass?: boolean): void;
  8563. /** @hidden */
  8564. _isSynchronizedViewMatrix(): boolean;
  8565. /** @hidden */
  8566. _computeLocalCameraSpeed(): number;
  8567. /**
  8568. * Defines the target the camera should look at.
  8569. * @param target Defines the new target as a Vector or a mesh
  8570. */
  8571. setTarget(target: Vector3): void;
  8572. /**
  8573. * Return the current target position of the camera. This value is expressed in local space.
  8574. * @returns the target position
  8575. */
  8576. getTarget(): Vector3;
  8577. /** @hidden */
  8578. _decideIfNeedsToMove(): boolean;
  8579. /** @hidden */
  8580. _updatePosition(): void;
  8581. /** @hidden */
  8582. _checkInputs(): void;
  8583. protected _updateCameraRotationMatrix(): void;
  8584. /**
  8585. * 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)
  8586. * @returns the current camera
  8587. */
  8588. private _rotateUpVectorWithCameraRotationMatrix;
  8589. private _cachedRotationZ;
  8590. private _cachedQuaternionRotationZ;
  8591. /** @hidden */
  8592. _getViewMatrix(): Matrix;
  8593. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8594. /**
  8595. * @hidden
  8596. */
  8597. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8598. /**
  8599. * @hidden
  8600. */
  8601. _updateRigCameras(): void;
  8602. private _getRigCamPositionAndTarget;
  8603. /**
  8604. * Gets the current object class name.
  8605. * @return the class name
  8606. */
  8607. getClassName(): string;
  8608. }
  8609. }
  8610. declare module "babylonjs/Events/keyboardEvents" {
  8611. /**
  8612. * Gather the list of keyboard event types as constants.
  8613. */
  8614. export class KeyboardEventTypes {
  8615. /**
  8616. * The keydown event is fired when a key becomes active (pressed).
  8617. */
  8618. static readonly KEYDOWN: number;
  8619. /**
  8620. * The keyup event is fired when a key has been released.
  8621. */
  8622. static readonly KEYUP: number;
  8623. }
  8624. /**
  8625. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8626. */
  8627. export class KeyboardInfo {
  8628. /**
  8629. * Defines the type of event (KeyboardEventTypes)
  8630. */
  8631. type: number;
  8632. /**
  8633. * Defines the related dom event
  8634. */
  8635. event: KeyboardEvent;
  8636. /**
  8637. * Instantiates a new keyboard info.
  8638. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8639. * @param type Defines the type of event (KeyboardEventTypes)
  8640. * @param event Defines the related dom event
  8641. */
  8642. constructor(
  8643. /**
  8644. * Defines the type of event (KeyboardEventTypes)
  8645. */
  8646. type: number,
  8647. /**
  8648. * Defines the related dom event
  8649. */
  8650. event: KeyboardEvent);
  8651. }
  8652. /**
  8653. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8654. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8655. */
  8656. export class KeyboardInfoPre extends KeyboardInfo {
  8657. /**
  8658. * Defines the type of event (KeyboardEventTypes)
  8659. */
  8660. type: number;
  8661. /**
  8662. * Defines the related dom event
  8663. */
  8664. event: KeyboardEvent;
  8665. /**
  8666. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8667. */
  8668. skipOnPointerObservable: boolean;
  8669. /**
  8670. * Instantiates a new keyboard pre info.
  8671. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8672. * @param type Defines the type of event (KeyboardEventTypes)
  8673. * @param event Defines the related dom event
  8674. */
  8675. constructor(
  8676. /**
  8677. * Defines the type of event (KeyboardEventTypes)
  8678. */
  8679. type: number,
  8680. /**
  8681. * Defines the related dom event
  8682. */
  8683. event: KeyboardEvent);
  8684. }
  8685. }
  8686. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8687. import { Nullable } from "babylonjs/types";
  8688. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8689. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8690. /**
  8691. * Manage the keyboard inputs to control the movement of a free camera.
  8692. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8693. */
  8694. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8695. /**
  8696. * Defines the camera the input is attached to.
  8697. */
  8698. camera: FreeCamera;
  8699. /**
  8700. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8701. */
  8702. keysUp: number[];
  8703. /**
  8704. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8705. */
  8706. keysDown: number[];
  8707. /**
  8708. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8709. */
  8710. keysLeft: number[];
  8711. /**
  8712. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8713. */
  8714. keysRight: number[];
  8715. private _keys;
  8716. private _onCanvasBlurObserver;
  8717. private _onKeyboardObserver;
  8718. private _engine;
  8719. private _scene;
  8720. /**
  8721. * Attach the input controls to a specific dom element to get the input from.
  8722. * @param element Defines the element the controls should be listened from
  8723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8724. */
  8725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8726. /**
  8727. * Detach the current controls from the specified dom element.
  8728. * @param element Defines the element to stop listening the inputs from
  8729. */
  8730. detachControl(element: Nullable<HTMLElement>): void;
  8731. /**
  8732. * Update the current camera state depending on the inputs that have been used this frame.
  8733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8734. */
  8735. checkInputs(): void;
  8736. /**
  8737. * Gets the class name of the current intput.
  8738. * @returns the class name
  8739. */
  8740. getClassName(): string;
  8741. /** @hidden */
  8742. _onLostFocus(): void;
  8743. /**
  8744. * Get the friendly name associated with the input class.
  8745. * @returns the input friendly name
  8746. */
  8747. getSimpleName(): string;
  8748. }
  8749. }
  8750. declare module "babylonjs/Lights/shadowLight" {
  8751. import { Camera } from "babylonjs/Cameras/camera";
  8752. import { Scene } from "babylonjs/scene";
  8753. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8754. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8755. import { Light } from "babylonjs/Lights/light";
  8756. /**
  8757. * Interface describing all the common properties and methods a shadow light needs to implement.
  8758. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8759. * as well as binding the different shadow properties to the effects.
  8760. */
  8761. export interface IShadowLight extends Light {
  8762. /**
  8763. * The light id in the scene (used in scene.findLighById for instance)
  8764. */
  8765. id: string;
  8766. /**
  8767. * The position the shdow will be casted from.
  8768. */
  8769. position: Vector3;
  8770. /**
  8771. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8772. */
  8773. direction: Vector3;
  8774. /**
  8775. * The transformed position. Position of the light in world space taking parenting in account.
  8776. */
  8777. transformedPosition: Vector3;
  8778. /**
  8779. * The transformed direction. Direction of the light in world space taking parenting in account.
  8780. */
  8781. transformedDirection: Vector3;
  8782. /**
  8783. * The friendly name of the light in the scene.
  8784. */
  8785. name: string;
  8786. /**
  8787. * Defines the shadow projection clipping minimum z value.
  8788. */
  8789. shadowMinZ: number;
  8790. /**
  8791. * Defines the shadow projection clipping maximum z value.
  8792. */
  8793. shadowMaxZ: number;
  8794. /**
  8795. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8796. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8797. */
  8798. computeTransformedInformation(): boolean;
  8799. /**
  8800. * Gets the scene the light belongs to.
  8801. * @returns The scene
  8802. */
  8803. getScene(): Scene;
  8804. /**
  8805. * Callback defining a custom Projection Matrix Builder.
  8806. * This can be used to override the default projection matrix computation.
  8807. */
  8808. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8809. /**
  8810. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8811. * @param matrix The materix to updated with the projection information
  8812. * @param viewMatrix The transform matrix of the light
  8813. * @param renderList The list of mesh to render in the map
  8814. * @returns The current light
  8815. */
  8816. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8817. /**
  8818. * Gets the current depth scale used in ESM.
  8819. * @returns The scale
  8820. */
  8821. getDepthScale(): number;
  8822. /**
  8823. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8824. * @returns true if a cube texture needs to be use
  8825. */
  8826. needCube(): boolean;
  8827. /**
  8828. * Detects if the projection matrix requires to be recomputed this frame.
  8829. * @returns true if it requires to be recomputed otherwise, false.
  8830. */
  8831. needProjectionMatrixCompute(): boolean;
  8832. /**
  8833. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8834. */
  8835. forceProjectionMatrixCompute(): void;
  8836. /**
  8837. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8838. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8839. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8840. */
  8841. getShadowDirection(faceIndex?: number): Vector3;
  8842. /**
  8843. * Gets the minZ used for shadow according to both the scene and the light.
  8844. * @param activeCamera The camera we are returning the min for
  8845. * @returns the depth min z
  8846. */
  8847. getDepthMinZ(activeCamera: Camera): number;
  8848. /**
  8849. * Gets the maxZ used for shadow according to both the scene and the light.
  8850. * @param activeCamera The camera we are returning the max for
  8851. * @returns the depth max z
  8852. */
  8853. getDepthMaxZ(activeCamera: Camera): number;
  8854. }
  8855. /**
  8856. * Base implementation IShadowLight
  8857. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8858. */
  8859. export abstract class ShadowLight extends Light implements IShadowLight {
  8860. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8861. protected _position: Vector3;
  8862. protected _setPosition(value: Vector3): void;
  8863. /**
  8864. * Sets the position the shadow will be casted from. Also use as the light position for both
  8865. * point and spot lights.
  8866. */
  8867. /**
  8868. * Sets the position the shadow will be casted from. Also use as the light position for both
  8869. * point and spot lights.
  8870. */
  8871. position: Vector3;
  8872. protected _direction: Vector3;
  8873. protected _setDirection(value: Vector3): void;
  8874. /**
  8875. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8876. * Also use as the light direction on spot and directional lights.
  8877. */
  8878. /**
  8879. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8880. * Also use as the light direction on spot and directional lights.
  8881. */
  8882. direction: Vector3;
  8883. private _shadowMinZ;
  8884. /**
  8885. * Gets the shadow projection clipping minimum z value.
  8886. */
  8887. /**
  8888. * Sets the shadow projection clipping minimum z value.
  8889. */
  8890. shadowMinZ: number;
  8891. private _shadowMaxZ;
  8892. /**
  8893. * Sets the shadow projection clipping maximum z value.
  8894. */
  8895. /**
  8896. * Gets the shadow projection clipping maximum z value.
  8897. */
  8898. shadowMaxZ: number;
  8899. /**
  8900. * Callback defining a custom Projection Matrix Builder.
  8901. * This can be used to override the default projection matrix computation.
  8902. */
  8903. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8904. /**
  8905. * The transformed position. Position of the light in world space taking parenting in account.
  8906. */
  8907. transformedPosition: Vector3;
  8908. /**
  8909. * The transformed direction. Direction of the light in world space taking parenting in account.
  8910. */
  8911. transformedDirection: Vector3;
  8912. private _needProjectionMatrixCompute;
  8913. /**
  8914. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8915. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8916. */
  8917. computeTransformedInformation(): boolean;
  8918. /**
  8919. * Return the depth scale used for the shadow map.
  8920. * @returns the depth scale.
  8921. */
  8922. getDepthScale(): number;
  8923. /**
  8924. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8925. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8926. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8927. */
  8928. getShadowDirection(faceIndex?: number): Vector3;
  8929. /**
  8930. * Returns the ShadowLight absolute position in the World.
  8931. * @returns the position vector in world space
  8932. */
  8933. getAbsolutePosition(): Vector3;
  8934. /**
  8935. * Sets the ShadowLight direction toward the passed target.
  8936. * @param target The point to target in local space
  8937. * @returns the updated ShadowLight direction
  8938. */
  8939. setDirectionToTarget(target: Vector3): Vector3;
  8940. /**
  8941. * Returns the light rotation in euler definition.
  8942. * @returns the x y z rotation in local space.
  8943. */
  8944. getRotation(): Vector3;
  8945. /**
  8946. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8947. * @returns true if a cube texture needs to be use
  8948. */
  8949. needCube(): boolean;
  8950. /**
  8951. * Detects if the projection matrix requires to be recomputed this frame.
  8952. * @returns true if it requires to be recomputed otherwise, false.
  8953. */
  8954. needProjectionMatrixCompute(): boolean;
  8955. /**
  8956. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8957. */
  8958. forceProjectionMatrixCompute(): void;
  8959. /** @hidden */
  8960. _initCache(): void;
  8961. /** @hidden */
  8962. _isSynchronized(): boolean;
  8963. /**
  8964. * Computes the world matrix of the node
  8965. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8966. * @returns the world matrix
  8967. */
  8968. computeWorldMatrix(force?: boolean): Matrix;
  8969. /**
  8970. * Gets the minZ used for shadow according to both the scene and the light.
  8971. * @param activeCamera The camera we are returning the min for
  8972. * @returns the depth min z
  8973. */
  8974. getDepthMinZ(activeCamera: Camera): number;
  8975. /**
  8976. * Gets the maxZ used for shadow according to both the scene and the light.
  8977. * @param activeCamera The camera we are returning the max for
  8978. * @returns the depth max z
  8979. */
  8980. getDepthMaxZ(activeCamera: Camera): number;
  8981. /**
  8982. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8983. * @param matrix The materix to updated with the projection information
  8984. * @param viewMatrix The transform matrix of the light
  8985. * @param renderList The list of mesh to render in the map
  8986. * @returns The current light
  8987. */
  8988. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8989. }
  8990. }
  8991. declare module "babylonjs/Materials/effectFallbacks" {
  8992. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8993. import { Effect } from "babylonjs/Materials/effect";
  8994. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8995. /**
  8996. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8997. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8998. */
  8999. export class EffectFallbacks implements IEffectFallbacks {
  9000. private _defines;
  9001. private _currentRank;
  9002. private _maxRank;
  9003. private _mesh;
  9004. /**
  9005. * Removes the fallback from the bound mesh.
  9006. */
  9007. unBindMesh(): void;
  9008. /**
  9009. * Adds a fallback on the specified property.
  9010. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9011. * @param define The name of the define in the shader
  9012. */
  9013. addFallback(rank: number, define: string): void;
  9014. /**
  9015. * Sets the mesh to use CPU skinning when needing to fallback.
  9016. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9017. * @param mesh The mesh to use the fallbacks.
  9018. */
  9019. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9020. /**
  9021. * Checks to see if more fallbacks are still availible.
  9022. */
  9023. readonly hasMoreFallbacks: boolean;
  9024. /**
  9025. * Removes the defines that should be removed when falling back.
  9026. * @param currentDefines defines the current define statements for the shader.
  9027. * @param effect defines the current effect we try to compile
  9028. * @returns The resulting defines with defines of the current rank removed.
  9029. */
  9030. reduce(currentDefines: string, effect: Effect): string;
  9031. }
  9032. }
  9033. declare module "babylonjs/Materials/materialHelper" {
  9034. import { Nullable } from "babylonjs/types";
  9035. import { Scene } from "babylonjs/scene";
  9036. import { Engine } from "babylonjs/Engines/engine";
  9037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9038. import { Light } from "babylonjs/Lights/light";
  9039. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9040. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9042. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9043. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9044. /**
  9045. * "Static Class" containing the most commonly used helper while dealing with material for
  9046. * rendering purpose.
  9047. *
  9048. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9049. *
  9050. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9051. */
  9052. export class MaterialHelper {
  9053. /**
  9054. * Bind the current view position to an effect.
  9055. * @param effect The effect to be bound
  9056. * @param scene The scene the eyes position is used from
  9057. */
  9058. static BindEyePosition(effect: Effect, scene: Scene): void;
  9059. /**
  9060. * Helps preparing the defines values about the UVs in used in the effect.
  9061. * UVs are shared as much as we can accross channels in the shaders.
  9062. * @param texture The texture we are preparing the UVs for
  9063. * @param defines The defines to update
  9064. * @param key The channel key "diffuse", "specular"... used in the shader
  9065. */
  9066. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9067. /**
  9068. * Binds a texture matrix value to its corrsponding uniform
  9069. * @param texture The texture to bind the matrix for
  9070. * @param uniformBuffer The uniform buffer receivin the data
  9071. * @param key The channel key "diffuse", "specular"... used in the shader
  9072. */
  9073. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9074. /**
  9075. * Gets the current status of the fog (should it be enabled?)
  9076. * @param mesh defines the mesh to evaluate for fog support
  9077. * @param scene defines the hosting scene
  9078. * @returns true if fog must be enabled
  9079. */
  9080. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9081. /**
  9082. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9083. * @param mesh defines the current mesh
  9084. * @param scene defines the current scene
  9085. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9086. * @param pointsCloud defines if point cloud rendering has to be turned on
  9087. * @param fogEnabled defines if fog has to be turned on
  9088. * @param alphaTest defines if alpha testing has to be turned on
  9089. * @param defines defines the current list of defines
  9090. */
  9091. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9092. /**
  9093. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9094. * @param scene defines the current scene
  9095. * @param engine defines the current engine
  9096. * @param defines specifies the list of active defines
  9097. * @param useInstances defines if instances have to be turned on
  9098. * @param useClipPlane defines if clip plane have to be turned on
  9099. */
  9100. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9101. /**
  9102. * Prepares the defines for bones
  9103. * @param mesh The mesh containing the geometry data we will draw
  9104. * @param defines The defines to update
  9105. */
  9106. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9107. /**
  9108. * Prepares the defines for morph targets
  9109. * @param mesh The mesh containing the geometry data we will draw
  9110. * @param defines The defines to update
  9111. */
  9112. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9113. /**
  9114. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9115. * @param mesh The mesh containing the geometry data we will draw
  9116. * @param defines The defines to update
  9117. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9118. * @param useBones Precise whether bones should be used or not (override mesh info)
  9119. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9120. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9121. * @returns false if defines are considered not dirty and have not been checked
  9122. */
  9123. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9124. /**
  9125. * Prepares the defines related to multiview
  9126. * @param scene The scene we are intending to draw
  9127. * @param defines The defines to update
  9128. */
  9129. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9130. /**
  9131. * Prepares the defines related to the light information passed in parameter
  9132. * @param scene The scene we are intending to draw
  9133. * @param mesh The mesh the effect is compiling for
  9134. * @param light The light the effect is compiling for
  9135. * @param lightIndex The index of the light
  9136. * @param defines The defines to update
  9137. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9138. * @param state Defines the current state regarding what is needed (normals, etc...)
  9139. */
  9140. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9141. needNormals: boolean;
  9142. needRebuild: boolean;
  9143. shadowEnabled: boolean;
  9144. specularEnabled: boolean;
  9145. lightmapMode: boolean;
  9146. }): void;
  9147. /**
  9148. * Prepares the defines related to the light information passed in parameter
  9149. * @param scene The scene we are intending to draw
  9150. * @param mesh The mesh the effect is compiling for
  9151. * @param defines The defines to update
  9152. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9153. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9154. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9155. * @returns true if normals will be required for the rest of the effect
  9156. */
  9157. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9158. /**
  9159. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9160. * @param lightIndex defines the light index
  9161. * @param uniformsList The uniform list
  9162. * @param samplersList The sampler list
  9163. * @param projectedLightTexture defines if projected texture must be used
  9164. * @param uniformBuffersList defines an optional list of uniform buffers
  9165. */
  9166. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9167. /**
  9168. * Prepares the uniforms and samplers list to be used in the effect
  9169. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9170. * @param samplersList The sampler list
  9171. * @param defines The defines helping in the list generation
  9172. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9173. */
  9174. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9175. /**
  9176. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9177. * @param defines The defines to update while falling back
  9178. * @param fallbacks The authorized effect fallbacks
  9179. * @param maxSimultaneousLights The maximum number of lights allowed
  9180. * @param rank the current rank of the Effect
  9181. * @returns The newly affected rank
  9182. */
  9183. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9184. private static _TmpMorphInfluencers;
  9185. /**
  9186. * Prepares the list of attributes required for morph targets according to the effect defines.
  9187. * @param attribs The current list of supported attribs
  9188. * @param mesh The mesh to prepare the morph targets attributes for
  9189. * @param influencers The number of influencers
  9190. */
  9191. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9192. /**
  9193. * Prepares the list of attributes required for morph targets according to the effect defines.
  9194. * @param attribs The current list of supported attribs
  9195. * @param mesh The mesh to prepare the morph targets attributes for
  9196. * @param defines The current Defines of the effect
  9197. */
  9198. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9199. /**
  9200. * Prepares the list of attributes required for bones according to the effect defines.
  9201. * @param attribs The current list of supported attribs
  9202. * @param mesh The mesh to prepare the bones attributes for
  9203. * @param defines The current Defines of the effect
  9204. * @param fallbacks The current efffect fallback strategy
  9205. */
  9206. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9207. /**
  9208. * Check and prepare the list of attributes required for instances according to the effect defines.
  9209. * @param attribs The current list of supported attribs
  9210. * @param defines The current MaterialDefines of the effect
  9211. */
  9212. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9213. /**
  9214. * Add the list of attributes required for instances to the attribs array.
  9215. * @param attribs The current list of supported attribs
  9216. */
  9217. static PushAttributesForInstances(attribs: string[]): void;
  9218. /**
  9219. * Binds the light shadow information to the effect for the given mesh.
  9220. * @param light The light containing the generator
  9221. * @param scene The scene the lights belongs to
  9222. * @param mesh The mesh we are binding the information to render
  9223. * @param lightIndex The light index in the effect used to render the mesh
  9224. * @param effect The effect we are binding the data to
  9225. */
  9226. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9227. /**
  9228. * Binds the light information to the effect.
  9229. * @param light The light containing the generator
  9230. * @param effect The effect we are binding the data to
  9231. * @param lightIndex The light index in the effect used to render
  9232. */
  9233. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9234. /**
  9235. * Binds the lights information from the scene to the effect for the given mesh.
  9236. * @param light Light to bind
  9237. * @param lightIndex Light index
  9238. * @param scene The scene where the light belongs to
  9239. * @param mesh The mesh we are binding the information to render
  9240. * @param effect The effect we are binding the data to
  9241. * @param useSpecular Defines if specular is supported
  9242. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9243. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9244. */
  9245. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9246. /**
  9247. * Binds the lights information from the scene to the effect for the given mesh.
  9248. * @param scene The scene the lights belongs to
  9249. * @param mesh The mesh we are binding the information to render
  9250. * @param effect The effect we are binding the data to
  9251. * @param defines The generated defines for the effect
  9252. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9253. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9254. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9255. */
  9256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9257. private static _tempFogColor;
  9258. /**
  9259. * Binds the fog information from the scene to the effect for the given mesh.
  9260. * @param scene The scene the lights belongs to
  9261. * @param mesh The mesh we are binding the information to render
  9262. * @param effect The effect we are binding the data to
  9263. * @param linearSpace Defines if the fog effect is applied in linear space
  9264. */
  9265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9266. /**
  9267. * Binds the bones information from the mesh to the effect.
  9268. * @param mesh The mesh we are binding the information to render
  9269. * @param effect The effect we are binding the data to
  9270. */
  9271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9272. /**
  9273. * Binds the morph targets information from the mesh to the effect.
  9274. * @param abstractMesh The mesh we are binding the information to render
  9275. * @param effect The effect we are binding the data to
  9276. */
  9277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9278. /**
  9279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9280. * @param defines The generated defines used in the effect
  9281. * @param effect The effect we are binding the data to
  9282. * @param scene The scene we are willing to render with logarithmic scale for
  9283. */
  9284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9285. /**
  9286. * Binds the clip plane information from the scene to the effect.
  9287. * @param scene The scene the clip plane information are extracted from
  9288. * @param effect The effect we are binding the data to
  9289. */
  9290. static BindClipPlane(effect: Effect, scene: Scene): void;
  9291. }
  9292. }
  9293. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9294. /** @hidden */
  9295. export var packingFunctions: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9301. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9302. /** @hidden */
  9303. export var shadowMapPixelShader: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9309. /** @hidden */
  9310. export var bonesDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9316. /** @hidden */
  9317. export var morphTargetsVertexGlobalDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9323. /** @hidden */
  9324. export var morphTargetsVertexDeclaration: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9330. /** @hidden */
  9331. export var instancesDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9337. /** @hidden */
  9338. export var helperFunctions: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9344. /** @hidden */
  9345. export var morphTargetsVertex: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9351. /** @hidden */
  9352. export var instancesVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9358. /** @hidden */
  9359. export var bonesVertex: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9365. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9366. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9368. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9369. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9371. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9372. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9373. /** @hidden */
  9374. export var shadowMapVertexShader: {
  9375. name: string;
  9376. shader: string;
  9377. };
  9378. }
  9379. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9380. /** @hidden */
  9381. export var depthBoxBlurPixelShader: {
  9382. name: string;
  9383. shader: string;
  9384. };
  9385. }
  9386. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9387. import { Nullable } from "babylonjs/types";
  9388. import { Scene } from "babylonjs/scene";
  9389. import { Matrix } from "babylonjs/Maths/math.vector";
  9390. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9392. import { Mesh } from "babylonjs/Meshes/mesh";
  9393. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9394. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9395. import { Effect } from "babylonjs/Materials/effect";
  9396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9397. import "babylonjs/Shaders/shadowMap.fragment";
  9398. import "babylonjs/Shaders/shadowMap.vertex";
  9399. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9400. import { Observable } from "babylonjs/Misc/observable";
  9401. /**
  9402. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9403. */
  9404. export interface ICustomShaderOptions {
  9405. /**
  9406. * Gets or sets the custom shader name to use
  9407. */
  9408. shaderName: string;
  9409. /**
  9410. * The list of attribute names used in the shader
  9411. */
  9412. attributes?: string[];
  9413. /**
  9414. * The list of unifrom names used in the shader
  9415. */
  9416. uniforms?: string[];
  9417. /**
  9418. * The list of sampler names used in the shader
  9419. */
  9420. samplers?: string[];
  9421. /**
  9422. * The list of defines used in the shader
  9423. */
  9424. defines?: string[];
  9425. }
  9426. /**
  9427. * Interface to implement to create a shadow generator compatible with BJS.
  9428. */
  9429. export interface IShadowGenerator {
  9430. /**
  9431. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9432. * @returns The render target texture if present otherwise, null
  9433. */
  9434. getShadowMap(): Nullable<RenderTargetTexture>;
  9435. /**
  9436. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9437. * @returns The render target texture if the shadow map is present otherwise, null
  9438. */
  9439. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9440. /**
  9441. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9442. * @param subMesh The submesh we want to render in the shadow map
  9443. * @param useInstances Defines wether will draw in the map using instances
  9444. * @returns true if ready otherwise, false
  9445. */
  9446. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9447. /**
  9448. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9449. * @param defines Defines of the material we want to update
  9450. * @param lightIndex Index of the light in the enabled light list of the material
  9451. */
  9452. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9453. /**
  9454. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9455. * defined in the generator but impacting the effect).
  9456. * It implies the unifroms available on the materials are the standard BJS ones.
  9457. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9458. * @param effect The effect we are binfing the information for
  9459. */
  9460. bindShadowLight(lightIndex: string, effect: Effect): void;
  9461. /**
  9462. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9463. * (eq to shadow prjection matrix * light transform matrix)
  9464. * @returns The transform matrix used to create the shadow map
  9465. */
  9466. getTransformMatrix(): Matrix;
  9467. /**
  9468. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9469. * Cube and 2D textures for instance.
  9470. */
  9471. recreateShadowMap(): void;
  9472. /**
  9473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9474. * @param onCompiled Callback triggered at the and of the effects compilation
  9475. * @param options Sets of optional options forcing the compilation with different modes
  9476. */
  9477. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9478. useInstances: boolean;
  9479. }>): void;
  9480. /**
  9481. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9482. * @param options Sets of optional options forcing the compilation with different modes
  9483. * @returns A promise that resolves when the compilation completes
  9484. */
  9485. forceCompilationAsync(options?: Partial<{
  9486. useInstances: boolean;
  9487. }>): Promise<void>;
  9488. /**
  9489. * Serializes the shadow generator setup to a json object.
  9490. * @returns The serialized JSON object
  9491. */
  9492. serialize(): any;
  9493. /**
  9494. * Disposes the Shadow map and related Textures and effects.
  9495. */
  9496. dispose(): void;
  9497. }
  9498. /**
  9499. * Default implementation IShadowGenerator.
  9500. * This is the main object responsible of generating shadows in the framework.
  9501. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9502. */
  9503. export class ShadowGenerator implements IShadowGenerator {
  9504. /**
  9505. * Shadow generator mode None: no filtering applied.
  9506. */
  9507. static readonly FILTER_NONE: number;
  9508. /**
  9509. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9510. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9511. */
  9512. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9513. /**
  9514. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9515. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9516. */
  9517. static readonly FILTER_POISSONSAMPLING: number;
  9518. /**
  9519. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9520. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9521. */
  9522. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9523. /**
  9524. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9525. * edge artifacts on steep falloff.
  9526. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9527. */
  9528. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9529. /**
  9530. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9531. * edge artifacts on steep falloff.
  9532. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9533. */
  9534. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9535. /**
  9536. * Shadow generator mode PCF: Percentage Closer Filtering
  9537. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9538. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9539. */
  9540. static readonly FILTER_PCF: number;
  9541. /**
  9542. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9543. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9544. * Contact Hardening
  9545. */
  9546. static readonly FILTER_PCSS: number;
  9547. /**
  9548. * Reserved for PCF and PCSS
  9549. * Highest Quality.
  9550. *
  9551. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9552. *
  9553. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9554. */
  9555. static readonly QUALITY_HIGH: number;
  9556. /**
  9557. * Reserved for PCF and PCSS
  9558. * Good tradeoff for quality/perf cross devices
  9559. *
  9560. * Execute PCF on a 3*3 kernel.
  9561. *
  9562. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9563. */
  9564. static readonly QUALITY_MEDIUM: number;
  9565. /**
  9566. * Reserved for PCF and PCSS
  9567. * The lowest quality but the fastest.
  9568. *
  9569. * Execute PCF on a 1*1 kernel.
  9570. *
  9571. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9572. */
  9573. static readonly QUALITY_LOW: number;
  9574. /** Gets or sets the custom shader name to use */
  9575. customShaderOptions: ICustomShaderOptions;
  9576. /**
  9577. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9578. */
  9579. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9580. /**
  9581. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9582. */
  9583. onAfterShadowMapRenderObservable: Observable<Effect>;
  9584. /**
  9585. * Observable triggered before a mesh is rendered in the shadow map.
  9586. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9587. */
  9588. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9589. /**
  9590. * Observable triggered after a mesh is rendered in the shadow map.
  9591. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9592. */
  9593. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9594. private _bias;
  9595. /**
  9596. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9597. */
  9598. /**
  9599. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9600. */
  9601. bias: number;
  9602. private _normalBias;
  9603. /**
  9604. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9605. */
  9606. /**
  9607. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9608. */
  9609. normalBias: number;
  9610. private _blurBoxOffset;
  9611. /**
  9612. * Gets the blur box offset: offset applied during the blur pass.
  9613. * Only useful if useKernelBlur = false
  9614. */
  9615. /**
  9616. * Sets the blur box offset: offset applied during the blur pass.
  9617. * Only useful if useKernelBlur = false
  9618. */
  9619. blurBoxOffset: number;
  9620. private _blurScale;
  9621. /**
  9622. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9623. * 2 means half of the size.
  9624. */
  9625. /**
  9626. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9627. * 2 means half of the size.
  9628. */
  9629. blurScale: number;
  9630. private _blurKernel;
  9631. /**
  9632. * Gets the blur kernel: kernel size of the blur pass.
  9633. * Only useful if useKernelBlur = true
  9634. */
  9635. /**
  9636. * Sets the blur kernel: kernel size of the blur pass.
  9637. * Only useful if useKernelBlur = true
  9638. */
  9639. blurKernel: number;
  9640. private _useKernelBlur;
  9641. /**
  9642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9644. */
  9645. /**
  9646. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9647. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9648. */
  9649. useKernelBlur: boolean;
  9650. private _depthScale;
  9651. /**
  9652. * Gets the depth scale used in ESM mode.
  9653. */
  9654. /**
  9655. * Sets the depth scale used in ESM mode.
  9656. * This can override the scale stored on the light.
  9657. */
  9658. depthScale: number;
  9659. private _filter;
  9660. /**
  9661. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9662. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9663. */
  9664. /**
  9665. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9666. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9667. */
  9668. filter: number;
  9669. /**
  9670. * Gets if the current filter is set to Poisson Sampling.
  9671. */
  9672. /**
  9673. * Sets the current filter to Poisson Sampling.
  9674. */
  9675. usePoissonSampling: boolean;
  9676. /**
  9677. * Gets if the current filter is set to ESM.
  9678. */
  9679. /**
  9680. * Sets the current filter is to ESM.
  9681. */
  9682. useExponentialShadowMap: boolean;
  9683. /**
  9684. * Gets if the current filter is set to filtered ESM.
  9685. */
  9686. /**
  9687. * Gets if the current filter is set to filtered ESM.
  9688. */
  9689. useBlurExponentialShadowMap: boolean;
  9690. /**
  9691. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9692. * exponential to prevent steep falloff artifacts).
  9693. */
  9694. /**
  9695. * Sets the current filter to "close ESM" (using the inverse of the
  9696. * exponential to prevent steep falloff artifacts).
  9697. */
  9698. useCloseExponentialShadowMap: boolean;
  9699. /**
  9700. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9701. * exponential to prevent steep falloff artifacts).
  9702. */
  9703. /**
  9704. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9705. * exponential to prevent steep falloff artifacts).
  9706. */
  9707. useBlurCloseExponentialShadowMap: boolean;
  9708. /**
  9709. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9710. */
  9711. /**
  9712. * Sets the current filter to "PCF" (percentage closer filtering).
  9713. */
  9714. usePercentageCloserFiltering: boolean;
  9715. private _filteringQuality;
  9716. /**
  9717. * Gets the PCF or PCSS Quality.
  9718. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9719. */
  9720. /**
  9721. * Sets the PCF or PCSS Quality.
  9722. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9723. */
  9724. filteringQuality: number;
  9725. /**
  9726. * Gets if the current filter is set to "PCSS" (contact hardening).
  9727. */
  9728. /**
  9729. * Sets the current filter to "PCSS" (contact hardening).
  9730. */
  9731. useContactHardeningShadow: boolean;
  9732. private _contactHardeningLightSizeUVRatio;
  9733. /**
  9734. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9735. * Using a ratio helps keeping shape stability independently of the map size.
  9736. *
  9737. * It does not account for the light projection as it was having too much
  9738. * instability during the light setup or during light position changes.
  9739. *
  9740. * Only valid if useContactHardeningShadow is true.
  9741. */
  9742. /**
  9743. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9744. * Using a ratio helps keeping shape stability independently of the map size.
  9745. *
  9746. * It does not account for the light projection as it was having too much
  9747. * instability during the light setup or during light position changes.
  9748. *
  9749. * Only valid if useContactHardeningShadow is true.
  9750. */
  9751. contactHardeningLightSizeUVRatio: number;
  9752. private _darkness;
  9753. /** Gets or sets the actual darkness of a shadow */
  9754. darkness: number;
  9755. /**
  9756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9757. * 0 means strongest and 1 would means no shadow.
  9758. * @returns the darkness.
  9759. */
  9760. getDarkness(): number;
  9761. /**
  9762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9764. * @returns the shadow generator allowing fluent coding.
  9765. */
  9766. setDarkness(darkness: number): ShadowGenerator;
  9767. private _transparencyShadow;
  9768. /** Gets or sets the ability to have transparent shadow */
  9769. transparencyShadow: boolean;
  9770. /**
  9771. * Sets the ability to have transparent shadow (boolean).
  9772. * @param transparent True if transparent else False
  9773. * @returns the shadow generator allowing fluent coding
  9774. */
  9775. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9776. private _shadowMap;
  9777. private _shadowMap2;
  9778. /**
  9779. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9780. * @returns The render target texture if present otherwise, null
  9781. */
  9782. getShadowMap(): Nullable<RenderTargetTexture>;
  9783. /**
  9784. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9785. * @returns The render target texture if the shadow map is present otherwise, null
  9786. */
  9787. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9788. /**
  9789. * Gets the class name of that object
  9790. * @returns "ShadowGenerator"
  9791. */
  9792. getClassName(): string;
  9793. /**
  9794. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9795. * @param mesh Mesh to add
  9796. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9797. * @returns the Shadow Generator itself
  9798. */
  9799. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9800. /**
  9801. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9802. * @param mesh Mesh to remove
  9803. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9804. * @returns the Shadow Generator itself
  9805. */
  9806. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9807. /**
  9808. * Controls the extent to which the shadows fade out at the edge of the frustum
  9809. * Used only by directionals and spots
  9810. */
  9811. frustumEdgeFalloff: number;
  9812. private _light;
  9813. /**
  9814. * Returns the associated light object.
  9815. * @returns the light generating the shadow
  9816. */
  9817. getLight(): IShadowLight;
  9818. /**
  9819. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9820. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9821. * It might on the other hand introduce peter panning.
  9822. */
  9823. forceBackFacesOnly: boolean;
  9824. private _scene;
  9825. private _lightDirection;
  9826. private _effect;
  9827. private _viewMatrix;
  9828. private _projectionMatrix;
  9829. private _transformMatrix;
  9830. private _cachedPosition;
  9831. private _cachedDirection;
  9832. private _cachedDefines;
  9833. private _currentRenderID;
  9834. private _boxBlurPostprocess;
  9835. private _kernelBlurXPostprocess;
  9836. private _kernelBlurYPostprocess;
  9837. private _blurPostProcesses;
  9838. private _mapSize;
  9839. private _currentFaceIndex;
  9840. private _currentFaceIndexCache;
  9841. private _textureType;
  9842. private _defaultTextureMatrix;
  9843. /** @hidden */
  9844. static _SceneComponentInitialization: (scene: Scene) => void;
  9845. /**
  9846. * Creates a ShadowGenerator object.
  9847. * A ShadowGenerator is the required tool to use the shadows.
  9848. * Each light casting shadows needs to use its own ShadowGenerator.
  9849. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9850. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9851. * @param light The light object generating the shadows.
  9852. * @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.
  9853. */
  9854. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9855. private _initializeGenerator;
  9856. private _initializeShadowMap;
  9857. private _initializeBlurRTTAndPostProcesses;
  9858. private _renderForShadowMap;
  9859. private _renderSubMeshForShadowMap;
  9860. private _applyFilterValues;
  9861. /**
  9862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9863. * @param onCompiled Callback triggered at the and of the effects compilation
  9864. * @param options Sets of optional options forcing the compilation with different modes
  9865. */
  9866. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9867. useInstances: boolean;
  9868. }>): void;
  9869. /**
  9870. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9871. * @param options Sets of optional options forcing the compilation with different modes
  9872. * @returns A promise that resolves when the compilation completes
  9873. */
  9874. forceCompilationAsync(options?: Partial<{
  9875. useInstances: boolean;
  9876. }>): Promise<void>;
  9877. /**
  9878. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9879. * @param subMesh The submesh we want to render in the shadow map
  9880. * @param useInstances Defines wether will draw in the map using instances
  9881. * @returns true if ready otherwise, false
  9882. */
  9883. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9884. /**
  9885. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9886. * @param defines Defines of the material we want to update
  9887. * @param lightIndex Index of the light in the enabled light list of the material
  9888. */
  9889. prepareDefines(defines: any, lightIndex: number): void;
  9890. /**
  9891. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9892. * defined in the generator but impacting the effect).
  9893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9894. * @param effect The effect we are binfing the information for
  9895. */
  9896. bindShadowLight(lightIndex: string, effect: Effect): void;
  9897. /**
  9898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9899. * (eq to shadow prjection matrix * light transform matrix)
  9900. * @returns The transform matrix used to create the shadow map
  9901. */
  9902. getTransformMatrix(): Matrix;
  9903. /**
  9904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9905. * Cube and 2D textures for instance.
  9906. */
  9907. recreateShadowMap(): void;
  9908. private _disposeBlurPostProcesses;
  9909. private _disposeRTTandPostProcesses;
  9910. /**
  9911. * Disposes the ShadowGenerator.
  9912. * Returns nothing.
  9913. */
  9914. dispose(): void;
  9915. /**
  9916. * Serializes the shadow generator setup to a json object.
  9917. * @returns The serialized JSON object
  9918. */
  9919. serialize(): any;
  9920. /**
  9921. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9922. * @param parsedShadowGenerator The JSON object to parse
  9923. * @param scene The scene to create the shadow map for
  9924. * @returns The parsed shadow generator
  9925. */
  9926. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9927. }
  9928. }
  9929. declare module "babylonjs/Lights/light" {
  9930. import { Nullable } from "babylonjs/types";
  9931. import { Scene } from "babylonjs/scene";
  9932. import { Vector3 } from "babylonjs/Maths/math.vector";
  9933. import { Color3 } from "babylonjs/Maths/math.color";
  9934. import { Node } from "babylonjs/node";
  9935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9936. import { Effect } from "babylonjs/Materials/effect";
  9937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9938. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9939. /**
  9940. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9941. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9942. * 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.
  9943. */
  9944. export abstract class Light extends Node {
  9945. /**
  9946. * Falloff Default: light is falling off following the material specification:
  9947. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9948. */
  9949. static readonly FALLOFF_DEFAULT: number;
  9950. /**
  9951. * Falloff Physical: light is falling off following the inverse squared distance law.
  9952. */
  9953. static readonly FALLOFF_PHYSICAL: number;
  9954. /**
  9955. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9956. * to enhance interoperability with other engines.
  9957. */
  9958. static readonly FALLOFF_GLTF: number;
  9959. /**
  9960. * Falloff Standard: light is falling off like in the standard material
  9961. * to enhance interoperability with other materials.
  9962. */
  9963. static readonly FALLOFF_STANDARD: number;
  9964. /**
  9965. * If every light affecting the material is in this lightmapMode,
  9966. * material.lightmapTexture adds or multiplies
  9967. * (depends on material.useLightmapAsShadowmap)
  9968. * after every other light calculations.
  9969. */
  9970. static readonly LIGHTMAP_DEFAULT: number;
  9971. /**
  9972. * material.lightmapTexture as only diffuse lighting from this light
  9973. * adds only specular lighting from this light
  9974. * adds dynamic shadows
  9975. */
  9976. static readonly LIGHTMAP_SPECULAR: number;
  9977. /**
  9978. * material.lightmapTexture as only lighting
  9979. * no light calculation from this light
  9980. * only adds dynamic shadows from this light
  9981. */
  9982. static readonly LIGHTMAP_SHADOWSONLY: number;
  9983. /**
  9984. * Each light type uses the default quantity according to its type:
  9985. * point/spot lights use luminous intensity
  9986. * directional lights use illuminance
  9987. */
  9988. static readonly INTENSITYMODE_AUTOMATIC: number;
  9989. /**
  9990. * lumen (lm)
  9991. */
  9992. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9993. /**
  9994. * candela (lm/sr)
  9995. */
  9996. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9997. /**
  9998. * lux (lm/m^2)
  9999. */
  10000. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10001. /**
  10002. * nit (cd/m^2)
  10003. */
  10004. static readonly INTENSITYMODE_LUMINANCE: number;
  10005. /**
  10006. * Light type const id of the point light.
  10007. */
  10008. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10009. /**
  10010. * Light type const id of the directional light.
  10011. */
  10012. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10013. /**
  10014. * Light type const id of the spot light.
  10015. */
  10016. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10017. /**
  10018. * Light type const id of the hemispheric light.
  10019. */
  10020. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10021. /**
  10022. * Diffuse gives the basic color to an object.
  10023. */
  10024. diffuse: Color3;
  10025. /**
  10026. * Specular produces a highlight color on an object.
  10027. * Note: This is note affecting PBR materials.
  10028. */
  10029. specular: Color3;
  10030. /**
  10031. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10032. * falling off base on range or angle.
  10033. * This can be set to any values in Light.FALLOFF_x.
  10034. *
  10035. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10036. * other types of materials.
  10037. */
  10038. falloffType: number;
  10039. /**
  10040. * Strength of the light.
  10041. * Note: By default it is define in the framework own unit.
  10042. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10043. */
  10044. intensity: number;
  10045. private _range;
  10046. protected _inverseSquaredRange: number;
  10047. /**
  10048. * Defines how far from the source the light is impacting in scene units.
  10049. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10050. */
  10051. /**
  10052. * Defines how far from the source the light is impacting in scene units.
  10053. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10054. */
  10055. range: number;
  10056. /**
  10057. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10058. * of light.
  10059. */
  10060. private _photometricScale;
  10061. private _intensityMode;
  10062. /**
  10063. * Gets the photometric scale used to interpret the intensity.
  10064. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10065. */
  10066. /**
  10067. * Sets the photometric scale used to interpret the intensity.
  10068. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10069. */
  10070. intensityMode: number;
  10071. private _radius;
  10072. /**
  10073. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10074. */
  10075. /**
  10076. * sets the light radius used by PBR Materials to simulate soft area lights.
  10077. */
  10078. radius: number;
  10079. private _renderPriority;
  10080. /**
  10081. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10082. * exceeding the number allowed of the materials.
  10083. */
  10084. renderPriority: number;
  10085. private _shadowEnabled;
  10086. /**
  10087. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10088. * the current shadow generator.
  10089. */
  10090. /**
  10091. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10092. * the current shadow generator.
  10093. */
  10094. shadowEnabled: boolean;
  10095. private _includedOnlyMeshes;
  10096. /**
  10097. * Gets the only meshes impacted by this light.
  10098. */
  10099. /**
  10100. * Sets the only meshes impacted by this light.
  10101. */
  10102. includedOnlyMeshes: AbstractMesh[];
  10103. private _excludedMeshes;
  10104. /**
  10105. * Gets the meshes not impacted by this light.
  10106. */
  10107. /**
  10108. * Sets the meshes not impacted by this light.
  10109. */
  10110. excludedMeshes: AbstractMesh[];
  10111. private _excludeWithLayerMask;
  10112. /**
  10113. * Gets the layer id use to find what meshes are not impacted by the light.
  10114. * Inactive if 0
  10115. */
  10116. /**
  10117. * Sets the layer id use to find what meshes are not impacted by the light.
  10118. * Inactive if 0
  10119. */
  10120. excludeWithLayerMask: number;
  10121. private _includeOnlyWithLayerMask;
  10122. /**
  10123. * Gets the layer id use to find what meshes are impacted by the light.
  10124. * Inactive if 0
  10125. */
  10126. /**
  10127. * Sets the layer id use to find what meshes are impacted by the light.
  10128. * Inactive if 0
  10129. */
  10130. includeOnlyWithLayerMask: number;
  10131. private _lightmapMode;
  10132. /**
  10133. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10134. */
  10135. /**
  10136. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10137. */
  10138. lightmapMode: number;
  10139. /**
  10140. * Shadow generator associted to the light.
  10141. * @hidden Internal use only.
  10142. */
  10143. _shadowGenerator: Nullable<IShadowGenerator>;
  10144. /**
  10145. * @hidden Internal use only.
  10146. */
  10147. _excludedMeshesIds: string[];
  10148. /**
  10149. * @hidden Internal use only.
  10150. */
  10151. _includedOnlyMeshesIds: string[];
  10152. /**
  10153. * The current light unifom buffer.
  10154. * @hidden Internal use only.
  10155. */
  10156. _uniformBuffer: UniformBuffer;
  10157. /**
  10158. * Creates a Light object in the scene.
  10159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10160. * @param name The firendly name of the light
  10161. * @param scene The scene the light belongs too
  10162. */
  10163. constructor(name: string, scene: Scene);
  10164. protected abstract _buildUniformLayout(): void;
  10165. /**
  10166. * Sets the passed Effect "effect" with the Light information.
  10167. * @param effect The effect to update
  10168. * @param lightIndex The index of the light in the effect to update
  10169. * @returns The light
  10170. */
  10171. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10172. /**
  10173. * Sets the passed Effect "effect" with the Light information.
  10174. * @param effect The effect to update
  10175. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10176. * @returns The light
  10177. */
  10178. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10179. /**
  10180. * Returns the string "Light".
  10181. * @returns the class name
  10182. */
  10183. getClassName(): string;
  10184. /** @hidden */
  10185. readonly _isLight: boolean;
  10186. /**
  10187. * Converts the light information to a readable string for debug purpose.
  10188. * @param fullDetails Supports for multiple levels of logging within scene loading
  10189. * @returns the human readable light info
  10190. */
  10191. toString(fullDetails?: boolean): string;
  10192. /** @hidden */
  10193. protected _syncParentEnabledState(): void;
  10194. /**
  10195. * Set the enabled state of this node.
  10196. * @param value - the new enabled state
  10197. */
  10198. setEnabled(value: boolean): void;
  10199. /**
  10200. * Returns the Light associated shadow generator if any.
  10201. * @return the associated shadow generator.
  10202. */
  10203. getShadowGenerator(): Nullable<IShadowGenerator>;
  10204. /**
  10205. * Returns a Vector3, the absolute light position in the World.
  10206. * @returns the world space position of the light
  10207. */
  10208. getAbsolutePosition(): Vector3;
  10209. /**
  10210. * Specifies if the light will affect the passed mesh.
  10211. * @param mesh The mesh to test against the light
  10212. * @return true the mesh is affected otherwise, false.
  10213. */
  10214. canAffectMesh(mesh: AbstractMesh): boolean;
  10215. /**
  10216. * Sort function to order lights for rendering.
  10217. * @param a First Light object to compare to second.
  10218. * @param b Second Light object to compare first.
  10219. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10220. */
  10221. static CompareLightsPriority(a: Light, b: Light): number;
  10222. /**
  10223. * Releases resources associated with this node.
  10224. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10225. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10226. */
  10227. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10228. /**
  10229. * Returns the light type ID (integer).
  10230. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10231. */
  10232. getTypeID(): number;
  10233. /**
  10234. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10235. * @returns the scaled intensity in intensity mode unit
  10236. */
  10237. getScaledIntensity(): number;
  10238. /**
  10239. * Returns a new Light object, named "name", from the current one.
  10240. * @param name The name of the cloned light
  10241. * @returns the new created light
  10242. */
  10243. clone(name: string): Nullable<Light>;
  10244. /**
  10245. * Serializes the current light into a Serialization object.
  10246. * @returns the serialized object.
  10247. */
  10248. serialize(): any;
  10249. /**
  10250. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10251. * This new light is named "name" and added to the passed scene.
  10252. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10253. * @param name The friendly name of the light
  10254. * @param scene The scene the new light will belong to
  10255. * @returns the constructor function
  10256. */
  10257. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10258. /**
  10259. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10260. * @param parsedLight The JSON representation of the light
  10261. * @param scene The scene to create the parsed light in
  10262. * @returns the created light after parsing
  10263. */
  10264. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10265. private _hookArrayForExcluded;
  10266. private _hookArrayForIncludedOnly;
  10267. private _resyncMeshes;
  10268. /**
  10269. * Forces the meshes to update their light related information in their rendering used effects
  10270. * @hidden Internal Use Only
  10271. */
  10272. _markMeshesAsLightDirty(): void;
  10273. /**
  10274. * Recomputes the cached photometric scale if needed.
  10275. */
  10276. private _computePhotometricScale;
  10277. /**
  10278. * Returns the Photometric Scale according to the light type and intensity mode.
  10279. */
  10280. private _getPhotometricScale;
  10281. /**
  10282. * Reorder the light in the scene according to their defined priority.
  10283. * @hidden Internal Use Only
  10284. */
  10285. _reorderLightsInScene(): void;
  10286. /**
  10287. * Prepares the list of defines specific to the light type.
  10288. * @param defines the list of defines
  10289. * @param lightIndex defines the index of the light for the effect
  10290. */
  10291. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10292. }
  10293. }
  10294. declare module "babylonjs/Actions/action" {
  10295. import { Observable } from "babylonjs/Misc/observable";
  10296. import { Condition } from "babylonjs/Actions/condition";
  10297. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10298. import { ActionManager } from "babylonjs/Actions/actionManager";
  10299. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10300. /**
  10301. * Interface used to define Action
  10302. */
  10303. export interface IAction {
  10304. /**
  10305. * Trigger for the action
  10306. */
  10307. trigger: number;
  10308. /** Options of the trigger */
  10309. triggerOptions: any;
  10310. /**
  10311. * Gets the trigger parameters
  10312. * @returns the trigger parameters
  10313. */
  10314. getTriggerParameter(): any;
  10315. /**
  10316. * Internal only - executes current action event
  10317. * @hidden
  10318. */
  10319. _executeCurrent(evt?: ActionEvent): void;
  10320. /**
  10321. * Serialize placeholder for child classes
  10322. * @param parent of child
  10323. * @returns the serialized object
  10324. */
  10325. serialize(parent: any): any;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _prepare(): void;
  10331. /**
  10332. * Internal only - manager for action
  10333. * @hidden
  10334. */
  10335. _actionManager: AbstractActionManager;
  10336. /**
  10337. * Adds action to chain of actions, may be a DoNothingAction
  10338. * @param action defines the next action to execute
  10339. * @returns The action passed in
  10340. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10341. */
  10342. then(action: IAction): IAction;
  10343. }
  10344. /**
  10345. * The action to be carried out following a trigger
  10346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10347. */
  10348. export class Action implements IAction {
  10349. /** the trigger, with or without parameters, for the action */
  10350. triggerOptions: any;
  10351. /**
  10352. * Trigger for the action
  10353. */
  10354. trigger: number;
  10355. /**
  10356. * Internal only - manager for action
  10357. * @hidden
  10358. */
  10359. _actionManager: ActionManager;
  10360. private _nextActiveAction;
  10361. private _child;
  10362. private _condition?;
  10363. private _triggerParameter;
  10364. /**
  10365. * An event triggered prior to action being executed.
  10366. */
  10367. onBeforeExecuteObservable: Observable<Action>;
  10368. /**
  10369. * Creates a new Action
  10370. * @param triggerOptions the trigger, with or without parameters, for the action
  10371. * @param condition an optional determinant of action
  10372. */
  10373. constructor(
  10374. /** the trigger, with or without parameters, for the action */
  10375. triggerOptions: any, condition?: Condition);
  10376. /**
  10377. * Internal only
  10378. * @hidden
  10379. */
  10380. _prepare(): void;
  10381. /**
  10382. * Gets the trigger parameters
  10383. * @returns the trigger parameters
  10384. */
  10385. getTriggerParameter(): any;
  10386. /**
  10387. * Internal only - executes current action event
  10388. * @hidden
  10389. */
  10390. _executeCurrent(evt?: ActionEvent): void;
  10391. /**
  10392. * Execute placeholder for child classes
  10393. * @param evt optional action event
  10394. */
  10395. execute(evt?: ActionEvent): void;
  10396. /**
  10397. * Skips to next active action
  10398. */
  10399. skipToNextActiveAction(): void;
  10400. /**
  10401. * Adds action to chain of actions, may be a DoNothingAction
  10402. * @param action defines the next action to execute
  10403. * @returns The action passed in
  10404. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10405. */
  10406. then(action: Action): Action;
  10407. /**
  10408. * Internal only
  10409. * @hidden
  10410. */
  10411. _getProperty(propertyPath: string): string;
  10412. /**
  10413. * Internal only
  10414. * @hidden
  10415. */
  10416. _getEffectiveTarget(target: any, propertyPath: string): any;
  10417. /**
  10418. * Serialize placeholder for child classes
  10419. * @param parent of child
  10420. * @returns the serialized object
  10421. */
  10422. serialize(parent: any): any;
  10423. /**
  10424. * Internal only called by serialize
  10425. * @hidden
  10426. */
  10427. protected _serialize(serializedAction: any, parent?: any): any;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. static _SerializeValueAsString: (value: any) => string;
  10433. /**
  10434. * Internal only
  10435. * @hidden
  10436. */
  10437. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10438. name: string;
  10439. targetType: string;
  10440. value: string;
  10441. };
  10442. }
  10443. }
  10444. declare module "babylonjs/Actions/condition" {
  10445. import { ActionManager } from "babylonjs/Actions/actionManager";
  10446. /**
  10447. * A Condition applied to an Action
  10448. */
  10449. export class Condition {
  10450. /**
  10451. * Internal only - manager for action
  10452. * @hidden
  10453. */
  10454. _actionManager: ActionManager;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. _evaluationId: number;
  10460. /**
  10461. * Internal only
  10462. * @hidden
  10463. */
  10464. _currentResult: boolean;
  10465. /**
  10466. * Creates a new Condition
  10467. * @param actionManager the manager of the action the condition is applied to
  10468. */
  10469. constructor(actionManager: ActionManager);
  10470. /**
  10471. * Check if the current condition is valid
  10472. * @returns a boolean
  10473. */
  10474. isValid(): boolean;
  10475. /**
  10476. * Internal only
  10477. * @hidden
  10478. */
  10479. _getProperty(propertyPath: string): string;
  10480. /**
  10481. * Internal only
  10482. * @hidden
  10483. */
  10484. _getEffectiveTarget(target: any, propertyPath: string): any;
  10485. /**
  10486. * Serialize placeholder for child classes
  10487. * @returns the serialized object
  10488. */
  10489. serialize(): any;
  10490. /**
  10491. * Internal only
  10492. * @hidden
  10493. */
  10494. protected _serialize(serializedCondition: any): any;
  10495. }
  10496. /**
  10497. * Defines specific conditional operators as extensions of Condition
  10498. */
  10499. export class ValueCondition extends Condition {
  10500. /** path to specify the property of the target the conditional operator uses */
  10501. propertyPath: string;
  10502. /** the value compared by the conditional operator against the current value of the property */
  10503. value: any;
  10504. /** the conditional operator, default ValueCondition.IsEqual */
  10505. operator: number;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private static _IsEqual;
  10511. /**
  10512. * Internal only
  10513. * @hidden
  10514. */
  10515. private static _IsDifferent;
  10516. /**
  10517. * Internal only
  10518. * @hidden
  10519. */
  10520. private static _IsGreater;
  10521. /**
  10522. * Internal only
  10523. * @hidden
  10524. */
  10525. private static _IsLesser;
  10526. /**
  10527. * returns the number for IsEqual
  10528. */
  10529. static readonly IsEqual: number;
  10530. /**
  10531. * Returns the number for IsDifferent
  10532. */
  10533. static readonly IsDifferent: number;
  10534. /**
  10535. * Returns the number for IsGreater
  10536. */
  10537. static readonly IsGreater: number;
  10538. /**
  10539. * Returns the number for IsLesser
  10540. */
  10541. static readonly IsLesser: number;
  10542. /**
  10543. * Internal only The action manager for the condition
  10544. * @hidden
  10545. */
  10546. _actionManager: ActionManager;
  10547. /**
  10548. * Internal only
  10549. * @hidden
  10550. */
  10551. private _target;
  10552. /**
  10553. * Internal only
  10554. * @hidden
  10555. */
  10556. private _effectiveTarget;
  10557. /**
  10558. * Internal only
  10559. * @hidden
  10560. */
  10561. private _property;
  10562. /**
  10563. * Creates a new ValueCondition
  10564. * @param actionManager manager for the action the condition applies to
  10565. * @param target for the action
  10566. * @param propertyPath path to specify the property of the target the conditional operator uses
  10567. * @param value the value compared by the conditional operator against the current value of the property
  10568. * @param operator the conditional operator, default ValueCondition.IsEqual
  10569. */
  10570. constructor(actionManager: ActionManager, target: any,
  10571. /** path to specify the property of the target the conditional operator uses */
  10572. propertyPath: string,
  10573. /** the value compared by the conditional operator against the current value of the property */
  10574. value: any,
  10575. /** the conditional operator, default ValueCondition.IsEqual */
  10576. operator?: number);
  10577. /**
  10578. * Compares the given value with the property value for the specified conditional operator
  10579. * @returns the result of the comparison
  10580. */
  10581. isValid(): boolean;
  10582. /**
  10583. * Serialize the ValueCondition into a JSON compatible object
  10584. * @returns serialization object
  10585. */
  10586. serialize(): any;
  10587. /**
  10588. * Gets the name of the conditional operator for the ValueCondition
  10589. * @param operator the conditional operator
  10590. * @returns the name
  10591. */
  10592. static GetOperatorName(operator: number): string;
  10593. }
  10594. /**
  10595. * Defines a predicate condition as an extension of Condition
  10596. */
  10597. export class PredicateCondition extends Condition {
  10598. /** defines the predicate function used to validate the condition */
  10599. predicate: () => boolean;
  10600. /**
  10601. * Internal only - manager for action
  10602. * @hidden
  10603. */
  10604. _actionManager: ActionManager;
  10605. /**
  10606. * Creates a new PredicateCondition
  10607. * @param actionManager manager for the action the condition applies to
  10608. * @param predicate defines the predicate function used to validate the condition
  10609. */
  10610. constructor(actionManager: ActionManager,
  10611. /** defines the predicate function used to validate the condition */
  10612. predicate: () => boolean);
  10613. /**
  10614. * @returns the validity of the predicate condition
  10615. */
  10616. isValid(): boolean;
  10617. }
  10618. /**
  10619. * Defines a state condition as an extension of Condition
  10620. */
  10621. export class StateCondition extends Condition {
  10622. /** Value to compare with target state */
  10623. value: string;
  10624. /**
  10625. * Internal only - manager for action
  10626. * @hidden
  10627. */
  10628. _actionManager: ActionManager;
  10629. /**
  10630. * Internal only
  10631. * @hidden
  10632. */
  10633. private _target;
  10634. /**
  10635. * Creates a new StateCondition
  10636. * @param actionManager manager for the action the condition applies to
  10637. * @param target of the condition
  10638. * @param value to compare with target state
  10639. */
  10640. constructor(actionManager: ActionManager, target: any,
  10641. /** Value to compare with target state */
  10642. value: string);
  10643. /**
  10644. * Gets a boolean indicating if the current condition is met
  10645. * @returns the validity of the state
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Serialize the StateCondition into a JSON compatible object
  10650. * @returns serialization object
  10651. */
  10652. serialize(): any;
  10653. }
  10654. }
  10655. declare module "babylonjs/Actions/directActions" {
  10656. import { Action } from "babylonjs/Actions/action";
  10657. import { Condition } from "babylonjs/Actions/condition";
  10658. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10659. /**
  10660. * This defines an action responsible to toggle a boolean once triggered.
  10661. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10662. */
  10663. export class SwitchBooleanAction extends Action {
  10664. /**
  10665. * The path to the boolean property in the target object
  10666. */
  10667. propertyPath: string;
  10668. private _target;
  10669. private _effectiveTarget;
  10670. private _property;
  10671. /**
  10672. * Instantiate the action
  10673. * @param triggerOptions defines the trigger options
  10674. * @param target defines the object containing the boolean
  10675. * @param propertyPath defines the path to the boolean property in the target object
  10676. * @param condition defines the trigger related conditions
  10677. */
  10678. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10679. /** @hidden */
  10680. _prepare(): void;
  10681. /**
  10682. * Execute the action toggle the boolean value.
  10683. */
  10684. execute(): void;
  10685. /**
  10686. * Serializes the actions and its related information.
  10687. * @param parent defines the object to serialize in
  10688. * @returns the serialized object
  10689. */
  10690. serialize(parent: any): any;
  10691. }
  10692. /**
  10693. * This defines an action responsible to set a the state field of the target
  10694. * to a desired value once triggered.
  10695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10696. */
  10697. export class SetStateAction extends Action {
  10698. /**
  10699. * The value to store in the state field.
  10700. */
  10701. value: string;
  10702. private _target;
  10703. /**
  10704. * Instantiate the action
  10705. * @param triggerOptions defines the trigger options
  10706. * @param target defines the object containing the state property
  10707. * @param value defines the value to store in the state field
  10708. * @param condition defines the trigger related conditions
  10709. */
  10710. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10711. /**
  10712. * Execute the action and store the value on the target state property.
  10713. */
  10714. execute(): void;
  10715. /**
  10716. * Serializes the actions and its related information.
  10717. * @param parent defines the object to serialize in
  10718. * @returns the serialized object
  10719. */
  10720. serialize(parent: any): any;
  10721. }
  10722. /**
  10723. * This defines an action responsible to set a property of the target
  10724. * to a desired value once triggered.
  10725. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10726. */
  10727. export class SetValueAction extends Action {
  10728. /**
  10729. * The path of the property to set in the target.
  10730. */
  10731. propertyPath: string;
  10732. /**
  10733. * The value to set in the property
  10734. */
  10735. value: any;
  10736. private _target;
  10737. private _effectiveTarget;
  10738. private _property;
  10739. /**
  10740. * Instantiate the action
  10741. * @param triggerOptions defines the trigger options
  10742. * @param target defines the object containing the property
  10743. * @param propertyPath defines the path of the property to set in the target
  10744. * @param value defines the value to set in the property
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10748. /** @hidden */
  10749. _prepare(): void;
  10750. /**
  10751. * Execute the action and set the targetted property to the desired value.
  10752. */
  10753. execute(): void;
  10754. /**
  10755. * Serializes the actions and its related information.
  10756. * @param parent defines the object to serialize in
  10757. * @returns the serialized object
  10758. */
  10759. serialize(parent: any): any;
  10760. }
  10761. /**
  10762. * This defines an action responsible to increment the target value
  10763. * to a desired value once triggered.
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10765. */
  10766. export class IncrementValueAction extends Action {
  10767. /**
  10768. * The path of the property to increment in the target.
  10769. */
  10770. propertyPath: string;
  10771. /**
  10772. * The value we should increment the property by.
  10773. */
  10774. value: any;
  10775. private _target;
  10776. private _effectiveTarget;
  10777. private _property;
  10778. /**
  10779. * Instantiate the action
  10780. * @param triggerOptions defines the trigger options
  10781. * @param target defines the object containing the property
  10782. * @param propertyPath defines the path of the property to increment in the target
  10783. * @param value defines the value value we should increment the property by
  10784. * @param condition defines the trigger related conditions
  10785. */
  10786. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10787. /** @hidden */
  10788. _prepare(): void;
  10789. /**
  10790. * Execute the action and increment the target of the value amount.
  10791. */
  10792. execute(): void;
  10793. /**
  10794. * Serializes the actions and its related information.
  10795. * @param parent defines the object to serialize in
  10796. * @returns the serialized object
  10797. */
  10798. serialize(parent: any): any;
  10799. }
  10800. /**
  10801. * This defines an action responsible to start an animation once triggered.
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10803. */
  10804. export class PlayAnimationAction extends Action {
  10805. /**
  10806. * Where the animation should start (animation frame)
  10807. */
  10808. from: number;
  10809. /**
  10810. * Where the animation should stop (animation frame)
  10811. */
  10812. to: number;
  10813. /**
  10814. * Define if the animation should loop or stop after the first play.
  10815. */
  10816. loop?: boolean;
  10817. private _target;
  10818. /**
  10819. * Instantiate the action
  10820. * @param triggerOptions defines the trigger options
  10821. * @param target defines the target animation or animation name
  10822. * @param from defines from where the animation should start (animation frame)
  10823. * @param end defines where the animation should stop (animation frame)
  10824. * @param loop defines if the animation should loop or stop after the first play
  10825. * @param condition defines the trigger related conditions
  10826. */
  10827. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10828. /** @hidden */
  10829. _prepare(): void;
  10830. /**
  10831. * Execute the action and play the animation.
  10832. */
  10833. execute(): void;
  10834. /**
  10835. * Serializes the actions and its related information.
  10836. * @param parent defines the object to serialize in
  10837. * @returns the serialized object
  10838. */
  10839. serialize(parent: any): any;
  10840. }
  10841. /**
  10842. * This defines an action responsible to stop an animation once triggered.
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10844. */
  10845. export class StopAnimationAction extends Action {
  10846. private _target;
  10847. /**
  10848. * Instantiate the action
  10849. * @param triggerOptions defines the trigger options
  10850. * @param target defines the target animation or animation name
  10851. * @param condition defines the trigger related conditions
  10852. */
  10853. constructor(triggerOptions: any, target: any, condition?: Condition);
  10854. /** @hidden */
  10855. _prepare(): void;
  10856. /**
  10857. * Execute the action and stop the animation.
  10858. */
  10859. execute(): void;
  10860. /**
  10861. * Serializes the actions and its related information.
  10862. * @param parent defines the object to serialize in
  10863. * @returns the serialized object
  10864. */
  10865. serialize(parent: any): any;
  10866. }
  10867. /**
  10868. * This defines an action responsible that does nothing once triggered.
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10870. */
  10871. export class DoNothingAction extends Action {
  10872. /**
  10873. * Instantiate the action
  10874. * @param triggerOptions defines the trigger options
  10875. * @param condition defines the trigger related conditions
  10876. */
  10877. constructor(triggerOptions?: any, condition?: Condition);
  10878. /**
  10879. * Execute the action and do nothing.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible to trigger several actions once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class CombineAction extends Action {
  10894. /**
  10895. * The list of aggregated animations to run.
  10896. */
  10897. children: Action[];
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param children defines the list of aggregated animations to run
  10902. * @param condition defines the trigger related conditions
  10903. */
  10904. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10905. /** @hidden */
  10906. _prepare(): void;
  10907. /**
  10908. * Execute the action and executes all the aggregated actions.
  10909. */
  10910. execute(evt: ActionEvent): void;
  10911. /**
  10912. * Serializes the actions and its related information.
  10913. * @param parent defines the object to serialize in
  10914. * @returns the serialized object
  10915. */
  10916. serialize(parent: any): any;
  10917. }
  10918. /**
  10919. * This defines an action responsible to run code (external event) once triggered.
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10921. */
  10922. export class ExecuteCodeAction extends Action {
  10923. /**
  10924. * The callback function to run.
  10925. */
  10926. func: (evt: ActionEvent) => void;
  10927. /**
  10928. * Instantiate the action
  10929. * @param triggerOptions defines the trigger options
  10930. * @param func defines the callback function to run
  10931. * @param condition defines the trigger related conditions
  10932. */
  10933. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10934. /**
  10935. * Execute the action and run the attached code.
  10936. */
  10937. execute(evt: ActionEvent): void;
  10938. }
  10939. /**
  10940. * This defines an action responsible to set the parent property of the target once triggered.
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10942. */
  10943. export class SetParentAction extends Action {
  10944. private _parent;
  10945. private _target;
  10946. /**
  10947. * Instantiate the action
  10948. * @param triggerOptions defines the trigger options
  10949. * @param target defines the target containing the parent property
  10950. * @param parent defines from where the animation should start (animation frame)
  10951. * @param condition defines the trigger related conditions
  10952. */
  10953. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10954. /** @hidden */
  10955. _prepare(): void;
  10956. /**
  10957. * Execute the action and set the parent property.
  10958. */
  10959. execute(): void;
  10960. /**
  10961. * Serializes the actions and its related information.
  10962. * @param parent defines the object to serialize in
  10963. * @returns the serialized object
  10964. */
  10965. serialize(parent: any): any;
  10966. }
  10967. }
  10968. declare module "babylonjs/Actions/actionManager" {
  10969. import { Nullable } from "babylonjs/types";
  10970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10971. import { Scene } from "babylonjs/scene";
  10972. import { IAction } from "babylonjs/Actions/action";
  10973. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10974. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10975. /**
  10976. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10977. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10979. */
  10980. export class ActionManager extends AbstractActionManager {
  10981. /**
  10982. * Nothing
  10983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10984. */
  10985. static readonly NothingTrigger: number;
  10986. /**
  10987. * On pick
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10989. */
  10990. static readonly OnPickTrigger: number;
  10991. /**
  10992. * On left pick
  10993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10994. */
  10995. static readonly OnLeftPickTrigger: number;
  10996. /**
  10997. * On right pick
  10998. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10999. */
  11000. static readonly OnRightPickTrigger: number;
  11001. /**
  11002. * On center pick
  11003. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11004. */
  11005. static readonly OnCenterPickTrigger: number;
  11006. /**
  11007. * On pick down
  11008. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11009. */
  11010. static readonly OnPickDownTrigger: number;
  11011. /**
  11012. * On double pick
  11013. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11014. */
  11015. static readonly OnDoublePickTrigger: number;
  11016. /**
  11017. * On pick up
  11018. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11019. */
  11020. static readonly OnPickUpTrigger: number;
  11021. /**
  11022. * On pick out.
  11023. * This trigger will only be raised if you also declared a OnPickDown
  11024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11025. */
  11026. static readonly OnPickOutTrigger: number;
  11027. /**
  11028. * On long press
  11029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11030. */
  11031. static readonly OnLongPressTrigger: number;
  11032. /**
  11033. * On pointer over
  11034. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11035. */
  11036. static readonly OnPointerOverTrigger: number;
  11037. /**
  11038. * On pointer out
  11039. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11040. */
  11041. static readonly OnPointerOutTrigger: number;
  11042. /**
  11043. * On every frame
  11044. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11045. */
  11046. static readonly OnEveryFrameTrigger: number;
  11047. /**
  11048. * On intersection enter
  11049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11050. */
  11051. static readonly OnIntersectionEnterTrigger: number;
  11052. /**
  11053. * On intersection exit
  11054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11055. */
  11056. static readonly OnIntersectionExitTrigger: number;
  11057. /**
  11058. * On key down
  11059. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11060. */
  11061. static readonly OnKeyDownTrigger: number;
  11062. /**
  11063. * On key up
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11065. */
  11066. static readonly OnKeyUpTrigger: number;
  11067. private _scene;
  11068. /**
  11069. * Creates a new action manager
  11070. * @param scene defines the hosting scene
  11071. */
  11072. constructor(scene: Scene);
  11073. /**
  11074. * Releases all associated resources
  11075. */
  11076. dispose(): void;
  11077. /**
  11078. * Gets hosting scene
  11079. * @returns the hosting scene
  11080. */
  11081. getScene(): Scene;
  11082. /**
  11083. * Does this action manager handles actions of any of the given triggers
  11084. * @param triggers defines the triggers to be tested
  11085. * @return a boolean indicating whether one (or more) of the triggers is handled
  11086. */
  11087. hasSpecificTriggers(triggers: number[]): boolean;
  11088. /**
  11089. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11090. * speed.
  11091. * @param triggerA defines the trigger to be tested
  11092. * @param triggerB defines the trigger to be tested
  11093. * @return a boolean indicating whether one (or more) of the triggers is handled
  11094. */
  11095. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11096. /**
  11097. * Does this action manager handles actions of a given trigger
  11098. * @param trigger defines the trigger to be tested
  11099. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11100. * @return whether the trigger is handled
  11101. */
  11102. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11103. /**
  11104. * Does this action manager has pointer triggers
  11105. */
  11106. readonly hasPointerTriggers: boolean;
  11107. /**
  11108. * Does this action manager has pick triggers
  11109. */
  11110. readonly hasPickTriggers: boolean;
  11111. /**
  11112. * Registers an action to this action manager
  11113. * @param action defines the action to be registered
  11114. * @return the action amended (prepared) after registration
  11115. */
  11116. registerAction(action: IAction): Nullable<IAction>;
  11117. /**
  11118. * Unregisters an action to this action manager
  11119. * @param action defines the action to be unregistered
  11120. * @return a boolean indicating whether the action has been unregistered
  11121. */
  11122. unregisterAction(action: IAction): Boolean;
  11123. /**
  11124. * Process a specific trigger
  11125. * @param trigger defines the trigger to process
  11126. * @param evt defines the event details to be processed
  11127. */
  11128. processTrigger(trigger: number, evt?: IActionEvent): void;
  11129. /** @hidden */
  11130. _getEffectiveTarget(target: any, propertyPath: string): any;
  11131. /** @hidden */
  11132. _getProperty(propertyPath: string): string;
  11133. /**
  11134. * Serialize this manager to a JSON object
  11135. * @param name defines the property name to store this manager
  11136. * @returns a JSON representation of this manager
  11137. */
  11138. serialize(name: string): any;
  11139. /**
  11140. * Creates a new ActionManager from a JSON data
  11141. * @param parsedActions defines the JSON data to read from
  11142. * @param object defines the hosting mesh
  11143. * @param scene defines the hosting scene
  11144. */
  11145. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11146. /**
  11147. * Get a trigger name by index
  11148. * @param trigger defines the trigger index
  11149. * @returns a trigger name
  11150. */
  11151. static GetTriggerName(trigger: number): string;
  11152. }
  11153. }
  11154. declare module "babylonjs/Culling/ray" {
  11155. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11156. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11158. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11159. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11160. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11161. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11162. import { Plane } from "babylonjs/Maths/math.plane";
  11163. /**
  11164. * Class representing a ray with position and direction
  11165. */
  11166. export class Ray {
  11167. /** origin point */
  11168. origin: Vector3;
  11169. /** direction */
  11170. direction: Vector3;
  11171. /** length of the ray */
  11172. length: number;
  11173. private static readonly TmpVector3;
  11174. private _tmpRay;
  11175. /**
  11176. * Creates a new ray
  11177. * @param origin origin point
  11178. * @param direction direction
  11179. * @param length length of the ray
  11180. */
  11181. constructor(
  11182. /** origin point */
  11183. origin: Vector3,
  11184. /** direction */
  11185. direction: Vector3,
  11186. /** length of the ray */
  11187. length?: number);
  11188. /**
  11189. * Checks if the ray intersects a box
  11190. * @param minimum bound of the box
  11191. * @param maximum bound of the box
  11192. * @param intersectionTreshold extra extend to be added to the box in all direction
  11193. * @returns if the box was hit
  11194. */
  11195. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11196. /**
  11197. * Checks if the ray intersects a box
  11198. * @param box the bounding box to check
  11199. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11200. * @returns if the box was hit
  11201. */
  11202. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11203. /**
  11204. * If the ray hits a sphere
  11205. * @param sphere the bounding sphere to check
  11206. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11207. * @returns true if it hits the sphere
  11208. */
  11209. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11210. /**
  11211. * If the ray hits a triange
  11212. * @param vertex0 triangle vertex
  11213. * @param vertex1 triangle vertex
  11214. * @param vertex2 triangle vertex
  11215. * @returns intersection information if hit
  11216. */
  11217. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11218. /**
  11219. * Checks if ray intersects a plane
  11220. * @param plane the plane to check
  11221. * @returns the distance away it was hit
  11222. */
  11223. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11224. /**
  11225. * Calculate the intercept of a ray on a given axis
  11226. * @param axis to check 'x' | 'y' | 'z'
  11227. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11228. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11229. */
  11230. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11231. /**
  11232. * Checks if ray intersects a mesh
  11233. * @param mesh the mesh to check
  11234. * @param fastCheck if only the bounding box should checked
  11235. * @returns picking info of the intersecton
  11236. */
  11237. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11238. /**
  11239. * Checks if ray intersects a mesh
  11240. * @param meshes the meshes to check
  11241. * @param fastCheck if only the bounding box should checked
  11242. * @param results array to store result in
  11243. * @returns Array of picking infos
  11244. */
  11245. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11246. private _comparePickingInfo;
  11247. private static smallnum;
  11248. private static rayl;
  11249. /**
  11250. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11251. * @param sega the first point of the segment to test the intersection against
  11252. * @param segb the second point of the segment to test the intersection against
  11253. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11254. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11255. */
  11256. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11257. /**
  11258. * Update the ray from viewport position
  11259. * @param x position
  11260. * @param y y position
  11261. * @param viewportWidth viewport width
  11262. * @param viewportHeight viewport height
  11263. * @param world world matrix
  11264. * @param view view matrix
  11265. * @param projection projection matrix
  11266. * @returns this ray updated
  11267. */
  11268. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11269. /**
  11270. * Creates a ray with origin and direction of 0,0,0
  11271. * @returns the new ray
  11272. */
  11273. static Zero(): Ray;
  11274. /**
  11275. * Creates a new ray from screen space and viewport
  11276. * @param x position
  11277. * @param y y position
  11278. * @param viewportWidth viewport width
  11279. * @param viewportHeight viewport height
  11280. * @param world world matrix
  11281. * @param view view matrix
  11282. * @param projection projection matrix
  11283. * @returns new ray
  11284. */
  11285. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11286. /**
  11287. * 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
  11288. * transformed to the given world matrix.
  11289. * @param origin The origin point
  11290. * @param end The end point
  11291. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11292. * @returns the new ray
  11293. */
  11294. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11295. /**
  11296. * Transforms a ray by a matrix
  11297. * @param ray ray to transform
  11298. * @param matrix matrix to apply
  11299. * @returns the resulting new ray
  11300. */
  11301. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11302. /**
  11303. * Transforms a ray by a matrix
  11304. * @param ray ray to transform
  11305. * @param matrix matrix to apply
  11306. * @param result ray to store result in
  11307. */
  11308. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11309. /**
  11310. * Unproject a ray from screen space to object space
  11311. * @param sourceX defines the screen space x coordinate to use
  11312. * @param sourceY defines the screen space y coordinate to use
  11313. * @param viewportWidth defines the current width of the viewport
  11314. * @param viewportHeight defines the current height of the viewport
  11315. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11316. * @param view defines the view matrix to use
  11317. * @param projection defines the projection matrix to use
  11318. */
  11319. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11320. }
  11321. /**
  11322. * Type used to define predicate used to select faces when a mesh intersection is detected
  11323. */
  11324. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11325. module "babylonjs/scene" {
  11326. interface Scene {
  11327. /** @hidden */
  11328. _tempPickingRay: Nullable<Ray>;
  11329. /** @hidden */
  11330. _cachedRayForTransform: Ray;
  11331. /** @hidden */
  11332. _pickWithRayInverseMatrix: Matrix;
  11333. /** @hidden */
  11334. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11335. /** @hidden */
  11336. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11337. }
  11338. }
  11339. }
  11340. declare module "babylonjs/sceneComponent" {
  11341. import { Scene } from "babylonjs/scene";
  11342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11344. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11345. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11346. import { Nullable } from "babylonjs/types";
  11347. import { Camera } from "babylonjs/Cameras/camera";
  11348. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11349. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11350. import { AbstractScene } from "babylonjs/abstractScene";
  11351. /**
  11352. * Groups all the scene component constants in one place to ease maintenance.
  11353. * @hidden
  11354. */
  11355. export class SceneComponentConstants {
  11356. static readonly NAME_EFFECTLAYER: string;
  11357. static readonly NAME_LAYER: string;
  11358. static readonly NAME_LENSFLARESYSTEM: string;
  11359. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11360. static readonly NAME_PARTICLESYSTEM: string;
  11361. static readonly NAME_GAMEPAD: string;
  11362. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11363. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11364. static readonly NAME_DEPTHRENDERER: string;
  11365. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11366. static readonly NAME_SPRITE: string;
  11367. static readonly NAME_OUTLINERENDERER: string;
  11368. static readonly NAME_PROCEDURALTEXTURE: string;
  11369. static readonly NAME_SHADOWGENERATOR: string;
  11370. static readonly NAME_OCTREE: string;
  11371. static readonly NAME_PHYSICSENGINE: string;
  11372. static readonly NAME_AUDIO: string;
  11373. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11374. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11375. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11376. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11378. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11379. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11380. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11381. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11382. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11383. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11384. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11385. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11386. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11387. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11388. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11389. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11390. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11391. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11392. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11393. static readonly STEP_AFTERRENDER_AUDIO: number;
  11394. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11395. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11396. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11397. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11398. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11399. static readonly STEP_POINTERMOVE_SPRITE: number;
  11400. static readonly STEP_POINTERDOWN_SPRITE: number;
  11401. static readonly STEP_POINTERUP_SPRITE: number;
  11402. }
  11403. /**
  11404. * This represents a scene component.
  11405. *
  11406. * This is used to decouple the dependency the scene is having on the different workloads like
  11407. * layers, post processes...
  11408. */
  11409. export interface ISceneComponent {
  11410. /**
  11411. * The name of the component. Each component must have a unique name.
  11412. */
  11413. name: string;
  11414. /**
  11415. * The scene the component belongs to.
  11416. */
  11417. scene: Scene;
  11418. /**
  11419. * Register the component to one instance of a scene.
  11420. */
  11421. register(): void;
  11422. /**
  11423. * Rebuilds the elements related to this component in case of
  11424. * context lost for instance.
  11425. */
  11426. rebuild(): void;
  11427. /**
  11428. * Disposes the component and the associated ressources.
  11429. */
  11430. dispose(): void;
  11431. }
  11432. /**
  11433. * This represents a SERIALIZABLE scene component.
  11434. *
  11435. * This extends Scene Component to add Serialization methods on top.
  11436. */
  11437. export interface ISceneSerializableComponent extends ISceneComponent {
  11438. /**
  11439. * Adds all the elements from the container to the scene
  11440. * @param container the container holding the elements
  11441. */
  11442. addFromContainer(container: AbstractScene): void;
  11443. /**
  11444. * Removes all the elements in the container from the scene
  11445. * @param container contains the elements to remove
  11446. * @param dispose if the removed element should be disposed (default: false)
  11447. */
  11448. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11449. /**
  11450. * Serializes the component data to the specified json object
  11451. * @param serializationObject The object to serialize to
  11452. */
  11453. serialize(serializationObject: any): void;
  11454. }
  11455. /**
  11456. * Strong typing of a Mesh related stage step action
  11457. */
  11458. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11459. /**
  11460. * Strong typing of a Evaluate Sub Mesh related stage step action
  11461. */
  11462. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11463. /**
  11464. * Strong typing of a Active Mesh related stage step action
  11465. */
  11466. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11467. /**
  11468. * Strong typing of a Camera related stage step action
  11469. */
  11470. export type CameraStageAction = (camera: Camera) => void;
  11471. /**
  11472. * Strong typing of a Camera Frame buffer related stage step action
  11473. */
  11474. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11475. /**
  11476. * Strong typing of a Render Target related stage step action
  11477. */
  11478. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11479. /**
  11480. * Strong typing of a RenderingGroup related stage step action
  11481. */
  11482. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11483. /**
  11484. * Strong typing of a Mesh Render related stage step action
  11485. */
  11486. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11487. /**
  11488. * Strong typing of a simple stage step action
  11489. */
  11490. export type SimpleStageAction = () => void;
  11491. /**
  11492. * Strong typing of a render target action.
  11493. */
  11494. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11495. /**
  11496. * Strong typing of a pointer move action.
  11497. */
  11498. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11499. /**
  11500. * Strong typing of a pointer up/down action.
  11501. */
  11502. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11503. /**
  11504. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11505. * @hidden
  11506. */
  11507. export class Stage<T extends Function> extends Array<{
  11508. index: number;
  11509. component: ISceneComponent;
  11510. action: T;
  11511. }> {
  11512. /**
  11513. * Hide ctor from the rest of the world.
  11514. * @param items The items to add.
  11515. */
  11516. private constructor();
  11517. /**
  11518. * Creates a new Stage.
  11519. * @returns A new instance of a Stage
  11520. */
  11521. static Create<T extends Function>(): Stage<T>;
  11522. /**
  11523. * Registers a step in an ordered way in the targeted stage.
  11524. * @param index Defines the position to register the step in
  11525. * @param component Defines the component attached to the step
  11526. * @param action Defines the action to launch during the step
  11527. */
  11528. registerStep(index: number, component: ISceneComponent, action: T): void;
  11529. /**
  11530. * Clears all the steps from the stage.
  11531. */
  11532. clear(): void;
  11533. }
  11534. }
  11535. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11536. import { Nullable } from "babylonjs/types";
  11537. import { Observable } from "babylonjs/Misc/observable";
  11538. import { Scene } from "babylonjs/scene";
  11539. import { Sprite } from "babylonjs/Sprites/sprite";
  11540. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11541. import { Ray } from "babylonjs/Culling/ray";
  11542. import { Camera } from "babylonjs/Cameras/camera";
  11543. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11544. import { ISceneComponent } from "babylonjs/sceneComponent";
  11545. module "babylonjs/scene" {
  11546. interface Scene {
  11547. /** @hidden */
  11548. _pointerOverSprite: Nullable<Sprite>;
  11549. /** @hidden */
  11550. _pickedDownSprite: Nullable<Sprite>;
  11551. /** @hidden */
  11552. _tempSpritePickingRay: Nullable<Ray>;
  11553. /**
  11554. * All of the sprite managers added to this scene
  11555. * @see http://doc.babylonjs.com/babylon101/sprites
  11556. */
  11557. spriteManagers: Array<ISpriteManager>;
  11558. /**
  11559. * An event triggered when sprites rendering is about to start
  11560. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11561. */
  11562. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11563. /**
  11564. * An event triggered when sprites rendering is done
  11565. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11566. */
  11567. onAfterSpritesRenderingObservable: Observable<Scene>;
  11568. /** @hidden */
  11569. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11570. /** Launch a ray to try to pick a sprite in the scene
  11571. * @param x position on screen
  11572. * @param y position on screen
  11573. * @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
  11574. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11575. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11576. * @returns a PickingInfo
  11577. */
  11578. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11579. /** Use the given ray to pick a sprite in the scene
  11580. * @param ray The ray (in world space) to use to pick meshes
  11581. * @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
  11582. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11583. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11584. * @returns a PickingInfo
  11585. */
  11586. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11587. /** @hidden */
  11588. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11589. /** Launch a ray to try to pick sprites in the scene
  11590. * @param x position on screen
  11591. * @param y position on screen
  11592. * @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
  11593. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11594. * @returns a PickingInfo array
  11595. */
  11596. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11597. /** Use the given ray to pick sprites in the scene
  11598. * @param ray The ray (in world space) to use to pick meshes
  11599. * @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
  11600. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11601. * @returns a PickingInfo array
  11602. */
  11603. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11604. /**
  11605. * Force the sprite under the pointer
  11606. * @param sprite defines the sprite to use
  11607. */
  11608. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11609. /**
  11610. * Gets the sprite under the pointer
  11611. * @returns a Sprite or null if no sprite is under the pointer
  11612. */
  11613. getPointerOverSprite(): Nullable<Sprite>;
  11614. }
  11615. }
  11616. /**
  11617. * Defines the sprite scene component responsible to manage sprites
  11618. * in a given scene.
  11619. */
  11620. export class SpriteSceneComponent implements ISceneComponent {
  11621. /**
  11622. * The component name helpfull to identify the component in the list of scene components.
  11623. */
  11624. readonly name: string;
  11625. /**
  11626. * The scene the component belongs to.
  11627. */
  11628. scene: Scene;
  11629. /** @hidden */
  11630. private _spritePredicate;
  11631. /**
  11632. * Creates a new instance of the component for the given scene
  11633. * @param scene Defines the scene to register the component in
  11634. */
  11635. constructor(scene: Scene);
  11636. /**
  11637. * Registers the component in a given scene
  11638. */
  11639. register(): void;
  11640. /**
  11641. * Rebuilds the elements related to this component in case of
  11642. * context lost for instance.
  11643. */
  11644. rebuild(): void;
  11645. /**
  11646. * Disposes the component and the associated ressources.
  11647. */
  11648. dispose(): void;
  11649. private _pickSpriteButKeepRay;
  11650. private _pointerMove;
  11651. private _pointerDown;
  11652. private _pointerUp;
  11653. }
  11654. }
  11655. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11656. /** @hidden */
  11657. export var fogFragmentDeclaration: {
  11658. name: string;
  11659. shader: string;
  11660. };
  11661. }
  11662. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11663. /** @hidden */
  11664. export var fogFragment: {
  11665. name: string;
  11666. shader: string;
  11667. };
  11668. }
  11669. declare module "babylonjs/Shaders/sprites.fragment" {
  11670. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11671. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11672. /** @hidden */
  11673. export var spritesPixelShader: {
  11674. name: string;
  11675. shader: string;
  11676. };
  11677. }
  11678. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11679. /** @hidden */
  11680. export var fogVertexDeclaration: {
  11681. name: string;
  11682. shader: string;
  11683. };
  11684. }
  11685. declare module "babylonjs/Shaders/sprites.vertex" {
  11686. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11687. /** @hidden */
  11688. export var spritesVertexShader: {
  11689. name: string;
  11690. shader: string;
  11691. };
  11692. }
  11693. declare module "babylonjs/Sprites/spriteManager" {
  11694. import { IDisposable, Scene } from "babylonjs/scene";
  11695. import { Nullable } from "babylonjs/types";
  11696. import { Observable } from "babylonjs/Misc/observable";
  11697. import { Sprite } from "babylonjs/Sprites/sprite";
  11698. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11699. import { Camera } from "babylonjs/Cameras/camera";
  11700. import { Texture } from "babylonjs/Materials/Textures/texture";
  11701. import "babylonjs/Shaders/sprites.fragment";
  11702. import "babylonjs/Shaders/sprites.vertex";
  11703. import { Ray } from "babylonjs/Culling/ray";
  11704. /**
  11705. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11706. */
  11707. export interface ISpriteManager extends IDisposable {
  11708. /**
  11709. * Restricts the camera to viewing objects with the same layerMask.
  11710. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11711. */
  11712. layerMask: number;
  11713. /**
  11714. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11715. */
  11716. isPickable: boolean;
  11717. /**
  11718. * Specifies the rendering group id for this mesh (0 by default)
  11719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11720. */
  11721. renderingGroupId: number;
  11722. /**
  11723. * Defines the list of sprites managed by the manager.
  11724. */
  11725. sprites: Array<Sprite>;
  11726. /**
  11727. * Tests the intersection of a sprite with a specific ray.
  11728. * @param ray The ray we are sending to test the collision
  11729. * @param camera The camera space we are sending rays in
  11730. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11731. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11732. * @returns picking info or null.
  11733. */
  11734. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11735. /**
  11736. * Intersects the sprites with a ray
  11737. * @param ray defines the ray to intersect with
  11738. * @param camera defines the current active camera
  11739. * @param predicate defines a predicate used to select candidate sprites
  11740. * @returns null if no hit or a PickingInfo array
  11741. */
  11742. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11743. /**
  11744. * Renders the list of sprites on screen.
  11745. */
  11746. render(): void;
  11747. }
  11748. /**
  11749. * Class used to manage multiple sprites on the same spritesheet
  11750. * @see http://doc.babylonjs.com/babylon101/sprites
  11751. */
  11752. export class SpriteManager implements ISpriteManager {
  11753. /** defines the manager's name */
  11754. name: string;
  11755. /** Gets the list of sprites */
  11756. sprites: Sprite[];
  11757. /** Gets or sets the rendering group id (0 by default) */
  11758. renderingGroupId: number;
  11759. /** Gets or sets camera layer mask */
  11760. layerMask: number;
  11761. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11762. fogEnabled: boolean;
  11763. /** Gets or sets a boolean indicating if the sprites are pickable */
  11764. isPickable: boolean;
  11765. /** Defines the default width of a cell in the spritesheet */
  11766. cellWidth: number;
  11767. /** Defines the default height of a cell in the spritesheet */
  11768. cellHeight: number;
  11769. /** Associative array from JSON sprite data file */
  11770. private _cellData;
  11771. /** Array of sprite names from JSON sprite data file */
  11772. private _spriteMap;
  11773. /** True when packed cell data from JSON file is ready*/
  11774. private _packedAndReady;
  11775. /**
  11776. * An event triggered when the manager is disposed.
  11777. */
  11778. onDisposeObservable: Observable<SpriteManager>;
  11779. private _onDisposeObserver;
  11780. /**
  11781. * Callback called when the manager is disposed
  11782. */
  11783. onDispose: () => void;
  11784. private _capacity;
  11785. private _fromPacked;
  11786. private _spriteTexture;
  11787. private _epsilon;
  11788. private _scene;
  11789. private _vertexData;
  11790. private _buffer;
  11791. private _vertexBuffers;
  11792. private _indexBuffer;
  11793. private _effectBase;
  11794. private _effectFog;
  11795. /**
  11796. * Gets or sets the spritesheet texture
  11797. */
  11798. texture: Texture;
  11799. /**
  11800. * Creates a new sprite manager
  11801. * @param name defines the manager's name
  11802. * @param imgUrl defines the sprite sheet url
  11803. * @param capacity defines the maximum allowed number of sprites
  11804. * @param cellSize defines the size of a sprite cell
  11805. * @param scene defines the hosting scene
  11806. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11807. * @param samplingMode defines the smapling mode to use with spritesheet
  11808. * @param fromPacked set to false; do not alter
  11809. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11810. */
  11811. constructor(
  11812. /** defines the manager's name */
  11813. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11814. private _makePacked;
  11815. private _appendSpriteVertex;
  11816. /**
  11817. * Intersects the sprites with a ray
  11818. * @param ray defines the ray to intersect with
  11819. * @param camera defines the current active camera
  11820. * @param predicate defines a predicate used to select candidate sprites
  11821. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11822. * @returns null if no hit or a PickingInfo
  11823. */
  11824. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11825. /**
  11826. * Intersects the sprites with a ray
  11827. * @param ray defines the ray to intersect with
  11828. * @param camera defines the current active camera
  11829. * @param predicate defines a predicate used to select candidate sprites
  11830. * @returns null if no hit or a PickingInfo array
  11831. */
  11832. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11833. /**
  11834. * Render all child sprites
  11835. */
  11836. render(): void;
  11837. /**
  11838. * Release associated resources
  11839. */
  11840. dispose(): void;
  11841. }
  11842. }
  11843. declare module "babylonjs/Sprites/sprite" {
  11844. import { Vector3 } from "babylonjs/Maths/math.vector";
  11845. import { Nullable } from "babylonjs/types";
  11846. import { ActionManager } from "babylonjs/Actions/actionManager";
  11847. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11848. import { Color4 } from "babylonjs/Maths/math.color";
  11849. /**
  11850. * Class used to represent a sprite
  11851. * @see http://doc.babylonjs.com/babylon101/sprites
  11852. */
  11853. export class Sprite {
  11854. /** defines the name */
  11855. name: string;
  11856. /** Gets or sets the current world position */
  11857. position: Vector3;
  11858. /** Gets or sets the main color */
  11859. color: Color4;
  11860. /** Gets or sets the width */
  11861. width: number;
  11862. /** Gets or sets the height */
  11863. height: number;
  11864. /** Gets or sets rotation angle */
  11865. angle: number;
  11866. /** Gets or sets the cell index in the sprite sheet */
  11867. cellIndex: number;
  11868. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11869. cellRef: string;
  11870. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11871. invertU: number;
  11872. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11873. invertV: number;
  11874. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11875. disposeWhenFinishedAnimating: boolean;
  11876. /** Gets the list of attached animations */
  11877. animations: Animation[];
  11878. /** Gets or sets a boolean indicating if the sprite can be picked */
  11879. isPickable: boolean;
  11880. /**
  11881. * Gets or sets the associated action manager
  11882. */
  11883. actionManager: Nullable<ActionManager>;
  11884. private _animationStarted;
  11885. private _loopAnimation;
  11886. private _fromIndex;
  11887. private _toIndex;
  11888. private _delay;
  11889. private _direction;
  11890. private _manager;
  11891. private _time;
  11892. private _onAnimationEnd;
  11893. /**
  11894. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11895. */
  11896. isVisible: boolean;
  11897. /**
  11898. * Gets or sets the sprite size
  11899. */
  11900. size: number;
  11901. /**
  11902. * Creates a new Sprite
  11903. * @param name defines the name
  11904. * @param manager defines the manager
  11905. */
  11906. constructor(
  11907. /** defines the name */
  11908. name: string, manager: ISpriteManager);
  11909. /**
  11910. * Starts an animation
  11911. * @param from defines the initial key
  11912. * @param to defines the end key
  11913. * @param loop defines if the animation must loop
  11914. * @param delay defines the start delay (in ms)
  11915. * @param onAnimationEnd defines a callback to call when animation ends
  11916. */
  11917. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11918. /** Stops current animation (if any) */
  11919. stopAnimation(): void;
  11920. /** @hidden */
  11921. _animate(deltaTime: number): void;
  11922. /** Release associated resources */
  11923. dispose(): void;
  11924. }
  11925. }
  11926. declare module "babylonjs/Collisions/pickingInfo" {
  11927. import { Nullable } from "babylonjs/types";
  11928. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11930. import { Sprite } from "babylonjs/Sprites/sprite";
  11931. import { Ray } from "babylonjs/Culling/ray";
  11932. /**
  11933. * Information about the result of picking within a scene
  11934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11935. */
  11936. export class PickingInfo {
  11937. /** @hidden */
  11938. _pickingUnavailable: boolean;
  11939. /**
  11940. * If the pick collided with an object
  11941. */
  11942. hit: boolean;
  11943. /**
  11944. * Distance away where the pick collided
  11945. */
  11946. distance: number;
  11947. /**
  11948. * The location of pick collision
  11949. */
  11950. pickedPoint: Nullable<Vector3>;
  11951. /**
  11952. * The mesh corresponding the the pick collision
  11953. */
  11954. pickedMesh: Nullable<AbstractMesh>;
  11955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11956. bu: number;
  11957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11958. bv: number;
  11959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11960. faceId: number;
  11961. /** Id of the the submesh that was picked */
  11962. subMeshId: number;
  11963. /** If a sprite was picked, this will be the sprite the pick collided with */
  11964. pickedSprite: Nullable<Sprite>;
  11965. /**
  11966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11967. */
  11968. originMesh: Nullable<AbstractMesh>;
  11969. /**
  11970. * The ray that was used to perform the picking.
  11971. */
  11972. ray: Nullable<Ray>;
  11973. /**
  11974. * Gets the normal correspodning to the face the pick collided with
  11975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11977. * @returns The normal correspodning to the face the pick collided with
  11978. */
  11979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11980. /**
  11981. * Gets the texture coordinates of where the pick occured
  11982. * @returns the vector containing the coordnates of the texture
  11983. */
  11984. getTextureCoordinates(): Nullable<Vector2>;
  11985. }
  11986. }
  11987. declare module "babylonjs/Events/pointerEvents" {
  11988. import { Nullable } from "babylonjs/types";
  11989. import { Vector2 } from "babylonjs/Maths/math.vector";
  11990. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11991. import { Ray } from "babylonjs/Culling/ray";
  11992. /**
  11993. * Gather the list of pointer event types as constants.
  11994. */
  11995. export class PointerEventTypes {
  11996. /**
  11997. * 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.
  11998. */
  11999. static readonly POINTERDOWN: number;
  12000. /**
  12001. * The pointerup event is fired when a pointer is no longer active.
  12002. */
  12003. static readonly POINTERUP: number;
  12004. /**
  12005. * The pointermove event is fired when a pointer changes coordinates.
  12006. */
  12007. static readonly POINTERMOVE: number;
  12008. /**
  12009. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12010. */
  12011. static readonly POINTERWHEEL: number;
  12012. /**
  12013. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12014. */
  12015. static readonly POINTERPICK: number;
  12016. /**
  12017. * The pointertap event is fired when a the object has been touched and released without drag.
  12018. */
  12019. static readonly POINTERTAP: number;
  12020. /**
  12021. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12022. */
  12023. static readonly POINTERDOUBLETAP: number;
  12024. }
  12025. /**
  12026. * Base class of pointer info types.
  12027. */
  12028. export class PointerInfoBase {
  12029. /**
  12030. * Defines the type of event (PointerEventTypes)
  12031. */
  12032. type: number;
  12033. /**
  12034. * Defines the related dom event
  12035. */
  12036. event: PointerEvent | MouseWheelEvent;
  12037. /**
  12038. * Instantiates the base class of pointers info.
  12039. * @param type Defines the type of event (PointerEventTypes)
  12040. * @param event Defines the related dom event
  12041. */
  12042. constructor(
  12043. /**
  12044. * Defines the type of event (PointerEventTypes)
  12045. */
  12046. type: number,
  12047. /**
  12048. * Defines the related dom event
  12049. */
  12050. event: PointerEvent | MouseWheelEvent);
  12051. }
  12052. /**
  12053. * This class is used to store pointer related info for the onPrePointerObservable event.
  12054. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12055. */
  12056. export class PointerInfoPre extends PointerInfoBase {
  12057. /**
  12058. * Ray from a pointer if availible (eg. 6dof controller)
  12059. */
  12060. ray: Nullable<Ray>;
  12061. /**
  12062. * Defines the local position of the pointer on the canvas.
  12063. */
  12064. localPosition: Vector2;
  12065. /**
  12066. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12067. */
  12068. skipOnPointerObservable: boolean;
  12069. /**
  12070. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12071. * @param type Defines the type of event (PointerEventTypes)
  12072. * @param event Defines the related dom event
  12073. * @param localX Defines the local x coordinates of the pointer when the event occured
  12074. * @param localY Defines the local y coordinates of the pointer when the event occured
  12075. */
  12076. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12077. }
  12078. /**
  12079. * This type contains all the data related to a pointer event in Babylon.js.
  12080. * 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.
  12081. */
  12082. export class PointerInfo extends PointerInfoBase {
  12083. /**
  12084. * Defines the picking info associated to the info (if any)\
  12085. */
  12086. pickInfo: Nullable<PickingInfo>;
  12087. /**
  12088. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12089. * @param type Defines the type of event (PointerEventTypes)
  12090. * @param event Defines the related dom event
  12091. * @param pickInfo Defines the picking info associated to the info (if any)\
  12092. */
  12093. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12094. /**
  12095. * Defines the picking info associated to the info (if any)\
  12096. */
  12097. pickInfo: Nullable<PickingInfo>);
  12098. }
  12099. /**
  12100. * Data relating to a touch event on the screen.
  12101. */
  12102. export interface PointerTouch {
  12103. /**
  12104. * X coordinate of touch.
  12105. */
  12106. x: number;
  12107. /**
  12108. * Y coordinate of touch.
  12109. */
  12110. y: number;
  12111. /**
  12112. * Id of touch. Unique for each finger.
  12113. */
  12114. pointerId: number;
  12115. /**
  12116. * Event type passed from DOM.
  12117. */
  12118. type: any;
  12119. }
  12120. }
  12121. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12122. import { Observable } from "babylonjs/Misc/observable";
  12123. import { Nullable } from "babylonjs/types";
  12124. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12126. /**
  12127. * Manage the mouse inputs to control the movement of a free camera.
  12128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12129. */
  12130. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12131. /**
  12132. * Define if touch is enabled in the mouse input
  12133. */
  12134. touchEnabled: boolean;
  12135. /**
  12136. * Defines the camera the input is attached to.
  12137. */
  12138. camera: FreeCamera;
  12139. /**
  12140. * Defines the buttons associated with the input to handle camera move.
  12141. */
  12142. buttons: number[];
  12143. /**
  12144. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12145. */
  12146. angularSensibility: number;
  12147. private _pointerInput;
  12148. private _onMouseMove;
  12149. private _observer;
  12150. private previousPosition;
  12151. /**
  12152. * Observable for when a pointer move event occurs containing the move offset
  12153. */
  12154. onPointerMovedObservable: Observable<{
  12155. offsetX: number;
  12156. offsetY: number;
  12157. }>;
  12158. /**
  12159. * @hidden
  12160. * If the camera should be rotated automatically based on pointer movement
  12161. */
  12162. _allowCameraRotation: boolean;
  12163. /**
  12164. * Manage the mouse inputs to control the movement of a free camera.
  12165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12166. * @param touchEnabled Defines if touch is enabled or not
  12167. */
  12168. constructor(
  12169. /**
  12170. * Define if touch is enabled in the mouse input
  12171. */
  12172. touchEnabled?: boolean);
  12173. /**
  12174. * Attach the input controls to a specific dom element to get the input from.
  12175. * @param element Defines the element the controls should be listened from
  12176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12177. */
  12178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12179. /**
  12180. * Called on JS contextmenu event.
  12181. * Override this method to provide functionality.
  12182. */
  12183. protected onContextMenu(evt: PointerEvent): void;
  12184. /**
  12185. * Detach the current controls from the specified dom element.
  12186. * @param element Defines the element to stop listening the inputs from
  12187. */
  12188. detachControl(element: Nullable<HTMLElement>): void;
  12189. /**
  12190. * Gets the class name of the current intput.
  12191. * @returns the class name
  12192. */
  12193. getClassName(): string;
  12194. /**
  12195. * Get the friendly name associated with the input class.
  12196. * @returns the input friendly name
  12197. */
  12198. getSimpleName(): string;
  12199. }
  12200. }
  12201. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12202. import { Nullable } from "babylonjs/types";
  12203. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12204. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12205. /**
  12206. * Manage the touch inputs to control the movement of a free camera.
  12207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12208. */
  12209. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12210. /**
  12211. * Defines the camera the input is attached to.
  12212. */
  12213. camera: FreeCamera;
  12214. /**
  12215. * Defines the touch sensibility for rotation.
  12216. * The higher the faster.
  12217. */
  12218. touchAngularSensibility: number;
  12219. /**
  12220. * Defines the touch sensibility for move.
  12221. * The higher the faster.
  12222. */
  12223. touchMoveSensibility: number;
  12224. private _offsetX;
  12225. private _offsetY;
  12226. private _pointerPressed;
  12227. private _pointerInput;
  12228. private _observer;
  12229. private _onLostFocus;
  12230. /**
  12231. * Attach the input controls to a specific dom element to get the input from.
  12232. * @param element Defines the element the controls should be listened from
  12233. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12234. */
  12235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12236. /**
  12237. * Detach the current controls from the specified dom element.
  12238. * @param element Defines the element to stop listening the inputs from
  12239. */
  12240. detachControl(element: Nullable<HTMLElement>): void;
  12241. /**
  12242. * Update the current camera state depending on the inputs that have been used this frame.
  12243. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12244. */
  12245. checkInputs(): void;
  12246. /**
  12247. * Gets the class name of the current intput.
  12248. * @returns the class name
  12249. */
  12250. getClassName(): string;
  12251. /**
  12252. * Get the friendly name associated with the input class.
  12253. * @returns the input friendly name
  12254. */
  12255. getSimpleName(): string;
  12256. }
  12257. }
  12258. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12259. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12260. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12261. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12262. import { Nullable } from "babylonjs/types";
  12263. /**
  12264. * Default Inputs manager for the FreeCamera.
  12265. * It groups all the default supported inputs for ease of use.
  12266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12267. */
  12268. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12269. /**
  12270. * @hidden
  12271. */
  12272. _mouseInput: Nullable<FreeCameraMouseInput>;
  12273. /**
  12274. * Instantiates a new FreeCameraInputsManager.
  12275. * @param camera Defines the camera the inputs belong to
  12276. */
  12277. constructor(camera: FreeCamera);
  12278. /**
  12279. * Add keyboard input support to the input manager.
  12280. * @returns the current input manager
  12281. */
  12282. addKeyboard(): FreeCameraInputsManager;
  12283. /**
  12284. * Add mouse input support to the input manager.
  12285. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12286. * @returns the current input manager
  12287. */
  12288. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12289. /**
  12290. * Removes the mouse input support from the manager
  12291. * @returns the current input manager
  12292. */
  12293. removeMouse(): FreeCameraInputsManager;
  12294. /**
  12295. * Add touch input support to the input manager.
  12296. * @returns the current input manager
  12297. */
  12298. addTouch(): FreeCameraInputsManager;
  12299. /**
  12300. * Remove all attached input methods from a camera
  12301. */
  12302. clear(): void;
  12303. }
  12304. }
  12305. declare module "babylonjs/Cameras/freeCamera" {
  12306. import { Vector3 } from "babylonjs/Maths/math.vector";
  12307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12308. import { Scene } from "babylonjs/scene";
  12309. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12310. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12311. /**
  12312. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12313. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12315. */
  12316. export class FreeCamera extends TargetCamera {
  12317. /**
  12318. * Define the collision ellipsoid of the camera.
  12319. * This is helpful to simulate a camera body like the player body around the camera
  12320. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12321. */
  12322. ellipsoid: Vector3;
  12323. /**
  12324. * Define an offset for the position of the ellipsoid around the camera.
  12325. * This can be helpful to determine the center of the body near the gravity center of the body
  12326. * instead of its head.
  12327. */
  12328. ellipsoidOffset: Vector3;
  12329. /**
  12330. * Enable or disable collisions of the camera with the rest of the scene objects.
  12331. */
  12332. checkCollisions: boolean;
  12333. /**
  12334. * Enable or disable gravity on the camera.
  12335. */
  12336. applyGravity: boolean;
  12337. /**
  12338. * Define the input manager associated to the camera.
  12339. */
  12340. inputs: FreeCameraInputsManager;
  12341. /**
  12342. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12343. * Higher values reduce sensitivity.
  12344. */
  12345. /**
  12346. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12347. * Higher values reduce sensitivity.
  12348. */
  12349. angularSensibility: number;
  12350. /**
  12351. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12352. */
  12353. keysUp: number[];
  12354. /**
  12355. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12356. */
  12357. keysDown: number[];
  12358. /**
  12359. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12360. */
  12361. keysLeft: number[];
  12362. /**
  12363. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12364. */
  12365. keysRight: number[];
  12366. /**
  12367. * Event raised when the camera collide with a mesh in the scene.
  12368. */
  12369. onCollide: (collidedMesh: AbstractMesh) => void;
  12370. private _collider;
  12371. private _needMoveForGravity;
  12372. private _oldPosition;
  12373. private _diffPosition;
  12374. private _newPosition;
  12375. /** @hidden */
  12376. _localDirection: Vector3;
  12377. /** @hidden */
  12378. _transformedDirection: Vector3;
  12379. /**
  12380. * Instantiates a Free Camera.
  12381. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12382. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12383. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12384. * @param name Define the name of the camera in the scene
  12385. * @param position Define the start position of the camera in the scene
  12386. * @param scene Define the scene the camera belongs to
  12387. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12388. */
  12389. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12390. /**
  12391. * Attached controls to the current camera.
  12392. * @param element Defines the element the controls should be listened from
  12393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12394. */
  12395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12396. /**
  12397. * Detach the current controls from the camera.
  12398. * The camera will stop reacting to inputs.
  12399. * @param element Defines the element to stop listening the inputs from
  12400. */
  12401. detachControl(element: HTMLElement): void;
  12402. private _collisionMask;
  12403. /**
  12404. * Define a collision mask to limit the list of object the camera can collide with
  12405. */
  12406. collisionMask: number;
  12407. /** @hidden */
  12408. _collideWithWorld(displacement: Vector3): void;
  12409. private _onCollisionPositionChange;
  12410. /** @hidden */
  12411. _checkInputs(): void;
  12412. /** @hidden */
  12413. _decideIfNeedsToMove(): boolean;
  12414. /** @hidden */
  12415. _updatePosition(): void;
  12416. /**
  12417. * Destroy the camera and release the current resources hold by it.
  12418. */
  12419. dispose(): void;
  12420. /**
  12421. * Gets the current object class name.
  12422. * @return the class name
  12423. */
  12424. getClassName(): string;
  12425. }
  12426. }
  12427. declare module "babylonjs/Gamepads/gamepad" {
  12428. import { Observable } from "babylonjs/Misc/observable";
  12429. /**
  12430. * Represents a gamepad control stick position
  12431. */
  12432. export class StickValues {
  12433. /**
  12434. * The x component of the control stick
  12435. */
  12436. x: number;
  12437. /**
  12438. * The y component of the control stick
  12439. */
  12440. y: number;
  12441. /**
  12442. * Initializes the gamepad x and y control stick values
  12443. * @param x The x component of the gamepad control stick value
  12444. * @param y The y component of the gamepad control stick value
  12445. */
  12446. constructor(
  12447. /**
  12448. * The x component of the control stick
  12449. */
  12450. x: number,
  12451. /**
  12452. * The y component of the control stick
  12453. */
  12454. y: number);
  12455. }
  12456. /**
  12457. * An interface which manages callbacks for gamepad button changes
  12458. */
  12459. export interface GamepadButtonChanges {
  12460. /**
  12461. * Called when a gamepad has been changed
  12462. */
  12463. changed: boolean;
  12464. /**
  12465. * Called when a gamepad press event has been triggered
  12466. */
  12467. pressChanged: boolean;
  12468. /**
  12469. * Called when a touch event has been triggered
  12470. */
  12471. touchChanged: boolean;
  12472. /**
  12473. * Called when a value has changed
  12474. */
  12475. valueChanged: boolean;
  12476. }
  12477. /**
  12478. * Represents a gamepad
  12479. */
  12480. export class Gamepad {
  12481. /**
  12482. * The id of the gamepad
  12483. */
  12484. id: string;
  12485. /**
  12486. * The index of the gamepad
  12487. */
  12488. index: number;
  12489. /**
  12490. * The browser gamepad
  12491. */
  12492. browserGamepad: any;
  12493. /**
  12494. * Specifies what type of gamepad this represents
  12495. */
  12496. type: number;
  12497. private _leftStick;
  12498. private _rightStick;
  12499. /** @hidden */
  12500. _isConnected: boolean;
  12501. private _leftStickAxisX;
  12502. private _leftStickAxisY;
  12503. private _rightStickAxisX;
  12504. private _rightStickAxisY;
  12505. /**
  12506. * Triggered when the left control stick has been changed
  12507. */
  12508. private _onleftstickchanged;
  12509. /**
  12510. * Triggered when the right control stick has been changed
  12511. */
  12512. private _onrightstickchanged;
  12513. /**
  12514. * Represents a gamepad controller
  12515. */
  12516. static GAMEPAD: number;
  12517. /**
  12518. * Represents a generic controller
  12519. */
  12520. static GENERIC: number;
  12521. /**
  12522. * Represents an XBox controller
  12523. */
  12524. static XBOX: number;
  12525. /**
  12526. * Represents a pose-enabled controller
  12527. */
  12528. static POSE_ENABLED: number;
  12529. /**
  12530. * Represents an Dual Shock controller
  12531. */
  12532. static DUALSHOCK: number;
  12533. /**
  12534. * Specifies whether the left control stick should be Y-inverted
  12535. */
  12536. protected _invertLeftStickY: boolean;
  12537. /**
  12538. * Specifies if the gamepad has been connected
  12539. */
  12540. readonly isConnected: boolean;
  12541. /**
  12542. * Initializes the gamepad
  12543. * @param id The id of the gamepad
  12544. * @param index The index of the gamepad
  12545. * @param browserGamepad The browser gamepad
  12546. * @param leftStickX The x component of the left joystick
  12547. * @param leftStickY The y component of the left joystick
  12548. * @param rightStickX The x component of the right joystick
  12549. * @param rightStickY The y component of the right joystick
  12550. */
  12551. constructor(
  12552. /**
  12553. * The id of the gamepad
  12554. */
  12555. id: string,
  12556. /**
  12557. * The index of the gamepad
  12558. */
  12559. index: number,
  12560. /**
  12561. * The browser gamepad
  12562. */
  12563. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12564. /**
  12565. * Callback triggered when the left joystick has changed
  12566. * @param callback
  12567. */
  12568. onleftstickchanged(callback: (values: StickValues) => void): void;
  12569. /**
  12570. * Callback triggered when the right joystick has changed
  12571. * @param callback
  12572. */
  12573. onrightstickchanged(callback: (values: StickValues) => void): void;
  12574. /**
  12575. * Gets the left joystick
  12576. */
  12577. /**
  12578. * Sets the left joystick values
  12579. */
  12580. leftStick: StickValues;
  12581. /**
  12582. * Gets the right joystick
  12583. */
  12584. /**
  12585. * Sets the right joystick value
  12586. */
  12587. rightStick: StickValues;
  12588. /**
  12589. * Updates the gamepad joystick positions
  12590. */
  12591. update(): void;
  12592. /**
  12593. * Disposes the gamepad
  12594. */
  12595. dispose(): void;
  12596. }
  12597. /**
  12598. * Represents a generic gamepad
  12599. */
  12600. export class GenericPad extends Gamepad {
  12601. private _buttons;
  12602. private _onbuttondown;
  12603. private _onbuttonup;
  12604. /**
  12605. * Observable triggered when a button has been pressed
  12606. */
  12607. onButtonDownObservable: Observable<number>;
  12608. /**
  12609. * Observable triggered when a button has been released
  12610. */
  12611. onButtonUpObservable: Observable<number>;
  12612. /**
  12613. * Callback triggered when a button has been pressed
  12614. * @param callback Called when a button has been pressed
  12615. */
  12616. onbuttondown(callback: (buttonPressed: number) => void): void;
  12617. /**
  12618. * Callback triggered when a button has been released
  12619. * @param callback Called when a button has been released
  12620. */
  12621. onbuttonup(callback: (buttonReleased: number) => void): void;
  12622. /**
  12623. * Initializes the generic gamepad
  12624. * @param id The id of the generic gamepad
  12625. * @param index The index of the generic gamepad
  12626. * @param browserGamepad The browser gamepad
  12627. */
  12628. constructor(id: string, index: number, browserGamepad: any);
  12629. private _setButtonValue;
  12630. /**
  12631. * Updates the generic gamepad
  12632. */
  12633. update(): void;
  12634. /**
  12635. * Disposes the generic gamepad
  12636. */
  12637. dispose(): void;
  12638. }
  12639. }
  12640. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12641. import { Nullable } from "babylonjs/types";
  12642. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12643. import { Scene } from "babylonjs/scene";
  12644. module "babylonjs/Engines/engine" {
  12645. interface Engine {
  12646. /**
  12647. * Creates a raw texture
  12648. * @param data defines the data to store in the texture
  12649. * @param width defines the width of the texture
  12650. * @param height defines the height of the texture
  12651. * @param format defines the format of the data
  12652. * @param generateMipMaps defines if the engine should generate the mip levels
  12653. * @param invertY defines if data must be stored with Y axis inverted
  12654. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12655. * @param compression defines the compression used (null by default)
  12656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12657. * @returns the raw texture inside an InternalTexture
  12658. */
  12659. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12660. /**
  12661. * Update a raw texture
  12662. * @param texture defines the texture to update
  12663. * @param data defines the data to store in the texture
  12664. * @param format defines the format of the data
  12665. * @param invertY defines if data must be stored with Y axis inverted
  12666. */
  12667. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12668. /**
  12669. * Update a raw texture
  12670. * @param texture defines the texture to update
  12671. * @param data defines the data to store in the texture
  12672. * @param format defines the format of the data
  12673. * @param invertY defines if data must be stored with Y axis inverted
  12674. * @param compression defines the compression used (null by default)
  12675. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12676. */
  12677. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12678. /**
  12679. * Creates a new raw cube texture
  12680. * @param data defines the array of data to use to create each face
  12681. * @param size defines the size of the textures
  12682. * @param format defines the format of the data
  12683. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12684. * @param generateMipMaps defines if the engine should generate the mip levels
  12685. * @param invertY defines if data must be stored with Y axis inverted
  12686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12687. * @param compression defines the compression used (null by default)
  12688. * @returns the cube texture as an InternalTexture
  12689. */
  12690. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12691. /**
  12692. * Update a raw cube texture
  12693. * @param texture defines the texture to udpdate
  12694. * @param data defines the data to store
  12695. * @param format defines the data format
  12696. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12697. * @param invertY defines if data must be stored with Y axis inverted
  12698. */
  12699. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12700. /**
  12701. * Update a raw cube texture
  12702. * @param texture defines the texture to udpdate
  12703. * @param data defines the data to store
  12704. * @param format defines the data format
  12705. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12706. * @param invertY defines if data must be stored with Y axis inverted
  12707. * @param compression defines the compression used (null by default)
  12708. */
  12709. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12710. /**
  12711. * Update a raw cube texture
  12712. * @param texture defines the texture to udpdate
  12713. * @param data defines the data to store
  12714. * @param format defines the data format
  12715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12716. * @param invertY defines if data must be stored with Y axis inverted
  12717. * @param compression defines the compression used (null by default)
  12718. * @param level defines which level of the texture to update
  12719. */
  12720. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12721. /**
  12722. * Creates a new raw cube texture from a specified url
  12723. * @param url defines the url where the data is located
  12724. * @param scene defines the current scene
  12725. * @param size defines the size of the textures
  12726. * @param format defines the format of the data
  12727. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12728. * @param noMipmap defines if the engine should avoid generating the mip levels
  12729. * @param callback defines a callback used to extract texture data from loaded data
  12730. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12731. * @param onLoad defines a callback called when texture is loaded
  12732. * @param onError defines a callback called if there is an error
  12733. * @returns the cube texture as an InternalTexture
  12734. */
  12735. 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;
  12736. /**
  12737. * Creates a new raw cube texture from a specified url
  12738. * @param url defines the url where the data is located
  12739. * @param scene defines the current scene
  12740. * @param size defines the size of the textures
  12741. * @param format defines the format of the data
  12742. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12743. * @param noMipmap defines if the engine should avoid generating the mip levels
  12744. * @param callback defines a callback used to extract texture data from loaded data
  12745. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12746. * @param onLoad defines a callback called when texture is loaded
  12747. * @param onError defines a callback called if there is an error
  12748. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12749. * @param invertY defines if data must be stored with Y axis inverted
  12750. * @returns the cube texture as an InternalTexture
  12751. */
  12752. 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;
  12753. /**
  12754. * Creates a new raw 3D texture
  12755. * @param data defines the data used to create the texture
  12756. * @param width defines the width of the texture
  12757. * @param height defines the height of the texture
  12758. * @param depth defines the depth of the texture
  12759. * @param format defines the format of the texture
  12760. * @param generateMipMaps defines if the engine must generate mip levels
  12761. * @param invertY defines if data must be stored with Y axis inverted
  12762. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12763. * @param compression defines the compressed used (can be null)
  12764. * @param textureType defines the compressed used (can be null)
  12765. * @returns a new raw 3D texture (stored in an InternalTexture)
  12766. */
  12767. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12768. /**
  12769. * Update a raw 3D texture
  12770. * @param texture defines the texture to update
  12771. * @param data defines the data to store
  12772. * @param format defines the data format
  12773. * @param invertY defines if data must be stored with Y axis inverted
  12774. */
  12775. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12776. /**
  12777. * Update a raw 3D texture
  12778. * @param texture defines the texture to update
  12779. * @param data defines the data to store
  12780. * @param format defines the data format
  12781. * @param invertY defines if data must be stored with Y axis inverted
  12782. * @param compression defines the used compression (can be null)
  12783. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12784. */
  12785. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12786. }
  12787. }
  12788. }
  12789. declare module "babylonjs/Materials/Textures/rawTexture" {
  12790. import { Scene } from "babylonjs/scene";
  12791. import { Texture } from "babylonjs/Materials/Textures/texture";
  12792. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12793. /**
  12794. * Raw texture can help creating a texture directly from an array of data.
  12795. * This can be super useful if you either get the data from an uncompressed source or
  12796. * if you wish to create your texture pixel by pixel.
  12797. */
  12798. export class RawTexture extends Texture {
  12799. /**
  12800. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12801. */
  12802. format: number;
  12803. private _engine;
  12804. /**
  12805. * Instantiates a new RawTexture.
  12806. * Raw texture can help creating a texture directly from an array of data.
  12807. * This can be super useful if you either get the data from an uncompressed source or
  12808. * if you wish to create your texture pixel by pixel.
  12809. * @param data define the array of data to use to create the texture
  12810. * @param width define the width of the texture
  12811. * @param height define the height of the texture
  12812. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12813. * @param scene define the scene the texture belongs to
  12814. * @param generateMipMaps define whether mip maps should be generated or not
  12815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12817. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12818. */
  12819. constructor(data: ArrayBufferView, width: number, height: number,
  12820. /**
  12821. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12822. */
  12823. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12824. /**
  12825. * Updates the texture underlying data.
  12826. * @param data Define the new data of the texture
  12827. */
  12828. update(data: ArrayBufferView): void;
  12829. /**
  12830. * Creates a luminance texture from some data.
  12831. * @param data Define the texture data
  12832. * @param width Define the width of the texture
  12833. * @param height Define the height of the texture
  12834. * @param scene Define the scene the texture belongs to
  12835. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12836. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12837. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12838. * @returns the luminance texture
  12839. */
  12840. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12841. /**
  12842. * Creates a luminance alpha texture from some data.
  12843. * @param data Define the texture data
  12844. * @param width Define the width of the texture
  12845. * @param height Define the height of the texture
  12846. * @param scene Define the scene the texture belongs to
  12847. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12848. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12849. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12850. * @returns the luminance alpha texture
  12851. */
  12852. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12853. /**
  12854. * Creates an alpha texture from some data.
  12855. * @param data Define the texture data
  12856. * @param width Define the width of the texture
  12857. * @param height Define the height of the texture
  12858. * @param scene Define the scene the texture belongs to
  12859. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12860. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12861. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12862. * @returns the alpha texture
  12863. */
  12864. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12865. /**
  12866. * Creates a RGB texture from some data.
  12867. * @param data Define the texture data
  12868. * @param width Define the width of the texture
  12869. * @param height Define the height of the texture
  12870. * @param scene Define the scene the texture belongs to
  12871. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12872. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12873. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12874. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12875. * @returns the RGB alpha texture
  12876. */
  12877. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12878. /**
  12879. * Creates a RGBA texture from some data.
  12880. * @param data Define the texture data
  12881. * @param width Define the width of the texture
  12882. * @param height Define the height of the texture
  12883. * @param scene Define the scene the texture belongs to
  12884. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12885. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12886. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12887. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12888. * @returns the RGBA texture
  12889. */
  12890. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12891. /**
  12892. * Creates a R texture from some data.
  12893. * @param data Define the texture data
  12894. * @param width Define the width of the texture
  12895. * @param height Define the height of the texture
  12896. * @param scene Define the scene the texture belongs to
  12897. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12898. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12899. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12900. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12901. * @returns the R texture
  12902. */
  12903. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12904. }
  12905. }
  12906. declare module "babylonjs/Maths/math.size" {
  12907. /**
  12908. * Interface for the size containing width and height
  12909. */
  12910. export interface ISize {
  12911. /**
  12912. * Width
  12913. */
  12914. width: number;
  12915. /**
  12916. * Heighht
  12917. */
  12918. height: number;
  12919. }
  12920. /**
  12921. * Size containing widht and height
  12922. */
  12923. export class Size implements ISize {
  12924. /**
  12925. * Width
  12926. */
  12927. width: number;
  12928. /**
  12929. * Height
  12930. */
  12931. height: number;
  12932. /**
  12933. * Creates a Size object from the given width and height (floats).
  12934. * @param width width of the new size
  12935. * @param height height of the new size
  12936. */
  12937. constructor(width: number, height: number);
  12938. /**
  12939. * Returns a string with the Size width and height
  12940. * @returns a string with the Size width and height
  12941. */
  12942. toString(): string;
  12943. /**
  12944. * "Size"
  12945. * @returns the string "Size"
  12946. */
  12947. getClassName(): string;
  12948. /**
  12949. * Returns the Size hash code.
  12950. * @returns a hash code for a unique width and height
  12951. */
  12952. getHashCode(): number;
  12953. /**
  12954. * Updates the current size from the given one.
  12955. * @param src the given size
  12956. */
  12957. copyFrom(src: Size): void;
  12958. /**
  12959. * Updates in place the current Size from the given floats.
  12960. * @param width width of the new size
  12961. * @param height height of the new size
  12962. * @returns the updated Size.
  12963. */
  12964. copyFromFloats(width: number, height: number): Size;
  12965. /**
  12966. * Updates in place the current Size from the given floats.
  12967. * @param width width to set
  12968. * @param height height to set
  12969. * @returns the updated Size.
  12970. */
  12971. set(width: number, height: number): Size;
  12972. /**
  12973. * Multiplies the width and height by numbers
  12974. * @param w factor to multiple the width by
  12975. * @param h factor to multiple the height by
  12976. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12977. */
  12978. multiplyByFloats(w: number, h: number): Size;
  12979. /**
  12980. * Clones the size
  12981. * @returns a new Size copied from the given one.
  12982. */
  12983. clone(): Size;
  12984. /**
  12985. * True if the current Size and the given one width and height are strictly equal.
  12986. * @param other the other size to compare against
  12987. * @returns True if the current Size and the given one width and height are strictly equal.
  12988. */
  12989. equals(other: Size): boolean;
  12990. /**
  12991. * The surface of the Size : width * height (float).
  12992. */
  12993. readonly surface: number;
  12994. /**
  12995. * Create a new size of zero
  12996. * @returns a new Size set to (0.0, 0.0)
  12997. */
  12998. static Zero(): Size;
  12999. /**
  13000. * Sums the width and height of two sizes
  13001. * @param otherSize size to add to this size
  13002. * @returns a new Size set as the addition result of the current Size and the given one.
  13003. */
  13004. add(otherSize: Size): Size;
  13005. /**
  13006. * Subtracts the width and height of two
  13007. * @param otherSize size to subtract to this size
  13008. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13009. */
  13010. subtract(otherSize: Size): Size;
  13011. /**
  13012. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13013. * @param start starting size to lerp between
  13014. * @param end end size to lerp between
  13015. * @param amount amount to lerp between the start and end values
  13016. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13017. */
  13018. static Lerp(start: Size, end: Size, amount: number): Size;
  13019. }
  13020. }
  13021. declare module "babylonjs/Animations/runtimeAnimation" {
  13022. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13023. import { Animatable } from "babylonjs/Animations/animatable";
  13024. import { Scene } from "babylonjs/scene";
  13025. /**
  13026. * Defines a runtime animation
  13027. */
  13028. export class RuntimeAnimation {
  13029. private _events;
  13030. /**
  13031. * The current frame of the runtime animation
  13032. */
  13033. private _currentFrame;
  13034. /**
  13035. * The animation used by the runtime animation
  13036. */
  13037. private _animation;
  13038. /**
  13039. * The target of the runtime animation
  13040. */
  13041. private _target;
  13042. /**
  13043. * The initiating animatable
  13044. */
  13045. private _host;
  13046. /**
  13047. * The original value of the runtime animation
  13048. */
  13049. private _originalValue;
  13050. /**
  13051. * The original blend value of the runtime animation
  13052. */
  13053. private _originalBlendValue;
  13054. /**
  13055. * The offsets cache of the runtime animation
  13056. */
  13057. private _offsetsCache;
  13058. /**
  13059. * The high limits cache of the runtime animation
  13060. */
  13061. private _highLimitsCache;
  13062. /**
  13063. * Specifies if the runtime animation has been stopped
  13064. */
  13065. private _stopped;
  13066. /**
  13067. * The blending factor of the runtime animation
  13068. */
  13069. private _blendingFactor;
  13070. /**
  13071. * The BabylonJS scene
  13072. */
  13073. private _scene;
  13074. /**
  13075. * The current value of the runtime animation
  13076. */
  13077. private _currentValue;
  13078. /** @hidden */
  13079. _animationState: _IAnimationState;
  13080. /**
  13081. * The active target of the runtime animation
  13082. */
  13083. private _activeTargets;
  13084. private _currentActiveTarget;
  13085. private _directTarget;
  13086. /**
  13087. * The target path of the runtime animation
  13088. */
  13089. private _targetPath;
  13090. /**
  13091. * The weight of the runtime animation
  13092. */
  13093. private _weight;
  13094. /**
  13095. * The ratio offset of the runtime animation
  13096. */
  13097. private _ratioOffset;
  13098. /**
  13099. * The previous delay of the runtime animation
  13100. */
  13101. private _previousDelay;
  13102. /**
  13103. * The previous ratio of the runtime animation
  13104. */
  13105. private _previousRatio;
  13106. private _enableBlending;
  13107. private _keys;
  13108. private _minFrame;
  13109. private _maxFrame;
  13110. private _minValue;
  13111. private _maxValue;
  13112. private _targetIsArray;
  13113. /**
  13114. * Gets the current frame of the runtime animation
  13115. */
  13116. readonly currentFrame: number;
  13117. /**
  13118. * Gets the weight of the runtime animation
  13119. */
  13120. readonly weight: number;
  13121. /**
  13122. * Gets the current value of the runtime animation
  13123. */
  13124. readonly currentValue: any;
  13125. /**
  13126. * Gets the target path of the runtime animation
  13127. */
  13128. readonly targetPath: string;
  13129. /**
  13130. * Gets the actual target of the runtime animation
  13131. */
  13132. readonly target: any;
  13133. /** @hidden */
  13134. _onLoop: () => void;
  13135. /**
  13136. * Create a new RuntimeAnimation object
  13137. * @param target defines the target of the animation
  13138. * @param animation defines the source animation object
  13139. * @param scene defines the hosting scene
  13140. * @param host defines the initiating Animatable
  13141. */
  13142. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13143. private _preparePath;
  13144. /**
  13145. * Gets the animation from the runtime animation
  13146. */
  13147. readonly animation: Animation;
  13148. /**
  13149. * Resets the runtime animation to the beginning
  13150. * @param restoreOriginal defines whether to restore the target property to the original value
  13151. */
  13152. reset(restoreOriginal?: boolean): void;
  13153. /**
  13154. * Specifies if the runtime animation is stopped
  13155. * @returns Boolean specifying if the runtime animation is stopped
  13156. */
  13157. isStopped(): boolean;
  13158. /**
  13159. * Disposes of the runtime animation
  13160. */
  13161. dispose(): void;
  13162. /**
  13163. * Apply the interpolated value to the target
  13164. * @param currentValue defines the value computed by the animation
  13165. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13166. */
  13167. setValue(currentValue: any, weight: number): void;
  13168. private _getOriginalValues;
  13169. private _setValue;
  13170. /**
  13171. * Gets the loop pmode of the runtime animation
  13172. * @returns Loop Mode
  13173. */
  13174. private _getCorrectLoopMode;
  13175. /**
  13176. * Move the current animation to a given frame
  13177. * @param frame defines the frame to move to
  13178. */
  13179. goToFrame(frame: number): void;
  13180. /**
  13181. * @hidden Internal use only
  13182. */
  13183. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13184. /**
  13185. * Execute the current animation
  13186. * @param delay defines the delay to add to the current frame
  13187. * @param from defines the lower bound of the animation range
  13188. * @param to defines the upper bound of the animation range
  13189. * @param loop defines if the current animation must loop
  13190. * @param speedRatio defines the current speed ratio
  13191. * @param weight defines the weight of the animation (default is -1 so no weight)
  13192. * @param onLoop optional callback called when animation loops
  13193. * @returns a boolean indicating if the animation is running
  13194. */
  13195. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13196. }
  13197. }
  13198. declare module "babylonjs/Animations/animatable" {
  13199. import { Animation } from "babylonjs/Animations/animation";
  13200. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13201. import { Nullable } from "babylonjs/types";
  13202. import { Observable } from "babylonjs/Misc/observable";
  13203. import { Scene } from "babylonjs/scene";
  13204. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13205. import { Node } from "babylonjs/node";
  13206. /**
  13207. * Class used to store an actual running animation
  13208. */
  13209. export class Animatable {
  13210. /** defines the target object */
  13211. target: any;
  13212. /** defines the starting frame number (default is 0) */
  13213. fromFrame: number;
  13214. /** defines the ending frame number (default is 100) */
  13215. toFrame: number;
  13216. /** defines if the animation must loop (default is false) */
  13217. loopAnimation: boolean;
  13218. /** defines a callback to call when animation ends if it is not looping */
  13219. onAnimationEnd?: (() => void) | null | undefined;
  13220. /** defines a callback to call when animation loops */
  13221. onAnimationLoop?: (() => void) | null | undefined;
  13222. private _localDelayOffset;
  13223. private _pausedDelay;
  13224. private _runtimeAnimations;
  13225. private _paused;
  13226. private _scene;
  13227. private _speedRatio;
  13228. private _weight;
  13229. private _syncRoot;
  13230. /**
  13231. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13232. * This will only apply for non looping animation (default is true)
  13233. */
  13234. disposeOnEnd: boolean;
  13235. /**
  13236. * Gets a boolean indicating if the animation has started
  13237. */
  13238. animationStarted: boolean;
  13239. /**
  13240. * Observer raised when the animation ends
  13241. */
  13242. onAnimationEndObservable: Observable<Animatable>;
  13243. /**
  13244. * Observer raised when the animation loops
  13245. */
  13246. onAnimationLoopObservable: Observable<Animatable>;
  13247. /**
  13248. * Gets the root Animatable used to synchronize and normalize animations
  13249. */
  13250. readonly syncRoot: Nullable<Animatable>;
  13251. /**
  13252. * Gets the current frame of the first RuntimeAnimation
  13253. * Used to synchronize Animatables
  13254. */
  13255. readonly masterFrame: number;
  13256. /**
  13257. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13258. */
  13259. weight: number;
  13260. /**
  13261. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13262. */
  13263. speedRatio: number;
  13264. /**
  13265. * Creates a new Animatable
  13266. * @param scene defines the hosting scene
  13267. * @param target defines the target object
  13268. * @param fromFrame defines the starting frame number (default is 0)
  13269. * @param toFrame defines the ending frame number (default is 100)
  13270. * @param loopAnimation defines if the animation must loop (default is false)
  13271. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13272. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13273. * @param animations defines a group of animation to add to the new Animatable
  13274. * @param onAnimationLoop defines a callback to call when animation loops
  13275. */
  13276. constructor(scene: Scene,
  13277. /** defines the target object */
  13278. target: any,
  13279. /** defines the starting frame number (default is 0) */
  13280. fromFrame?: number,
  13281. /** defines the ending frame number (default is 100) */
  13282. toFrame?: number,
  13283. /** defines if the animation must loop (default is false) */
  13284. loopAnimation?: boolean, speedRatio?: number,
  13285. /** defines a callback to call when animation ends if it is not looping */
  13286. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13287. /** defines a callback to call when animation loops */
  13288. onAnimationLoop?: (() => void) | null | undefined);
  13289. /**
  13290. * Synchronize and normalize current Animatable with a source Animatable
  13291. * This is useful when using animation weights and when animations are not of the same length
  13292. * @param root defines the root Animatable to synchronize with
  13293. * @returns the current Animatable
  13294. */
  13295. syncWith(root: Animatable): Animatable;
  13296. /**
  13297. * Gets the list of runtime animations
  13298. * @returns an array of RuntimeAnimation
  13299. */
  13300. getAnimations(): RuntimeAnimation[];
  13301. /**
  13302. * Adds more animations to the current animatable
  13303. * @param target defines the target of the animations
  13304. * @param animations defines the new animations to add
  13305. */
  13306. appendAnimations(target: any, animations: Animation[]): void;
  13307. /**
  13308. * Gets the source animation for a specific property
  13309. * @param property defines the propertyu to look for
  13310. * @returns null or the source animation for the given property
  13311. */
  13312. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13313. /**
  13314. * Gets the runtime animation for a specific property
  13315. * @param property defines the propertyu to look for
  13316. * @returns null or the runtime animation for the given property
  13317. */
  13318. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13319. /**
  13320. * Resets the animatable to its original state
  13321. */
  13322. reset(): void;
  13323. /**
  13324. * Allows the animatable to blend with current running animations
  13325. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13326. * @param blendingSpeed defines the blending speed to use
  13327. */
  13328. enableBlending(blendingSpeed: number): void;
  13329. /**
  13330. * Disable animation blending
  13331. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13332. */
  13333. disableBlending(): void;
  13334. /**
  13335. * Jump directly to a given frame
  13336. * @param frame defines the frame to jump to
  13337. */
  13338. goToFrame(frame: number): void;
  13339. /**
  13340. * Pause the animation
  13341. */
  13342. pause(): void;
  13343. /**
  13344. * Restart the animation
  13345. */
  13346. restart(): void;
  13347. private _raiseOnAnimationEnd;
  13348. /**
  13349. * Stop and delete the current animation
  13350. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13351. * @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)
  13352. */
  13353. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13354. /**
  13355. * Wait asynchronously for the animation to end
  13356. * @returns a promise which will be fullfilled when the animation ends
  13357. */
  13358. waitAsync(): Promise<Animatable>;
  13359. /** @hidden */
  13360. _animate(delay: number): boolean;
  13361. }
  13362. module "babylonjs/scene" {
  13363. interface Scene {
  13364. /** @hidden */
  13365. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13366. /** @hidden */
  13367. _processLateAnimationBindingsForMatrices(holder: {
  13368. totalWeight: number;
  13369. animations: RuntimeAnimation[];
  13370. originalValue: Matrix;
  13371. }): any;
  13372. /** @hidden */
  13373. _processLateAnimationBindingsForQuaternions(holder: {
  13374. totalWeight: number;
  13375. animations: RuntimeAnimation[];
  13376. originalValue: Quaternion;
  13377. }, refQuaternion: Quaternion): Quaternion;
  13378. /** @hidden */
  13379. _processLateAnimationBindings(): void;
  13380. /**
  13381. * Will start the animation sequence of a given target
  13382. * @param target defines the target
  13383. * @param from defines from which frame should animation start
  13384. * @param to defines until which frame should animation run.
  13385. * @param weight defines the weight to apply to the animation (1.0 by default)
  13386. * @param loop defines if the animation loops
  13387. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13388. * @param onAnimationEnd defines the function to be executed when the animation ends
  13389. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13390. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13391. * @param onAnimationLoop defines the callback to call when an animation loops
  13392. * @returns the animatable object created for this animation
  13393. */
  13394. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13395. /**
  13396. * Will start the animation sequence of a given target
  13397. * @param target defines the target
  13398. * @param from defines from which frame should animation start
  13399. * @param to defines until which frame should animation run.
  13400. * @param loop defines if the animation loops
  13401. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13402. * @param onAnimationEnd defines the function to be executed when the animation ends
  13403. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13404. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13405. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13406. * @param onAnimationLoop defines the callback to call when an animation loops
  13407. * @returns the animatable object created for this animation
  13408. */
  13409. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13410. /**
  13411. * Will start the animation sequence of a given target and its hierarchy
  13412. * @param target defines the target
  13413. * @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.
  13414. * @param from defines from which frame should animation start
  13415. * @param to defines until which frame should animation run.
  13416. * @param loop defines if the animation loops
  13417. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13418. * @param onAnimationEnd defines the function to be executed when the animation ends
  13419. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13420. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13421. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13422. * @param onAnimationLoop defines the callback to call when an animation loops
  13423. * @returns the list of created animatables
  13424. */
  13425. 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[];
  13426. /**
  13427. * Begin a new animation on a given node
  13428. * @param target defines the target where the animation will take place
  13429. * @param animations defines the list of animations to start
  13430. * @param from defines the initial value
  13431. * @param to defines the final value
  13432. * @param loop defines if you want animation to loop (off by default)
  13433. * @param speedRatio defines the speed ratio to apply to all animations
  13434. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13435. * @param onAnimationLoop defines the callback to call when an animation loops
  13436. * @returns the list of created animatables
  13437. */
  13438. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13439. /**
  13440. * Begin a new animation on a given node and its hierarchy
  13441. * @param target defines the root node where the animation will take place
  13442. * @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.
  13443. * @param animations defines the list of animations to start
  13444. * @param from defines the initial value
  13445. * @param to defines the final value
  13446. * @param loop defines if you want animation to loop (off by default)
  13447. * @param speedRatio defines the speed ratio to apply to all animations
  13448. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13449. * @param onAnimationLoop defines the callback to call when an animation loops
  13450. * @returns the list of animatables created for all nodes
  13451. */
  13452. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13453. /**
  13454. * Gets the animatable associated with a specific target
  13455. * @param target defines the target of the animatable
  13456. * @returns the required animatable if found
  13457. */
  13458. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13459. /**
  13460. * Gets all animatables associated with a given target
  13461. * @param target defines the target to look animatables for
  13462. * @returns an array of Animatables
  13463. */
  13464. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13465. /**
  13466. * Stops and removes all animations that have been applied to the scene
  13467. */
  13468. stopAllAnimations(): void;
  13469. /**
  13470. * Gets the current delta time used by animation engine
  13471. */
  13472. deltaTime: number;
  13473. }
  13474. }
  13475. module "babylonjs/Bones/bone" {
  13476. interface Bone {
  13477. /**
  13478. * Copy an animation range from another bone
  13479. * @param source defines the source bone
  13480. * @param rangeName defines the range name to copy
  13481. * @param frameOffset defines the frame offset
  13482. * @param rescaleAsRequired defines if rescaling must be applied if required
  13483. * @param skelDimensionsRatio defines the scaling ratio
  13484. * @returns true if operation was successful
  13485. */
  13486. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13487. }
  13488. }
  13489. }
  13490. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13491. /**
  13492. * Class used to override all child animations of a given target
  13493. */
  13494. export class AnimationPropertiesOverride {
  13495. /**
  13496. * Gets or sets a value indicating if animation blending must be used
  13497. */
  13498. enableBlending: boolean;
  13499. /**
  13500. * Gets or sets the blending speed to use when enableBlending is true
  13501. */
  13502. blendingSpeed: number;
  13503. /**
  13504. * Gets or sets the default loop mode to use
  13505. */
  13506. loopMode: number;
  13507. }
  13508. }
  13509. declare module "babylonjs/Bones/skeleton" {
  13510. import { Bone } from "babylonjs/Bones/bone";
  13511. import { Observable } from "babylonjs/Misc/observable";
  13512. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13513. import { Scene } from "babylonjs/scene";
  13514. import { Nullable } from "babylonjs/types";
  13515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13516. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13517. import { Animatable } from "babylonjs/Animations/animatable";
  13518. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13519. import { Animation } from "babylonjs/Animations/animation";
  13520. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13521. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13523. /**
  13524. * Class used to handle skinning animations
  13525. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13526. */
  13527. export class Skeleton implements IAnimatable {
  13528. /** defines the skeleton name */
  13529. name: string;
  13530. /** defines the skeleton Id */
  13531. id: string;
  13532. /**
  13533. * Defines the list of child bones
  13534. */
  13535. bones: Bone[];
  13536. /**
  13537. * Defines an estimate of the dimension of the skeleton at rest
  13538. */
  13539. dimensionsAtRest: Vector3;
  13540. /**
  13541. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13542. */
  13543. needInitialSkinMatrix: boolean;
  13544. /**
  13545. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13546. */
  13547. overrideMesh: Nullable<AbstractMesh>;
  13548. /**
  13549. * Gets the list of animations attached to this skeleton
  13550. */
  13551. animations: Array<Animation>;
  13552. private _scene;
  13553. private _isDirty;
  13554. private _transformMatrices;
  13555. private _transformMatrixTexture;
  13556. private _meshesWithPoseMatrix;
  13557. private _animatables;
  13558. private _identity;
  13559. private _synchronizedWithMesh;
  13560. private _ranges;
  13561. private _lastAbsoluteTransformsUpdateId;
  13562. private _canUseTextureForBones;
  13563. private _uniqueId;
  13564. /** @hidden */
  13565. _numBonesWithLinkedTransformNode: number;
  13566. /** @hidden */
  13567. _hasWaitingData: Nullable<boolean>;
  13568. /**
  13569. * Specifies if the skeleton should be serialized
  13570. */
  13571. doNotSerialize: boolean;
  13572. private _useTextureToStoreBoneMatrices;
  13573. /**
  13574. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13575. * Please note that this option is not available if the hardware does not support it
  13576. */
  13577. useTextureToStoreBoneMatrices: boolean;
  13578. private _animationPropertiesOverride;
  13579. /**
  13580. * Gets or sets the animation properties override
  13581. */
  13582. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13583. /**
  13584. * List of inspectable custom properties (used by the Inspector)
  13585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13586. */
  13587. inspectableCustomProperties: IInspectable[];
  13588. /**
  13589. * An observable triggered before computing the skeleton's matrices
  13590. */
  13591. onBeforeComputeObservable: Observable<Skeleton>;
  13592. /**
  13593. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13594. */
  13595. readonly isUsingTextureForMatrices: boolean;
  13596. /**
  13597. * Gets the unique ID of this skeleton
  13598. */
  13599. readonly uniqueId: number;
  13600. /**
  13601. * Creates a new skeleton
  13602. * @param name defines the skeleton name
  13603. * @param id defines the skeleton Id
  13604. * @param scene defines the hosting scene
  13605. */
  13606. constructor(
  13607. /** defines the skeleton name */
  13608. name: string,
  13609. /** defines the skeleton Id */
  13610. id: string, scene: Scene);
  13611. /**
  13612. * Gets the current object class name.
  13613. * @return the class name
  13614. */
  13615. getClassName(): string;
  13616. /**
  13617. * Returns an array containing the root bones
  13618. * @returns an array containing the root bones
  13619. */
  13620. getChildren(): Array<Bone>;
  13621. /**
  13622. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13623. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13624. * @returns a Float32Array containing matrices data
  13625. */
  13626. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13627. /**
  13628. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13629. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13630. * @returns a raw texture containing the data
  13631. */
  13632. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13633. /**
  13634. * Gets the current hosting scene
  13635. * @returns a scene object
  13636. */
  13637. getScene(): Scene;
  13638. /**
  13639. * Gets a string representing the current skeleton data
  13640. * @param fullDetails defines a boolean indicating if we want a verbose version
  13641. * @returns a string representing the current skeleton data
  13642. */
  13643. toString(fullDetails?: boolean): string;
  13644. /**
  13645. * Get bone's index searching by name
  13646. * @param name defines bone's name to search for
  13647. * @return the indice of the bone. Returns -1 if not found
  13648. */
  13649. getBoneIndexByName(name: string): number;
  13650. /**
  13651. * Creater a new animation range
  13652. * @param name defines the name of the range
  13653. * @param from defines the start key
  13654. * @param to defines the end key
  13655. */
  13656. createAnimationRange(name: string, from: number, to: number): void;
  13657. /**
  13658. * Delete a specific animation range
  13659. * @param name defines the name of the range
  13660. * @param deleteFrames defines if frames must be removed as well
  13661. */
  13662. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13663. /**
  13664. * Gets a specific animation range
  13665. * @param name defines the name of the range to look for
  13666. * @returns the requested animation range or null if not found
  13667. */
  13668. getAnimationRange(name: string): Nullable<AnimationRange>;
  13669. /**
  13670. * Gets the list of all animation ranges defined on this skeleton
  13671. * @returns an array
  13672. */
  13673. getAnimationRanges(): Nullable<AnimationRange>[];
  13674. /**
  13675. * Copy animation range from a source skeleton.
  13676. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13677. * @param source defines the source skeleton
  13678. * @param name defines the name of the range to copy
  13679. * @param rescaleAsRequired defines if rescaling must be applied if required
  13680. * @returns true if operation was successful
  13681. */
  13682. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13683. /**
  13684. * Forces the skeleton to go to rest pose
  13685. */
  13686. returnToRest(): void;
  13687. private _getHighestAnimationFrame;
  13688. /**
  13689. * Begin a specific animation range
  13690. * @param name defines the name of the range to start
  13691. * @param loop defines if looping must be turned on (false by default)
  13692. * @param speedRatio defines the speed ratio to apply (1 by default)
  13693. * @param onAnimationEnd defines a callback which will be called when animation will end
  13694. * @returns a new animatable
  13695. */
  13696. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13697. /** @hidden */
  13698. _markAsDirty(): void;
  13699. /** @hidden */
  13700. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13701. /** @hidden */
  13702. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13703. private _computeTransformMatrices;
  13704. /**
  13705. * Build all resources required to render a skeleton
  13706. */
  13707. prepare(): void;
  13708. /**
  13709. * Gets the list of animatables currently running for this skeleton
  13710. * @returns an array of animatables
  13711. */
  13712. getAnimatables(): IAnimatable[];
  13713. /**
  13714. * Clone the current skeleton
  13715. * @param name defines the name of the new skeleton
  13716. * @param id defines the id of the new skeleton
  13717. * @returns the new skeleton
  13718. */
  13719. clone(name: string, id: string): Skeleton;
  13720. /**
  13721. * Enable animation blending for this skeleton
  13722. * @param blendingSpeed defines the blending speed to apply
  13723. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13724. */
  13725. enableBlending(blendingSpeed?: number): void;
  13726. /**
  13727. * Releases all resources associated with the current skeleton
  13728. */
  13729. dispose(): void;
  13730. /**
  13731. * Serialize the skeleton in a JSON object
  13732. * @returns a JSON object
  13733. */
  13734. serialize(): any;
  13735. /**
  13736. * Creates a new skeleton from serialized data
  13737. * @param parsedSkeleton defines the serialized data
  13738. * @param scene defines the hosting scene
  13739. * @returns a new skeleton
  13740. */
  13741. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13742. /**
  13743. * Compute all node absolute transforms
  13744. * @param forceUpdate defines if computation must be done even if cache is up to date
  13745. */
  13746. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13747. /**
  13748. * Gets the root pose matrix
  13749. * @returns a matrix
  13750. */
  13751. getPoseMatrix(): Nullable<Matrix>;
  13752. /**
  13753. * Sorts bones per internal index
  13754. */
  13755. sortBones(): void;
  13756. private _sortBones;
  13757. }
  13758. }
  13759. declare module "babylonjs/Bones/bone" {
  13760. import { Skeleton } from "babylonjs/Bones/skeleton";
  13761. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13762. import { Nullable } from "babylonjs/types";
  13763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13764. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13765. import { Node } from "babylonjs/node";
  13766. import { Space } from "babylonjs/Maths/math.axis";
  13767. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13768. /**
  13769. * Class used to store bone information
  13770. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13771. */
  13772. export class Bone extends Node {
  13773. /**
  13774. * defines the bone name
  13775. */
  13776. name: string;
  13777. private static _tmpVecs;
  13778. private static _tmpQuat;
  13779. private static _tmpMats;
  13780. /**
  13781. * Gets the list of child bones
  13782. */
  13783. children: Bone[];
  13784. /** Gets the animations associated with this bone */
  13785. animations: import("babylonjs/Animations/animation").Animation[];
  13786. /**
  13787. * Gets or sets bone length
  13788. */
  13789. length: number;
  13790. /**
  13791. * @hidden Internal only
  13792. * Set this value to map this bone to a different index in the transform matrices
  13793. * Set this value to -1 to exclude the bone from the transform matrices
  13794. */
  13795. _index: Nullable<number>;
  13796. private _skeleton;
  13797. private _localMatrix;
  13798. private _restPose;
  13799. private _baseMatrix;
  13800. private _absoluteTransform;
  13801. private _invertedAbsoluteTransform;
  13802. private _parent;
  13803. private _scalingDeterminant;
  13804. private _worldTransform;
  13805. private _localScaling;
  13806. private _localRotation;
  13807. private _localPosition;
  13808. private _needToDecompose;
  13809. private _needToCompose;
  13810. /** @hidden */
  13811. _linkedTransformNode: Nullable<TransformNode>;
  13812. /** @hidden */
  13813. _waitingTransformNodeId: Nullable<string>;
  13814. /** @hidden */
  13815. /** @hidden */
  13816. _matrix: Matrix;
  13817. /**
  13818. * Create a new bone
  13819. * @param name defines the bone name
  13820. * @param skeleton defines the parent skeleton
  13821. * @param parentBone defines the parent (can be null if the bone is the root)
  13822. * @param localMatrix defines the local matrix
  13823. * @param restPose defines the rest pose matrix
  13824. * @param baseMatrix defines the base matrix
  13825. * @param index defines index of the bone in the hiearchy
  13826. */
  13827. constructor(
  13828. /**
  13829. * defines the bone name
  13830. */
  13831. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13832. /**
  13833. * Gets the current object class name.
  13834. * @return the class name
  13835. */
  13836. getClassName(): string;
  13837. /**
  13838. * Gets the parent skeleton
  13839. * @returns a skeleton
  13840. */
  13841. getSkeleton(): Skeleton;
  13842. /**
  13843. * Gets parent bone
  13844. * @returns a bone or null if the bone is the root of the bone hierarchy
  13845. */
  13846. getParent(): Nullable<Bone>;
  13847. /**
  13848. * Returns an array containing the root bones
  13849. * @returns an array containing the root bones
  13850. */
  13851. getChildren(): Array<Bone>;
  13852. /**
  13853. * Sets the parent bone
  13854. * @param parent defines the parent (can be null if the bone is the root)
  13855. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13856. */
  13857. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13858. /**
  13859. * Gets the local matrix
  13860. * @returns a matrix
  13861. */
  13862. getLocalMatrix(): Matrix;
  13863. /**
  13864. * Gets the base matrix (initial matrix which remains unchanged)
  13865. * @returns a matrix
  13866. */
  13867. getBaseMatrix(): Matrix;
  13868. /**
  13869. * Gets the rest pose matrix
  13870. * @returns a matrix
  13871. */
  13872. getRestPose(): Matrix;
  13873. /**
  13874. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13875. */
  13876. getWorldMatrix(): Matrix;
  13877. /**
  13878. * Sets the local matrix to rest pose matrix
  13879. */
  13880. returnToRest(): void;
  13881. /**
  13882. * Gets the inverse of the absolute transform matrix.
  13883. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13884. * @returns a matrix
  13885. */
  13886. getInvertedAbsoluteTransform(): Matrix;
  13887. /**
  13888. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13889. * @returns a matrix
  13890. */
  13891. getAbsoluteTransform(): Matrix;
  13892. /**
  13893. * Links with the given transform node.
  13894. * The local matrix of this bone is copied from the transform node every frame.
  13895. * @param transformNode defines the transform node to link to
  13896. */
  13897. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13898. /**
  13899. * Gets the node used to drive the bone's transformation
  13900. * @returns a transform node or null
  13901. */
  13902. getTransformNode(): Nullable<TransformNode>;
  13903. /** Gets or sets current position (in local space) */
  13904. position: Vector3;
  13905. /** Gets or sets current rotation (in local space) */
  13906. rotation: Vector3;
  13907. /** Gets or sets current rotation quaternion (in local space) */
  13908. rotationQuaternion: Quaternion;
  13909. /** Gets or sets current scaling (in local space) */
  13910. scaling: Vector3;
  13911. /**
  13912. * Gets the animation properties override
  13913. */
  13914. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13915. private _decompose;
  13916. private _compose;
  13917. /**
  13918. * Update the base and local matrices
  13919. * @param matrix defines the new base or local matrix
  13920. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13921. * @param updateLocalMatrix defines if the local matrix should be updated
  13922. */
  13923. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13924. /** @hidden */
  13925. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13926. /**
  13927. * Flag the bone as dirty (Forcing it to update everything)
  13928. */
  13929. markAsDirty(): void;
  13930. /** @hidden */
  13931. _markAsDirtyAndCompose(): void;
  13932. private _markAsDirtyAndDecompose;
  13933. /**
  13934. * Translate the bone in local or world space
  13935. * @param vec The amount to translate the bone
  13936. * @param space The space that the translation is in
  13937. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13938. */
  13939. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13940. /**
  13941. * Set the postion of the bone in local or world space
  13942. * @param position The position to set the bone
  13943. * @param space The space that the position is in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. */
  13946. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13947. /**
  13948. * Set the absolute position of the bone (world space)
  13949. * @param position The position to set the bone
  13950. * @param mesh The mesh that this bone is attached to
  13951. */
  13952. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13953. /**
  13954. * Scale the bone on the x, y and z axes (in local space)
  13955. * @param x The amount to scale the bone on the x axis
  13956. * @param y The amount to scale the bone on the y axis
  13957. * @param z The amount to scale the bone on the z axis
  13958. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13959. */
  13960. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13961. /**
  13962. * Set the bone scaling in local space
  13963. * @param scale defines the scaling vector
  13964. */
  13965. setScale(scale: Vector3): void;
  13966. /**
  13967. * Gets the current scaling in local space
  13968. * @returns the current scaling vector
  13969. */
  13970. getScale(): Vector3;
  13971. /**
  13972. * Gets the current scaling in local space and stores it in a target vector
  13973. * @param result defines the target vector
  13974. */
  13975. getScaleToRef(result: Vector3): void;
  13976. /**
  13977. * Set the yaw, pitch, and roll of the bone in local or world space
  13978. * @param yaw The rotation of the bone on the y axis
  13979. * @param pitch The rotation of the bone on the x axis
  13980. * @param roll The rotation of the bone on the z axis
  13981. * @param space The space that the axes of rotation are in
  13982. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13983. */
  13984. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13985. /**
  13986. * Add a rotation to the bone on an axis in local or world space
  13987. * @param axis The axis to rotate the bone on
  13988. * @param amount The amount to rotate the bone
  13989. * @param space The space that the axis is in
  13990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13991. */
  13992. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13993. /**
  13994. * Set the rotation of the bone to a particular axis angle in local or world space
  13995. * @param axis The axis to rotate the bone on
  13996. * @param angle The angle that the bone should be rotated to
  13997. * @param space The space that the axis is in
  13998. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13999. */
  14000. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14001. /**
  14002. * Set the euler rotation of the bone in local of world space
  14003. * @param rotation The euler rotation that the bone should be set to
  14004. * @param space The space that the rotation is in
  14005. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14006. */
  14007. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14008. /**
  14009. * Set the quaternion rotation of the bone in local of world space
  14010. * @param quat The quaternion rotation that the bone should be set to
  14011. * @param space The space that the rotation is in
  14012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14013. */
  14014. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14015. /**
  14016. * Set the rotation matrix of the bone in local of world space
  14017. * @param rotMat The rotation matrix that the bone should be set to
  14018. * @param space The space that the rotation is in
  14019. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14020. */
  14021. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14022. private _rotateWithMatrix;
  14023. private _getNegativeRotationToRef;
  14024. /**
  14025. * Get the position of the bone in local or world space
  14026. * @param space The space that the returned position is in
  14027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14028. * @returns The position of the bone
  14029. */
  14030. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14031. /**
  14032. * Copy the position of the bone to a vector3 in local or world space
  14033. * @param space The space that the returned position is in
  14034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14035. * @param result The vector3 to copy the position to
  14036. */
  14037. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14038. /**
  14039. * Get the absolute position of the bone (world space)
  14040. * @param mesh The mesh that this bone is attached to
  14041. * @returns The absolute position of the bone
  14042. */
  14043. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14044. /**
  14045. * Copy the absolute position of the bone (world space) to the result param
  14046. * @param mesh The mesh that this bone is attached to
  14047. * @param result The vector3 to copy the absolute position to
  14048. */
  14049. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14050. /**
  14051. * Compute the absolute transforms of this bone and its children
  14052. */
  14053. computeAbsoluteTransforms(): void;
  14054. /**
  14055. * Get the world direction from an axis that is in the local space of the bone
  14056. * @param localAxis The local direction that is used to compute the world direction
  14057. * @param mesh The mesh that this bone is attached to
  14058. * @returns The world direction
  14059. */
  14060. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14061. /**
  14062. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14063. * @param localAxis The local direction that is used to compute the world direction
  14064. * @param mesh The mesh that this bone is attached to
  14065. * @param result The vector3 that the world direction will be copied to
  14066. */
  14067. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14068. /**
  14069. * Get the euler rotation of the bone in local or world space
  14070. * @param space The space that the rotation should be in
  14071. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14072. * @returns The euler rotation
  14073. */
  14074. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14075. /**
  14076. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14077. * @param space The space that the rotation should be in
  14078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14079. * @param result The vector3 that the rotation should be copied to
  14080. */
  14081. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14082. /**
  14083. * Get the quaternion rotation of the bone in either local or world space
  14084. * @param space The space that the rotation should be in
  14085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14086. * @returns The quaternion rotation
  14087. */
  14088. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14089. /**
  14090. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14091. * @param space The space that the rotation should be in
  14092. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14093. * @param result The quaternion that the rotation should be copied to
  14094. */
  14095. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14096. /**
  14097. * Get the rotation matrix of the bone in local or world space
  14098. * @param space The space that the rotation should be in
  14099. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14100. * @returns The rotation matrix
  14101. */
  14102. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14103. /**
  14104. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14105. * @param space The space that the rotation should be in
  14106. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14107. * @param result The quaternion that the rotation should be copied to
  14108. */
  14109. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14110. /**
  14111. * Get the world position of a point that is in the local space of the bone
  14112. * @param position The local position
  14113. * @param mesh The mesh that this bone is attached to
  14114. * @returns The world position
  14115. */
  14116. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14117. /**
  14118. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14119. * @param position The local position
  14120. * @param mesh The mesh that this bone is attached to
  14121. * @param result The vector3 that the world position should be copied to
  14122. */
  14123. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14124. /**
  14125. * Get the local position of a point that is in world space
  14126. * @param position The world position
  14127. * @param mesh The mesh that this bone is attached to
  14128. * @returns The local position
  14129. */
  14130. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14131. /**
  14132. * Get the local position of a point that is in world space and copy it to the result param
  14133. * @param position The world position
  14134. * @param mesh The mesh that this bone is attached to
  14135. * @param result The vector3 that the local position should be copied to
  14136. */
  14137. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14138. }
  14139. }
  14140. declare module "babylonjs/Meshes/transformNode" {
  14141. import { DeepImmutable } from "babylonjs/types";
  14142. import { Observable } from "babylonjs/Misc/observable";
  14143. import { Nullable } from "babylonjs/types";
  14144. import { Camera } from "babylonjs/Cameras/camera";
  14145. import { Scene } from "babylonjs/scene";
  14146. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14147. import { Node } from "babylonjs/node";
  14148. import { Bone } from "babylonjs/Bones/bone";
  14149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14150. import { Space } from "babylonjs/Maths/math.axis";
  14151. /**
  14152. * 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.
  14153. * @see https://doc.babylonjs.com/how_to/transformnode
  14154. */
  14155. export class TransformNode extends Node {
  14156. /**
  14157. * Object will not rotate to face the camera
  14158. */
  14159. static BILLBOARDMODE_NONE: number;
  14160. /**
  14161. * Object will rotate to face the camera but only on the x axis
  14162. */
  14163. static BILLBOARDMODE_X: number;
  14164. /**
  14165. * Object will rotate to face the camera but only on the y axis
  14166. */
  14167. static BILLBOARDMODE_Y: number;
  14168. /**
  14169. * Object will rotate to face the camera but only on the z axis
  14170. */
  14171. static BILLBOARDMODE_Z: number;
  14172. /**
  14173. * Object will rotate to face the camera
  14174. */
  14175. static BILLBOARDMODE_ALL: number;
  14176. /**
  14177. * Object will rotate to face the camera's position instead of orientation
  14178. */
  14179. static BILLBOARDMODE_USE_POSITION: number;
  14180. private _forward;
  14181. private _forwardInverted;
  14182. private _up;
  14183. private _right;
  14184. private _rightInverted;
  14185. private _position;
  14186. private _rotation;
  14187. private _rotationQuaternion;
  14188. protected _scaling: Vector3;
  14189. protected _isDirty: boolean;
  14190. private _transformToBoneReferal;
  14191. private _isAbsoluteSynced;
  14192. private _billboardMode;
  14193. /**
  14194. * Gets or sets the billboard mode. Default is 0.
  14195. *
  14196. * | Value | Type | Description |
  14197. * | --- | --- | --- |
  14198. * | 0 | BILLBOARDMODE_NONE | |
  14199. * | 1 | BILLBOARDMODE_X | |
  14200. * | 2 | BILLBOARDMODE_Y | |
  14201. * | 4 | BILLBOARDMODE_Z | |
  14202. * | 7 | BILLBOARDMODE_ALL | |
  14203. *
  14204. */
  14205. billboardMode: number;
  14206. private _preserveParentRotationForBillboard;
  14207. /**
  14208. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14209. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14210. */
  14211. preserveParentRotationForBillboard: boolean;
  14212. /**
  14213. * 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
  14214. */
  14215. scalingDeterminant: number;
  14216. private _infiniteDistance;
  14217. /**
  14218. * Gets or sets the distance of the object to max, often used by skybox
  14219. */
  14220. infiniteDistance: boolean;
  14221. /**
  14222. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14223. * By default the system will update normals to compensate
  14224. */
  14225. ignoreNonUniformScaling: boolean;
  14226. /**
  14227. * 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
  14228. */
  14229. reIntegrateRotationIntoRotationQuaternion: boolean;
  14230. /** @hidden */
  14231. _poseMatrix: Nullable<Matrix>;
  14232. /** @hidden */
  14233. _localMatrix: Matrix;
  14234. private _usePivotMatrix;
  14235. private _absolutePosition;
  14236. private _absoluteScaling;
  14237. private _absoluteRotationQuaternion;
  14238. private _pivotMatrix;
  14239. private _pivotMatrixInverse;
  14240. protected _postMultiplyPivotMatrix: boolean;
  14241. protected _isWorldMatrixFrozen: boolean;
  14242. /** @hidden */
  14243. _indexInSceneTransformNodesArray: number;
  14244. /**
  14245. * An event triggered after the world matrix is updated
  14246. */
  14247. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14248. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14249. /**
  14250. * Gets a string identifying the name of the class
  14251. * @returns "TransformNode" string
  14252. */
  14253. getClassName(): string;
  14254. /**
  14255. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14256. */
  14257. position: Vector3;
  14258. /**
  14259. * 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)).
  14260. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14261. */
  14262. rotation: Vector3;
  14263. /**
  14264. * 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)).
  14265. */
  14266. scaling: Vector3;
  14267. /**
  14268. * 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).
  14269. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14270. */
  14271. rotationQuaternion: Nullable<Quaternion>;
  14272. /**
  14273. * The forward direction of that transform in world space.
  14274. */
  14275. readonly forward: Vector3;
  14276. /**
  14277. * The up direction of that transform in world space.
  14278. */
  14279. readonly up: Vector3;
  14280. /**
  14281. * The right direction of that transform in world space.
  14282. */
  14283. readonly right: Vector3;
  14284. /**
  14285. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14286. * @param matrix the matrix to copy the pose from
  14287. * @returns this TransformNode.
  14288. */
  14289. updatePoseMatrix(matrix: Matrix): TransformNode;
  14290. /**
  14291. * Returns the mesh Pose matrix.
  14292. * @returns the pose matrix
  14293. */
  14294. getPoseMatrix(): Matrix;
  14295. /** @hidden */
  14296. _isSynchronized(): boolean;
  14297. /** @hidden */
  14298. _initCache(): void;
  14299. /**
  14300. * Flag the transform node as dirty (Forcing it to update everything)
  14301. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14302. * @returns this transform node
  14303. */
  14304. markAsDirty(property: string): TransformNode;
  14305. /**
  14306. * Returns the current mesh absolute position.
  14307. * Returns a Vector3.
  14308. */
  14309. readonly absolutePosition: Vector3;
  14310. /**
  14311. * Returns the current mesh absolute scaling.
  14312. * Returns a Vector3.
  14313. */
  14314. readonly absoluteScaling: Vector3;
  14315. /**
  14316. * Returns the current mesh absolute rotation.
  14317. * Returns a Quaternion.
  14318. */
  14319. readonly absoluteRotationQuaternion: Quaternion;
  14320. /**
  14321. * Sets a new matrix to apply before all other transformation
  14322. * @param matrix defines the transform matrix
  14323. * @returns the current TransformNode
  14324. */
  14325. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14326. /**
  14327. * Sets a new pivot matrix to the current node
  14328. * @param matrix defines the new pivot matrix to use
  14329. * @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
  14330. * @returns the current TransformNode
  14331. */
  14332. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14333. /**
  14334. * Returns the mesh pivot matrix.
  14335. * Default : Identity.
  14336. * @returns the matrix
  14337. */
  14338. getPivotMatrix(): Matrix;
  14339. /**
  14340. * Instantiate (when possible) or clone that node with its hierarchy
  14341. * @param newParent defines the new parent to use for the instance (or clone)
  14342. * @returns an instance (or a clone) of the current node with its hiearchy
  14343. */
  14344. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14345. /**
  14346. * Prevents the World matrix to be computed any longer
  14347. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14348. * @returns the TransformNode.
  14349. */
  14350. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14351. /**
  14352. * Allows back the World matrix computation.
  14353. * @returns the TransformNode.
  14354. */
  14355. unfreezeWorldMatrix(): this;
  14356. /**
  14357. * True if the World matrix has been frozen.
  14358. */
  14359. readonly isWorldMatrixFrozen: boolean;
  14360. /**
  14361. * Retuns the mesh absolute position in the World.
  14362. * @returns a Vector3.
  14363. */
  14364. getAbsolutePosition(): Vector3;
  14365. /**
  14366. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14367. * @param absolutePosition the absolute position to set
  14368. * @returns the TransformNode.
  14369. */
  14370. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14371. /**
  14372. * Sets the mesh position in its local space.
  14373. * @param vector3 the position to set in localspace
  14374. * @returns the TransformNode.
  14375. */
  14376. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14377. /**
  14378. * Returns the mesh position in the local space from the current World matrix values.
  14379. * @returns a new Vector3.
  14380. */
  14381. getPositionExpressedInLocalSpace(): Vector3;
  14382. /**
  14383. * Translates the mesh along the passed Vector3 in its local space.
  14384. * @param vector3 the distance to translate in localspace
  14385. * @returns the TransformNode.
  14386. */
  14387. locallyTranslate(vector3: Vector3): TransformNode;
  14388. private static _lookAtVectorCache;
  14389. /**
  14390. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14391. * @param targetPoint the position (must be in same space as current mesh) to look at
  14392. * @param yawCor optional yaw (y-axis) correction in radians
  14393. * @param pitchCor optional pitch (x-axis) correction in radians
  14394. * @param rollCor optional roll (z-axis) correction in radians
  14395. * @param space the choosen space of the target
  14396. * @returns the TransformNode.
  14397. */
  14398. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14399. /**
  14400. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14401. * This Vector3 is expressed in the World space.
  14402. * @param localAxis axis to rotate
  14403. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14404. */
  14405. getDirection(localAxis: Vector3): Vector3;
  14406. /**
  14407. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14408. * localAxis is expressed in the mesh local space.
  14409. * result is computed in the Wordl space from the mesh World matrix.
  14410. * @param localAxis axis to rotate
  14411. * @param result the resulting transformnode
  14412. * @returns this TransformNode.
  14413. */
  14414. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14415. /**
  14416. * Sets this transform node rotation to the given local axis.
  14417. * @param localAxis the axis in local space
  14418. * @param yawCor optional yaw (y-axis) correction in radians
  14419. * @param pitchCor optional pitch (x-axis) correction in radians
  14420. * @param rollCor optional roll (z-axis) correction in radians
  14421. * @returns this TransformNode
  14422. */
  14423. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14424. /**
  14425. * Sets a new pivot point to the current node
  14426. * @param point defines the new pivot point to use
  14427. * @param space defines if the point is in world or local space (local by default)
  14428. * @returns the current TransformNode
  14429. */
  14430. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14431. /**
  14432. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14433. * @returns the pivot point
  14434. */
  14435. getPivotPoint(): Vector3;
  14436. /**
  14437. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14438. * @param result the vector3 to store the result
  14439. * @returns this TransformNode.
  14440. */
  14441. getPivotPointToRef(result: Vector3): TransformNode;
  14442. /**
  14443. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14444. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14445. */
  14446. getAbsolutePivotPoint(): Vector3;
  14447. /**
  14448. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14449. * @param result vector3 to store the result
  14450. * @returns this TransformNode.
  14451. */
  14452. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14453. /**
  14454. * Defines the passed node as the parent of the current node.
  14455. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14456. * @see https://doc.babylonjs.com/how_to/parenting
  14457. * @param node the node ot set as the parent
  14458. * @returns this TransformNode.
  14459. */
  14460. setParent(node: Nullable<Node>): TransformNode;
  14461. private _nonUniformScaling;
  14462. /**
  14463. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14464. */
  14465. readonly nonUniformScaling: boolean;
  14466. /** @hidden */
  14467. _updateNonUniformScalingState(value: boolean): boolean;
  14468. /**
  14469. * Attach the current TransformNode to another TransformNode associated with a bone
  14470. * @param bone Bone affecting the TransformNode
  14471. * @param affectedTransformNode TransformNode associated with the bone
  14472. * @returns this object
  14473. */
  14474. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14475. /**
  14476. * Detach the transform node if its associated with a bone
  14477. * @returns this object
  14478. */
  14479. detachFromBone(): TransformNode;
  14480. private static _rotationAxisCache;
  14481. /**
  14482. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14483. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14484. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14485. * The passed axis is also normalized.
  14486. * @param axis the axis to rotate around
  14487. * @param amount the amount to rotate in radians
  14488. * @param space Space to rotate in (Default: local)
  14489. * @returns the TransformNode.
  14490. */
  14491. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14492. /**
  14493. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14494. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14495. * The passed axis is also normalized. .
  14496. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14497. * @param point the point to rotate around
  14498. * @param axis the axis to rotate around
  14499. * @param amount the amount to rotate in radians
  14500. * @returns the TransformNode
  14501. */
  14502. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14503. /**
  14504. * Translates the mesh along the axis vector for the passed distance in the given space.
  14505. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14506. * @param axis the axis to translate in
  14507. * @param distance the distance to translate
  14508. * @param space Space to rotate in (Default: local)
  14509. * @returns the TransformNode.
  14510. */
  14511. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14512. /**
  14513. * Adds a rotation step to the mesh current rotation.
  14514. * x, y, z are Euler angles expressed in radians.
  14515. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14516. * This means this rotation is made in the mesh local space only.
  14517. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14518. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14519. * ```javascript
  14520. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14521. * ```
  14522. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14523. * 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.
  14524. * @param x Rotation to add
  14525. * @param y Rotation to add
  14526. * @param z Rotation to add
  14527. * @returns the TransformNode.
  14528. */
  14529. addRotation(x: number, y: number, z: number): TransformNode;
  14530. /**
  14531. * @hidden
  14532. */
  14533. protected _getEffectiveParent(): Nullable<Node>;
  14534. /**
  14535. * Computes the world matrix of the node
  14536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14537. * @returns the world matrix
  14538. */
  14539. computeWorldMatrix(force?: boolean): Matrix;
  14540. protected _afterComputeWorldMatrix(): void;
  14541. /**
  14542. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14543. * @param func callback function to add
  14544. *
  14545. * @returns the TransformNode.
  14546. */
  14547. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14548. /**
  14549. * Removes a registered callback function.
  14550. * @param func callback function to remove
  14551. * @returns the TransformNode.
  14552. */
  14553. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14554. /**
  14555. * Gets the position of the current mesh in camera space
  14556. * @param camera defines the camera to use
  14557. * @returns a position
  14558. */
  14559. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14560. /**
  14561. * Returns the distance from the mesh to the active camera
  14562. * @param camera defines the camera to use
  14563. * @returns the distance
  14564. */
  14565. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14566. /**
  14567. * Clone the current transform node
  14568. * @param name Name of the new clone
  14569. * @param newParent New parent for the clone
  14570. * @param doNotCloneChildren Do not clone children hierarchy
  14571. * @returns the new transform node
  14572. */
  14573. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14574. /**
  14575. * Serializes the objects information.
  14576. * @param currentSerializationObject defines the object to serialize in
  14577. * @returns the serialized object
  14578. */
  14579. serialize(currentSerializationObject?: any): any;
  14580. /**
  14581. * Returns a new TransformNode object parsed from the source provided.
  14582. * @param parsedTransformNode is the source.
  14583. * @param scene the scne the object belongs to
  14584. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14585. * @returns a new TransformNode object parsed from the source provided.
  14586. */
  14587. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14588. /**
  14589. * Get all child-transformNodes of this node
  14590. * @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
  14591. * @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
  14592. * @returns an array of TransformNode
  14593. */
  14594. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14595. /**
  14596. * Releases resources associated with this transform node.
  14597. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14598. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14599. */
  14600. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14601. /**
  14602. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14603. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14604. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14605. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14606. * @returns the current mesh
  14607. */
  14608. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14609. private _syncAbsoluteScalingAndRotation;
  14610. }
  14611. }
  14612. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14613. import { Observable } from "babylonjs/Misc/observable";
  14614. import { Nullable } from "babylonjs/types";
  14615. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14616. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14618. import { Ray } from "babylonjs/Culling/ray";
  14619. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14620. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14621. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14622. /**
  14623. * Defines the types of pose enabled controllers that are supported
  14624. */
  14625. export enum PoseEnabledControllerType {
  14626. /**
  14627. * HTC Vive
  14628. */
  14629. VIVE = 0,
  14630. /**
  14631. * Oculus Rift
  14632. */
  14633. OCULUS = 1,
  14634. /**
  14635. * Windows mixed reality
  14636. */
  14637. WINDOWS = 2,
  14638. /**
  14639. * Samsung gear VR
  14640. */
  14641. GEAR_VR = 3,
  14642. /**
  14643. * Google Daydream
  14644. */
  14645. DAYDREAM = 4,
  14646. /**
  14647. * Generic
  14648. */
  14649. GENERIC = 5
  14650. }
  14651. /**
  14652. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14653. */
  14654. export interface MutableGamepadButton {
  14655. /**
  14656. * Value of the button/trigger
  14657. */
  14658. value: number;
  14659. /**
  14660. * If the button/trigger is currently touched
  14661. */
  14662. touched: boolean;
  14663. /**
  14664. * If the button/trigger is currently pressed
  14665. */
  14666. pressed: boolean;
  14667. }
  14668. /**
  14669. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14670. * @hidden
  14671. */
  14672. export interface ExtendedGamepadButton extends GamepadButton {
  14673. /**
  14674. * If the button/trigger is currently pressed
  14675. */
  14676. readonly pressed: boolean;
  14677. /**
  14678. * If the button/trigger is currently touched
  14679. */
  14680. readonly touched: boolean;
  14681. /**
  14682. * Value of the button/trigger
  14683. */
  14684. readonly value: number;
  14685. }
  14686. /** @hidden */
  14687. export interface _GamePadFactory {
  14688. /**
  14689. * Returns wether or not the current gamepad can be created for this type of controller.
  14690. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14691. * @returns true if it can be created, otherwise false
  14692. */
  14693. canCreate(gamepadInfo: any): boolean;
  14694. /**
  14695. * Creates a new instance of the Gamepad.
  14696. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14697. * @returns the new gamepad instance
  14698. */
  14699. create(gamepadInfo: any): Gamepad;
  14700. }
  14701. /**
  14702. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14703. */
  14704. export class PoseEnabledControllerHelper {
  14705. /** @hidden */
  14706. static _ControllerFactories: _GamePadFactory[];
  14707. /** @hidden */
  14708. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14709. /**
  14710. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14711. * @param vrGamepad the gamepad to initialized
  14712. * @returns a vr controller of the type the gamepad identified as
  14713. */
  14714. static InitiateController(vrGamepad: any): Gamepad;
  14715. }
  14716. /**
  14717. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14718. */
  14719. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14720. /**
  14721. * If the controller is used in a webXR session
  14722. */
  14723. isXR: boolean;
  14724. private _deviceRoomPosition;
  14725. private _deviceRoomRotationQuaternion;
  14726. /**
  14727. * The device position in babylon space
  14728. */
  14729. devicePosition: Vector3;
  14730. /**
  14731. * The device rotation in babylon space
  14732. */
  14733. deviceRotationQuaternion: Quaternion;
  14734. /**
  14735. * The scale factor of the device in babylon space
  14736. */
  14737. deviceScaleFactor: number;
  14738. /**
  14739. * (Likely devicePosition should be used instead) The device position in its room space
  14740. */
  14741. position: Vector3;
  14742. /**
  14743. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14744. */
  14745. rotationQuaternion: Quaternion;
  14746. /**
  14747. * The type of controller (Eg. Windows mixed reality)
  14748. */
  14749. controllerType: PoseEnabledControllerType;
  14750. protected _calculatedPosition: Vector3;
  14751. private _calculatedRotation;
  14752. /**
  14753. * The raw pose from the device
  14754. */
  14755. rawPose: DevicePose;
  14756. private _trackPosition;
  14757. private _maxRotationDistFromHeadset;
  14758. private _draggedRoomRotation;
  14759. /**
  14760. * @hidden
  14761. */
  14762. _disableTrackPosition(fixedPosition: Vector3): void;
  14763. /**
  14764. * Internal, the mesh attached to the controller
  14765. * @hidden
  14766. */
  14767. _mesh: Nullable<AbstractMesh>;
  14768. private _poseControlledCamera;
  14769. private _leftHandSystemQuaternion;
  14770. /**
  14771. * Internal, matrix used to convert room space to babylon space
  14772. * @hidden
  14773. */
  14774. _deviceToWorld: Matrix;
  14775. /**
  14776. * Node to be used when casting a ray from the controller
  14777. * @hidden
  14778. */
  14779. _pointingPoseNode: Nullable<TransformNode>;
  14780. /**
  14781. * Name of the child mesh that can be used to cast a ray from the controller
  14782. */
  14783. static readonly POINTING_POSE: string;
  14784. /**
  14785. * Creates a new PoseEnabledController from a gamepad
  14786. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14787. */
  14788. constructor(browserGamepad: any);
  14789. private _workingMatrix;
  14790. /**
  14791. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14792. */
  14793. update(): void;
  14794. /**
  14795. * Updates only the pose device and mesh without doing any button event checking
  14796. */
  14797. protected _updatePoseAndMesh(): void;
  14798. /**
  14799. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14800. * @param poseData raw pose fromthe device
  14801. */
  14802. updateFromDevice(poseData: DevicePose): void;
  14803. /**
  14804. * @hidden
  14805. */
  14806. _meshAttachedObservable: Observable<AbstractMesh>;
  14807. /**
  14808. * Attaches a mesh to the controller
  14809. * @param mesh the mesh to be attached
  14810. */
  14811. attachToMesh(mesh: AbstractMesh): void;
  14812. /**
  14813. * Attaches the controllers mesh to a camera
  14814. * @param camera the camera the mesh should be attached to
  14815. */
  14816. attachToPoseControlledCamera(camera: TargetCamera): void;
  14817. /**
  14818. * Disposes of the controller
  14819. */
  14820. dispose(): void;
  14821. /**
  14822. * The mesh that is attached to the controller
  14823. */
  14824. readonly mesh: Nullable<AbstractMesh>;
  14825. /**
  14826. * Gets the ray of the controller in the direction the controller is pointing
  14827. * @param length the length the resulting ray should be
  14828. * @returns a ray in the direction the controller is pointing
  14829. */
  14830. getForwardRay(length?: number): Ray;
  14831. }
  14832. }
  14833. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14834. import { Observable } from "babylonjs/Misc/observable";
  14835. import { Scene } from "babylonjs/scene";
  14836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14837. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14838. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14839. import { Nullable } from "babylonjs/types";
  14840. /**
  14841. * Defines the WebVRController object that represents controllers tracked in 3D space
  14842. */
  14843. export abstract class WebVRController extends PoseEnabledController {
  14844. /**
  14845. * Internal, the default controller model for the controller
  14846. */
  14847. protected _defaultModel: Nullable<AbstractMesh>;
  14848. /**
  14849. * Fired when the trigger state has changed
  14850. */
  14851. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14852. /**
  14853. * Fired when the main button state has changed
  14854. */
  14855. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14856. /**
  14857. * Fired when the secondary button state has changed
  14858. */
  14859. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14860. /**
  14861. * Fired when the pad state has changed
  14862. */
  14863. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14864. /**
  14865. * Fired when controllers stick values have changed
  14866. */
  14867. onPadValuesChangedObservable: Observable<StickValues>;
  14868. /**
  14869. * Array of button availible on the controller
  14870. */
  14871. protected _buttons: Array<MutableGamepadButton>;
  14872. private _onButtonStateChange;
  14873. /**
  14874. * Fired when a controller button's state has changed
  14875. * @param callback the callback containing the button that was modified
  14876. */
  14877. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14878. /**
  14879. * X and Y axis corresponding to the controllers joystick
  14880. */
  14881. pad: StickValues;
  14882. /**
  14883. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14884. */
  14885. hand: string;
  14886. /**
  14887. * The default controller model for the controller
  14888. */
  14889. readonly defaultModel: Nullable<AbstractMesh>;
  14890. /**
  14891. * Creates a new WebVRController from a gamepad
  14892. * @param vrGamepad the gamepad that the WebVRController should be created from
  14893. */
  14894. constructor(vrGamepad: any);
  14895. /**
  14896. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14897. */
  14898. update(): void;
  14899. /**
  14900. * Function to be called when a button is modified
  14901. */
  14902. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14903. /**
  14904. * Loads a mesh and attaches it to the controller
  14905. * @param scene the scene the mesh should be added to
  14906. * @param meshLoaded callback for when the mesh has been loaded
  14907. */
  14908. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14909. private _setButtonValue;
  14910. private _changes;
  14911. private _checkChanges;
  14912. /**
  14913. * Disposes of th webVRCOntroller
  14914. */
  14915. dispose(): void;
  14916. }
  14917. }
  14918. declare module "babylonjs/Lights/hemisphericLight" {
  14919. import { Nullable } from "babylonjs/types";
  14920. import { Scene } from "babylonjs/scene";
  14921. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14922. import { Color3 } from "babylonjs/Maths/math.color";
  14923. import { Effect } from "babylonjs/Materials/effect";
  14924. import { Light } from "babylonjs/Lights/light";
  14925. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14926. /**
  14927. * The HemisphericLight simulates the ambient environment light,
  14928. * so the passed direction is the light reflection direction, not the incoming direction.
  14929. */
  14930. export class HemisphericLight extends Light {
  14931. /**
  14932. * The groundColor is the light in the opposite direction to the one specified during creation.
  14933. * 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.
  14934. */
  14935. groundColor: Color3;
  14936. /**
  14937. * The light reflection direction, not the incoming direction.
  14938. */
  14939. direction: Vector3;
  14940. /**
  14941. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14942. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14943. * The HemisphericLight can't cast shadows.
  14944. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14945. * @param name The friendly name of the light
  14946. * @param direction The direction of the light reflection
  14947. * @param scene The scene the light belongs to
  14948. */
  14949. constructor(name: string, direction: Vector3, scene: Scene);
  14950. protected _buildUniformLayout(): void;
  14951. /**
  14952. * Returns the string "HemisphericLight".
  14953. * @return The class name
  14954. */
  14955. getClassName(): string;
  14956. /**
  14957. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14958. * Returns the updated direction.
  14959. * @param target The target the direction should point to
  14960. * @return The computed direction
  14961. */
  14962. setDirectionToTarget(target: Vector3): Vector3;
  14963. /**
  14964. * Returns the shadow generator associated to the light.
  14965. * @returns Always null for hemispheric lights because it does not support shadows.
  14966. */
  14967. getShadowGenerator(): Nullable<IShadowGenerator>;
  14968. /**
  14969. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14970. * @param effect The effect to update
  14971. * @param lightIndex The index of the light in the effect to update
  14972. * @returns The hemispheric light
  14973. */
  14974. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14975. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14976. /**
  14977. * Computes the world matrix of the node
  14978. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14979. * @param useWasUpdatedFlag defines a reserved property
  14980. * @returns the world matrix
  14981. */
  14982. computeWorldMatrix(): Matrix;
  14983. /**
  14984. * Returns the integer 3.
  14985. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14986. */
  14987. getTypeID(): number;
  14988. /**
  14989. * Prepares the list of defines specific to the light type.
  14990. * @param defines the list of defines
  14991. * @param lightIndex defines the index of the light for the effect
  14992. */
  14993. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14994. }
  14995. }
  14996. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14997. /** @hidden */
  14998. export var vrMultiviewToSingleviewPixelShader: {
  14999. name: string;
  15000. shader: string;
  15001. };
  15002. }
  15003. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15004. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15005. import { Scene } from "babylonjs/scene";
  15006. /**
  15007. * Renders to multiple views with a single draw call
  15008. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15009. */
  15010. export class MultiviewRenderTarget extends RenderTargetTexture {
  15011. /**
  15012. * Creates a multiview render target
  15013. * @param scene scene used with the render target
  15014. * @param size the size of the render target (used for each view)
  15015. */
  15016. constructor(scene: Scene, size?: number | {
  15017. width: number;
  15018. height: number;
  15019. } | {
  15020. ratio: number;
  15021. });
  15022. /**
  15023. * @hidden
  15024. * @param faceIndex the face index, if its a cube texture
  15025. */
  15026. _bindFrameBuffer(faceIndex?: number): void;
  15027. /**
  15028. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15029. * @returns the view count
  15030. */
  15031. getViewCount(): number;
  15032. }
  15033. }
  15034. declare module "babylonjs/Maths/math.frustum" {
  15035. import { Matrix } from "babylonjs/Maths/math.vector";
  15036. import { DeepImmutable } from "babylonjs/types";
  15037. import { Plane } from "babylonjs/Maths/math.plane";
  15038. /**
  15039. * Represents a camera frustum
  15040. */
  15041. export class Frustum {
  15042. /**
  15043. * Gets the planes representing the frustum
  15044. * @param transform matrix to be applied to the returned planes
  15045. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15046. */
  15047. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15048. /**
  15049. * Gets the near frustum plane transformed by the transform matrix
  15050. * @param transform transformation matrix to be applied to the resulting frustum plane
  15051. * @param frustumPlane the resuling frustum plane
  15052. */
  15053. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15054. /**
  15055. * Gets the far frustum plane transformed by the transform matrix
  15056. * @param transform transformation matrix to be applied to the resulting frustum plane
  15057. * @param frustumPlane the resuling frustum plane
  15058. */
  15059. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15060. /**
  15061. * Gets the left frustum plane transformed by the transform matrix
  15062. * @param transform transformation matrix to be applied to the resulting frustum plane
  15063. * @param frustumPlane the resuling frustum plane
  15064. */
  15065. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15066. /**
  15067. * Gets the right frustum plane transformed by the transform matrix
  15068. * @param transform transformation matrix to be applied to the resulting frustum plane
  15069. * @param frustumPlane the resuling frustum plane
  15070. */
  15071. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15072. /**
  15073. * Gets the top frustum plane transformed by the transform matrix
  15074. * @param transform transformation matrix to be applied to the resulting frustum plane
  15075. * @param frustumPlane the resuling frustum plane
  15076. */
  15077. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15078. /**
  15079. * Gets the bottom frustum plane transformed by the transform matrix
  15080. * @param transform transformation matrix to be applied to the resulting frustum plane
  15081. * @param frustumPlane the resuling frustum plane
  15082. */
  15083. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15084. /**
  15085. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15086. * @param transform transformation matrix to be applied to the resulting frustum planes
  15087. * @param frustumPlanes the resuling frustum planes
  15088. */
  15089. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15090. }
  15091. }
  15092. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15093. import { Camera } from "babylonjs/Cameras/camera";
  15094. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15095. import { Nullable } from "babylonjs/types";
  15096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15097. import { Matrix } from "babylonjs/Maths/math.vector";
  15098. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15099. module "babylonjs/Engines/engine" {
  15100. interface Engine {
  15101. /**
  15102. * Creates a new multiview render target
  15103. * @param width defines the width of the texture
  15104. * @param height defines the height of the texture
  15105. * @returns the created multiview texture
  15106. */
  15107. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15108. /**
  15109. * Binds a multiview framebuffer to be drawn to
  15110. * @param multiviewTexture texture to bind
  15111. */
  15112. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15113. }
  15114. }
  15115. module "babylonjs/Cameras/camera" {
  15116. interface Camera {
  15117. /**
  15118. * @hidden
  15119. * 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)
  15120. */
  15121. _useMultiviewToSingleView: boolean;
  15122. /**
  15123. * @hidden
  15124. * 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)
  15125. */
  15126. _multiviewTexture: Nullable<RenderTargetTexture>;
  15127. /**
  15128. * @hidden
  15129. * ensures the multiview texture of the camera exists and has the specified width/height
  15130. * @param width height to set on the multiview texture
  15131. * @param height width to set on the multiview texture
  15132. */
  15133. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15134. }
  15135. }
  15136. module "babylonjs/scene" {
  15137. interface Scene {
  15138. /** @hidden */
  15139. _transformMatrixR: Matrix;
  15140. /** @hidden */
  15141. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15142. /** @hidden */
  15143. _createMultiviewUbo(): void;
  15144. /** @hidden */
  15145. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15146. /** @hidden */
  15147. _renderMultiviewToSingleView(camera: Camera): void;
  15148. }
  15149. }
  15150. }
  15151. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15152. import { Camera } from "babylonjs/Cameras/camera";
  15153. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15154. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15155. import "babylonjs/Engines/Extensions/engine.multiview";
  15156. /**
  15157. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15158. * This will not be used for webXR as it supports displaying texture arrays directly
  15159. */
  15160. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15161. /**
  15162. * Initializes a VRMultiviewToSingleview
  15163. * @param name name of the post process
  15164. * @param camera camera to be applied to
  15165. * @param scaleFactor scaling factor to the size of the output texture
  15166. */
  15167. constructor(name: string, camera: Camera, scaleFactor: number);
  15168. }
  15169. }
  15170. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15171. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15172. import { Nullable } from "babylonjs/types";
  15173. import { Size } from "babylonjs/Maths/math.size";
  15174. import { Observable } from "babylonjs/Misc/observable";
  15175. module "babylonjs/Engines/engine" {
  15176. interface Engine {
  15177. /** @hidden */
  15178. _vrDisplay: any;
  15179. /** @hidden */
  15180. _vrSupported: boolean;
  15181. /** @hidden */
  15182. _oldSize: Size;
  15183. /** @hidden */
  15184. _oldHardwareScaleFactor: number;
  15185. /** @hidden */
  15186. _vrExclusivePointerMode: boolean;
  15187. /** @hidden */
  15188. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15189. /** @hidden */
  15190. _onVRDisplayPointerRestricted: () => void;
  15191. /** @hidden */
  15192. _onVRDisplayPointerUnrestricted: () => void;
  15193. /** @hidden */
  15194. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15195. /** @hidden */
  15196. _onVrDisplayDisconnect: Nullable<() => void>;
  15197. /** @hidden */
  15198. _onVrDisplayPresentChange: Nullable<() => void>;
  15199. /**
  15200. * Observable signaled when VR display mode changes
  15201. */
  15202. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15203. /**
  15204. * Observable signaled when VR request present is complete
  15205. */
  15206. onVRRequestPresentComplete: Observable<boolean>;
  15207. /**
  15208. * Observable signaled when VR request present starts
  15209. */
  15210. onVRRequestPresentStart: Observable<Engine>;
  15211. /**
  15212. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15213. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15214. */
  15215. isInVRExclusivePointerMode: boolean;
  15216. /**
  15217. * Gets a boolean indicating if a webVR device was detected
  15218. * @returns true if a webVR device was detected
  15219. */
  15220. isVRDevicePresent(): boolean;
  15221. /**
  15222. * Gets the current webVR device
  15223. * @returns the current webVR device (or null)
  15224. */
  15225. getVRDevice(): any;
  15226. /**
  15227. * Initializes a webVR display and starts listening to display change events
  15228. * The onVRDisplayChangedObservable will be notified upon these changes
  15229. * @returns A promise containing a VRDisplay and if vr is supported
  15230. */
  15231. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15232. /** @hidden */
  15233. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15234. /**
  15235. * Call this function to switch to webVR mode
  15236. * Will do nothing if webVR is not supported or if there is no webVR device
  15237. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15238. */
  15239. enableVR(): void;
  15240. /** @hidden */
  15241. _onVRFullScreenTriggered(): void;
  15242. }
  15243. }
  15244. }
  15245. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15246. import { Nullable } from "babylonjs/types";
  15247. import { Observable } from "babylonjs/Misc/observable";
  15248. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15249. import { Scene } from "babylonjs/scene";
  15250. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15251. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15252. import { Node } from "babylonjs/node";
  15253. import { Ray } from "babylonjs/Culling/ray";
  15254. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15255. import "babylonjs/Engines/Extensions/engine.webVR";
  15256. /**
  15257. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15258. * IMPORTANT!! The data is right-hand data.
  15259. * @export
  15260. * @interface DevicePose
  15261. */
  15262. export interface DevicePose {
  15263. /**
  15264. * The position of the device, values in array are [x,y,z].
  15265. */
  15266. readonly position: Nullable<Float32Array>;
  15267. /**
  15268. * The linearVelocity of the device, values in array are [x,y,z].
  15269. */
  15270. readonly linearVelocity: Nullable<Float32Array>;
  15271. /**
  15272. * The linearAcceleration of the device, values in array are [x,y,z].
  15273. */
  15274. readonly linearAcceleration: Nullable<Float32Array>;
  15275. /**
  15276. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15277. */
  15278. readonly orientation: Nullable<Float32Array>;
  15279. /**
  15280. * The angularVelocity of the device, values in array are [x,y,z].
  15281. */
  15282. readonly angularVelocity: Nullable<Float32Array>;
  15283. /**
  15284. * The angularAcceleration of the device, values in array are [x,y,z].
  15285. */
  15286. readonly angularAcceleration: Nullable<Float32Array>;
  15287. }
  15288. /**
  15289. * Interface representing a pose controlled object in Babylon.
  15290. * A pose controlled object has both regular pose values as well as pose values
  15291. * from an external device such as a VR head mounted display
  15292. */
  15293. export interface PoseControlled {
  15294. /**
  15295. * The position of the object in babylon space.
  15296. */
  15297. position: Vector3;
  15298. /**
  15299. * The rotation quaternion of the object in babylon space.
  15300. */
  15301. rotationQuaternion: Quaternion;
  15302. /**
  15303. * The position of the device in babylon space.
  15304. */
  15305. devicePosition?: Vector3;
  15306. /**
  15307. * The rotation quaternion of the device in babylon space.
  15308. */
  15309. deviceRotationQuaternion: Quaternion;
  15310. /**
  15311. * The raw pose coming from the device.
  15312. */
  15313. rawPose: Nullable<DevicePose>;
  15314. /**
  15315. * The scale of the device to be used when translating from device space to babylon space.
  15316. */
  15317. deviceScaleFactor: number;
  15318. /**
  15319. * Updates the poseControlled values based on the input device pose.
  15320. * @param poseData the pose data to update the object with
  15321. */
  15322. updateFromDevice(poseData: DevicePose): void;
  15323. }
  15324. /**
  15325. * Set of options to customize the webVRCamera
  15326. */
  15327. export interface WebVROptions {
  15328. /**
  15329. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15330. */
  15331. trackPosition?: boolean;
  15332. /**
  15333. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15334. */
  15335. positionScale?: number;
  15336. /**
  15337. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15338. */
  15339. displayName?: string;
  15340. /**
  15341. * Should the native controller meshes be initialized. (default: true)
  15342. */
  15343. controllerMeshes?: boolean;
  15344. /**
  15345. * Creating a default HemiLight only on controllers. (default: true)
  15346. */
  15347. defaultLightingOnControllers?: boolean;
  15348. /**
  15349. * If you don't want to use the default VR button of the helper. (default: false)
  15350. */
  15351. useCustomVRButton?: boolean;
  15352. /**
  15353. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15354. */
  15355. customVRButton?: HTMLButtonElement;
  15356. /**
  15357. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15358. */
  15359. rayLength?: number;
  15360. /**
  15361. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15362. */
  15363. defaultHeight?: number;
  15364. /**
  15365. * If multiview should be used if availible (default: false)
  15366. */
  15367. useMultiview?: boolean;
  15368. }
  15369. /**
  15370. * This represents a WebVR camera.
  15371. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15372. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15373. */
  15374. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15375. private webVROptions;
  15376. /**
  15377. * @hidden
  15378. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15379. */
  15380. _vrDevice: any;
  15381. /**
  15382. * The rawPose of the vrDevice.
  15383. */
  15384. rawPose: Nullable<DevicePose>;
  15385. private _onVREnabled;
  15386. private _specsVersion;
  15387. private _attached;
  15388. private _frameData;
  15389. protected _descendants: Array<Node>;
  15390. private _deviceRoomPosition;
  15391. /** @hidden */
  15392. _deviceRoomRotationQuaternion: Quaternion;
  15393. private _standingMatrix;
  15394. /**
  15395. * Represents device position in babylon space.
  15396. */
  15397. devicePosition: Vector3;
  15398. /**
  15399. * Represents device rotation in babylon space.
  15400. */
  15401. deviceRotationQuaternion: Quaternion;
  15402. /**
  15403. * The scale of the device to be used when translating from device space to babylon space.
  15404. */
  15405. deviceScaleFactor: number;
  15406. private _deviceToWorld;
  15407. private _worldToDevice;
  15408. /**
  15409. * References to the webVR controllers for the vrDevice.
  15410. */
  15411. controllers: Array<WebVRController>;
  15412. /**
  15413. * Emits an event when a controller is attached.
  15414. */
  15415. onControllersAttachedObservable: Observable<WebVRController[]>;
  15416. /**
  15417. * Emits an event when a controller's mesh has been loaded;
  15418. */
  15419. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15420. /**
  15421. * Emits an event when the HMD's pose has been updated.
  15422. */
  15423. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15424. private _poseSet;
  15425. /**
  15426. * If the rig cameras be used as parent instead of this camera.
  15427. */
  15428. rigParenting: boolean;
  15429. private _lightOnControllers;
  15430. private _defaultHeight?;
  15431. /**
  15432. * Instantiates a WebVRFreeCamera.
  15433. * @param name The name of the WebVRFreeCamera
  15434. * @param position The starting anchor position for the camera
  15435. * @param scene The scene the camera belongs to
  15436. * @param webVROptions a set of customizable options for the webVRCamera
  15437. */
  15438. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15439. /**
  15440. * Gets the device distance from the ground in meters.
  15441. * @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.
  15442. */
  15443. deviceDistanceToRoomGround(): number;
  15444. /**
  15445. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15446. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15447. */
  15448. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15449. /**
  15450. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15451. * @returns A promise with a boolean set to if the standing matrix is supported.
  15452. */
  15453. useStandingMatrixAsync(): Promise<boolean>;
  15454. /**
  15455. * Disposes the camera
  15456. */
  15457. dispose(): void;
  15458. /**
  15459. * Gets a vrController by name.
  15460. * @param name The name of the controller to retreive
  15461. * @returns the controller matching the name specified or null if not found
  15462. */
  15463. getControllerByName(name: string): Nullable<WebVRController>;
  15464. private _leftController;
  15465. /**
  15466. * The controller corresponding to the users left hand.
  15467. */
  15468. readonly leftController: Nullable<WebVRController>;
  15469. private _rightController;
  15470. /**
  15471. * The controller corresponding to the users right hand.
  15472. */
  15473. readonly rightController: Nullable<WebVRController>;
  15474. /**
  15475. * Casts a ray forward from the vrCamera's gaze.
  15476. * @param length Length of the ray (default: 100)
  15477. * @returns the ray corresponding to the gaze
  15478. */
  15479. getForwardRay(length?: number): Ray;
  15480. /**
  15481. * @hidden
  15482. * Updates the camera based on device's frame data
  15483. */
  15484. _checkInputs(): void;
  15485. /**
  15486. * Updates the poseControlled values based on the input device pose.
  15487. * @param poseData Pose coming from the device
  15488. */
  15489. updateFromDevice(poseData: DevicePose): void;
  15490. private _htmlElementAttached;
  15491. private _detachIfAttached;
  15492. /**
  15493. * WebVR's attach control will start broadcasting frames to the device.
  15494. * Note that in certain browsers (chrome for example) this function must be called
  15495. * within a user-interaction callback. Example:
  15496. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15497. *
  15498. * @param element html element to attach the vrDevice to
  15499. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15500. */
  15501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15502. /**
  15503. * Detaches the camera from the html element and disables VR
  15504. *
  15505. * @param element html element to detach from
  15506. */
  15507. detachControl(element: HTMLElement): void;
  15508. /**
  15509. * @returns the name of this class
  15510. */
  15511. getClassName(): string;
  15512. /**
  15513. * Calls resetPose on the vrDisplay
  15514. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15515. */
  15516. resetToCurrentRotation(): void;
  15517. /**
  15518. * @hidden
  15519. * Updates the rig cameras (left and right eye)
  15520. */
  15521. _updateRigCameras(): void;
  15522. private _workingVector;
  15523. private _oneVector;
  15524. private _workingMatrix;
  15525. private updateCacheCalled;
  15526. private _correctPositionIfNotTrackPosition;
  15527. /**
  15528. * @hidden
  15529. * Updates the cached values of the camera
  15530. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15531. */
  15532. _updateCache(ignoreParentClass?: boolean): void;
  15533. /**
  15534. * @hidden
  15535. * Get current device position in babylon world
  15536. */
  15537. _computeDevicePosition(): void;
  15538. /**
  15539. * Updates the current device position and rotation in the babylon world
  15540. */
  15541. update(): void;
  15542. /**
  15543. * @hidden
  15544. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15545. * @returns an identity matrix
  15546. */
  15547. _getViewMatrix(): Matrix;
  15548. private _tmpMatrix;
  15549. /**
  15550. * This function is called by the two RIG cameras.
  15551. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15552. * @hidden
  15553. */
  15554. _getWebVRViewMatrix(): Matrix;
  15555. /** @hidden */
  15556. _getWebVRProjectionMatrix(): Matrix;
  15557. private _onGamepadConnectedObserver;
  15558. private _onGamepadDisconnectedObserver;
  15559. private _updateCacheWhenTrackingDisabledObserver;
  15560. /**
  15561. * Initializes the controllers and their meshes
  15562. */
  15563. initControllers(): void;
  15564. }
  15565. }
  15566. declare module "babylonjs/PostProcesses/postProcess" {
  15567. import { Nullable } from "babylonjs/types";
  15568. import { SmartArray } from "babylonjs/Misc/smartArray";
  15569. import { Observable } from "babylonjs/Misc/observable";
  15570. import { Vector2 } from "babylonjs/Maths/math.vector";
  15571. import { Camera } from "babylonjs/Cameras/camera";
  15572. import { Effect } from "babylonjs/Materials/effect";
  15573. import "babylonjs/Shaders/postprocess.vertex";
  15574. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15575. import { Engine } from "babylonjs/Engines/engine";
  15576. import { Color4 } from "babylonjs/Maths/math.color";
  15577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15578. /**
  15579. * Size options for a post process
  15580. */
  15581. export type PostProcessOptions = {
  15582. width: number;
  15583. height: number;
  15584. };
  15585. /**
  15586. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15587. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15588. */
  15589. export class PostProcess {
  15590. /** Name of the PostProcess. */
  15591. name: string;
  15592. /**
  15593. * Gets or sets the unique id of the post process
  15594. */
  15595. uniqueId: number;
  15596. /**
  15597. * Width of the texture to apply the post process on
  15598. */
  15599. width: number;
  15600. /**
  15601. * Height of the texture to apply the post process on
  15602. */
  15603. height: number;
  15604. /**
  15605. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15606. * @hidden
  15607. */
  15608. _outputTexture: Nullable<InternalTexture>;
  15609. /**
  15610. * Sampling mode used by the shader
  15611. * See https://doc.babylonjs.com/classes/3.1/texture
  15612. */
  15613. renderTargetSamplingMode: number;
  15614. /**
  15615. * Clear color to use when screen clearing
  15616. */
  15617. clearColor: Color4;
  15618. /**
  15619. * If the buffer needs to be cleared before applying the post process. (default: true)
  15620. * Should be set to false if shader will overwrite all previous pixels.
  15621. */
  15622. autoClear: boolean;
  15623. /**
  15624. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15625. */
  15626. alphaMode: number;
  15627. /**
  15628. * Sets the setAlphaBlendConstants of the babylon engine
  15629. */
  15630. alphaConstants: Color4;
  15631. /**
  15632. * Animations to be used for the post processing
  15633. */
  15634. animations: import("babylonjs/Animations/animation").Animation[];
  15635. /**
  15636. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15637. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15638. */
  15639. enablePixelPerfectMode: boolean;
  15640. /**
  15641. * Force the postprocess to be applied without taking in account viewport
  15642. */
  15643. forceFullscreenViewport: boolean;
  15644. /**
  15645. * List of inspectable custom properties (used by the Inspector)
  15646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15647. */
  15648. inspectableCustomProperties: IInspectable[];
  15649. /**
  15650. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15651. *
  15652. * | Value | Type | Description |
  15653. * | ----- | ----------------------------------- | ----------- |
  15654. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15655. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15656. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15657. *
  15658. */
  15659. scaleMode: number;
  15660. /**
  15661. * Force textures to be a power of two (default: false)
  15662. */
  15663. alwaysForcePOT: boolean;
  15664. private _samples;
  15665. /**
  15666. * Number of sample textures (default: 1)
  15667. */
  15668. samples: number;
  15669. /**
  15670. * Modify the scale of the post process to be the same as the viewport (default: false)
  15671. */
  15672. adaptScaleToCurrentViewport: boolean;
  15673. private _camera;
  15674. private _scene;
  15675. private _engine;
  15676. private _options;
  15677. private _reusable;
  15678. private _textureType;
  15679. /**
  15680. * Smart array of input and output textures for the post process.
  15681. * @hidden
  15682. */
  15683. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15684. /**
  15685. * The index in _textures that corresponds to the output texture.
  15686. * @hidden
  15687. */
  15688. _currentRenderTextureInd: number;
  15689. private _effect;
  15690. private _samplers;
  15691. private _fragmentUrl;
  15692. private _vertexUrl;
  15693. private _parameters;
  15694. private _scaleRatio;
  15695. protected _indexParameters: any;
  15696. private _shareOutputWithPostProcess;
  15697. private _texelSize;
  15698. private _forcedOutputTexture;
  15699. /**
  15700. * Returns the fragment url or shader name used in the post process.
  15701. * @returns the fragment url or name in the shader store.
  15702. */
  15703. getEffectName(): string;
  15704. /**
  15705. * An event triggered when the postprocess is activated.
  15706. */
  15707. onActivateObservable: Observable<Camera>;
  15708. private _onActivateObserver;
  15709. /**
  15710. * A function that is added to the onActivateObservable
  15711. */
  15712. onActivate: Nullable<(camera: Camera) => void>;
  15713. /**
  15714. * An event triggered when the postprocess changes its size.
  15715. */
  15716. onSizeChangedObservable: Observable<PostProcess>;
  15717. private _onSizeChangedObserver;
  15718. /**
  15719. * A function that is added to the onSizeChangedObservable
  15720. */
  15721. onSizeChanged: (postProcess: PostProcess) => void;
  15722. /**
  15723. * An event triggered when the postprocess applies its effect.
  15724. */
  15725. onApplyObservable: Observable<Effect>;
  15726. private _onApplyObserver;
  15727. /**
  15728. * A function that is added to the onApplyObservable
  15729. */
  15730. onApply: (effect: Effect) => void;
  15731. /**
  15732. * An event triggered before rendering the postprocess
  15733. */
  15734. onBeforeRenderObservable: Observable<Effect>;
  15735. private _onBeforeRenderObserver;
  15736. /**
  15737. * A function that is added to the onBeforeRenderObservable
  15738. */
  15739. onBeforeRender: (effect: Effect) => void;
  15740. /**
  15741. * An event triggered after rendering the postprocess
  15742. */
  15743. onAfterRenderObservable: Observable<Effect>;
  15744. private _onAfterRenderObserver;
  15745. /**
  15746. * A function that is added to the onAfterRenderObservable
  15747. */
  15748. onAfterRender: (efect: Effect) => void;
  15749. /**
  15750. * 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
  15751. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15752. */
  15753. inputTexture: InternalTexture;
  15754. /**
  15755. * Gets the camera which post process is applied to.
  15756. * @returns The camera the post process is applied to.
  15757. */
  15758. getCamera(): Camera;
  15759. /**
  15760. * Gets the texel size of the postprocess.
  15761. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15762. */
  15763. readonly texelSize: Vector2;
  15764. /**
  15765. * Creates a new instance PostProcess
  15766. * @param name The name of the PostProcess.
  15767. * @param fragmentUrl The url of the fragment shader to be used.
  15768. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15769. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15770. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15771. * @param camera The camera to apply the render pass to.
  15772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15773. * @param engine The engine which the post process will be applied. (default: current engine)
  15774. * @param reusable If the post process can be reused on the same frame. (default: false)
  15775. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15776. * @param textureType Type of textures used when performing the post process. (default: 0)
  15777. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15778. * @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
  15779. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15780. */
  15781. constructor(
  15782. /** Name of the PostProcess. */
  15783. 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);
  15784. /**
  15785. * Gets a string idenfifying the name of the class
  15786. * @returns "PostProcess" string
  15787. */
  15788. getClassName(): string;
  15789. /**
  15790. * Gets the engine which this post process belongs to.
  15791. * @returns The engine the post process was enabled with.
  15792. */
  15793. getEngine(): Engine;
  15794. /**
  15795. * The effect that is created when initializing the post process.
  15796. * @returns The created effect corresponding the the postprocess.
  15797. */
  15798. getEffect(): Effect;
  15799. /**
  15800. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15801. * @param postProcess The post process to share the output with.
  15802. * @returns This post process.
  15803. */
  15804. shareOutputWith(postProcess: PostProcess): PostProcess;
  15805. /**
  15806. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15807. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15808. */
  15809. useOwnOutput(): void;
  15810. /**
  15811. * Updates the effect with the current post process compile time values and recompiles the shader.
  15812. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15813. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15814. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15815. * @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
  15816. * @param onCompiled Called when the shader has been compiled.
  15817. * @param onError Called if there is an error when compiling a shader.
  15818. */
  15819. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15820. /**
  15821. * The post process is reusable if it can be used multiple times within one frame.
  15822. * @returns If the post process is reusable
  15823. */
  15824. isReusable(): boolean;
  15825. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15826. markTextureDirty(): void;
  15827. /**
  15828. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15829. * 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.
  15830. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15831. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15832. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15833. * @returns The target texture that was bound to be written to.
  15834. */
  15835. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15836. /**
  15837. * If the post process is supported.
  15838. */
  15839. readonly isSupported: boolean;
  15840. /**
  15841. * The aspect ratio of the output texture.
  15842. */
  15843. readonly aspectRatio: number;
  15844. /**
  15845. * Get a value indicating if the post-process is ready to be used
  15846. * @returns true if the post-process is ready (shader is compiled)
  15847. */
  15848. isReady(): boolean;
  15849. /**
  15850. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15851. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15852. */
  15853. apply(): Nullable<Effect>;
  15854. private _disposeTextures;
  15855. /**
  15856. * Disposes the post process.
  15857. * @param camera The camera to dispose the post process on.
  15858. */
  15859. dispose(camera?: Camera): void;
  15860. }
  15861. }
  15862. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15863. /** @hidden */
  15864. export var kernelBlurVaryingDeclaration: {
  15865. name: string;
  15866. shader: string;
  15867. };
  15868. }
  15869. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15870. /** @hidden */
  15871. export var kernelBlurFragment: {
  15872. name: string;
  15873. shader: string;
  15874. };
  15875. }
  15876. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15877. /** @hidden */
  15878. export var kernelBlurFragment2: {
  15879. name: string;
  15880. shader: string;
  15881. };
  15882. }
  15883. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15884. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15885. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15886. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15887. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15888. /** @hidden */
  15889. export var kernelBlurPixelShader: {
  15890. name: string;
  15891. shader: string;
  15892. };
  15893. }
  15894. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15895. /** @hidden */
  15896. export var kernelBlurVertex: {
  15897. name: string;
  15898. shader: string;
  15899. };
  15900. }
  15901. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15902. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15903. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15904. /** @hidden */
  15905. export var kernelBlurVertexShader: {
  15906. name: string;
  15907. shader: string;
  15908. };
  15909. }
  15910. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15911. import { Vector2 } from "babylonjs/Maths/math.vector";
  15912. import { Nullable } from "babylonjs/types";
  15913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15914. import { Camera } from "babylonjs/Cameras/camera";
  15915. import { Effect } from "babylonjs/Materials/effect";
  15916. import { Engine } from "babylonjs/Engines/engine";
  15917. import "babylonjs/Shaders/kernelBlur.fragment";
  15918. import "babylonjs/Shaders/kernelBlur.vertex";
  15919. /**
  15920. * The Blur Post Process which blurs an image based on a kernel and direction.
  15921. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15922. */
  15923. export class BlurPostProcess extends PostProcess {
  15924. /** The direction in which to blur the image. */
  15925. direction: Vector2;
  15926. private blockCompilation;
  15927. protected _kernel: number;
  15928. protected _idealKernel: number;
  15929. protected _packedFloat: boolean;
  15930. private _staticDefines;
  15931. /**
  15932. * Sets the length in pixels of the blur sample region
  15933. */
  15934. /**
  15935. * Gets the length in pixels of the blur sample region
  15936. */
  15937. kernel: number;
  15938. /**
  15939. * Sets wether or not the blur needs to unpack/repack floats
  15940. */
  15941. /**
  15942. * Gets wether or not the blur is unpacking/repacking floats
  15943. */
  15944. packedFloat: boolean;
  15945. /**
  15946. * Creates a new instance BlurPostProcess
  15947. * @param name The name of the effect.
  15948. * @param direction The direction in which to blur the image.
  15949. * @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.
  15950. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15951. * @param camera The camera to apply the render pass to.
  15952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15953. * @param engine The engine which the post process will be applied. (default: current engine)
  15954. * @param reusable If the post process can be reused on the same frame. (default: false)
  15955. * @param textureType Type of textures used when performing the post process. (default: 0)
  15956. * @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)
  15957. */
  15958. constructor(name: string,
  15959. /** The direction in which to blur the image. */
  15960. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15961. /**
  15962. * Updates the effect with the current post process compile time values and recompiles the shader.
  15963. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15964. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15965. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15966. * @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
  15967. * @param onCompiled Called when the shader has been compiled.
  15968. * @param onError Called if there is an error when compiling a shader.
  15969. */
  15970. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15971. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15972. /**
  15973. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15974. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15975. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15976. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15977. * The gaps between physical kernels are compensated for in the weighting of the samples
  15978. * @param idealKernel Ideal blur kernel.
  15979. * @return Nearest best kernel.
  15980. */
  15981. protected _nearestBestKernel(idealKernel: number): number;
  15982. /**
  15983. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15984. * @param x The point on the Gaussian distribution to sample.
  15985. * @return the value of the Gaussian function at x.
  15986. */
  15987. protected _gaussianWeight(x: number): number;
  15988. /**
  15989. * Generates a string that can be used as a floating point number in GLSL.
  15990. * @param x Value to print.
  15991. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15992. * @return GLSL float string.
  15993. */
  15994. protected _glslFloat(x: number, decimalFigures?: number): string;
  15995. }
  15996. }
  15997. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15998. import { Scene } from "babylonjs/scene";
  15999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16000. import { Plane } from "babylonjs/Maths/math.plane";
  16001. /**
  16002. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16003. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16004. * You can then easily use it as a reflectionTexture on a flat surface.
  16005. * In case the surface is not a plane, please consider relying on reflection probes.
  16006. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16007. */
  16008. export class MirrorTexture extends RenderTargetTexture {
  16009. private scene;
  16010. /**
  16011. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16012. * 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.
  16013. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16014. */
  16015. mirrorPlane: Plane;
  16016. /**
  16017. * Define the blur ratio used to blur the reflection if needed.
  16018. */
  16019. blurRatio: number;
  16020. /**
  16021. * Define the adaptive blur kernel used to blur the reflection if needed.
  16022. * This will autocompute the closest best match for the `blurKernel`
  16023. */
  16024. adaptiveBlurKernel: number;
  16025. /**
  16026. * Define the blur kernel used to blur the reflection if needed.
  16027. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16028. */
  16029. blurKernel: number;
  16030. /**
  16031. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16032. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16033. */
  16034. blurKernelX: number;
  16035. /**
  16036. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16037. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16038. */
  16039. blurKernelY: number;
  16040. private _autoComputeBlurKernel;
  16041. protected _onRatioRescale(): void;
  16042. private _updateGammaSpace;
  16043. private _imageProcessingConfigChangeObserver;
  16044. private _transformMatrix;
  16045. private _mirrorMatrix;
  16046. private _savedViewMatrix;
  16047. private _blurX;
  16048. private _blurY;
  16049. private _adaptiveBlurKernel;
  16050. private _blurKernelX;
  16051. private _blurKernelY;
  16052. private _blurRatio;
  16053. /**
  16054. * Instantiates a Mirror Texture.
  16055. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16056. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16057. * You can then easily use it as a reflectionTexture on a flat surface.
  16058. * In case the surface is not a plane, please consider relying on reflection probes.
  16059. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16060. * @param name
  16061. * @param size
  16062. * @param scene
  16063. * @param generateMipMaps
  16064. * @param type
  16065. * @param samplingMode
  16066. * @param generateDepthBuffer
  16067. */
  16068. constructor(name: string, size: number | {
  16069. width: number;
  16070. height: number;
  16071. } | {
  16072. ratio: number;
  16073. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16074. private _preparePostProcesses;
  16075. /**
  16076. * Clone the mirror texture.
  16077. * @returns the cloned texture
  16078. */
  16079. clone(): MirrorTexture;
  16080. /**
  16081. * Serialize the texture to a JSON representation you could use in Parse later on
  16082. * @returns the serialized JSON representation
  16083. */
  16084. serialize(): any;
  16085. /**
  16086. * Dispose the texture and release its associated resources.
  16087. */
  16088. dispose(): void;
  16089. }
  16090. }
  16091. declare module "babylonjs/Materials/Textures/texture" {
  16092. import { Observable } from "babylonjs/Misc/observable";
  16093. import { Nullable } from "babylonjs/types";
  16094. import { Scene } from "babylonjs/scene";
  16095. import { Matrix } from "babylonjs/Maths/math.vector";
  16096. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16097. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16098. import { Engine } from "babylonjs/Engines/engine";
  16099. /**
  16100. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16101. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16102. */
  16103. export class Texture extends BaseTexture {
  16104. /**
  16105. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16106. */
  16107. static SerializeBuffers: boolean;
  16108. /** @hidden */
  16109. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16110. /** @hidden */
  16111. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16112. /** @hidden */
  16113. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16114. /** nearest is mag = nearest and min = nearest and mip = linear */
  16115. static readonly NEAREST_SAMPLINGMODE: number;
  16116. /** nearest is mag = nearest and min = nearest and mip = linear */
  16117. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16118. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16119. static readonly BILINEAR_SAMPLINGMODE: number;
  16120. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16121. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16122. /** Trilinear is mag = linear and min = linear and mip = linear */
  16123. static readonly TRILINEAR_SAMPLINGMODE: number;
  16124. /** Trilinear is mag = linear and min = linear and mip = linear */
  16125. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16126. /** mag = nearest and min = nearest and mip = nearest */
  16127. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16128. /** mag = nearest and min = linear and mip = nearest */
  16129. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16130. /** mag = nearest and min = linear and mip = linear */
  16131. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16132. /** mag = nearest and min = linear and mip = none */
  16133. static readonly NEAREST_LINEAR: number;
  16134. /** mag = nearest and min = nearest and mip = none */
  16135. static readonly NEAREST_NEAREST: number;
  16136. /** mag = linear and min = nearest and mip = nearest */
  16137. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16138. /** mag = linear and min = nearest and mip = linear */
  16139. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16140. /** mag = linear and min = linear and mip = none */
  16141. static readonly LINEAR_LINEAR: number;
  16142. /** mag = linear and min = nearest and mip = none */
  16143. static readonly LINEAR_NEAREST: number;
  16144. /** Explicit coordinates mode */
  16145. static readonly EXPLICIT_MODE: number;
  16146. /** Spherical coordinates mode */
  16147. static readonly SPHERICAL_MODE: number;
  16148. /** Planar coordinates mode */
  16149. static readonly PLANAR_MODE: number;
  16150. /** Cubic coordinates mode */
  16151. static readonly CUBIC_MODE: number;
  16152. /** Projection coordinates mode */
  16153. static readonly PROJECTION_MODE: number;
  16154. /** Inverse Cubic coordinates mode */
  16155. static readonly SKYBOX_MODE: number;
  16156. /** Inverse Cubic coordinates mode */
  16157. static readonly INVCUBIC_MODE: number;
  16158. /** Equirectangular coordinates mode */
  16159. static readonly EQUIRECTANGULAR_MODE: number;
  16160. /** Equirectangular Fixed coordinates mode */
  16161. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16162. /** Equirectangular Fixed Mirrored coordinates mode */
  16163. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16164. /** Texture is not repeating outside of 0..1 UVs */
  16165. static readonly CLAMP_ADDRESSMODE: number;
  16166. /** Texture is repeating outside of 0..1 UVs */
  16167. static readonly WRAP_ADDRESSMODE: number;
  16168. /** Texture is repeating and mirrored */
  16169. static readonly MIRROR_ADDRESSMODE: number;
  16170. /**
  16171. * 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
  16172. */
  16173. static UseSerializedUrlIfAny: boolean;
  16174. /**
  16175. * Define the url of the texture.
  16176. */
  16177. url: Nullable<string>;
  16178. /**
  16179. * Define an offset on the texture to offset the u coordinates of the UVs
  16180. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16181. */
  16182. uOffset: number;
  16183. /**
  16184. * Define an offset on the texture to offset the v coordinates of the UVs
  16185. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16186. */
  16187. vOffset: number;
  16188. /**
  16189. * Define an offset on the texture to scale the u coordinates of the UVs
  16190. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16191. */
  16192. uScale: number;
  16193. /**
  16194. * Define an offset on the texture to scale the v coordinates of the UVs
  16195. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16196. */
  16197. vScale: number;
  16198. /**
  16199. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16200. * @see http://doc.babylonjs.com/how_to/more_materials
  16201. */
  16202. uAng: number;
  16203. /**
  16204. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16205. * @see http://doc.babylonjs.com/how_to/more_materials
  16206. */
  16207. vAng: number;
  16208. /**
  16209. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16210. * @see http://doc.babylonjs.com/how_to/more_materials
  16211. */
  16212. wAng: number;
  16213. /**
  16214. * Defines the center of rotation (U)
  16215. */
  16216. uRotationCenter: number;
  16217. /**
  16218. * Defines the center of rotation (V)
  16219. */
  16220. vRotationCenter: number;
  16221. /**
  16222. * Defines the center of rotation (W)
  16223. */
  16224. wRotationCenter: number;
  16225. /**
  16226. * Are mip maps generated for this texture or not.
  16227. */
  16228. readonly noMipmap: boolean;
  16229. /**
  16230. * List of inspectable custom properties (used by the Inspector)
  16231. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16232. */
  16233. inspectableCustomProperties: Nullable<IInspectable[]>;
  16234. private _noMipmap;
  16235. /** @hidden */
  16236. _invertY: boolean;
  16237. private _rowGenerationMatrix;
  16238. private _cachedTextureMatrix;
  16239. private _projectionModeMatrix;
  16240. private _t0;
  16241. private _t1;
  16242. private _t2;
  16243. private _cachedUOffset;
  16244. private _cachedVOffset;
  16245. private _cachedUScale;
  16246. private _cachedVScale;
  16247. private _cachedUAng;
  16248. private _cachedVAng;
  16249. private _cachedWAng;
  16250. private _cachedProjectionMatrixId;
  16251. private _cachedCoordinatesMode;
  16252. /** @hidden */
  16253. protected _initialSamplingMode: number;
  16254. /** @hidden */
  16255. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16256. private _deleteBuffer;
  16257. protected _format: Nullable<number>;
  16258. private _delayedOnLoad;
  16259. private _delayedOnError;
  16260. /**
  16261. * Observable triggered once the texture has been loaded.
  16262. */
  16263. onLoadObservable: Observable<Texture>;
  16264. protected _isBlocking: boolean;
  16265. /**
  16266. * Is the texture preventing material to render while loading.
  16267. * If false, a default texture will be used instead of the loading one during the preparation step.
  16268. */
  16269. isBlocking: boolean;
  16270. /**
  16271. * Get the current sampling mode associated with the texture.
  16272. */
  16273. readonly samplingMode: number;
  16274. /**
  16275. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16276. */
  16277. readonly invertY: boolean;
  16278. /**
  16279. * Instantiates a new texture.
  16280. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16281. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16282. * @param url define the url of the picture to load as a texture
  16283. * @param scene define the scene or engine the texture will belong to
  16284. * @param noMipmap define if the texture will require mip maps or not
  16285. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16286. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16287. * @param onLoad define a callback triggered when the texture has been loaded
  16288. * @param onError define a callback triggered when an error occurred during the loading session
  16289. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16290. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16291. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16292. */
  16293. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16294. /**
  16295. * Update the url (and optional buffer) of this texture if url was null during construction.
  16296. * @param url the url of the texture
  16297. * @param buffer the buffer of the texture (defaults to null)
  16298. * @param onLoad callback called when the texture is loaded (defaults to null)
  16299. */
  16300. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16301. /**
  16302. * Finish the loading sequence of a texture flagged as delayed load.
  16303. * @hidden
  16304. */
  16305. delayLoad(): void;
  16306. private _prepareRowForTextureGeneration;
  16307. /**
  16308. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16309. * @returns the transform matrix of the texture.
  16310. */
  16311. getTextureMatrix(): Matrix;
  16312. /**
  16313. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16314. * @returns The reflection texture transform
  16315. */
  16316. getReflectionTextureMatrix(): Matrix;
  16317. /**
  16318. * Clones the texture.
  16319. * @returns the cloned texture
  16320. */
  16321. clone(): Texture;
  16322. /**
  16323. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16324. * @returns The JSON representation of the texture
  16325. */
  16326. serialize(): any;
  16327. /**
  16328. * Get the current class name of the texture useful for serialization or dynamic coding.
  16329. * @returns "Texture"
  16330. */
  16331. getClassName(): string;
  16332. /**
  16333. * Dispose the texture and release its associated resources.
  16334. */
  16335. dispose(): void;
  16336. /**
  16337. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16338. * @param parsedTexture Define the JSON representation of the texture
  16339. * @param scene Define the scene the parsed texture should be instantiated in
  16340. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16341. * @returns The parsed texture if successful
  16342. */
  16343. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16344. /**
  16345. * Creates a texture from its base 64 representation.
  16346. * @param data Define the base64 payload without the data: prefix
  16347. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16348. * @param scene Define the scene the texture should belong to
  16349. * @param noMipmap Forces the texture to not create mip map information if true
  16350. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16351. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16352. * @param onLoad define a callback triggered when the texture has been loaded
  16353. * @param onError define a callback triggered when an error occurred during the loading session
  16354. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16355. * @returns the created texture
  16356. */
  16357. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16358. /**
  16359. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16360. * @param data Define the base64 payload without the data: prefix
  16361. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16362. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16363. * @param scene Define the scene the texture should belong to
  16364. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16365. * @param noMipmap Forces the texture to not create mip map information if true
  16366. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16367. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16368. * @param onLoad define a callback triggered when the texture has been loaded
  16369. * @param onError define a callback triggered when an error occurred during the loading session
  16370. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16371. * @returns the created texture
  16372. */
  16373. 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;
  16374. }
  16375. }
  16376. declare module "babylonjs/PostProcesses/postProcessManager" {
  16377. import { Nullable } from "babylonjs/types";
  16378. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16379. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16380. import { Scene } from "babylonjs/scene";
  16381. /**
  16382. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16383. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16384. */
  16385. export class PostProcessManager {
  16386. private _scene;
  16387. private _indexBuffer;
  16388. private _vertexBuffers;
  16389. /**
  16390. * Creates a new instance PostProcess
  16391. * @param scene The scene that the post process is associated with.
  16392. */
  16393. constructor(scene: Scene);
  16394. private _prepareBuffers;
  16395. private _buildIndexBuffer;
  16396. /**
  16397. * Rebuilds the vertex buffers of the manager.
  16398. * @hidden
  16399. */
  16400. _rebuild(): void;
  16401. /**
  16402. * Prepares a frame to be run through a post process.
  16403. * @param sourceTexture The input texture to the post procesess. (default: null)
  16404. * @param postProcesses An array of post processes to be run. (default: null)
  16405. * @returns True if the post processes were able to be run.
  16406. * @hidden
  16407. */
  16408. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16409. /**
  16410. * Manually render a set of post processes to a texture.
  16411. * @param postProcesses An array of post processes to be run.
  16412. * @param targetTexture The target texture to render to.
  16413. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16414. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16415. * @param lodLevel defines which lod of the texture to render to
  16416. */
  16417. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16418. /**
  16419. * Finalize the result of the output of the postprocesses.
  16420. * @param doNotPresent If true the result will not be displayed to the screen.
  16421. * @param targetTexture The target texture to render to.
  16422. * @param faceIndex The index of the face to bind the target texture to.
  16423. * @param postProcesses The array of post processes to render.
  16424. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16425. * @hidden
  16426. */
  16427. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16428. /**
  16429. * Disposes of the post process manager.
  16430. */
  16431. dispose(): void;
  16432. }
  16433. }
  16434. declare module "babylonjs/Misc/gradients" {
  16435. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16436. /** Interface used by value gradients (color, factor, ...) */
  16437. export interface IValueGradient {
  16438. /**
  16439. * Gets or sets the gradient value (between 0 and 1)
  16440. */
  16441. gradient: number;
  16442. }
  16443. /** Class used to store color4 gradient */
  16444. export class ColorGradient implements IValueGradient {
  16445. /**
  16446. * Gets or sets the gradient value (between 0 and 1)
  16447. */
  16448. gradient: number;
  16449. /**
  16450. * Gets or sets first associated color
  16451. */
  16452. color1: Color4;
  16453. /**
  16454. * Gets or sets second associated color
  16455. */
  16456. color2?: Color4;
  16457. /**
  16458. * Will get a color picked randomly between color1 and color2.
  16459. * If color2 is undefined then color1 will be used
  16460. * @param result defines the target Color4 to store the result in
  16461. */
  16462. getColorToRef(result: Color4): void;
  16463. }
  16464. /** Class used to store color 3 gradient */
  16465. export class Color3Gradient implements IValueGradient {
  16466. /**
  16467. * Gets or sets the gradient value (between 0 and 1)
  16468. */
  16469. gradient: number;
  16470. /**
  16471. * Gets or sets the associated color
  16472. */
  16473. color: Color3;
  16474. }
  16475. /** Class used to store factor gradient */
  16476. export class FactorGradient implements IValueGradient {
  16477. /**
  16478. * Gets or sets the gradient value (between 0 and 1)
  16479. */
  16480. gradient: number;
  16481. /**
  16482. * Gets or sets first associated factor
  16483. */
  16484. factor1: number;
  16485. /**
  16486. * Gets or sets second associated factor
  16487. */
  16488. factor2?: number;
  16489. /**
  16490. * Will get a number picked randomly between factor1 and factor2.
  16491. * If factor2 is undefined then factor1 will be used
  16492. * @returns the picked number
  16493. */
  16494. getFactor(): number;
  16495. }
  16496. /**
  16497. * Helper used to simplify some generic gradient tasks
  16498. */
  16499. export class GradientHelper {
  16500. /**
  16501. * Gets the current gradient from an array of IValueGradient
  16502. * @param ratio defines the current ratio to get
  16503. * @param gradients defines the array of IValueGradient
  16504. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16505. */
  16506. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16507. }
  16508. }
  16509. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16511. import { Nullable } from "babylonjs/types";
  16512. module "babylonjs/Engines/thinEngine" {
  16513. interface ThinEngine {
  16514. /**
  16515. * Creates a dynamic texture
  16516. * @param width defines the width of the texture
  16517. * @param height defines the height of the texture
  16518. * @param generateMipMaps defines if the engine should generate the mip levels
  16519. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16520. * @returns the dynamic texture inside an InternalTexture
  16521. */
  16522. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16523. /**
  16524. * Update the content of a dynamic texture
  16525. * @param texture defines the texture to update
  16526. * @param canvas defines the canvas containing the source
  16527. * @param invertY defines if data must be stored with Y axis inverted
  16528. * @param premulAlpha defines if alpha is stored as premultiplied
  16529. * @param format defines the format of the data
  16530. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16531. */
  16532. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16533. }
  16534. }
  16535. }
  16536. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16537. import { Scene } from "babylonjs/scene";
  16538. import { Texture } from "babylonjs/Materials/Textures/texture";
  16539. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16540. /**
  16541. * A class extending Texture allowing drawing on a texture
  16542. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16543. */
  16544. export class DynamicTexture extends Texture {
  16545. private _generateMipMaps;
  16546. private _canvas;
  16547. private _context;
  16548. private _engine;
  16549. /**
  16550. * Creates a DynamicTexture
  16551. * @param name defines the name of the texture
  16552. * @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
  16553. * @param scene defines the scene where you want the texture
  16554. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16555. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16556. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16557. */
  16558. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16559. /**
  16560. * Get the current class name of the texture useful for serialization or dynamic coding.
  16561. * @returns "DynamicTexture"
  16562. */
  16563. getClassName(): string;
  16564. /**
  16565. * Gets the current state of canRescale
  16566. */
  16567. readonly canRescale: boolean;
  16568. private _recreate;
  16569. /**
  16570. * Scales the texture
  16571. * @param ratio the scale factor to apply to both width and height
  16572. */
  16573. scale(ratio: number): void;
  16574. /**
  16575. * Resizes the texture
  16576. * @param width the new width
  16577. * @param height the new height
  16578. */
  16579. scaleTo(width: number, height: number): void;
  16580. /**
  16581. * Gets the context of the canvas used by the texture
  16582. * @returns the canvas context of the dynamic texture
  16583. */
  16584. getContext(): CanvasRenderingContext2D;
  16585. /**
  16586. * Clears the texture
  16587. */
  16588. clear(): void;
  16589. /**
  16590. * Updates the texture
  16591. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16592. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16593. */
  16594. update(invertY?: boolean, premulAlpha?: boolean): void;
  16595. /**
  16596. * Draws text onto the texture
  16597. * @param text defines the text to be drawn
  16598. * @param x defines the placement of the text from the left
  16599. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16600. * @param font defines the font to be used with font-style, font-size, font-name
  16601. * @param color defines the color used for the text
  16602. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16603. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16604. * @param update defines whether texture is immediately update (default is true)
  16605. */
  16606. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16607. /**
  16608. * Clones the texture
  16609. * @returns the clone of the texture.
  16610. */
  16611. clone(): DynamicTexture;
  16612. /**
  16613. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16614. * @returns a serialized dynamic texture object
  16615. */
  16616. serialize(): any;
  16617. /** @hidden */
  16618. _rebuild(): void;
  16619. }
  16620. }
  16621. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16622. import { Scene } from "babylonjs/scene";
  16623. import { ISceneComponent } from "babylonjs/sceneComponent";
  16624. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16625. module "babylonjs/abstractScene" {
  16626. interface AbstractScene {
  16627. /**
  16628. * The list of procedural textures added to the scene
  16629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16630. */
  16631. proceduralTextures: Array<ProceduralTexture>;
  16632. }
  16633. }
  16634. /**
  16635. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16636. * in a given scene.
  16637. */
  16638. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16639. /**
  16640. * The component name helpfull to identify the component in the list of scene components.
  16641. */
  16642. readonly name: string;
  16643. /**
  16644. * The scene the component belongs to.
  16645. */
  16646. scene: Scene;
  16647. /**
  16648. * Creates a new instance of the component for the given scene
  16649. * @param scene Defines the scene to register the component in
  16650. */
  16651. constructor(scene: Scene);
  16652. /**
  16653. * Registers the component in a given scene
  16654. */
  16655. register(): void;
  16656. /**
  16657. * Rebuilds the elements related to this component in case of
  16658. * context lost for instance.
  16659. */
  16660. rebuild(): void;
  16661. /**
  16662. * Disposes the component and the associated ressources.
  16663. */
  16664. dispose(): void;
  16665. private _beforeClear;
  16666. }
  16667. }
  16668. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16669. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16670. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16671. module "babylonjs/Engines/thinEngine" {
  16672. interface ThinEngine {
  16673. /**
  16674. * Creates a new render target cube texture
  16675. * @param size defines the size of the texture
  16676. * @param options defines the options used to create the texture
  16677. * @returns a new render target cube texture stored in an InternalTexture
  16678. */
  16679. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16680. }
  16681. }
  16682. }
  16683. declare module "babylonjs/Shaders/procedural.vertex" {
  16684. /** @hidden */
  16685. export var proceduralVertexShader: {
  16686. name: string;
  16687. shader: string;
  16688. };
  16689. }
  16690. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16691. import { Observable } from "babylonjs/Misc/observable";
  16692. import { Nullable } from "babylonjs/types";
  16693. import { Scene } from "babylonjs/scene";
  16694. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16695. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16696. import { Effect } from "babylonjs/Materials/effect";
  16697. import { Texture } from "babylonjs/Materials/Textures/texture";
  16698. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16699. import "babylonjs/Shaders/procedural.vertex";
  16700. /**
  16701. * 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.
  16702. * This is the base class of any Procedural texture and contains most of the shareable code.
  16703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16704. */
  16705. export class ProceduralTexture extends Texture {
  16706. isCube: boolean;
  16707. /**
  16708. * Define if the texture is enabled or not (disabled texture will not render)
  16709. */
  16710. isEnabled: boolean;
  16711. /**
  16712. * Define if the texture must be cleared before rendering (default is true)
  16713. */
  16714. autoClear: boolean;
  16715. /**
  16716. * Callback called when the texture is generated
  16717. */
  16718. onGenerated: () => void;
  16719. /**
  16720. * Event raised when the texture is generated
  16721. */
  16722. onGeneratedObservable: Observable<ProceduralTexture>;
  16723. /** @hidden */
  16724. _generateMipMaps: boolean;
  16725. /** @hidden **/
  16726. _effect: Effect;
  16727. /** @hidden */
  16728. _textures: {
  16729. [key: string]: Texture;
  16730. };
  16731. private _size;
  16732. private _currentRefreshId;
  16733. private _refreshRate;
  16734. private _vertexBuffers;
  16735. private _indexBuffer;
  16736. private _uniforms;
  16737. private _samplers;
  16738. private _fragment;
  16739. private _floats;
  16740. private _ints;
  16741. private _floatsArrays;
  16742. private _colors3;
  16743. private _colors4;
  16744. private _vectors2;
  16745. private _vectors3;
  16746. private _matrices;
  16747. private _fallbackTexture;
  16748. private _fallbackTextureUsed;
  16749. private _engine;
  16750. private _cachedDefines;
  16751. private _contentUpdateId;
  16752. private _contentData;
  16753. /**
  16754. * Instantiates a new procedural texture.
  16755. * 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.
  16756. * This is the base class of any Procedural texture and contains most of the shareable code.
  16757. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16758. * @param name Define the name of the texture
  16759. * @param size Define the size of the texture to create
  16760. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16761. * @param scene Define the scene the texture belongs to
  16762. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16763. * @param generateMipMaps Define if the texture should creates mip maps or not
  16764. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16765. */
  16766. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16767. /**
  16768. * The effect that is created when initializing the post process.
  16769. * @returns The created effect corresponding the the postprocess.
  16770. */
  16771. getEffect(): Effect;
  16772. /**
  16773. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16774. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16775. */
  16776. getContent(): Nullable<ArrayBufferView>;
  16777. private _createIndexBuffer;
  16778. /** @hidden */
  16779. _rebuild(): void;
  16780. /**
  16781. * Resets the texture in order to recreate its associated resources.
  16782. * This can be called in case of context loss
  16783. */
  16784. reset(): void;
  16785. protected _getDefines(): string;
  16786. /**
  16787. * Is the texture ready to be used ? (rendered at least once)
  16788. * @returns true if ready, otherwise, false.
  16789. */
  16790. isReady(): boolean;
  16791. /**
  16792. * Resets the refresh counter of the texture and start bak from scratch.
  16793. * Could be useful to regenerate the texture if it is setup to render only once.
  16794. */
  16795. resetRefreshCounter(): void;
  16796. /**
  16797. * Set the fragment shader to use in order to render the texture.
  16798. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16799. */
  16800. setFragment(fragment: any): void;
  16801. /**
  16802. * Define the refresh rate of the texture or the rendering frequency.
  16803. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16804. */
  16805. refreshRate: number;
  16806. /** @hidden */
  16807. _shouldRender(): boolean;
  16808. /**
  16809. * Get the size the texture is rendering at.
  16810. * @returns the size (texture is always squared)
  16811. */
  16812. getRenderSize(): number;
  16813. /**
  16814. * Resize the texture to new value.
  16815. * @param size Define the new size the texture should have
  16816. * @param generateMipMaps Define whether the new texture should create mip maps
  16817. */
  16818. resize(size: number, generateMipMaps: boolean): void;
  16819. private _checkUniform;
  16820. /**
  16821. * Set a texture in the shader program used to render.
  16822. * @param name Define the name of the uniform samplers as defined in the shader
  16823. * @param texture Define the texture to bind to this sampler
  16824. * @return the texture itself allowing "fluent" like uniform updates
  16825. */
  16826. setTexture(name: string, texture: Texture): ProceduralTexture;
  16827. /**
  16828. * Set a float in the shader.
  16829. * @param name Define the name of the uniform as defined in the shader
  16830. * @param value Define the value to give to the uniform
  16831. * @return the texture itself allowing "fluent" like uniform updates
  16832. */
  16833. setFloat(name: string, value: number): ProceduralTexture;
  16834. /**
  16835. * Set a int in the shader.
  16836. * @param name Define the name of the uniform as defined in the shader
  16837. * @param value Define the value to give to the uniform
  16838. * @return the texture itself allowing "fluent" like uniform updates
  16839. */
  16840. setInt(name: string, value: number): ProceduralTexture;
  16841. /**
  16842. * Set an array of floats in the shader.
  16843. * @param name Define the name of the uniform as defined in the shader
  16844. * @param value Define the value to give to the uniform
  16845. * @return the texture itself allowing "fluent" like uniform updates
  16846. */
  16847. setFloats(name: string, value: number[]): ProceduralTexture;
  16848. /**
  16849. * Set a vec3 in the shader from a Color3.
  16850. * @param name Define the name of the uniform as defined in the shader
  16851. * @param value Define the value to give to the uniform
  16852. * @return the texture itself allowing "fluent" like uniform updates
  16853. */
  16854. setColor3(name: string, value: Color3): ProceduralTexture;
  16855. /**
  16856. * Set a vec4 in the shader from a Color4.
  16857. * @param name Define the name of the uniform as defined in the shader
  16858. * @param value Define the value to give to the uniform
  16859. * @return the texture itself allowing "fluent" like uniform updates
  16860. */
  16861. setColor4(name: string, value: Color4): ProceduralTexture;
  16862. /**
  16863. * Set a vec2 in the shader from a Vector2.
  16864. * @param name Define the name of the uniform as defined in the shader
  16865. * @param value Define the value to give to the uniform
  16866. * @return the texture itself allowing "fluent" like uniform updates
  16867. */
  16868. setVector2(name: string, value: Vector2): ProceduralTexture;
  16869. /**
  16870. * Set a vec3 in the shader from a Vector3.
  16871. * @param name Define the name of the uniform as defined in the shader
  16872. * @param value Define the value to give to the uniform
  16873. * @return the texture itself allowing "fluent" like uniform updates
  16874. */
  16875. setVector3(name: string, value: Vector3): ProceduralTexture;
  16876. /**
  16877. * Set a mat4 in the shader from a MAtrix.
  16878. * @param name Define the name of the uniform as defined in the shader
  16879. * @param value Define the value to give to the uniform
  16880. * @return the texture itself allowing "fluent" like uniform updates
  16881. */
  16882. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16883. /**
  16884. * Render the texture to its associated render target.
  16885. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16886. */
  16887. render(useCameraPostProcess?: boolean): void;
  16888. /**
  16889. * Clone the texture.
  16890. * @returns the cloned texture
  16891. */
  16892. clone(): ProceduralTexture;
  16893. /**
  16894. * Dispose the texture and release its asoociated resources.
  16895. */
  16896. dispose(): void;
  16897. }
  16898. }
  16899. declare module "babylonjs/Particles/baseParticleSystem" {
  16900. import { Nullable } from "babylonjs/types";
  16901. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16903. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16904. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16905. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16906. import { Scene } from "babylonjs/scene";
  16907. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16908. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16909. import { Texture } from "babylonjs/Materials/Textures/texture";
  16910. import { Color4 } from "babylonjs/Maths/math.color";
  16911. import { Animation } from "babylonjs/Animations/animation";
  16912. /**
  16913. * This represents the base class for particle system in Babylon.
  16914. * 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.
  16915. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16916. * @example https://doc.babylonjs.com/babylon101/particles
  16917. */
  16918. export class BaseParticleSystem {
  16919. /**
  16920. * Source color is added to the destination color without alpha affecting the result
  16921. */
  16922. static BLENDMODE_ONEONE: number;
  16923. /**
  16924. * Blend current color and particle color using particle’s alpha
  16925. */
  16926. static BLENDMODE_STANDARD: number;
  16927. /**
  16928. * Add current color and particle color multiplied by particle’s alpha
  16929. */
  16930. static BLENDMODE_ADD: number;
  16931. /**
  16932. * Multiply current color with particle color
  16933. */
  16934. static BLENDMODE_MULTIPLY: number;
  16935. /**
  16936. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16937. */
  16938. static BLENDMODE_MULTIPLYADD: number;
  16939. /**
  16940. * List of animations used by the particle system.
  16941. */
  16942. animations: Animation[];
  16943. /**
  16944. * The id of the Particle system.
  16945. */
  16946. id: string;
  16947. /**
  16948. * The friendly name of the Particle system.
  16949. */
  16950. name: string;
  16951. /**
  16952. * The rendering group used by the Particle system to chose when to render.
  16953. */
  16954. renderingGroupId: number;
  16955. /**
  16956. * The emitter represents the Mesh or position we are attaching the particle system to.
  16957. */
  16958. emitter: Nullable<AbstractMesh | Vector3>;
  16959. /**
  16960. * The maximum number of particles to emit per frame
  16961. */
  16962. emitRate: number;
  16963. /**
  16964. * If you want to launch only a few particles at once, that can be done, as well.
  16965. */
  16966. manualEmitCount: number;
  16967. /**
  16968. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16969. */
  16970. updateSpeed: number;
  16971. /**
  16972. * The amount of time the particle system is running (depends of the overall update speed).
  16973. */
  16974. targetStopDuration: number;
  16975. /**
  16976. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16977. */
  16978. disposeOnStop: boolean;
  16979. /**
  16980. * Minimum power of emitting particles.
  16981. */
  16982. minEmitPower: number;
  16983. /**
  16984. * Maximum power of emitting particles.
  16985. */
  16986. maxEmitPower: number;
  16987. /**
  16988. * Minimum life time of emitting particles.
  16989. */
  16990. minLifeTime: number;
  16991. /**
  16992. * Maximum life time of emitting particles.
  16993. */
  16994. maxLifeTime: number;
  16995. /**
  16996. * Minimum Size of emitting particles.
  16997. */
  16998. minSize: number;
  16999. /**
  17000. * Maximum Size of emitting particles.
  17001. */
  17002. maxSize: number;
  17003. /**
  17004. * Minimum scale of emitting particles on X axis.
  17005. */
  17006. minScaleX: number;
  17007. /**
  17008. * Maximum scale of emitting particles on X axis.
  17009. */
  17010. maxScaleX: number;
  17011. /**
  17012. * Minimum scale of emitting particles on Y axis.
  17013. */
  17014. minScaleY: number;
  17015. /**
  17016. * Maximum scale of emitting particles on Y axis.
  17017. */
  17018. maxScaleY: number;
  17019. /**
  17020. * Gets or sets the minimal initial rotation in radians.
  17021. */
  17022. minInitialRotation: number;
  17023. /**
  17024. * Gets or sets the maximal initial rotation in radians.
  17025. */
  17026. maxInitialRotation: number;
  17027. /**
  17028. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17029. */
  17030. minAngularSpeed: number;
  17031. /**
  17032. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17033. */
  17034. maxAngularSpeed: number;
  17035. /**
  17036. * The texture used to render each particle. (this can be a spritesheet)
  17037. */
  17038. particleTexture: Nullable<Texture>;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * This can help using your own shader to render the particle system.
  17045. * The according effect will be created
  17046. */
  17047. customShader: any;
  17048. /**
  17049. * By default particle system starts as soon as they are created. This prevents the
  17050. * automatic start to happen and let you decide when to start emitting particles.
  17051. */
  17052. preventAutoStart: boolean;
  17053. private _noiseTexture;
  17054. /**
  17055. * Gets or sets a texture used to add random noise to particle positions
  17056. */
  17057. noiseTexture: Nullable<ProceduralTexture>;
  17058. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17059. noiseStrength: Vector3;
  17060. /**
  17061. * Callback triggered when the particle animation is ending.
  17062. */
  17063. onAnimationEnd: Nullable<() => void>;
  17064. /**
  17065. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17066. */
  17067. blendMode: number;
  17068. /**
  17069. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17070. * to override the particles.
  17071. */
  17072. forceDepthWrite: boolean;
  17073. /** 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 */
  17074. preWarmCycles: number;
  17075. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17076. preWarmStepOffset: number;
  17077. /**
  17078. * 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)
  17079. */
  17080. spriteCellChangeSpeed: number;
  17081. /**
  17082. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17083. */
  17084. startSpriteCellID: number;
  17085. /**
  17086. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17087. */
  17088. endSpriteCellID: number;
  17089. /**
  17090. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17091. */
  17092. spriteCellWidth: number;
  17093. /**
  17094. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17095. */
  17096. spriteCellHeight: number;
  17097. /**
  17098. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17099. */
  17100. spriteRandomStartCell: boolean;
  17101. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17102. translationPivot: Vector2;
  17103. /** @hidden */
  17104. protected _isAnimationSheetEnabled: boolean;
  17105. /**
  17106. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17107. */
  17108. beginAnimationOnStart: boolean;
  17109. /**
  17110. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17111. */
  17112. beginAnimationFrom: number;
  17113. /**
  17114. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17115. */
  17116. beginAnimationTo: number;
  17117. /**
  17118. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17119. */
  17120. beginAnimationLoop: boolean;
  17121. /**
  17122. * Gets or sets a world offset applied to all particles
  17123. */
  17124. worldOffset: Vector3;
  17125. /**
  17126. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17127. */
  17128. isAnimationSheetEnabled: boolean;
  17129. /**
  17130. * Get hosting scene
  17131. * @returns the scene
  17132. */
  17133. getScene(): Scene;
  17134. /**
  17135. * You can use gravity if you want to give an orientation to your particles.
  17136. */
  17137. gravity: Vector3;
  17138. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17139. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17140. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17141. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17142. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17143. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17144. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17145. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17146. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17147. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17148. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17149. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17150. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17151. /**
  17152. * Defines the delay in milliseconds before starting the system (0 by default)
  17153. */
  17154. startDelay: number;
  17155. /**
  17156. * Gets the current list of drag gradients.
  17157. * You must use addDragGradient and removeDragGradient to udpate this list
  17158. * @returns the list of drag gradients
  17159. */
  17160. getDragGradients(): Nullable<Array<FactorGradient>>;
  17161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17162. limitVelocityDamping: number;
  17163. /**
  17164. * Gets the current list of limit velocity gradients.
  17165. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17166. * @returns the list of limit velocity gradients
  17167. */
  17168. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17169. /**
  17170. * Gets the current list of color gradients.
  17171. * You must use addColorGradient and removeColorGradient to udpate this list
  17172. * @returns the list of color gradients
  17173. */
  17174. getColorGradients(): Nullable<Array<ColorGradient>>;
  17175. /**
  17176. * Gets the current list of size gradients.
  17177. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17178. * @returns the list of size gradients
  17179. */
  17180. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17181. /**
  17182. * Gets the current list of color remap gradients.
  17183. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17184. * @returns the list of color remap gradients
  17185. */
  17186. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17187. /**
  17188. * Gets the current list of alpha remap gradients.
  17189. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17190. * @returns the list of alpha remap gradients
  17191. */
  17192. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17193. /**
  17194. * Gets the current list of life time gradients.
  17195. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17196. * @returns the list of life time gradients
  17197. */
  17198. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17199. /**
  17200. * Gets the current list of angular speed gradients.
  17201. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17202. * @returns the list of angular speed gradients
  17203. */
  17204. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17205. /**
  17206. * Gets the current list of velocity gradients.
  17207. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17208. * @returns the list of velocity gradients
  17209. */
  17210. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17211. /**
  17212. * Gets the current list of start size gradients.
  17213. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17214. * @returns the list of start size gradients
  17215. */
  17216. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17217. /**
  17218. * Gets the current list of emit rate gradients.
  17219. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17220. * @returns the list of emit rate gradients
  17221. */
  17222. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17223. /**
  17224. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17225. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17226. */
  17227. direction1: Vector3;
  17228. /**
  17229. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17230. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17231. */
  17232. direction2: Vector3;
  17233. /**
  17234. * 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.
  17235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17236. */
  17237. minEmitBox: Vector3;
  17238. /**
  17239. * 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.
  17240. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17241. */
  17242. maxEmitBox: Vector3;
  17243. /**
  17244. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17245. */
  17246. color1: Color4;
  17247. /**
  17248. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17249. */
  17250. color2: Color4;
  17251. /**
  17252. * Color the particle will have at the end of its lifetime
  17253. */
  17254. colorDead: Color4;
  17255. /**
  17256. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17257. */
  17258. textureMask: Color4;
  17259. /**
  17260. * The particle emitter type defines the emitter used by the particle system.
  17261. * It can be for example box, sphere, or cone...
  17262. */
  17263. particleEmitterType: IParticleEmitterType;
  17264. /** @hidden */
  17265. _isSubEmitter: boolean;
  17266. /**
  17267. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17268. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17269. */
  17270. billboardMode: number;
  17271. protected _isBillboardBased: boolean;
  17272. /**
  17273. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17274. */
  17275. isBillboardBased: boolean;
  17276. /**
  17277. * The scene the particle system belongs to.
  17278. */
  17279. protected _scene: Scene;
  17280. /**
  17281. * Local cache of defines for image processing.
  17282. */
  17283. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17284. /**
  17285. * Default configuration related to image processing available in the standard Material.
  17286. */
  17287. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17288. /**
  17289. * Gets the image processing configuration used either in this material.
  17290. */
  17291. /**
  17292. * Sets the Default image processing configuration used either in the this material.
  17293. *
  17294. * If sets to null, the scene one is in use.
  17295. */
  17296. imageProcessingConfiguration: ImageProcessingConfiguration;
  17297. /**
  17298. * Attaches a new image processing configuration to the Standard Material.
  17299. * @param configuration
  17300. */
  17301. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17302. /** @hidden */
  17303. protected _reset(): void;
  17304. /** @hidden */
  17305. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17306. /**
  17307. * Instantiates a particle system.
  17308. * 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.
  17309. * @param name The name of the particle system
  17310. */
  17311. constructor(name: string);
  17312. /**
  17313. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17316. * @returns the emitter
  17317. */
  17318. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17319. /**
  17320. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17321. * @param radius The radius of the hemisphere to emit from
  17322. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17323. * @returns the emitter
  17324. */
  17325. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17326. /**
  17327. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17328. * @param radius The radius of the sphere to emit from
  17329. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17330. * @returns the emitter
  17331. */
  17332. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17333. /**
  17334. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17335. * @param radius The radius of the sphere to emit from
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17338. * @returns the emitter
  17339. */
  17340. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17341. /**
  17342. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17343. * @param radius The radius of the emission cylinder
  17344. * @param height The height of the emission cylinder
  17345. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17346. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17347. * @returns the emitter
  17348. */
  17349. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17350. /**
  17351. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17352. * @param radius The radius of the cylinder to emit from
  17353. * @param height The height of the emission cylinder
  17354. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17355. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17356. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17357. * @returns the emitter
  17358. */
  17359. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17360. /**
  17361. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17362. * @param radius The radius of the cone to emit from
  17363. * @param angle The base angle of the cone
  17364. * @returns the emitter
  17365. */
  17366. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17367. /**
  17368. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17371. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17372. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17373. * @returns the emitter
  17374. */
  17375. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17376. }
  17377. }
  17378. declare module "babylonjs/Particles/subEmitter" {
  17379. import { Scene } from "babylonjs/scene";
  17380. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17381. /**
  17382. * Type of sub emitter
  17383. */
  17384. export enum SubEmitterType {
  17385. /**
  17386. * Attached to the particle over it's lifetime
  17387. */
  17388. ATTACHED = 0,
  17389. /**
  17390. * Created when the particle dies
  17391. */
  17392. END = 1
  17393. }
  17394. /**
  17395. * Sub emitter class used to emit particles from an existing particle
  17396. */
  17397. export class SubEmitter {
  17398. /**
  17399. * the particle system to be used by the sub emitter
  17400. */
  17401. particleSystem: ParticleSystem;
  17402. /**
  17403. * Type of the submitter (Default: END)
  17404. */
  17405. type: SubEmitterType;
  17406. /**
  17407. * 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)
  17408. * Note: This only is supported when using an emitter of type Mesh
  17409. */
  17410. inheritDirection: boolean;
  17411. /**
  17412. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17413. */
  17414. inheritedVelocityAmount: number;
  17415. /**
  17416. * Creates a sub emitter
  17417. * @param particleSystem the particle system to be used by the sub emitter
  17418. */
  17419. constructor(
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem);
  17424. /**
  17425. * Clones the sub emitter
  17426. * @returns the cloned sub emitter
  17427. */
  17428. clone(): SubEmitter;
  17429. /**
  17430. * Serialize current object to a JSON object
  17431. * @returns the serialized object
  17432. */
  17433. serialize(): any;
  17434. /** @hidden */
  17435. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17436. /**
  17437. * Creates a new SubEmitter from a serialized JSON version
  17438. * @param serializationObject defines the JSON object to read from
  17439. * @param scene defines the hosting scene
  17440. * @param rootUrl defines the rootUrl for data loading
  17441. * @returns a new SubEmitter
  17442. */
  17443. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17444. /** Release associated resources */
  17445. dispose(): void;
  17446. }
  17447. }
  17448. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17449. /** @hidden */
  17450. export var clipPlaneFragmentDeclaration: {
  17451. name: string;
  17452. shader: string;
  17453. };
  17454. }
  17455. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17456. /** @hidden */
  17457. export var imageProcessingDeclaration: {
  17458. name: string;
  17459. shader: string;
  17460. };
  17461. }
  17462. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17463. /** @hidden */
  17464. export var imageProcessingFunctions: {
  17465. name: string;
  17466. shader: string;
  17467. };
  17468. }
  17469. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17470. /** @hidden */
  17471. export var clipPlaneFragment: {
  17472. name: string;
  17473. shader: string;
  17474. };
  17475. }
  17476. declare module "babylonjs/Shaders/particles.fragment" {
  17477. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17478. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17479. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17480. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17481. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17482. /** @hidden */
  17483. export var particlesPixelShader: {
  17484. name: string;
  17485. shader: string;
  17486. };
  17487. }
  17488. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17489. /** @hidden */
  17490. export var clipPlaneVertexDeclaration: {
  17491. name: string;
  17492. shader: string;
  17493. };
  17494. }
  17495. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17496. /** @hidden */
  17497. export var clipPlaneVertex: {
  17498. name: string;
  17499. shader: string;
  17500. };
  17501. }
  17502. declare module "babylonjs/Shaders/particles.vertex" {
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17505. /** @hidden */
  17506. export var particlesVertexShader: {
  17507. name: string;
  17508. shader: string;
  17509. };
  17510. }
  17511. declare module "babylonjs/Particles/particleSystem" {
  17512. import { Nullable } from "babylonjs/types";
  17513. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17514. import { Observable } from "babylonjs/Misc/observable";
  17515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17516. import { Effect } from "babylonjs/Materials/effect";
  17517. import { Scene, IDisposable } from "babylonjs/scene";
  17518. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17519. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17520. import { Particle } from "babylonjs/Particles/particle";
  17521. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17522. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17523. import "babylonjs/Shaders/particles.fragment";
  17524. import "babylonjs/Shaders/particles.vertex";
  17525. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17526. /**
  17527. * This represents a particle system in Babylon.
  17528. * 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.
  17529. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17530. * @example https://doc.babylonjs.com/babylon101/particles
  17531. */
  17532. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17533. /**
  17534. * Billboard mode will only apply to Y axis
  17535. */
  17536. static readonly BILLBOARDMODE_Y: number;
  17537. /**
  17538. * Billboard mode will apply to all axes
  17539. */
  17540. static readonly BILLBOARDMODE_ALL: number;
  17541. /**
  17542. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17543. */
  17544. static readonly BILLBOARDMODE_STRETCHED: number;
  17545. /**
  17546. * This function can be defined to provide custom update for active particles.
  17547. * This function will be called instead of regular update (age, position, color, etc.).
  17548. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17549. */
  17550. updateFunction: (particles: Particle[]) => void;
  17551. private _emitterWorldMatrix;
  17552. /**
  17553. * This function can be defined to specify initial direction for every new particle.
  17554. * It by default use the emitterType defined function
  17555. */
  17556. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17557. /**
  17558. * This function can be defined to specify initial position for every new particle.
  17559. * It by default use the emitterType defined function
  17560. */
  17561. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17562. /**
  17563. * @hidden
  17564. */
  17565. _inheritedVelocityOffset: Vector3;
  17566. /**
  17567. * An event triggered when the system is disposed
  17568. */
  17569. onDisposeObservable: Observable<ParticleSystem>;
  17570. private _onDisposeObserver;
  17571. /**
  17572. * Sets a callback that will be triggered when the system is disposed
  17573. */
  17574. onDispose: () => void;
  17575. private _particles;
  17576. private _epsilon;
  17577. private _capacity;
  17578. private _stockParticles;
  17579. private _newPartsExcess;
  17580. private _vertexData;
  17581. private _vertexBuffer;
  17582. private _vertexBuffers;
  17583. private _spriteBuffer;
  17584. private _indexBuffer;
  17585. private _effect;
  17586. private _customEffect;
  17587. private _cachedDefines;
  17588. private _scaledColorStep;
  17589. private _colorDiff;
  17590. private _scaledDirection;
  17591. private _scaledGravity;
  17592. private _currentRenderId;
  17593. private _alive;
  17594. private _useInstancing;
  17595. private _started;
  17596. private _stopped;
  17597. private _actualFrame;
  17598. private _scaledUpdateSpeed;
  17599. private _vertexBufferSize;
  17600. /** @hidden */
  17601. _currentEmitRateGradient: Nullable<FactorGradient>;
  17602. /** @hidden */
  17603. _currentEmitRate1: number;
  17604. /** @hidden */
  17605. _currentEmitRate2: number;
  17606. /** @hidden */
  17607. _currentStartSizeGradient: Nullable<FactorGradient>;
  17608. /** @hidden */
  17609. _currentStartSize1: number;
  17610. /** @hidden */
  17611. _currentStartSize2: number;
  17612. private readonly _rawTextureWidth;
  17613. private _rampGradientsTexture;
  17614. private _useRampGradients;
  17615. /** Gets or sets a boolean indicating that ramp gradients must be used
  17616. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17617. */
  17618. useRampGradients: boolean;
  17619. /**
  17620. * 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.
  17621. * 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: [])
  17622. */
  17623. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17624. private _subEmitters;
  17625. /**
  17626. * @hidden
  17627. * If the particle systems emitter should be disposed when the particle system is disposed
  17628. */
  17629. _disposeEmitterOnDispose: boolean;
  17630. /**
  17631. * The current active Sub-systems, this property is used by the root particle system only.
  17632. */
  17633. activeSubSystems: Array<ParticleSystem>;
  17634. private _rootParticleSystem;
  17635. /**
  17636. * Gets the current list of active particles
  17637. */
  17638. readonly particles: Particle[];
  17639. /**
  17640. * Returns the string "ParticleSystem"
  17641. * @returns a string containing the class name
  17642. */
  17643. getClassName(): string;
  17644. /**
  17645. * Instantiates a particle system.
  17646. * 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.
  17647. * @param name The name of the particle system
  17648. * @param capacity The max number of particles alive at the same time
  17649. * @param scene The scene the particle system belongs to
  17650. * @param customEffect a custom effect used to change the way particles are rendered by default
  17651. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17652. * @param epsilon Offset used to render the particles
  17653. */
  17654. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17655. private _addFactorGradient;
  17656. private _removeFactorGradient;
  17657. /**
  17658. * Adds a new life time gradient
  17659. * @param gradient defines the gradient to use (between 0 and 1)
  17660. * @param factor defines the life time factor to affect to the specified gradient
  17661. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17662. * @returns the current particle system
  17663. */
  17664. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17665. /**
  17666. * Remove a specific life time gradient
  17667. * @param gradient defines the gradient to remove
  17668. * @returns the current particle system
  17669. */
  17670. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17671. /**
  17672. * Adds a new size gradient
  17673. * @param gradient defines the gradient to use (between 0 and 1)
  17674. * @param factor defines the size factor to affect to the specified gradient
  17675. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17676. * @returns the current particle system
  17677. */
  17678. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17679. /**
  17680. * Remove a specific size gradient
  17681. * @param gradient defines the gradient to remove
  17682. * @returns the current particle system
  17683. */
  17684. removeSizeGradient(gradient: number): IParticleSystem;
  17685. /**
  17686. * Adds a new color remap gradient
  17687. * @param gradient defines the gradient to use (between 0 and 1)
  17688. * @param min defines the color remap minimal range
  17689. * @param max defines the color remap maximal range
  17690. * @returns the current particle system
  17691. */
  17692. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17693. /**
  17694. * Remove a specific color remap gradient
  17695. * @param gradient defines the gradient to remove
  17696. * @returns the current particle system
  17697. */
  17698. removeColorRemapGradient(gradient: number): IParticleSystem;
  17699. /**
  17700. * Adds a new alpha remap gradient
  17701. * @param gradient defines the gradient to use (between 0 and 1)
  17702. * @param min defines the alpha remap minimal range
  17703. * @param max defines the alpha remap maximal range
  17704. * @returns the current particle system
  17705. */
  17706. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17707. /**
  17708. * Remove a specific alpha remap gradient
  17709. * @param gradient defines the gradient to remove
  17710. * @returns the current particle system
  17711. */
  17712. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17713. /**
  17714. * Adds a new angular speed gradient
  17715. * @param gradient defines the gradient to use (between 0 and 1)
  17716. * @param factor defines the angular speed to affect to the specified gradient
  17717. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17718. * @returns the current particle system
  17719. */
  17720. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17721. /**
  17722. * Remove a specific angular speed gradient
  17723. * @param gradient defines the gradient to remove
  17724. * @returns the current particle system
  17725. */
  17726. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17727. /**
  17728. * Adds a new velocity gradient
  17729. * @param gradient defines the gradient to use (between 0 and 1)
  17730. * @param factor defines the velocity to affect to the specified gradient
  17731. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17732. * @returns the current particle system
  17733. */
  17734. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17735. /**
  17736. * Remove a specific velocity gradient
  17737. * @param gradient defines the gradient to remove
  17738. * @returns the current particle system
  17739. */
  17740. removeVelocityGradient(gradient: number): IParticleSystem;
  17741. /**
  17742. * Adds a new limit velocity gradient
  17743. * @param gradient defines the gradient to use (between 0 and 1)
  17744. * @param factor defines the limit velocity value to affect to the specified gradient
  17745. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17746. * @returns the current particle system
  17747. */
  17748. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17749. /**
  17750. * Remove a specific limit velocity gradient
  17751. * @param gradient defines the gradient to remove
  17752. * @returns the current particle system
  17753. */
  17754. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17755. /**
  17756. * Adds a new drag gradient
  17757. * @param gradient defines the gradient to use (between 0 and 1)
  17758. * @param factor defines the drag value to affect to the specified gradient
  17759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17760. * @returns the current particle system
  17761. */
  17762. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17763. /**
  17764. * Remove a specific drag gradient
  17765. * @param gradient defines the gradient to remove
  17766. * @returns the current particle system
  17767. */
  17768. removeDragGradient(gradient: number): IParticleSystem;
  17769. /**
  17770. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17771. * @param gradient defines the gradient to use (between 0 and 1)
  17772. * @param factor defines the emit rate value to affect to the specified gradient
  17773. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17774. * @returns the current particle system
  17775. */
  17776. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17777. /**
  17778. * Remove a specific emit rate gradient
  17779. * @param gradient defines the gradient to remove
  17780. * @returns the current particle system
  17781. */
  17782. removeEmitRateGradient(gradient: number): IParticleSystem;
  17783. /**
  17784. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17785. * @param gradient defines the gradient to use (between 0 and 1)
  17786. * @param factor defines the start size value to affect to the specified gradient
  17787. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17788. * @returns the current particle system
  17789. */
  17790. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17791. /**
  17792. * Remove a specific start size gradient
  17793. * @param gradient defines the gradient to remove
  17794. * @returns the current particle system
  17795. */
  17796. removeStartSizeGradient(gradient: number): IParticleSystem;
  17797. private _createRampGradientTexture;
  17798. /**
  17799. * Gets the current list of ramp gradients.
  17800. * You must use addRampGradient and removeRampGradient to udpate this list
  17801. * @returns the list of ramp gradients
  17802. */
  17803. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17804. /**
  17805. * Adds a new ramp gradient used to remap particle colors
  17806. * @param gradient defines the gradient to use (between 0 and 1)
  17807. * @param color defines the color to affect to the specified gradient
  17808. * @returns the current particle system
  17809. */
  17810. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17811. /**
  17812. * Remove a specific ramp gradient
  17813. * @param gradient defines the gradient to remove
  17814. * @returns the current particle system
  17815. */
  17816. removeRampGradient(gradient: number): ParticleSystem;
  17817. /**
  17818. * Adds a new color gradient
  17819. * @param gradient defines the gradient to use (between 0 and 1)
  17820. * @param color1 defines the color to affect to the specified gradient
  17821. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17822. * @returns this particle system
  17823. */
  17824. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17825. /**
  17826. * Remove a specific color gradient
  17827. * @param gradient defines the gradient to remove
  17828. * @returns this particle system
  17829. */
  17830. removeColorGradient(gradient: number): IParticleSystem;
  17831. private _fetchR;
  17832. protected _reset(): void;
  17833. private _resetEffect;
  17834. private _createVertexBuffers;
  17835. private _createIndexBuffer;
  17836. /**
  17837. * Gets the maximum number of particles active at the same time.
  17838. * @returns The max number of active particles.
  17839. */
  17840. getCapacity(): number;
  17841. /**
  17842. * Gets whether there are still active particles in the system.
  17843. * @returns True if it is alive, otherwise false.
  17844. */
  17845. isAlive(): boolean;
  17846. /**
  17847. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17848. * @returns True if it has been started, otherwise false.
  17849. */
  17850. isStarted(): boolean;
  17851. private _prepareSubEmitterInternalArray;
  17852. /**
  17853. * Starts the particle system and begins to emit
  17854. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17855. */
  17856. start(delay?: number): void;
  17857. /**
  17858. * Stops the particle system.
  17859. * @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.
  17860. */
  17861. stop(stopSubEmitters?: boolean): void;
  17862. /**
  17863. * Remove all active particles
  17864. */
  17865. reset(): void;
  17866. /**
  17867. * @hidden (for internal use only)
  17868. */
  17869. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17870. /**
  17871. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17872. * Its lifetime will start back at 0.
  17873. */
  17874. recycleParticle: (particle: Particle) => void;
  17875. private _stopSubEmitters;
  17876. private _createParticle;
  17877. private _removeFromRoot;
  17878. private _emitFromParticle;
  17879. private _update;
  17880. /** @hidden */
  17881. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17882. /** @hidden */
  17883. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17884. /** @hidden */
  17885. private _getEffect;
  17886. /**
  17887. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17888. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17889. */
  17890. animate(preWarmOnly?: boolean): void;
  17891. private _appendParticleVertices;
  17892. /**
  17893. * Rebuilds the particle system.
  17894. */
  17895. rebuild(): void;
  17896. /**
  17897. * Is this system ready to be used/rendered
  17898. * @return true if the system is ready
  17899. */
  17900. isReady(): boolean;
  17901. private _render;
  17902. /**
  17903. * Renders the particle system in its current state.
  17904. * @returns the current number of particles
  17905. */
  17906. render(): number;
  17907. /**
  17908. * Disposes the particle system and free the associated resources
  17909. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17910. */
  17911. dispose(disposeTexture?: boolean): void;
  17912. /**
  17913. * Clones the particle system.
  17914. * @param name The name of the cloned object
  17915. * @param newEmitter The new emitter to use
  17916. * @returns the cloned particle system
  17917. */
  17918. clone(name: string, newEmitter: any): ParticleSystem;
  17919. /**
  17920. * Serializes the particle system to a JSON object.
  17921. * @returns the JSON object
  17922. */
  17923. serialize(): any;
  17924. /** @hidden */
  17925. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17926. /** @hidden */
  17927. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17928. /**
  17929. * Parses a JSON object to create a particle system.
  17930. * @param parsedParticleSystem The JSON object to parse
  17931. * @param scene The scene to create the particle system in
  17932. * @param rootUrl The root url to use to load external dependencies like texture
  17933. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17934. * @returns the Parsed particle system
  17935. */
  17936. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17937. }
  17938. }
  17939. declare module "babylonjs/Particles/particle" {
  17940. import { Nullable } from "babylonjs/types";
  17941. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17942. import { Color4 } from "babylonjs/Maths/math.color";
  17943. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17944. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17945. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17946. /**
  17947. * A particle represents one of the element emitted by a particle system.
  17948. * This is mainly define by its coordinates, direction, velocity and age.
  17949. */
  17950. export class Particle {
  17951. /**
  17952. * The particle system the particle belongs to.
  17953. */
  17954. particleSystem: ParticleSystem;
  17955. private static _Count;
  17956. /**
  17957. * Unique ID of the particle
  17958. */
  17959. id: number;
  17960. /**
  17961. * The world position of the particle in the scene.
  17962. */
  17963. position: Vector3;
  17964. /**
  17965. * The world direction of the particle in the scene.
  17966. */
  17967. direction: Vector3;
  17968. /**
  17969. * The color of the particle.
  17970. */
  17971. color: Color4;
  17972. /**
  17973. * The color change of the particle per step.
  17974. */
  17975. colorStep: Color4;
  17976. /**
  17977. * Defines how long will the life of the particle be.
  17978. */
  17979. lifeTime: number;
  17980. /**
  17981. * The current age of the particle.
  17982. */
  17983. age: number;
  17984. /**
  17985. * The current size of the particle.
  17986. */
  17987. size: number;
  17988. /**
  17989. * The current scale of the particle.
  17990. */
  17991. scale: Vector2;
  17992. /**
  17993. * The current angle of the particle.
  17994. */
  17995. angle: number;
  17996. /**
  17997. * Defines how fast is the angle changing.
  17998. */
  17999. angularSpeed: number;
  18000. /**
  18001. * Defines the cell index used by the particle to be rendered from a sprite.
  18002. */
  18003. cellIndex: number;
  18004. /**
  18005. * The information required to support color remapping
  18006. */
  18007. remapData: Vector4;
  18008. /** @hidden */
  18009. _randomCellOffset?: number;
  18010. /** @hidden */
  18011. _initialDirection: Nullable<Vector3>;
  18012. /** @hidden */
  18013. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18014. /** @hidden */
  18015. _initialStartSpriteCellID: number;
  18016. /** @hidden */
  18017. _initialEndSpriteCellID: number;
  18018. /** @hidden */
  18019. _currentColorGradient: Nullable<ColorGradient>;
  18020. /** @hidden */
  18021. _currentColor1: Color4;
  18022. /** @hidden */
  18023. _currentColor2: Color4;
  18024. /** @hidden */
  18025. _currentSizeGradient: Nullable<FactorGradient>;
  18026. /** @hidden */
  18027. _currentSize1: number;
  18028. /** @hidden */
  18029. _currentSize2: number;
  18030. /** @hidden */
  18031. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18032. /** @hidden */
  18033. _currentAngularSpeed1: number;
  18034. /** @hidden */
  18035. _currentAngularSpeed2: number;
  18036. /** @hidden */
  18037. _currentVelocityGradient: Nullable<FactorGradient>;
  18038. /** @hidden */
  18039. _currentVelocity1: number;
  18040. /** @hidden */
  18041. _currentVelocity2: number;
  18042. /** @hidden */
  18043. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18044. /** @hidden */
  18045. _currentLimitVelocity1: number;
  18046. /** @hidden */
  18047. _currentLimitVelocity2: number;
  18048. /** @hidden */
  18049. _currentDragGradient: Nullable<FactorGradient>;
  18050. /** @hidden */
  18051. _currentDrag1: number;
  18052. /** @hidden */
  18053. _currentDrag2: number;
  18054. /** @hidden */
  18055. _randomNoiseCoordinates1: Vector3;
  18056. /** @hidden */
  18057. _randomNoiseCoordinates2: Vector3;
  18058. /**
  18059. * Creates a new instance Particle
  18060. * @param particleSystem the particle system the particle belongs to
  18061. */
  18062. constructor(
  18063. /**
  18064. * The particle system the particle belongs to.
  18065. */
  18066. particleSystem: ParticleSystem);
  18067. private updateCellInfoFromSystem;
  18068. /**
  18069. * Defines how the sprite cell index is updated for the particle
  18070. */
  18071. updateCellIndex(): void;
  18072. /** @hidden */
  18073. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18074. /** @hidden */
  18075. _inheritParticleInfoToSubEmitters(): void;
  18076. /** @hidden */
  18077. _reset(): void;
  18078. /**
  18079. * Copy the properties of particle to another one.
  18080. * @param other the particle to copy the information to.
  18081. */
  18082. copyTo(other: Particle): void;
  18083. }
  18084. }
  18085. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18086. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18087. import { Effect } from "babylonjs/Materials/effect";
  18088. import { Particle } from "babylonjs/Particles/particle";
  18089. /**
  18090. * Particle emitter represents a volume emitting particles.
  18091. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18092. */
  18093. export interface IParticleEmitterType {
  18094. /**
  18095. * Called by the particle System when the direction is computed for the created particle.
  18096. * @param worldMatrix is the world matrix of the particle system
  18097. * @param directionToUpdate is the direction vector to update with the result
  18098. * @param particle is the particle we are computed the direction for
  18099. */
  18100. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18101. /**
  18102. * Called by the particle System when the position is computed for the created particle.
  18103. * @param worldMatrix is the world matrix of the particle system
  18104. * @param positionToUpdate is the position vector to update with the result
  18105. * @param particle is the particle we are computed the position for
  18106. */
  18107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18108. /**
  18109. * Clones the current emitter and returns a copy of it
  18110. * @returns the new emitter
  18111. */
  18112. clone(): IParticleEmitterType;
  18113. /**
  18114. * Called by the GPUParticleSystem to setup the update shader
  18115. * @param effect defines the update shader
  18116. */
  18117. applyToShader(effect: Effect): void;
  18118. /**
  18119. * Returns a string to use to update the GPU particles update shader
  18120. * @returns the effect defines string
  18121. */
  18122. getEffectDefines(): string;
  18123. /**
  18124. * Returns a string representing the class name
  18125. * @returns a string containing the class name
  18126. */
  18127. getClassName(): string;
  18128. /**
  18129. * Serializes the particle system to a JSON object.
  18130. * @returns the JSON object
  18131. */
  18132. serialize(): any;
  18133. /**
  18134. * Parse properties from a JSON object
  18135. * @param serializationObject defines the JSON object
  18136. */
  18137. parse(serializationObject: any): void;
  18138. }
  18139. }
  18140. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18141. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18142. import { Effect } from "babylonjs/Materials/effect";
  18143. import { Particle } from "babylonjs/Particles/particle";
  18144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18145. /**
  18146. * Particle emitter emitting particles from the inside of a box.
  18147. * It emits the particles randomly between 2 given directions.
  18148. */
  18149. export class BoxParticleEmitter implements IParticleEmitterType {
  18150. /**
  18151. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18152. */
  18153. direction1: Vector3;
  18154. /**
  18155. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18156. */
  18157. direction2: Vector3;
  18158. /**
  18159. * 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.
  18160. */
  18161. minEmitBox: Vector3;
  18162. /**
  18163. * 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.
  18164. */
  18165. maxEmitBox: Vector3;
  18166. /**
  18167. * Creates a new instance BoxParticleEmitter
  18168. */
  18169. constructor();
  18170. /**
  18171. * Called by the particle System when the direction is computed for the created particle.
  18172. * @param worldMatrix is the world matrix of the particle system
  18173. * @param directionToUpdate is the direction vector to update with the result
  18174. * @param particle is the particle we are computed the direction for
  18175. */
  18176. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18177. /**
  18178. * Called by the particle System when the position is computed for the created particle.
  18179. * @param worldMatrix is the world matrix of the particle system
  18180. * @param positionToUpdate is the position vector to update with the result
  18181. * @param particle is the particle we are computed the position for
  18182. */
  18183. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18184. /**
  18185. * Clones the current emitter and returns a copy of it
  18186. * @returns the new emitter
  18187. */
  18188. clone(): BoxParticleEmitter;
  18189. /**
  18190. * Called by the GPUParticleSystem to setup the update shader
  18191. * @param effect defines the update shader
  18192. */
  18193. applyToShader(effect: Effect): void;
  18194. /**
  18195. * Returns a string to use to update the GPU particles update shader
  18196. * @returns a string containng the defines string
  18197. */
  18198. getEffectDefines(): string;
  18199. /**
  18200. * Returns the string "BoxParticleEmitter"
  18201. * @returns a string containing the class name
  18202. */
  18203. getClassName(): string;
  18204. /**
  18205. * Serializes the particle system to a JSON object.
  18206. * @returns the JSON object
  18207. */
  18208. serialize(): any;
  18209. /**
  18210. * Parse properties from a JSON object
  18211. * @param serializationObject defines the JSON object
  18212. */
  18213. parse(serializationObject: any): void;
  18214. }
  18215. }
  18216. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18217. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18218. import { Effect } from "babylonjs/Materials/effect";
  18219. import { Particle } from "babylonjs/Particles/particle";
  18220. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18221. /**
  18222. * Particle emitter emitting particles from the inside of a cone.
  18223. * It emits the particles alongside the cone volume from the base to the particle.
  18224. * The emission direction might be randomized.
  18225. */
  18226. export class ConeParticleEmitter implements IParticleEmitterType {
  18227. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18228. directionRandomizer: number;
  18229. private _radius;
  18230. private _angle;
  18231. private _height;
  18232. /**
  18233. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18234. */
  18235. radiusRange: number;
  18236. /**
  18237. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18238. */
  18239. heightRange: number;
  18240. /**
  18241. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18242. */
  18243. emitFromSpawnPointOnly: boolean;
  18244. /**
  18245. * Gets or sets the radius of the emission cone
  18246. */
  18247. radius: number;
  18248. /**
  18249. * Gets or sets the angle of the emission cone
  18250. */
  18251. angle: number;
  18252. private _buildHeight;
  18253. /**
  18254. * Creates a new instance ConeParticleEmitter
  18255. * @param radius the radius of the emission cone (1 by default)
  18256. * @param angle the cone base angle (PI by default)
  18257. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18258. */
  18259. constructor(radius?: number, angle?: number,
  18260. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18261. directionRandomizer?: number);
  18262. /**
  18263. * Called by the particle System when the direction is computed for the created particle.
  18264. * @param worldMatrix is the world matrix of the particle system
  18265. * @param directionToUpdate is the direction vector to update with the result
  18266. * @param particle is the particle we are computed the direction for
  18267. */
  18268. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18269. /**
  18270. * Called by the particle System when the position is computed for the created particle.
  18271. * @param worldMatrix is the world matrix of the particle system
  18272. * @param positionToUpdate is the position vector to update with the result
  18273. * @param particle is the particle we are computed the position for
  18274. */
  18275. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18276. /**
  18277. * Clones the current emitter and returns a copy of it
  18278. * @returns the new emitter
  18279. */
  18280. clone(): ConeParticleEmitter;
  18281. /**
  18282. * Called by the GPUParticleSystem to setup the update shader
  18283. * @param effect defines the update shader
  18284. */
  18285. applyToShader(effect: Effect): void;
  18286. /**
  18287. * Returns a string to use to update the GPU particles update shader
  18288. * @returns a string containng the defines string
  18289. */
  18290. getEffectDefines(): string;
  18291. /**
  18292. * Returns the string "ConeParticleEmitter"
  18293. * @returns a string containing the class name
  18294. */
  18295. getClassName(): string;
  18296. /**
  18297. * Serializes the particle system to a JSON object.
  18298. * @returns the JSON object
  18299. */
  18300. serialize(): any;
  18301. /**
  18302. * Parse properties from a JSON object
  18303. * @param serializationObject defines the JSON object
  18304. */
  18305. parse(serializationObject: any): void;
  18306. }
  18307. }
  18308. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18309. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18310. import { Effect } from "babylonjs/Materials/effect";
  18311. import { Particle } from "babylonjs/Particles/particle";
  18312. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18313. /**
  18314. * Particle emitter emitting particles from the inside of a cylinder.
  18315. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18316. */
  18317. export class CylinderParticleEmitter implements IParticleEmitterType {
  18318. /**
  18319. * The radius of the emission cylinder.
  18320. */
  18321. radius: number;
  18322. /**
  18323. * The height of the emission cylinder.
  18324. */
  18325. height: number;
  18326. /**
  18327. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18328. */
  18329. radiusRange: number;
  18330. /**
  18331. * How much to randomize the particle direction [0-1].
  18332. */
  18333. directionRandomizer: number;
  18334. /**
  18335. * Creates a new instance CylinderParticleEmitter
  18336. * @param radius the radius of the emission cylinder (1 by default)
  18337. * @param height the height of the emission cylinder (1 by default)
  18338. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18339. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18340. */
  18341. constructor(
  18342. /**
  18343. * The radius of the emission cylinder.
  18344. */
  18345. radius?: number,
  18346. /**
  18347. * The height of the emission cylinder.
  18348. */
  18349. height?: number,
  18350. /**
  18351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18352. */
  18353. radiusRange?: number,
  18354. /**
  18355. * How much to randomize the particle direction [0-1].
  18356. */
  18357. directionRandomizer?: number);
  18358. /**
  18359. * Called by the particle System when the direction is computed for the created particle.
  18360. * @param worldMatrix is the world matrix of the particle system
  18361. * @param directionToUpdate is the direction vector to update with the result
  18362. * @param particle is the particle we are computed the direction for
  18363. */
  18364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18365. /**
  18366. * Called by the particle System when the position is computed for the created particle.
  18367. * @param worldMatrix is the world matrix of the particle system
  18368. * @param positionToUpdate is the position vector to update with the result
  18369. * @param particle is the particle we are computed the position for
  18370. */
  18371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18372. /**
  18373. * Clones the current emitter and returns a copy of it
  18374. * @returns the new emitter
  18375. */
  18376. clone(): CylinderParticleEmitter;
  18377. /**
  18378. * Called by the GPUParticleSystem to setup the update shader
  18379. * @param effect defines the update shader
  18380. */
  18381. applyToShader(effect: Effect): void;
  18382. /**
  18383. * Returns a string to use to update the GPU particles update shader
  18384. * @returns a string containng the defines string
  18385. */
  18386. getEffectDefines(): string;
  18387. /**
  18388. * Returns the string "CylinderParticleEmitter"
  18389. * @returns a string containing the class name
  18390. */
  18391. getClassName(): string;
  18392. /**
  18393. * Serializes the particle system to a JSON object.
  18394. * @returns the JSON object
  18395. */
  18396. serialize(): any;
  18397. /**
  18398. * Parse properties from a JSON object
  18399. * @param serializationObject defines the JSON object
  18400. */
  18401. parse(serializationObject: any): void;
  18402. }
  18403. /**
  18404. * Particle emitter emitting particles from the inside of a cylinder.
  18405. * It emits the particles randomly between two vectors.
  18406. */
  18407. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18408. /**
  18409. * The min limit of the emission direction.
  18410. */
  18411. direction1: Vector3;
  18412. /**
  18413. * The max limit of the emission direction.
  18414. */
  18415. direction2: Vector3;
  18416. /**
  18417. * Creates a new instance CylinderDirectedParticleEmitter
  18418. * @param radius the radius of the emission cylinder (1 by default)
  18419. * @param height the height of the emission cylinder (1 by default)
  18420. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18421. * @param direction1 the min limit of the emission direction (up vector by default)
  18422. * @param direction2 the max limit of the emission direction (up vector by default)
  18423. */
  18424. constructor(radius?: number, height?: number, radiusRange?: number,
  18425. /**
  18426. * The min limit of the emission direction.
  18427. */
  18428. direction1?: Vector3,
  18429. /**
  18430. * The max limit of the emission direction.
  18431. */
  18432. direction2?: Vector3);
  18433. /**
  18434. * Called by the particle System when the direction is computed for the created particle.
  18435. * @param worldMatrix is the world matrix of the particle system
  18436. * @param directionToUpdate is the direction vector to update with the result
  18437. * @param particle is the particle we are computed the direction for
  18438. */
  18439. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18440. /**
  18441. * Clones the current emitter and returns a copy of it
  18442. * @returns the new emitter
  18443. */
  18444. clone(): CylinderDirectedParticleEmitter;
  18445. /**
  18446. * Called by the GPUParticleSystem to setup the update shader
  18447. * @param effect defines the update shader
  18448. */
  18449. applyToShader(effect: Effect): void;
  18450. /**
  18451. * Returns a string to use to update the GPU particles update shader
  18452. * @returns a string containng the defines string
  18453. */
  18454. getEffectDefines(): string;
  18455. /**
  18456. * Returns the string "CylinderDirectedParticleEmitter"
  18457. * @returns a string containing the class name
  18458. */
  18459. getClassName(): string;
  18460. /**
  18461. * Serializes the particle system to a JSON object.
  18462. * @returns the JSON object
  18463. */
  18464. serialize(): any;
  18465. /**
  18466. * Parse properties from a JSON object
  18467. * @param serializationObject defines the JSON object
  18468. */
  18469. parse(serializationObject: any): void;
  18470. }
  18471. }
  18472. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18473. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18474. import { Effect } from "babylonjs/Materials/effect";
  18475. import { Particle } from "babylonjs/Particles/particle";
  18476. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18477. /**
  18478. * Particle emitter emitting particles from the inside of a hemisphere.
  18479. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18480. */
  18481. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18482. /**
  18483. * The radius of the emission hemisphere.
  18484. */
  18485. radius: number;
  18486. /**
  18487. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18488. */
  18489. radiusRange: number;
  18490. /**
  18491. * How much to randomize the particle direction [0-1].
  18492. */
  18493. directionRandomizer: number;
  18494. /**
  18495. * Creates a new instance HemisphericParticleEmitter
  18496. * @param radius the radius of the emission hemisphere (1 by default)
  18497. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18498. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18499. */
  18500. constructor(
  18501. /**
  18502. * The radius of the emission hemisphere.
  18503. */
  18504. radius?: number,
  18505. /**
  18506. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18507. */
  18508. radiusRange?: number,
  18509. /**
  18510. * How much to randomize the particle direction [0-1].
  18511. */
  18512. directionRandomizer?: number);
  18513. /**
  18514. * Called by the particle System when the direction is computed for the created particle.
  18515. * @param worldMatrix is the world matrix of the particle system
  18516. * @param directionToUpdate is the direction vector to update with the result
  18517. * @param particle is the particle we are computed the direction for
  18518. */
  18519. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18520. /**
  18521. * Called by the particle System when the position is computed for the created particle.
  18522. * @param worldMatrix is the world matrix of the particle system
  18523. * @param positionToUpdate is the position vector to update with the result
  18524. * @param particle is the particle we are computed the position for
  18525. */
  18526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18527. /**
  18528. * Clones the current emitter and returns a copy of it
  18529. * @returns the new emitter
  18530. */
  18531. clone(): HemisphericParticleEmitter;
  18532. /**
  18533. * Called by the GPUParticleSystem to setup the update shader
  18534. * @param effect defines the update shader
  18535. */
  18536. applyToShader(effect: Effect): void;
  18537. /**
  18538. * Returns a string to use to update the GPU particles update shader
  18539. * @returns a string containng the defines string
  18540. */
  18541. getEffectDefines(): string;
  18542. /**
  18543. * Returns the string "HemisphericParticleEmitter"
  18544. * @returns a string containing the class name
  18545. */
  18546. getClassName(): string;
  18547. /**
  18548. * Serializes the particle system to a JSON object.
  18549. * @returns the JSON object
  18550. */
  18551. serialize(): any;
  18552. /**
  18553. * Parse properties from a JSON object
  18554. * @param serializationObject defines the JSON object
  18555. */
  18556. parse(serializationObject: any): void;
  18557. }
  18558. }
  18559. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18560. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18561. import { Effect } from "babylonjs/Materials/effect";
  18562. import { Particle } from "babylonjs/Particles/particle";
  18563. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18564. /**
  18565. * Particle emitter emitting particles from a point.
  18566. * It emits the particles randomly between 2 given directions.
  18567. */
  18568. export class PointParticleEmitter implements IParticleEmitterType {
  18569. /**
  18570. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18571. */
  18572. direction1: Vector3;
  18573. /**
  18574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18575. */
  18576. direction2: Vector3;
  18577. /**
  18578. * Creates a new instance PointParticleEmitter
  18579. */
  18580. constructor();
  18581. /**
  18582. * Called by the particle System when the direction is computed for the created particle.
  18583. * @param worldMatrix is the world matrix of the particle system
  18584. * @param directionToUpdate is the direction vector to update with the result
  18585. * @param particle is the particle we are computed the direction for
  18586. */
  18587. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18588. /**
  18589. * Called by the particle System when the position is computed for the created particle.
  18590. * @param worldMatrix is the world matrix of the particle system
  18591. * @param positionToUpdate is the position vector to update with the result
  18592. * @param particle is the particle we are computed the position for
  18593. */
  18594. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18595. /**
  18596. * Clones the current emitter and returns a copy of it
  18597. * @returns the new emitter
  18598. */
  18599. clone(): PointParticleEmitter;
  18600. /**
  18601. * Called by the GPUParticleSystem to setup the update shader
  18602. * @param effect defines the update shader
  18603. */
  18604. applyToShader(effect: Effect): void;
  18605. /**
  18606. * Returns a string to use to update the GPU particles update shader
  18607. * @returns a string containng the defines string
  18608. */
  18609. getEffectDefines(): string;
  18610. /**
  18611. * Returns the string "PointParticleEmitter"
  18612. * @returns a string containing the class name
  18613. */
  18614. getClassName(): string;
  18615. /**
  18616. * Serializes the particle system to a JSON object.
  18617. * @returns the JSON object
  18618. */
  18619. serialize(): any;
  18620. /**
  18621. * Parse properties from a JSON object
  18622. * @param serializationObject defines the JSON object
  18623. */
  18624. parse(serializationObject: any): void;
  18625. }
  18626. }
  18627. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18628. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18629. import { Effect } from "babylonjs/Materials/effect";
  18630. import { Particle } from "babylonjs/Particles/particle";
  18631. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18632. /**
  18633. * Particle emitter emitting particles from the inside of a sphere.
  18634. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18635. */
  18636. export class SphereParticleEmitter implements IParticleEmitterType {
  18637. /**
  18638. * The radius of the emission sphere.
  18639. */
  18640. radius: number;
  18641. /**
  18642. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18643. */
  18644. radiusRange: number;
  18645. /**
  18646. * How much to randomize the particle direction [0-1].
  18647. */
  18648. directionRandomizer: number;
  18649. /**
  18650. * Creates a new instance SphereParticleEmitter
  18651. * @param radius the radius of the emission sphere (1 by default)
  18652. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18653. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18654. */
  18655. constructor(
  18656. /**
  18657. * The radius of the emission sphere.
  18658. */
  18659. radius?: number,
  18660. /**
  18661. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18662. */
  18663. radiusRange?: number,
  18664. /**
  18665. * How much to randomize the particle direction [0-1].
  18666. */
  18667. directionRandomizer?: number);
  18668. /**
  18669. * Called by the particle System when the direction is computed for the created particle.
  18670. * @param worldMatrix is the world matrix of the particle system
  18671. * @param directionToUpdate is the direction vector to update with the result
  18672. * @param particle is the particle we are computed the direction for
  18673. */
  18674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18675. /**
  18676. * Called by the particle System when the position is computed for the created particle.
  18677. * @param worldMatrix is the world matrix of the particle system
  18678. * @param positionToUpdate is the position vector to update with the result
  18679. * @param particle is the particle we are computed the position for
  18680. */
  18681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18682. /**
  18683. * Clones the current emitter and returns a copy of it
  18684. * @returns the new emitter
  18685. */
  18686. clone(): SphereParticleEmitter;
  18687. /**
  18688. * Called by the GPUParticleSystem to setup the update shader
  18689. * @param effect defines the update shader
  18690. */
  18691. applyToShader(effect: Effect): void;
  18692. /**
  18693. * Returns a string to use to update the GPU particles update shader
  18694. * @returns a string containng the defines string
  18695. */
  18696. getEffectDefines(): string;
  18697. /**
  18698. * Returns the string "SphereParticleEmitter"
  18699. * @returns a string containing the class name
  18700. */
  18701. getClassName(): string;
  18702. /**
  18703. * Serializes the particle system to a JSON object.
  18704. * @returns the JSON object
  18705. */
  18706. serialize(): any;
  18707. /**
  18708. * Parse properties from a JSON object
  18709. * @param serializationObject defines the JSON object
  18710. */
  18711. parse(serializationObject: any): void;
  18712. }
  18713. /**
  18714. * Particle emitter emitting particles from the inside of a sphere.
  18715. * It emits the particles randomly between two vectors.
  18716. */
  18717. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18718. /**
  18719. * The min limit of the emission direction.
  18720. */
  18721. direction1: Vector3;
  18722. /**
  18723. * The max limit of the emission direction.
  18724. */
  18725. direction2: Vector3;
  18726. /**
  18727. * Creates a new instance SphereDirectedParticleEmitter
  18728. * @param radius the radius of the emission sphere (1 by default)
  18729. * @param direction1 the min limit of the emission direction (up vector by default)
  18730. * @param direction2 the max limit of the emission direction (up vector by default)
  18731. */
  18732. constructor(radius?: number,
  18733. /**
  18734. * The min limit of the emission direction.
  18735. */
  18736. direction1?: Vector3,
  18737. /**
  18738. * The max limit of the emission direction.
  18739. */
  18740. direction2?: Vector3);
  18741. /**
  18742. * Called by the particle System when the direction is computed for the created particle.
  18743. * @param worldMatrix is the world matrix of the particle system
  18744. * @param directionToUpdate is the direction vector to update with the result
  18745. * @param particle is the particle we are computed the direction for
  18746. */
  18747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18748. /**
  18749. * Clones the current emitter and returns a copy of it
  18750. * @returns the new emitter
  18751. */
  18752. clone(): SphereDirectedParticleEmitter;
  18753. /**
  18754. * Called by the GPUParticleSystem to setup the update shader
  18755. * @param effect defines the update shader
  18756. */
  18757. applyToShader(effect: Effect): void;
  18758. /**
  18759. * Returns a string to use to update the GPU particles update shader
  18760. * @returns a string containng the defines string
  18761. */
  18762. getEffectDefines(): string;
  18763. /**
  18764. * Returns the string "SphereDirectedParticleEmitter"
  18765. * @returns a string containing the class name
  18766. */
  18767. getClassName(): string;
  18768. /**
  18769. * Serializes the particle system to a JSON object.
  18770. * @returns the JSON object
  18771. */
  18772. serialize(): any;
  18773. /**
  18774. * Parse properties from a JSON object
  18775. * @param serializationObject defines the JSON object
  18776. */
  18777. parse(serializationObject: any): void;
  18778. }
  18779. }
  18780. declare module "babylonjs/Particles/EmitterTypes/index" {
  18781. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18782. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18783. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18784. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18785. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18786. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18787. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18788. }
  18789. declare module "babylonjs/Particles/IParticleSystem" {
  18790. import { Nullable } from "babylonjs/types";
  18791. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18792. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18795. import { Texture } from "babylonjs/Materials/Textures/texture";
  18796. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18797. import { Scene } from "babylonjs/scene";
  18798. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18799. import { Animation } from "babylonjs/Animations/animation";
  18800. /**
  18801. * Interface representing a particle system in Babylon.js.
  18802. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18803. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18804. */
  18805. export interface IParticleSystem {
  18806. /**
  18807. * List of animations used by the particle system.
  18808. */
  18809. animations: Animation[];
  18810. /**
  18811. * The id of the Particle system.
  18812. */
  18813. id: string;
  18814. /**
  18815. * The name of the Particle system.
  18816. */
  18817. name: string;
  18818. /**
  18819. * The emitter represents the Mesh or position we are attaching the particle system to.
  18820. */
  18821. emitter: Nullable<AbstractMesh | Vector3>;
  18822. /**
  18823. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18824. */
  18825. isBillboardBased: boolean;
  18826. /**
  18827. * The rendering group used by the Particle system to chose when to render.
  18828. */
  18829. renderingGroupId: number;
  18830. /**
  18831. * The layer mask we are rendering the particles through.
  18832. */
  18833. layerMask: number;
  18834. /**
  18835. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18836. */
  18837. updateSpeed: number;
  18838. /**
  18839. * The amount of time the particle system is running (depends of the overall update speed).
  18840. */
  18841. targetStopDuration: number;
  18842. /**
  18843. * The texture used to render each particle. (this can be a spritesheet)
  18844. */
  18845. particleTexture: Nullable<Texture>;
  18846. /**
  18847. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18848. */
  18849. blendMode: number;
  18850. /**
  18851. * Minimum life time of emitting particles.
  18852. */
  18853. minLifeTime: number;
  18854. /**
  18855. * Maximum life time of emitting particles.
  18856. */
  18857. maxLifeTime: number;
  18858. /**
  18859. * Minimum Size of emitting particles.
  18860. */
  18861. minSize: number;
  18862. /**
  18863. * Maximum Size of emitting particles.
  18864. */
  18865. maxSize: number;
  18866. /**
  18867. * Minimum scale of emitting particles on X axis.
  18868. */
  18869. minScaleX: number;
  18870. /**
  18871. * Maximum scale of emitting particles on X axis.
  18872. */
  18873. maxScaleX: number;
  18874. /**
  18875. * Minimum scale of emitting particles on Y axis.
  18876. */
  18877. minScaleY: number;
  18878. /**
  18879. * Maximum scale of emitting particles on Y axis.
  18880. */
  18881. maxScaleY: number;
  18882. /**
  18883. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18884. */
  18885. color1: Color4;
  18886. /**
  18887. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18888. */
  18889. color2: Color4;
  18890. /**
  18891. * Color the particle will have at the end of its lifetime.
  18892. */
  18893. colorDead: Color4;
  18894. /**
  18895. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18896. */
  18897. emitRate: number;
  18898. /**
  18899. * You can use gravity if you want to give an orientation to your particles.
  18900. */
  18901. gravity: Vector3;
  18902. /**
  18903. * Minimum power of emitting particles.
  18904. */
  18905. minEmitPower: number;
  18906. /**
  18907. * Maximum power of emitting particles.
  18908. */
  18909. maxEmitPower: number;
  18910. /**
  18911. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18912. */
  18913. minAngularSpeed: number;
  18914. /**
  18915. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18916. */
  18917. maxAngularSpeed: number;
  18918. /**
  18919. * Gets or sets the minimal initial rotation in radians.
  18920. */
  18921. minInitialRotation: number;
  18922. /**
  18923. * Gets or sets the maximal initial rotation in radians.
  18924. */
  18925. maxInitialRotation: number;
  18926. /**
  18927. * The particle emitter type defines the emitter used by the particle system.
  18928. * It can be for example box, sphere, or cone...
  18929. */
  18930. particleEmitterType: Nullable<IParticleEmitterType>;
  18931. /**
  18932. * Defines the delay in milliseconds before starting the system (0 by default)
  18933. */
  18934. startDelay: number;
  18935. /**
  18936. * 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
  18937. */
  18938. preWarmCycles: number;
  18939. /**
  18940. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18941. */
  18942. preWarmStepOffset: number;
  18943. /**
  18944. * 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)
  18945. */
  18946. spriteCellChangeSpeed: number;
  18947. /**
  18948. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18949. */
  18950. startSpriteCellID: number;
  18951. /**
  18952. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18953. */
  18954. endSpriteCellID: number;
  18955. /**
  18956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18957. */
  18958. spriteCellWidth: number;
  18959. /**
  18960. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18961. */
  18962. spriteCellHeight: number;
  18963. /**
  18964. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18965. */
  18966. spriteRandomStartCell: boolean;
  18967. /**
  18968. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18969. */
  18970. isAnimationSheetEnabled: boolean;
  18971. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18972. translationPivot: Vector2;
  18973. /**
  18974. * Gets or sets a texture used to add random noise to particle positions
  18975. */
  18976. noiseTexture: Nullable<BaseTexture>;
  18977. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18978. noiseStrength: Vector3;
  18979. /**
  18980. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18981. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18982. */
  18983. billboardMode: number;
  18984. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18985. limitVelocityDamping: number;
  18986. /**
  18987. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18988. */
  18989. beginAnimationOnStart: boolean;
  18990. /**
  18991. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18992. */
  18993. beginAnimationFrom: number;
  18994. /**
  18995. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18996. */
  18997. beginAnimationTo: number;
  18998. /**
  18999. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19000. */
  19001. beginAnimationLoop: boolean;
  19002. /**
  19003. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19004. */
  19005. disposeOnStop: boolean;
  19006. /**
  19007. * Gets the maximum number of particles active at the same time.
  19008. * @returns The max number of active particles.
  19009. */
  19010. getCapacity(): number;
  19011. /**
  19012. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19013. * @returns True if it has been started, otherwise false.
  19014. */
  19015. isStarted(): boolean;
  19016. /**
  19017. * Animates the particle system for this frame.
  19018. */
  19019. animate(): void;
  19020. /**
  19021. * Renders the particle system in its current state.
  19022. * @returns the current number of particles
  19023. */
  19024. render(): number;
  19025. /**
  19026. * Dispose the particle system and frees its associated resources.
  19027. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19028. */
  19029. dispose(disposeTexture?: boolean): void;
  19030. /**
  19031. * Clones the particle system.
  19032. * @param name The name of the cloned object
  19033. * @param newEmitter The new emitter to use
  19034. * @returns the cloned particle system
  19035. */
  19036. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19037. /**
  19038. * Serializes the particle system to a JSON object.
  19039. * @returns the JSON object
  19040. */
  19041. serialize(): any;
  19042. /**
  19043. * Rebuild the particle system
  19044. */
  19045. rebuild(): void;
  19046. /**
  19047. * Starts the particle system and begins to emit
  19048. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19049. */
  19050. start(delay?: number): void;
  19051. /**
  19052. * Stops the particle system.
  19053. */
  19054. stop(): void;
  19055. /**
  19056. * Remove all active particles
  19057. */
  19058. reset(): void;
  19059. /**
  19060. * Is this system ready to be used/rendered
  19061. * @return true if the system is ready
  19062. */
  19063. isReady(): boolean;
  19064. /**
  19065. * Adds a new color gradient
  19066. * @param gradient defines the gradient to use (between 0 and 1)
  19067. * @param color1 defines the color to affect to the specified gradient
  19068. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19069. * @returns the current particle system
  19070. */
  19071. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19072. /**
  19073. * Remove a specific color gradient
  19074. * @param gradient defines the gradient to remove
  19075. * @returns the current particle system
  19076. */
  19077. removeColorGradient(gradient: number): IParticleSystem;
  19078. /**
  19079. * Adds a new size gradient
  19080. * @param gradient defines the gradient to use (between 0 and 1)
  19081. * @param factor defines the size factor to affect to the specified gradient
  19082. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19083. * @returns the current particle system
  19084. */
  19085. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19086. /**
  19087. * Remove a specific size gradient
  19088. * @param gradient defines the gradient to remove
  19089. * @returns the current particle system
  19090. */
  19091. removeSizeGradient(gradient: number): IParticleSystem;
  19092. /**
  19093. * Gets the current list of color gradients.
  19094. * You must use addColorGradient and removeColorGradient to udpate this list
  19095. * @returns the list of color gradients
  19096. */
  19097. getColorGradients(): Nullable<Array<ColorGradient>>;
  19098. /**
  19099. * Gets the current list of size gradients.
  19100. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19101. * @returns the list of size gradients
  19102. */
  19103. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19104. /**
  19105. * Gets the current list of angular speed gradients.
  19106. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19107. * @returns the list of angular speed gradients
  19108. */
  19109. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19110. /**
  19111. * Adds a new angular speed gradient
  19112. * @param gradient defines the gradient to use (between 0 and 1)
  19113. * @param factor defines the angular speed to affect to the specified gradient
  19114. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19115. * @returns the current particle system
  19116. */
  19117. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19118. /**
  19119. * Remove a specific angular speed gradient
  19120. * @param gradient defines the gradient to remove
  19121. * @returns the current particle system
  19122. */
  19123. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19124. /**
  19125. * Gets the current list of velocity gradients.
  19126. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19127. * @returns the list of velocity gradients
  19128. */
  19129. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19130. /**
  19131. * Adds a new velocity gradient
  19132. * @param gradient defines the gradient to use (between 0 and 1)
  19133. * @param factor defines the velocity to affect to the specified gradient
  19134. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19135. * @returns the current particle system
  19136. */
  19137. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19138. /**
  19139. * Remove a specific velocity gradient
  19140. * @param gradient defines the gradient to remove
  19141. * @returns the current particle system
  19142. */
  19143. removeVelocityGradient(gradient: number): IParticleSystem;
  19144. /**
  19145. * Gets the current list of limit velocity gradients.
  19146. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19147. * @returns the list of limit velocity gradients
  19148. */
  19149. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19150. /**
  19151. * Adds a new limit velocity gradient
  19152. * @param gradient defines the gradient to use (between 0 and 1)
  19153. * @param factor defines the limit velocity to affect to the specified gradient
  19154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19155. * @returns the current particle system
  19156. */
  19157. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19158. /**
  19159. * Remove a specific limit velocity gradient
  19160. * @param gradient defines the gradient to remove
  19161. * @returns the current particle system
  19162. */
  19163. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19164. /**
  19165. * Adds a new drag gradient
  19166. * @param gradient defines the gradient to use (between 0 and 1)
  19167. * @param factor defines the drag to affect to the specified gradient
  19168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19169. * @returns the current particle system
  19170. */
  19171. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19172. /**
  19173. * Remove a specific drag gradient
  19174. * @param gradient defines the gradient to remove
  19175. * @returns the current particle system
  19176. */
  19177. removeDragGradient(gradient: number): IParticleSystem;
  19178. /**
  19179. * Gets the current list of drag gradients.
  19180. * You must use addDragGradient and removeDragGradient to udpate this list
  19181. * @returns the list of drag gradients
  19182. */
  19183. getDragGradients(): Nullable<Array<FactorGradient>>;
  19184. /**
  19185. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19186. * @param gradient defines the gradient to use (between 0 and 1)
  19187. * @param factor defines the emit rate to affect to the specified gradient
  19188. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19189. * @returns the current particle system
  19190. */
  19191. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19192. /**
  19193. * Remove a specific emit rate gradient
  19194. * @param gradient defines the gradient to remove
  19195. * @returns the current particle system
  19196. */
  19197. removeEmitRateGradient(gradient: number): IParticleSystem;
  19198. /**
  19199. * Gets the current list of emit rate gradients.
  19200. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19201. * @returns the list of emit rate gradients
  19202. */
  19203. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19204. /**
  19205. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19206. * @param gradient defines the gradient to use (between 0 and 1)
  19207. * @param factor defines the start size to affect to the specified gradient
  19208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19209. * @returns the current particle system
  19210. */
  19211. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19212. /**
  19213. * Remove a specific start size gradient
  19214. * @param gradient defines the gradient to remove
  19215. * @returns the current particle system
  19216. */
  19217. removeStartSizeGradient(gradient: number): IParticleSystem;
  19218. /**
  19219. * Gets the current list of start size gradients.
  19220. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19221. * @returns the list of start size gradients
  19222. */
  19223. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19224. /**
  19225. * Adds a new life time gradient
  19226. * @param gradient defines the gradient to use (between 0 and 1)
  19227. * @param factor defines the life time factor to affect to the specified gradient
  19228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19229. * @returns the current particle system
  19230. */
  19231. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19232. /**
  19233. * Remove a specific life time gradient
  19234. * @param gradient defines the gradient to remove
  19235. * @returns the current particle system
  19236. */
  19237. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19238. /**
  19239. * Gets the current list of life time gradients.
  19240. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19241. * @returns the list of life time gradients
  19242. */
  19243. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19244. /**
  19245. * Gets the current list of color gradients.
  19246. * You must use addColorGradient and removeColorGradient to udpate this list
  19247. * @returns the list of color gradients
  19248. */
  19249. getColorGradients(): Nullable<Array<ColorGradient>>;
  19250. /**
  19251. * Adds a new ramp gradient used to remap particle colors
  19252. * @param gradient defines the gradient to use (between 0 and 1)
  19253. * @param color defines the color to affect to the specified gradient
  19254. * @returns the current particle system
  19255. */
  19256. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19257. /**
  19258. * Gets the current list of ramp gradients.
  19259. * You must use addRampGradient and removeRampGradient to udpate this list
  19260. * @returns the list of ramp gradients
  19261. */
  19262. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19263. /** Gets or sets a boolean indicating that ramp gradients must be used
  19264. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19265. */
  19266. useRampGradients: boolean;
  19267. /**
  19268. * Adds a new color remap gradient
  19269. * @param gradient defines the gradient to use (between 0 and 1)
  19270. * @param min defines the color remap minimal range
  19271. * @param max defines the color remap maximal range
  19272. * @returns the current particle system
  19273. */
  19274. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19275. /**
  19276. * Gets the current list of color remap gradients.
  19277. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19278. * @returns the list of color remap gradients
  19279. */
  19280. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19281. /**
  19282. * Adds a new alpha remap gradient
  19283. * @param gradient defines the gradient to use (between 0 and 1)
  19284. * @param min defines the alpha remap minimal range
  19285. * @param max defines the alpha remap maximal range
  19286. * @returns the current particle system
  19287. */
  19288. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19289. /**
  19290. * Gets the current list of alpha remap gradients.
  19291. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19292. * @returns the list of alpha remap gradients
  19293. */
  19294. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19295. /**
  19296. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19297. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19298. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19299. * @returns the emitter
  19300. */
  19301. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19302. /**
  19303. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19304. * @param radius The radius of the hemisphere to emit from
  19305. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19306. * @returns the emitter
  19307. */
  19308. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19309. /**
  19310. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19311. * @param radius The radius of the sphere to emit from
  19312. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19313. * @returns the emitter
  19314. */
  19315. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19316. /**
  19317. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19318. * @param radius The radius of the sphere to emit from
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19321. * @returns the emitter
  19322. */
  19323. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19324. /**
  19325. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19326. * @param radius The radius of the emission cylinder
  19327. * @param height The height of the emission cylinder
  19328. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19329. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19330. * @returns the emitter
  19331. */
  19332. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19333. /**
  19334. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19335. * @param radius The radius of the cylinder to emit from
  19336. * @param height The height of the emission cylinder
  19337. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19338. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19339. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19340. * @returns the emitter
  19341. */
  19342. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19343. /**
  19344. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19345. * @param radius The radius of the cone to emit from
  19346. * @param angle The base angle of the cone
  19347. * @returns the emitter
  19348. */
  19349. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19350. /**
  19351. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19352. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19353. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19354. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19355. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19356. * @returns the emitter
  19357. */
  19358. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19359. /**
  19360. * Get hosting scene
  19361. * @returns the scene
  19362. */
  19363. getScene(): Scene;
  19364. }
  19365. }
  19366. declare module "babylonjs/Meshes/instancedMesh" {
  19367. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19368. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19369. import { Camera } from "babylonjs/Cameras/camera";
  19370. import { Node } from "babylonjs/node";
  19371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19372. import { Mesh } from "babylonjs/Meshes/mesh";
  19373. import { Material } from "babylonjs/Materials/material";
  19374. import { Skeleton } from "babylonjs/Bones/skeleton";
  19375. import { Light } from "babylonjs/Lights/light";
  19376. /**
  19377. * Creates an instance based on a source mesh.
  19378. */
  19379. export class InstancedMesh extends AbstractMesh {
  19380. private _sourceMesh;
  19381. private _currentLOD;
  19382. /** @hidden */
  19383. _indexInSourceMeshInstanceArray: number;
  19384. constructor(name: string, source: Mesh);
  19385. /**
  19386. * Returns the string "InstancedMesh".
  19387. */
  19388. getClassName(): string;
  19389. /** Gets the list of lights affecting that mesh */
  19390. readonly lightSources: Light[];
  19391. _resyncLightSources(): void;
  19392. _resyncLighSource(light: Light): void;
  19393. _removeLightSource(light: Light, dispose: boolean): void;
  19394. /**
  19395. * If the source mesh receives shadows
  19396. */
  19397. readonly receiveShadows: boolean;
  19398. /**
  19399. * The material of the source mesh
  19400. */
  19401. readonly material: Nullable<Material>;
  19402. /**
  19403. * Visibility of the source mesh
  19404. */
  19405. readonly visibility: number;
  19406. /**
  19407. * Skeleton of the source mesh
  19408. */
  19409. readonly skeleton: Nullable<Skeleton>;
  19410. /**
  19411. * Rendering ground id of the source mesh
  19412. */
  19413. renderingGroupId: number;
  19414. /**
  19415. * Returns the total number of vertices (integer).
  19416. */
  19417. getTotalVertices(): number;
  19418. /**
  19419. * Returns a positive integer : the total number of indices in this mesh geometry.
  19420. * @returns the numner of indices or zero if the mesh has no geometry.
  19421. */
  19422. getTotalIndices(): number;
  19423. /**
  19424. * The source mesh of the instance
  19425. */
  19426. readonly sourceMesh: Mesh;
  19427. /**
  19428. * Is this node ready to be used/rendered
  19429. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19430. * @return {boolean} is it ready
  19431. */
  19432. isReady(completeCheck?: boolean): boolean;
  19433. /**
  19434. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19435. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19436. * @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.
  19437. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19438. */
  19439. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19440. /**
  19441. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19442. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19443. * The `data` are either a numeric array either a Float32Array.
  19444. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19445. * 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).
  19446. * Note that a new underlying VertexBuffer object is created each call.
  19447. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19448. *
  19449. * Possible `kind` values :
  19450. * - VertexBuffer.PositionKind
  19451. * - VertexBuffer.UVKind
  19452. * - VertexBuffer.UV2Kind
  19453. * - VertexBuffer.UV3Kind
  19454. * - VertexBuffer.UV4Kind
  19455. * - VertexBuffer.UV5Kind
  19456. * - VertexBuffer.UV6Kind
  19457. * - VertexBuffer.ColorKind
  19458. * - VertexBuffer.MatricesIndicesKind
  19459. * - VertexBuffer.MatricesIndicesExtraKind
  19460. * - VertexBuffer.MatricesWeightsKind
  19461. * - VertexBuffer.MatricesWeightsExtraKind
  19462. *
  19463. * Returns the Mesh.
  19464. */
  19465. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19466. /**
  19467. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19468. * If the mesh has no geometry, it is simply returned as it is.
  19469. * The `data` are either a numeric array either a Float32Array.
  19470. * No new underlying VertexBuffer object is created.
  19471. * 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.
  19472. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19473. *
  19474. * Possible `kind` values :
  19475. * - VertexBuffer.PositionKind
  19476. * - VertexBuffer.UVKind
  19477. * - VertexBuffer.UV2Kind
  19478. * - VertexBuffer.UV3Kind
  19479. * - VertexBuffer.UV4Kind
  19480. * - VertexBuffer.UV5Kind
  19481. * - VertexBuffer.UV6Kind
  19482. * - VertexBuffer.ColorKind
  19483. * - VertexBuffer.MatricesIndicesKind
  19484. * - VertexBuffer.MatricesIndicesExtraKind
  19485. * - VertexBuffer.MatricesWeightsKind
  19486. * - VertexBuffer.MatricesWeightsExtraKind
  19487. *
  19488. * Returns the Mesh.
  19489. */
  19490. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19491. /**
  19492. * Sets the mesh indices.
  19493. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19494. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19495. * This method creates a new index buffer each call.
  19496. * Returns the Mesh.
  19497. */
  19498. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19499. /**
  19500. * Boolean : True if the mesh owns the requested kind of data.
  19501. */
  19502. isVerticesDataPresent(kind: string): boolean;
  19503. /**
  19504. * Returns an array of indices (IndicesArray).
  19505. */
  19506. getIndices(): Nullable<IndicesArray>;
  19507. readonly _positions: Nullable<Vector3[]>;
  19508. /**
  19509. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19510. * This means the mesh underlying bounding box and sphere are recomputed.
  19511. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19512. * @returns the current mesh
  19513. */
  19514. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19515. /** @hidden */
  19516. _preActivate(): InstancedMesh;
  19517. /** @hidden */
  19518. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19519. /** @hidden */
  19520. _postActivate(): void;
  19521. getWorldMatrix(): Matrix;
  19522. readonly isAnInstance: boolean;
  19523. /**
  19524. * Returns the current associated LOD AbstractMesh.
  19525. */
  19526. getLOD(camera: Camera): AbstractMesh;
  19527. /** @hidden */
  19528. _syncSubMeshes(): InstancedMesh;
  19529. /** @hidden */
  19530. _generatePointsArray(): boolean;
  19531. /**
  19532. * Creates a new InstancedMesh from the current mesh.
  19533. * - name (string) : the cloned mesh name
  19534. * - newParent (optional Node) : the optional Node to parent the clone to.
  19535. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19536. *
  19537. * Returns the clone.
  19538. */
  19539. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19540. /**
  19541. * Disposes the InstancedMesh.
  19542. * Returns nothing.
  19543. */
  19544. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19545. }
  19546. }
  19547. declare module "babylonjs/Materials/shaderMaterial" {
  19548. import { Scene } from "babylonjs/scene";
  19549. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19551. import { Mesh } from "babylonjs/Meshes/mesh";
  19552. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19553. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19554. import { Texture } from "babylonjs/Materials/Textures/texture";
  19555. import { Material } from "babylonjs/Materials/material";
  19556. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19557. /**
  19558. * Defines the options associated with the creation of a shader material.
  19559. */
  19560. export interface IShaderMaterialOptions {
  19561. /**
  19562. * Does the material work in alpha blend mode
  19563. */
  19564. needAlphaBlending: boolean;
  19565. /**
  19566. * Does the material work in alpha test mode
  19567. */
  19568. needAlphaTesting: boolean;
  19569. /**
  19570. * The list of attribute names used in the shader
  19571. */
  19572. attributes: string[];
  19573. /**
  19574. * The list of unifrom names used in the shader
  19575. */
  19576. uniforms: string[];
  19577. /**
  19578. * The list of UBO names used in the shader
  19579. */
  19580. uniformBuffers: string[];
  19581. /**
  19582. * The list of sampler names used in the shader
  19583. */
  19584. samplers: string[];
  19585. /**
  19586. * The list of defines used in the shader
  19587. */
  19588. defines: string[];
  19589. }
  19590. /**
  19591. * 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.
  19592. *
  19593. * This returned material effects how the mesh will look based on the code in the shaders.
  19594. *
  19595. * @see http://doc.babylonjs.com/how_to/shader_material
  19596. */
  19597. export class ShaderMaterial extends Material {
  19598. private _shaderPath;
  19599. private _options;
  19600. private _textures;
  19601. private _textureArrays;
  19602. private _floats;
  19603. private _ints;
  19604. private _floatsArrays;
  19605. private _colors3;
  19606. private _colors3Arrays;
  19607. private _colors4;
  19608. private _colors4Arrays;
  19609. private _vectors2;
  19610. private _vectors3;
  19611. private _vectors4;
  19612. private _matrices;
  19613. private _matrices3x3;
  19614. private _matrices2x2;
  19615. private _vectors2Arrays;
  19616. private _vectors3Arrays;
  19617. private _vectors4Arrays;
  19618. private _cachedWorldViewMatrix;
  19619. private _cachedWorldViewProjectionMatrix;
  19620. private _renderId;
  19621. /**
  19622. * Instantiate a new shader material.
  19623. * 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.
  19624. * This returned material effects how the mesh will look based on the code in the shaders.
  19625. * @see http://doc.babylonjs.com/how_to/shader_material
  19626. * @param name Define the name of the material in the scene
  19627. * @param scene Define the scene the material belongs to
  19628. * @param shaderPath Defines the route to the shader code in one of three ways:
  19629. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19630. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19631. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19632. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19633. * @param options Define the options used to create the shader
  19634. */
  19635. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19636. /**
  19637. * Gets the options used to compile the shader.
  19638. * They can be modified to trigger a new compilation
  19639. */
  19640. readonly options: IShaderMaterialOptions;
  19641. /**
  19642. * Gets the current class name of the material e.g. "ShaderMaterial"
  19643. * Mainly use in serialization.
  19644. * @returns the class name
  19645. */
  19646. getClassName(): string;
  19647. /**
  19648. * Specifies if the material will require alpha blending
  19649. * @returns a boolean specifying if alpha blending is needed
  19650. */
  19651. needAlphaBlending(): boolean;
  19652. /**
  19653. * Specifies if this material should be rendered in alpha test mode
  19654. * @returns a boolean specifying if an alpha test is needed.
  19655. */
  19656. needAlphaTesting(): boolean;
  19657. private _checkUniform;
  19658. /**
  19659. * Set a texture in the shader.
  19660. * @param name Define the name of the uniform samplers as defined in the shader
  19661. * @param texture Define the texture to bind to this sampler
  19662. * @return the material itself allowing "fluent" like uniform updates
  19663. */
  19664. setTexture(name: string, texture: Texture): ShaderMaterial;
  19665. /**
  19666. * Set a texture array in the shader.
  19667. * @param name Define the name of the uniform sampler array as defined in the shader
  19668. * @param textures Define the list of textures to bind to this sampler
  19669. * @return the material itself allowing "fluent" like uniform updates
  19670. */
  19671. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19672. /**
  19673. * Set a float in the shader.
  19674. * @param name Define the name of the uniform as defined in the shader
  19675. * @param value Define the value to give to the uniform
  19676. * @return the material itself allowing "fluent" like uniform updates
  19677. */
  19678. setFloat(name: string, value: number): ShaderMaterial;
  19679. /**
  19680. * Set a int in the shader.
  19681. * @param name Define the name of the uniform as defined in the shader
  19682. * @param value Define the value to give to the uniform
  19683. * @return the material itself allowing "fluent" like uniform updates
  19684. */
  19685. setInt(name: string, value: number): ShaderMaterial;
  19686. /**
  19687. * Set an array of floats in the shader.
  19688. * @param name Define the name of the uniform as defined in the shader
  19689. * @param value Define the value to give to the uniform
  19690. * @return the material itself allowing "fluent" like uniform updates
  19691. */
  19692. setFloats(name: string, value: number[]): ShaderMaterial;
  19693. /**
  19694. * Set a vec3 in the shader from a Color3.
  19695. * @param name Define the name of the uniform as defined in the shader
  19696. * @param value Define the value to give to the uniform
  19697. * @return the material itself allowing "fluent" like uniform updates
  19698. */
  19699. setColor3(name: string, value: Color3): ShaderMaterial;
  19700. /**
  19701. * Set a vec3 array in the shader from a Color3 array.
  19702. * @param name Define the name of the uniform as defined in the shader
  19703. * @param value Define the value to give to the uniform
  19704. * @return the material itself allowing "fluent" like uniform updates
  19705. */
  19706. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19707. /**
  19708. * Set a vec4 in the shader from a Color4.
  19709. * @param name Define the name of the uniform as defined in the shader
  19710. * @param value Define the value to give to the uniform
  19711. * @return the material itself allowing "fluent" like uniform updates
  19712. */
  19713. setColor4(name: string, value: Color4): ShaderMaterial;
  19714. /**
  19715. * Set a vec4 array in the shader from a Color4 array.
  19716. * @param name Define the name of the uniform as defined in the shader
  19717. * @param value Define the value to give to the uniform
  19718. * @return the material itself allowing "fluent" like uniform updates
  19719. */
  19720. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19721. /**
  19722. * Set a vec2 in the shader from a Vector2.
  19723. * @param name Define the name of the uniform as defined in the shader
  19724. * @param value Define the value to give to the uniform
  19725. * @return the material itself allowing "fluent" like uniform updates
  19726. */
  19727. setVector2(name: string, value: Vector2): ShaderMaterial;
  19728. /**
  19729. * Set a vec3 in the shader from a Vector3.
  19730. * @param name Define the name of the uniform as defined in the shader
  19731. * @param value Define the value to give to the uniform
  19732. * @return the material itself allowing "fluent" like uniform updates
  19733. */
  19734. setVector3(name: string, value: Vector3): ShaderMaterial;
  19735. /**
  19736. * Set a vec4 in the shader from a Vector4.
  19737. * @param name Define the name of the uniform as defined in the shader
  19738. * @param value Define the value to give to the uniform
  19739. * @return the material itself allowing "fluent" like uniform updates
  19740. */
  19741. setVector4(name: string, value: Vector4): ShaderMaterial;
  19742. /**
  19743. * Set a mat4 in the shader from a Matrix.
  19744. * @param name Define the name of the uniform as defined in the shader
  19745. * @param value Define the value to give to the uniform
  19746. * @return the material itself allowing "fluent" like uniform updates
  19747. */
  19748. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19749. /**
  19750. * Set a mat3 in the shader from a Float32Array.
  19751. * @param name Define the name of the uniform as defined in the shader
  19752. * @param value Define the value to give to the uniform
  19753. * @return the material itself allowing "fluent" like uniform updates
  19754. */
  19755. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19756. /**
  19757. * Set a mat2 in the shader from a Float32Array.
  19758. * @param name Define the name of the uniform as defined in the shader
  19759. * @param value Define the value to give to the uniform
  19760. * @return the material itself allowing "fluent" like uniform updates
  19761. */
  19762. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19763. /**
  19764. * Set a vec2 array in the shader from a number array.
  19765. * @param name Define the name of the uniform as defined in the shader
  19766. * @param value Define the value to give to the uniform
  19767. * @return the material itself allowing "fluent" like uniform updates
  19768. */
  19769. setArray2(name: string, value: number[]): ShaderMaterial;
  19770. /**
  19771. * Set a vec3 array in the shader from a number array.
  19772. * @param name Define the name of the uniform as defined in the shader
  19773. * @param value Define the value to give to the uniform
  19774. * @return the material itself allowing "fluent" like uniform updates
  19775. */
  19776. setArray3(name: string, value: number[]): ShaderMaterial;
  19777. /**
  19778. * Set a vec4 array in the shader from a number array.
  19779. * @param name Define the name of the uniform as defined in the shader
  19780. * @param value Define the value to give to the uniform
  19781. * @return the material itself allowing "fluent" like uniform updates
  19782. */
  19783. setArray4(name: string, value: number[]): ShaderMaterial;
  19784. private _checkCache;
  19785. /**
  19786. * Specifies that the submesh is ready to be used
  19787. * @param mesh defines the mesh to check
  19788. * @param subMesh defines which submesh to check
  19789. * @param useInstances specifies that instances should be used
  19790. * @returns a boolean indicating that the submesh is ready or not
  19791. */
  19792. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19793. /**
  19794. * Checks if the material is ready to render the requested mesh
  19795. * @param mesh Define the mesh to render
  19796. * @param useInstances Define whether or not the material is used with instances
  19797. * @returns true if ready, otherwise false
  19798. */
  19799. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19800. /**
  19801. * Binds the world matrix to the material
  19802. * @param world defines the world transformation matrix
  19803. */
  19804. bindOnlyWorldMatrix(world: Matrix): void;
  19805. /**
  19806. * Binds the material to the mesh
  19807. * @param world defines the world transformation matrix
  19808. * @param mesh defines the mesh to bind the material to
  19809. */
  19810. bind(world: Matrix, mesh?: Mesh): void;
  19811. /**
  19812. * Gets the active textures from the material
  19813. * @returns an array of textures
  19814. */
  19815. getActiveTextures(): BaseTexture[];
  19816. /**
  19817. * Specifies if the material uses a texture
  19818. * @param texture defines the texture to check against the material
  19819. * @returns a boolean specifying if the material uses the texture
  19820. */
  19821. hasTexture(texture: BaseTexture): boolean;
  19822. /**
  19823. * Makes a duplicate of the material, and gives it a new name
  19824. * @param name defines the new name for the duplicated material
  19825. * @returns the cloned material
  19826. */
  19827. clone(name: string): ShaderMaterial;
  19828. /**
  19829. * Disposes the material
  19830. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19831. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19832. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19833. */
  19834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19835. /**
  19836. * Serializes this material in a JSON representation
  19837. * @returns the serialized material object
  19838. */
  19839. serialize(): any;
  19840. /**
  19841. * Creates a shader material from parsed shader material data
  19842. * @param source defines the JSON represnetation of the material
  19843. * @param scene defines the hosting scene
  19844. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19845. * @returns a new material
  19846. */
  19847. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19848. }
  19849. }
  19850. declare module "babylonjs/Shaders/color.fragment" {
  19851. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19853. /** @hidden */
  19854. export var colorPixelShader: {
  19855. name: string;
  19856. shader: string;
  19857. };
  19858. }
  19859. declare module "babylonjs/Shaders/color.vertex" {
  19860. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19861. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19864. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19865. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19866. /** @hidden */
  19867. export var colorVertexShader: {
  19868. name: string;
  19869. shader: string;
  19870. };
  19871. }
  19872. declare module "babylonjs/Meshes/linesMesh" {
  19873. import { Nullable } from "babylonjs/types";
  19874. import { Scene } from "babylonjs/scene";
  19875. import { Color3 } from "babylonjs/Maths/math.color";
  19876. import { Node } from "babylonjs/node";
  19877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19878. import { Mesh } from "babylonjs/Meshes/mesh";
  19879. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19880. import { Effect } from "babylonjs/Materials/effect";
  19881. import { Material } from "babylonjs/Materials/material";
  19882. import "babylonjs/Shaders/color.fragment";
  19883. import "babylonjs/Shaders/color.vertex";
  19884. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19885. /**
  19886. * Line mesh
  19887. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19888. */
  19889. export class LinesMesh extends Mesh {
  19890. /**
  19891. * If vertex color should be applied to the mesh
  19892. */
  19893. readonly useVertexColor?: boolean | undefined;
  19894. /**
  19895. * If vertex alpha should be applied to the mesh
  19896. */
  19897. readonly useVertexAlpha?: boolean | undefined;
  19898. /**
  19899. * Color of the line (Default: White)
  19900. */
  19901. color: Color3;
  19902. /**
  19903. * Alpha of the line (Default: 1)
  19904. */
  19905. alpha: number;
  19906. /**
  19907. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19908. * This margin is expressed in world space coordinates, so its value may vary.
  19909. * Default value is 0.1
  19910. */
  19911. intersectionThreshold: number;
  19912. private _colorShader;
  19913. private color4;
  19914. /**
  19915. * Creates a new LinesMesh
  19916. * @param name defines the name
  19917. * @param scene defines the hosting scene
  19918. * @param parent defines the parent mesh if any
  19919. * @param source defines the optional source LinesMesh used to clone data from
  19920. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19921. * When false, achieved by calling a clone(), also passing False.
  19922. * This will make creation of children, recursive.
  19923. * @param useVertexColor defines if this LinesMesh supports vertex color
  19924. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19925. */
  19926. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19927. /**
  19928. * If vertex color should be applied to the mesh
  19929. */
  19930. useVertexColor?: boolean | undefined,
  19931. /**
  19932. * If vertex alpha should be applied to the mesh
  19933. */
  19934. useVertexAlpha?: boolean | undefined);
  19935. private _addClipPlaneDefine;
  19936. private _removeClipPlaneDefine;
  19937. isReady(): boolean;
  19938. /**
  19939. * Returns the string "LineMesh"
  19940. */
  19941. getClassName(): string;
  19942. /**
  19943. * @hidden
  19944. */
  19945. /**
  19946. * @hidden
  19947. */
  19948. material: Material;
  19949. /**
  19950. * @hidden
  19951. */
  19952. readonly checkCollisions: boolean;
  19953. /** @hidden */
  19954. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19955. /** @hidden */
  19956. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19957. /**
  19958. * Disposes of the line mesh
  19959. * @param doNotRecurse If children should be disposed
  19960. */
  19961. dispose(doNotRecurse?: boolean): void;
  19962. /**
  19963. * Returns a new LineMesh object cloned from the current one.
  19964. */
  19965. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19966. /**
  19967. * Creates a new InstancedLinesMesh object from the mesh model.
  19968. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19969. * @param name defines the name of the new instance
  19970. * @returns a new InstancedLinesMesh
  19971. */
  19972. createInstance(name: string): InstancedLinesMesh;
  19973. }
  19974. /**
  19975. * Creates an instance based on a source LinesMesh
  19976. */
  19977. export class InstancedLinesMesh extends InstancedMesh {
  19978. /**
  19979. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19980. * This margin is expressed in world space coordinates, so its value may vary.
  19981. * Initilized with the intersectionThreshold value of the source LinesMesh
  19982. */
  19983. intersectionThreshold: number;
  19984. constructor(name: string, source: LinesMesh);
  19985. /**
  19986. * Returns the string "InstancedLinesMesh".
  19987. */
  19988. getClassName(): string;
  19989. }
  19990. }
  19991. declare module "babylonjs/Shaders/line.fragment" {
  19992. /** @hidden */
  19993. export var linePixelShader: {
  19994. name: string;
  19995. shader: string;
  19996. };
  19997. }
  19998. declare module "babylonjs/Shaders/line.vertex" {
  19999. /** @hidden */
  20000. export var lineVertexShader: {
  20001. name: string;
  20002. shader: string;
  20003. };
  20004. }
  20005. declare module "babylonjs/Rendering/edgesRenderer" {
  20006. import { Nullable } from "babylonjs/types";
  20007. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20009. import { Vector3 } from "babylonjs/Maths/math.vector";
  20010. import { IDisposable } from "babylonjs/scene";
  20011. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20012. import "babylonjs/Shaders/line.fragment";
  20013. import "babylonjs/Shaders/line.vertex";
  20014. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20015. module "babylonjs/Meshes/abstractMesh" {
  20016. interface AbstractMesh {
  20017. /**
  20018. * Gets the edgesRenderer associated with the mesh
  20019. */
  20020. edgesRenderer: Nullable<EdgesRenderer>;
  20021. }
  20022. }
  20023. module "babylonjs/Meshes/linesMesh" {
  20024. interface LinesMesh {
  20025. /**
  20026. * Enables the edge rendering mode on the mesh.
  20027. * This mode makes the mesh edges visible
  20028. * @param epsilon defines the maximal distance between two angles to detect a face
  20029. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20030. * @returns the currentAbstractMesh
  20031. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20032. */
  20033. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20034. }
  20035. }
  20036. module "babylonjs/Meshes/linesMesh" {
  20037. interface InstancedLinesMesh {
  20038. /**
  20039. * Enables the edge rendering mode on the mesh.
  20040. * This mode makes the mesh edges visible
  20041. * @param epsilon defines the maximal distance between two angles to detect a face
  20042. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20043. * @returns the current InstancedLinesMesh
  20044. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20045. */
  20046. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20047. }
  20048. }
  20049. /**
  20050. * Defines the minimum contract an Edges renderer should follow.
  20051. */
  20052. export interface IEdgesRenderer extends IDisposable {
  20053. /**
  20054. * Gets or sets a boolean indicating if the edgesRenderer is active
  20055. */
  20056. isEnabled: boolean;
  20057. /**
  20058. * Renders the edges of the attached mesh,
  20059. */
  20060. render(): void;
  20061. /**
  20062. * Checks wether or not the edges renderer is ready to render.
  20063. * @return true if ready, otherwise false.
  20064. */
  20065. isReady(): boolean;
  20066. }
  20067. /**
  20068. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20069. */
  20070. export class EdgesRenderer implements IEdgesRenderer {
  20071. /**
  20072. * Define the size of the edges with an orthographic camera
  20073. */
  20074. edgesWidthScalerForOrthographic: number;
  20075. /**
  20076. * Define the size of the edges with a perspective camera
  20077. */
  20078. edgesWidthScalerForPerspective: number;
  20079. protected _source: AbstractMesh;
  20080. protected _linesPositions: number[];
  20081. protected _linesNormals: number[];
  20082. protected _linesIndices: number[];
  20083. protected _epsilon: number;
  20084. protected _indicesCount: number;
  20085. protected _lineShader: ShaderMaterial;
  20086. protected _ib: DataBuffer;
  20087. protected _buffers: {
  20088. [key: string]: Nullable<VertexBuffer>;
  20089. };
  20090. protected _checkVerticesInsteadOfIndices: boolean;
  20091. private _meshRebuildObserver;
  20092. private _meshDisposeObserver;
  20093. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20094. isEnabled: boolean;
  20095. /**
  20096. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20097. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20098. * @param source Mesh used to create edges
  20099. * @param epsilon sum of angles in adjacency to check for edge
  20100. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20101. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20102. */
  20103. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20104. protected _prepareRessources(): void;
  20105. /** @hidden */
  20106. _rebuild(): void;
  20107. /**
  20108. * Releases the required resources for the edges renderer
  20109. */
  20110. dispose(): void;
  20111. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20112. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20113. /**
  20114. * Checks if the pair of p0 and p1 is en edge
  20115. * @param faceIndex
  20116. * @param edge
  20117. * @param faceNormals
  20118. * @param p0
  20119. * @param p1
  20120. * @private
  20121. */
  20122. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20123. /**
  20124. * push line into the position, normal and index buffer
  20125. * @protected
  20126. */
  20127. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20128. /**
  20129. * Generates lines edges from adjacencjes
  20130. * @private
  20131. */
  20132. _generateEdgesLines(): void;
  20133. /**
  20134. * Checks wether or not the edges renderer is ready to render.
  20135. * @return true if ready, otherwise false.
  20136. */
  20137. isReady(): boolean;
  20138. /**
  20139. * Renders the edges of the attached mesh,
  20140. */
  20141. render(): void;
  20142. }
  20143. /**
  20144. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20145. */
  20146. export class LineEdgesRenderer extends EdgesRenderer {
  20147. /**
  20148. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20149. * @param source LineMesh used to generate edges
  20150. * @param epsilon not important (specified angle for edge detection)
  20151. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20152. */
  20153. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20154. /**
  20155. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20156. */
  20157. _generateEdgesLines(): void;
  20158. }
  20159. }
  20160. declare module "babylonjs/Rendering/renderingGroup" {
  20161. import { SmartArray } from "babylonjs/Misc/smartArray";
  20162. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20164. import { Nullable } from "babylonjs/types";
  20165. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20166. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20167. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20168. import { Material } from "babylonjs/Materials/material";
  20169. import { Scene } from "babylonjs/scene";
  20170. /**
  20171. * This represents the object necessary to create a rendering group.
  20172. * This is exclusively used and created by the rendering manager.
  20173. * To modify the behavior, you use the available helpers in your scene or meshes.
  20174. * @hidden
  20175. */
  20176. export class RenderingGroup {
  20177. index: number;
  20178. private static _zeroVector;
  20179. private _scene;
  20180. private _opaqueSubMeshes;
  20181. private _transparentSubMeshes;
  20182. private _alphaTestSubMeshes;
  20183. private _depthOnlySubMeshes;
  20184. private _particleSystems;
  20185. private _spriteManagers;
  20186. private _opaqueSortCompareFn;
  20187. private _alphaTestSortCompareFn;
  20188. private _transparentSortCompareFn;
  20189. private _renderOpaque;
  20190. private _renderAlphaTest;
  20191. private _renderTransparent;
  20192. /** @hidden */
  20193. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20194. onBeforeTransparentRendering: () => void;
  20195. /**
  20196. * Set the opaque sort comparison function.
  20197. * If null the sub meshes will be render in the order they were created
  20198. */
  20199. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20200. /**
  20201. * Set the alpha test sort comparison function.
  20202. * If null the sub meshes will be render in the order they were created
  20203. */
  20204. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20205. /**
  20206. * Set the transparent sort comparison function.
  20207. * If null the sub meshes will be render in the order they were created
  20208. */
  20209. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20210. /**
  20211. * Creates a new rendering group.
  20212. * @param index The rendering group index
  20213. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20214. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20215. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20216. */
  20217. 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>);
  20218. /**
  20219. * Render all the sub meshes contained in the group.
  20220. * @param customRenderFunction Used to override the default render behaviour of the group.
  20221. * @returns true if rendered some submeshes.
  20222. */
  20223. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20224. /**
  20225. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20226. * @param subMeshes The submeshes to render
  20227. */
  20228. private renderOpaqueSorted;
  20229. /**
  20230. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20231. * @param subMeshes The submeshes to render
  20232. */
  20233. private renderAlphaTestSorted;
  20234. /**
  20235. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20236. * @param subMeshes The submeshes to render
  20237. */
  20238. private renderTransparentSorted;
  20239. /**
  20240. * Renders the submeshes in a specified order.
  20241. * @param subMeshes The submeshes to sort before render
  20242. * @param sortCompareFn The comparison function use to sort
  20243. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20244. * @param transparent Specifies to activate blending if true
  20245. */
  20246. private static renderSorted;
  20247. /**
  20248. * Renders the submeshes in the order they were dispatched (no sort applied).
  20249. * @param subMeshes The submeshes to render
  20250. */
  20251. private static renderUnsorted;
  20252. /**
  20253. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20254. * are rendered back to front if in the same alpha index.
  20255. *
  20256. * @param a The first submesh
  20257. * @param b The second submesh
  20258. * @returns The result of the comparison
  20259. */
  20260. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20261. /**
  20262. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20263. * are rendered back to front.
  20264. *
  20265. * @param a The first submesh
  20266. * @param b The second submesh
  20267. * @returns The result of the comparison
  20268. */
  20269. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20270. /**
  20271. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20272. * are rendered front to back (prevent overdraw).
  20273. *
  20274. * @param a The first submesh
  20275. * @param b The second submesh
  20276. * @returns The result of the comparison
  20277. */
  20278. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20279. /**
  20280. * Resets the different lists of submeshes to prepare a new frame.
  20281. */
  20282. prepare(): void;
  20283. dispose(): void;
  20284. /**
  20285. * Inserts the submesh in its correct queue depending on its material.
  20286. * @param subMesh The submesh to dispatch
  20287. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20288. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20289. */
  20290. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20291. dispatchSprites(spriteManager: ISpriteManager): void;
  20292. dispatchParticles(particleSystem: IParticleSystem): void;
  20293. private _renderParticles;
  20294. private _renderSprites;
  20295. }
  20296. }
  20297. declare module "babylonjs/Rendering/renderingManager" {
  20298. import { Nullable } from "babylonjs/types";
  20299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20300. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20301. import { SmartArray } from "babylonjs/Misc/smartArray";
  20302. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20303. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20304. import { Material } from "babylonjs/Materials/material";
  20305. import { Scene } from "babylonjs/scene";
  20306. import { Camera } from "babylonjs/Cameras/camera";
  20307. /**
  20308. * Interface describing the different options available in the rendering manager
  20309. * regarding Auto Clear between groups.
  20310. */
  20311. export interface IRenderingManagerAutoClearSetup {
  20312. /**
  20313. * Defines whether or not autoclear is enable.
  20314. */
  20315. autoClear: boolean;
  20316. /**
  20317. * Defines whether or not to autoclear the depth buffer.
  20318. */
  20319. depth: boolean;
  20320. /**
  20321. * Defines whether or not to autoclear the stencil buffer.
  20322. */
  20323. stencil: boolean;
  20324. }
  20325. /**
  20326. * This class is used by the onRenderingGroupObservable
  20327. */
  20328. export class RenderingGroupInfo {
  20329. /**
  20330. * The Scene that being rendered
  20331. */
  20332. scene: Scene;
  20333. /**
  20334. * The camera currently used for the rendering pass
  20335. */
  20336. camera: Nullable<Camera>;
  20337. /**
  20338. * The ID of the renderingGroup being processed
  20339. */
  20340. renderingGroupId: number;
  20341. }
  20342. /**
  20343. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20344. * It is enable to manage the different groups as well as the different necessary sort functions.
  20345. * This should not be used directly aside of the few static configurations
  20346. */
  20347. export class RenderingManager {
  20348. /**
  20349. * The max id used for rendering groups (not included)
  20350. */
  20351. static MAX_RENDERINGGROUPS: number;
  20352. /**
  20353. * The min id used for rendering groups (included)
  20354. */
  20355. static MIN_RENDERINGGROUPS: number;
  20356. /**
  20357. * Used to globally prevent autoclearing scenes.
  20358. */
  20359. static AUTOCLEAR: boolean;
  20360. /**
  20361. * @hidden
  20362. */
  20363. _useSceneAutoClearSetup: boolean;
  20364. private _scene;
  20365. private _renderingGroups;
  20366. private _depthStencilBufferAlreadyCleaned;
  20367. private _autoClearDepthStencil;
  20368. private _customOpaqueSortCompareFn;
  20369. private _customAlphaTestSortCompareFn;
  20370. private _customTransparentSortCompareFn;
  20371. private _renderingGroupInfo;
  20372. /**
  20373. * Instantiates a new rendering group for a particular scene
  20374. * @param scene Defines the scene the groups belongs to
  20375. */
  20376. constructor(scene: Scene);
  20377. private _clearDepthStencilBuffer;
  20378. /**
  20379. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20380. * @hidden
  20381. */
  20382. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20383. /**
  20384. * Resets the different information of the group to prepare a new frame
  20385. * @hidden
  20386. */
  20387. reset(): void;
  20388. /**
  20389. * Dispose and release the group and its associated resources.
  20390. * @hidden
  20391. */
  20392. dispose(): void;
  20393. /**
  20394. * Clear the info related to rendering groups preventing retention points during dispose.
  20395. */
  20396. freeRenderingGroups(): void;
  20397. private _prepareRenderingGroup;
  20398. /**
  20399. * Add a sprite manager to the rendering manager in order to render it this frame.
  20400. * @param spriteManager Define the sprite manager to render
  20401. */
  20402. dispatchSprites(spriteManager: ISpriteManager): void;
  20403. /**
  20404. * Add a particle system to the rendering manager in order to render it this frame.
  20405. * @param particleSystem Define the particle system to render
  20406. */
  20407. dispatchParticles(particleSystem: IParticleSystem): void;
  20408. /**
  20409. * Add a submesh to the manager in order to render it this frame
  20410. * @param subMesh The submesh to dispatch
  20411. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20412. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20413. */
  20414. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20415. /**
  20416. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20417. * This allowed control for front to back rendering or reversly depending of the special needs.
  20418. *
  20419. * @param renderingGroupId The rendering group id corresponding to its index
  20420. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20421. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20422. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20423. */
  20424. 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;
  20425. /**
  20426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20427. *
  20428. * @param renderingGroupId The rendering group id corresponding to its index
  20429. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20430. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20431. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20432. */
  20433. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20434. /**
  20435. * Gets the current auto clear configuration for one rendering group of the rendering
  20436. * manager.
  20437. * @param index the rendering group index to get the information for
  20438. * @returns The auto clear setup for the requested rendering group
  20439. */
  20440. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20441. }
  20442. }
  20443. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20444. import { Observable } from "babylonjs/Misc/observable";
  20445. import { SmartArray } from "babylonjs/Misc/smartArray";
  20446. import { Nullable } from "babylonjs/types";
  20447. import { Camera } from "babylonjs/Cameras/camera";
  20448. import { Scene } from "babylonjs/scene";
  20449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20450. import { Color4 } from "babylonjs/Maths/math.color";
  20451. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20454. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20455. import { Texture } from "babylonjs/Materials/Textures/texture";
  20456. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20457. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20458. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20459. import { Engine } from "babylonjs/Engines/engine";
  20460. /**
  20461. * This Helps creating a texture that will be created from a camera in your scene.
  20462. * It is basically a dynamic texture that could be used to create special effects for instance.
  20463. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20464. */
  20465. export class RenderTargetTexture extends Texture {
  20466. isCube: boolean;
  20467. /**
  20468. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20469. */
  20470. static readonly REFRESHRATE_RENDER_ONCE: number;
  20471. /**
  20472. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20473. */
  20474. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20475. /**
  20476. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20477. * the central point of your effect and can save a lot of performances.
  20478. */
  20479. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20480. /**
  20481. * Use this predicate to dynamically define the list of mesh you want to render.
  20482. * If set, the renderList property will be overwritten.
  20483. */
  20484. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20485. private _renderList;
  20486. /**
  20487. * Use this list to define the list of mesh you want to render.
  20488. */
  20489. renderList: Nullable<Array<AbstractMesh>>;
  20490. private _hookArray;
  20491. /**
  20492. * Define if particles should be rendered in your texture.
  20493. */
  20494. renderParticles: boolean;
  20495. /**
  20496. * Define if sprites should be rendered in your texture.
  20497. */
  20498. renderSprites: boolean;
  20499. /**
  20500. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20501. */
  20502. coordinatesMode: number;
  20503. /**
  20504. * Define the camera used to render the texture.
  20505. */
  20506. activeCamera: Nullable<Camera>;
  20507. /**
  20508. * Override the render function of the texture with your own one.
  20509. */
  20510. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20511. /**
  20512. * Define if camera post processes should be use while rendering the texture.
  20513. */
  20514. useCameraPostProcesses: boolean;
  20515. /**
  20516. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20517. */
  20518. ignoreCameraViewport: boolean;
  20519. private _postProcessManager;
  20520. private _postProcesses;
  20521. private _resizeObserver;
  20522. /**
  20523. * An event triggered when the texture is unbind.
  20524. */
  20525. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20526. /**
  20527. * An event triggered when the texture is unbind.
  20528. */
  20529. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20530. private _onAfterUnbindObserver;
  20531. /**
  20532. * Set a after unbind callback in the texture.
  20533. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20534. */
  20535. onAfterUnbind: () => void;
  20536. /**
  20537. * An event triggered before rendering the texture
  20538. */
  20539. onBeforeRenderObservable: Observable<number>;
  20540. private _onBeforeRenderObserver;
  20541. /**
  20542. * Set a before render callback in the texture.
  20543. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20544. */
  20545. onBeforeRender: (faceIndex: number) => void;
  20546. /**
  20547. * An event triggered after rendering the texture
  20548. */
  20549. onAfterRenderObservable: Observable<number>;
  20550. private _onAfterRenderObserver;
  20551. /**
  20552. * Set a after render callback in the texture.
  20553. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20554. */
  20555. onAfterRender: (faceIndex: number) => void;
  20556. /**
  20557. * An event triggered after the texture clear
  20558. */
  20559. onClearObservable: Observable<Engine>;
  20560. private _onClearObserver;
  20561. /**
  20562. * Set a clear callback in the texture.
  20563. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20564. */
  20565. onClear: (Engine: Engine) => void;
  20566. /**
  20567. * An event triggered when the texture is resized.
  20568. */
  20569. onResizeObservable: Observable<RenderTargetTexture>;
  20570. /**
  20571. * Define the clear color of the Render Target if it should be different from the scene.
  20572. */
  20573. clearColor: Color4;
  20574. protected _size: number | {
  20575. width: number;
  20576. height: number;
  20577. };
  20578. protected _initialSizeParameter: number | {
  20579. width: number;
  20580. height: number;
  20581. } | {
  20582. ratio: number;
  20583. };
  20584. protected _sizeRatio: Nullable<number>;
  20585. /** @hidden */
  20586. _generateMipMaps: boolean;
  20587. protected _renderingManager: RenderingManager;
  20588. /** @hidden */
  20589. _waitingRenderList: string[];
  20590. protected _doNotChangeAspectRatio: boolean;
  20591. protected _currentRefreshId: number;
  20592. protected _refreshRate: number;
  20593. protected _textureMatrix: Matrix;
  20594. protected _samples: number;
  20595. protected _renderTargetOptions: RenderTargetCreationOptions;
  20596. /**
  20597. * Gets render target creation options that were used.
  20598. */
  20599. readonly renderTargetOptions: RenderTargetCreationOptions;
  20600. protected _engine: Engine;
  20601. protected _onRatioRescale(): void;
  20602. /**
  20603. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20604. * It must define where the camera used to render the texture is set
  20605. */
  20606. boundingBoxPosition: Vector3;
  20607. private _boundingBoxSize;
  20608. /**
  20609. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20610. * When defined, the cubemap will switch to local mode
  20611. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20612. * @example https://www.babylonjs-playground.com/#RNASML
  20613. */
  20614. boundingBoxSize: Vector3;
  20615. /**
  20616. * In case the RTT has been created with a depth texture, get the associated
  20617. * depth texture.
  20618. * Otherwise, return null.
  20619. */
  20620. depthStencilTexture: Nullable<InternalTexture>;
  20621. /**
  20622. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20623. * or used a shadow, depth texture...
  20624. * @param name The friendly name of the texture
  20625. * @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)
  20626. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20627. * @param generateMipMaps True if mip maps need to be generated after render.
  20628. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20629. * @param type The type of the buffer in the RTT (int, half float, float...)
  20630. * @param isCube True if a cube texture needs to be created
  20631. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20632. * @param generateDepthBuffer True to generate a depth buffer
  20633. * @param generateStencilBuffer True to generate a stencil buffer
  20634. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20635. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20636. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20637. */
  20638. constructor(name: string, size: number | {
  20639. width: number;
  20640. height: number;
  20641. } | {
  20642. ratio: number;
  20643. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20644. /**
  20645. * Creates a depth stencil texture.
  20646. * This is only available in WebGL 2 or with the depth texture extension available.
  20647. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20648. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20649. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20650. */
  20651. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20652. private _processSizeParameter;
  20653. /**
  20654. * Define the number of samples to use in case of MSAA.
  20655. * It defaults to one meaning no MSAA has been enabled.
  20656. */
  20657. samples: number;
  20658. /**
  20659. * Resets the refresh counter of the texture and start bak from scratch.
  20660. * Could be useful to regenerate the texture if it is setup to render only once.
  20661. */
  20662. resetRefreshCounter(): void;
  20663. /**
  20664. * Define the refresh rate of the texture or the rendering frequency.
  20665. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20666. */
  20667. refreshRate: number;
  20668. /**
  20669. * Adds a post process to the render target rendering passes.
  20670. * @param postProcess define the post process to add
  20671. */
  20672. addPostProcess(postProcess: PostProcess): void;
  20673. /**
  20674. * Clear all the post processes attached to the render target
  20675. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20676. */
  20677. clearPostProcesses(dispose?: boolean): void;
  20678. /**
  20679. * Remove one of the post process from the list of attached post processes to the texture
  20680. * @param postProcess define the post process to remove from the list
  20681. */
  20682. removePostProcess(postProcess: PostProcess): void;
  20683. /** @hidden */
  20684. _shouldRender(): boolean;
  20685. /**
  20686. * Gets the actual render size of the texture.
  20687. * @returns the width of the render size
  20688. */
  20689. getRenderSize(): number;
  20690. /**
  20691. * Gets the actual render width of the texture.
  20692. * @returns the width of the render size
  20693. */
  20694. getRenderWidth(): number;
  20695. /**
  20696. * Gets the actual render height of the texture.
  20697. * @returns the height of the render size
  20698. */
  20699. getRenderHeight(): number;
  20700. /**
  20701. * Get if the texture can be rescaled or not.
  20702. */
  20703. readonly canRescale: boolean;
  20704. /**
  20705. * Resize the texture using a ratio.
  20706. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20707. */
  20708. scale(ratio: number): void;
  20709. /**
  20710. * Get the texture reflection matrix used to rotate/transform the reflection.
  20711. * @returns the reflection matrix
  20712. */
  20713. getReflectionTextureMatrix(): Matrix;
  20714. /**
  20715. * Resize the texture to a new desired size.
  20716. * Be carrefull as it will recreate all the data in the new texture.
  20717. * @param size Define the new size. It can be:
  20718. * - a number for squared texture,
  20719. * - an object containing { width: number, height: number }
  20720. * - or an object containing a ratio { ratio: number }
  20721. */
  20722. resize(size: number | {
  20723. width: number;
  20724. height: number;
  20725. } | {
  20726. ratio: number;
  20727. }): void;
  20728. /**
  20729. * Renders all the objects from the render list into the texture.
  20730. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20731. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20732. */
  20733. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20734. private _bestReflectionRenderTargetDimension;
  20735. /**
  20736. * @hidden
  20737. * @param faceIndex face index to bind to if this is a cubetexture
  20738. */
  20739. _bindFrameBuffer(faceIndex?: number): void;
  20740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20741. private renderToTarget;
  20742. /**
  20743. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20744. * This allowed control for front to back rendering or reversly depending of the special needs.
  20745. *
  20746. * @param renderingGroupId The rendering group id corresponding to its index
  20747. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20748. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20749. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20750. */
  20751. 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;
  20752. /**
  20753. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20754. *
  20755. * @param renderingGroupId The rendering group id corresponding to its index
  20756. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20757. */
  20758. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20759. /**
  20760. * Clones the texture.
  20761. * @returns the cloned texture
  20762. */
  20763. clone(): RenderTargetTexture;
  20764. /**
  20765. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20766. * @returns The JSON representation of the texture
  20767. */
  20768. serialize(): any;
  20769. /**
  20770. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20771. */
  20772. disposeFramebufferObjects(): void;
  20773. /**
  20774. * Dispose the texture and release its associated resources.
  20775. */
  20776. dispose(): void;
  20777. /** @hidden */
  20778. _rebuild(): void;
  20779. /**
  20780. * Clear the info related to rendering groups preventing retention point in material dispose.
  20781. */
  20782. freeRenderingGroups(): void;
  20783. /**
  20784. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20785. * @returns the view count
  20786. */
  20787. getViewCount(): number;
  20788. }
  20789. }
  20790. declare module "babylonjs/Materials/material" {
  20791. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20792. import { SmartArray } from "babylonjs/Misc/smartArray";
  20793. import { Observable } from "babylonjs/Misc/observable";
  20794. import { Nullable } from "babylonjs/types";
  20795. import { Scene } from "babylonjs/scene";
  20796. import { Matrix } from "babylonjs/Maths/math.vector";
  20797. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20799. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20800. import { Effect } from "babylonjs/Materials/effect";
  20801. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20802. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20803. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20804. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20805. import { Mesh } from "babylonjs/Meshes/mesh";
  20806. import { Animation } from "babylonjs/Animations/animation";
  20807. /**
  20808. * Base class for the main features of a material in Babylon.js
  20809. */
  20810. export class Material implements IAnimatable {
  20811. /**
  20812. * Returns the triangle fill mode
  20813. */
  20814. static readonly TriangleFillMode: number;
  20815. /**
  20816. * Returns the wireframe mode
  20817. */
  20818. static readonly WireFrameFillMode: number;
  20819. /**
  20820. * Returns the point fill mode
  20821. */
  20822. static readonly PointFillMode: number;
  20823. /**
  20824. * Returns the point list draw mode
  20825. */
  20826. static readonly PointListDrawMode: number;
  20827. /**
  20828. * Returns the line list draw mode
  20829. */
  20830. static readonly LineListDrawMode: number;
  20831. /**
  20832. * Returns the line loop draw mode
  20833. */
  20834. static readonly LineLoopDrawMode: number;
  20835. /**
  20836. * Returns the line strip draw mode
  20837. */
  20838. static readonly LineStripDrawMode: number;
  20839. /**
  20840. * Returns the triangle strip draw mode
  20841. */
  20842. static readonly TriangleStripDrawMode: number;
  20843. /**
  20844. * Returns the triangle fan draw mode
  20845. */
  20846. static readonly TriangleFanDrawMode: number;
  20847. /**
  20848. * Stores the clock-wise side orientation
  20849. */
  20850. static readonly ClockWiseSideOrientation: number;
  20851. /**
  20852. * Stores the counter clock-wise side orientation
  20853. */
  20854. static readonly CounterClockWiseSideOrientation: number;
  20855. /**
  20856. * The dirty texture flag value
  20857. */
  20858. static readonly TextureDirtyFlag: number;
  20859. /**
  20860. * The dirty light flag value
  20861. */
  20862. static readonly LightDirtyFlag: number;
  20863. /**
  20864. * The dirty fresnel flag value
  20865. */
  20866. static readonly FresnelDirtyFlag: number;
  20867. /**
  20868. * The dirty attribute flag value
  20869. */
  20870. static readonly AttributesDirtyFlag: number;
  20871. /**
  20872. * The dirty misc flag value
  20873. */
  20874. static readonly MiscDirtyFlag: number;
  20875. /**
  20876. * The all dirty flag value
  20877. */
  20878. static readonly AllDirtyFlag: number;
  20879. /**
  20880. * The ID of the material
  20881. */
  20882. id: string;
  20883. /**
  20884. * Gets or sets the unique id of the material
  20885. */
  20886. uniqueId: number;
  20887. /**
  20888. * The name of the material
  20889. */
  20890. name: string;
  20891. /**
  20892. * Gets or sets user defined metadata
  20893. */
  20894. metadata: any;
  20895. /**
  20896. * For internal use only. Please do not use.
  20897. */
  20898. reservedDataStore: any;
  20899. /**
  20900. * Specifies if the ready state should be checked on each call
  20901. */
  20902. checkReadyOnEveryCall: boolean;
  20903. /**
  20904. * Specifies if the ready state should be checked once
  20905. */
  20906. checkReadyOnlyOnce: boolean;
  20907. /**
  20908. * The state of the material
  20909. */
  20910. state: string;
  20911. /**
  20912. * The alpha value of the material
  20913. */
  20914. protected _alpha: number;
  20915. /**
  20916. * List of inspectable custom properties (used by the Inspector)
  20917. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20918. */
  20919. inspectableCustomProperties: IInspectable[];
  20920. /**
  20921. * Sets the alpha value of the material
  20922. */
  20923. /**
  20924. * Gets the alpha value of the material
  20925. */
  20926. alpha: number;
  20927. /**
  20928. * Specifies if back face culling is enabled
  20929. */
  20930. protected _backFaceCulling: boolean;
  20931. /**
  20932. * Sets the back-face culling state
  20933. */
  20934. /**
  20935. * Gets the back-face culling state
  20936. */
  20937. backFaceCulling: boolean;
  20938. /**
  20939. * Stores the value for side orientation
  20940. */
  20941. sideOrientation: number;
  20942. /**
  20943. * Callback triggered when the material is compiled
  20944. */
  20945. onCompiled: Nullable<(effect: Effect) => void>;
  20946. /**
  20947. * Callback triggered when an error occurs
  20948. */
  20949. onError: Nullable<(effect: Effect, errors: string) => void>;
  20950. /**
  20951. * Callback triggered to get the render target textures
  20952. */
  20953. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20954. /**
  20955. * Gets a boolean indicating that current material needs to register RTT
  20956. */
  20957. readonly hasRenderTargetTextures: boolean;
  20958. /**
  20959. * Specifies if the material should be serialized
  20960. */
  20961. doNotSerialize: boolean;
  20962. /**
  20963. * @hidden
  20964. */
  20965. _storeEffectOnSubMeshes: boolean;
  20966. /**
  20967. * Stores the animations for the material
  20968. */
  20969. animations: Nullable<Array<Animation>>;
  20970. /**
  20971. * An event triggered when the material is disposed
  20972. */
  20973. onDisposeObservable: Observable<Material>;
  20974. /**
  20975. * An observer which watches for dispose events
  20976. */
  20977. private _onDisposeObserver;
  20978. private _onUnBindObservable;
  20979. /**
  20980. * Called during a dispose event
  20981. */
  20982. onDispose: () => void;
  20983. private _onBindObservable;
  20984. /**
  20985. * An event triggered when the material is bound
  20986. */
  20987. readonly onBindObservable: Observable<AbstractMesh>;
  20988. /**
  20989. * An observer which watches for bind events
  20990. */
  20991. private _onBindObserver;
  20992. /**
  20993. * Called during a bind event
  20994. */
  20995. onBind: (Mesh: AbstractMesh) => void;
  20996. /**
  20997. * An event triggered when the material is unbound
  20998. */
  20999. readonly onUnBindObservable: Observable<Material>;
  21000. /**
  21001. * Stores the value of the alpha mode
  21002. */
  21003. private _alphaMode;
  21004. /**
  21005. * Sets the value of the alpha mode.
  21006. *
  21007. * | Value | Type | Description |
  21008. * | --- | --- | --- |
  21009. * | 0 | ALPHA_DISABLE | |
  21010. * | 1 | ALPHA_ADD | |
  21011. * | 2 | ALPHA_COMBINE | |
  21012. * | 3 | ALPHA_SUBTRACT | |
  21013. * | 4 | ALPHA_MULTIPLY | |
  21014. * | 5 | ALPHA_MAXIMIZED | |
  21015. * | 6 | ALPHA_ONEONE | |
  21016. * | 7 | ALPHA_PREMULTIPLIED | |
  21017. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21018. * | 9 | ALPHA_INTERPOLATE | |
  21019. * | 10 | ALPHA_SCREENMODE | |
  21020. *
  21021. */
  21022. /**
  21023. * Gets the value of the alpha mode
  21024. */
  21025. alphaMode: number;
  21026. /**
  21027. * Stores the state of the need depth pre-pass value
  21028. */
  21029. private _needDepthPrePass;
  21030. /**
  21031. * Sets the need depth pre-pass value
  21032. */
  21033. /**
  21034. * Gets the depth pre-pass value
  21035. */
  21036. needDepthPrePass: boolean;
  21037. /**
  21038. * Specifies if depth writing should be disabled
  21039. */
  21040. disableDepthWrite: boolean;
  21041. /**
  21042. * Specifies if depth writing should be forced
  21043. */
  21044. forceDepthWrite: boolean;
  21045. /**
  21046. * Specifies if there should be a separate pass for culling
  21047. */
  21048. separateCullingPass: boolean;
  21049. /**
  21050. * Stores the state specifing if fog should be enabled
  21051. */
  21052. private _fogEnabled;
  21053. /**
  21054. * Sets the state for enabling fog
  21055. */
  21056. /**
  21057. * Gets the value of the fog enabled state
  21058. */
  21059. fogEnabled: boolean;
  21060. /**
  21061. * Stores the size of points
  21062. */
  21063. pointSize: number;
  21064. /**
  21065. * Stores the z offset value
  21066. */
  21067. zOffset: number;
  21068. /**
  21069. * Gets a value specifying if wireframe mode is enabled
  21070. */
  21071. /**
  21072. * Sets the state of wireframe mode
  21073. */
  21074. wireframe: boolean;
  21075. /**
  21076. * Gets the value specifying if point clouds are enabled
  21077. */
  21078. /**
  21079. * Sets the state of point cloud mode
  21080. */
  21081. pointsCloud: boolean;
  21082. /**
  21083. * Gets the material fill mode
  21084. */
  21085. /**
  21086. * Sets the material fill mode
  21087. */
  21088. fillMode: number;
  21089. /**
  21090. * @hidden
  21091. * Stores the effects for the material
  21092. */
  21093. _effect: Nullable<Effect>;
  21094. /**
  21095. * @hidden
  21096. * Specifies if the material was previously ready
  21097. */
  21098. _wasPreviouslyReady: boolean;
  21099. /**
  21100. * Specifies if uniform buffers should be used
  21101. */
  21102. private _useUBO;
  21103. /**
  21104. * Stores a reference to the scene
  21105. */
  21106. private _scene;
  21107. /**
  21108. * Stores the fill mode state
  21109. */
  21110. private _fillMode;
  21111. /**
  21112. * Specifies if the depth write state should be cached
  21113. */
  21114. private _cachedDepthWriteState;
  21115. /**
  21116. * Stores the uniform buffer
  21117. */
  21118. protected _uniformBuffer: UniformBuffer;
  21119. /** @hidden */
  21120. _indexInSceneMaterialArray: number;
  21121. /** @hidden */
  21122. meshMap: Nullable<{
  21123. [id: string]: AbstractMesh | undefined;
  21124. }>;
  21125. /**
  21126. * Creates a material instance
  21127. * @param name defines the name of the material
  21128. * @param scene defines the scene to reference
  21129. * @param doNotAdd specifies if the material should be added to the scene
  21130. */
  21131. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21132. /**
  21133. * Returns a string representation of the current material
  21134. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21135. * @returns a string with material information
  21136. */
  21137. toString(fullDetails?: boolean): string;
  21138. /**
  21139. * Gets the class name of the material
  21140. * @returns a string with the class name of the material
  21141. */
  21142. getClassName(): string;
  21143. /**
  21144. * Specifies if updates for the material been locked
  21145. */
  21146. readonly isFrozen: boolean;
  21147. /**
  21148. * Locks updates for the material
  21149. */
  21150. freeze(): void;
  21151. /**
  21152. * Unlocks updates for the material
  21153. */
  21154. unfreeze(): void;
  21155. /**
  21156. * Specifies if the material is ready to be used
  21157. * @param mesh defines the mesh to check
  21158. * @param useInstances specifies if instances should be used
  21159. * @returns a boolean indicating if the material is ready to be used
  21160. */
  21161. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21162. /**
  21163. * Specifies that the submesh is ready to be used
  21164. * @param mesh defines the mesh to check
  21165. * @param subMesh defines which submesh to check
  21166. * @param useInstances specifies that instances should be used
  21167. * @returns a boolean indicating that the submesh is ready or not
  21168. */
  21169. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21170. /**
  21171. * Returns the material effect
  21172. * @returns the effect associated with the material
  21173. */
  21174. getEffect(): Nullable<Effect>;
  21175. /**
  21176. * Returns the current scene
  21177. * @returns a Scene
  21178. */
  21179. getScene(): Scene;
  21180. /**
  21181. * Specifies if the material will require alpha blending
  21182. * @returns a boolean specifying if alpha blending is needed
  21183. */
  21184. needAlphaBlending(): boolean;
  21185. /**
  21186. * Specifies if the mesh will require alpha blending
  21187. * @param mesh defines the mesh to check
  21188. * @returns a boolean specifying if alpha blending is needed for the mesh
  21189. */
  21190. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21191. /**
  21192. * Specifies if this material should be rendered in alpha test mode
  21193. * @returns a boolean specifying if an alpha test is needed.
  21194. */
  21195. needAlphaTesting(): boolean;
  21196. /**
  21197. * Gets the texture used for the alpha test
  21198. * @returns the texture to use for alpha testing
  21199. */
  21200. getAlphaTestTexture(): Nullable<BaseTexture>;
  21201. /**
  21202. * Marks the material to indicate that it needs to be re-calculated
  21203. */
  21204. markDirty(): void;
  21205. /** @hidden */
  21206. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21207. /**
  21208. * Binds the material to the mesh
  21209. * @param world defines the world transformation matrix
  21210. * @param mesh defines the mesh to bind the material to
  21211. */
  21212. bind(world: Matrix, mesh?: Mesh): void;
  21213. /**
  21214. * Binds the submesh to the material
  21215. * @param world defines the world transformation matrix
  21216. * @param mesh defines the mesh containing the submesh
  21217. * @param subMesh defines the submesh to bind the material to
  21218. */
  21219. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21220. /**
  21221. * Binds the world matrix to the material
  21222. * @param world defines the world transformation matrix
  21223. */
  21224. bindOnlyWorldMatrix(world: Matrix): void;
  21225. /**
  21226. * Binds the scene's uniform buffer to the effect.
  21227. * @param effect defines the effect to bind to the scene uniform buffer
  21228. * @param sceneUbo defines the uniform buffer storing scene data
  21229. */
  21230. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21231. /**
  21232. * Binds the view matrix to the effect
  21233. * @param effect defines the effect to bind the view matrix to
  21234. */
  21235. bindView(effect: Effect): void;
  21236. /**
  21237. * Binds the view projection matrix to the effect
  21238. * @param effect defines the effect to bind the view projection matrix to
  21239. */
  21240. bindViewProjection(effect: Effect): void;
  21241. /**
  21242. * Specifies if material alpha testing should be turned on for the mesh
  21243. * @param mesh defines the mesh to check
  21244. */
  21245. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21246. /**
  21247. * Processes to execute after binding the material to a mesh
  21248. * @param mesh defines the rendered mesh
  21249. */
  21250. protected _afterBind(mesh?: Mesh): void;
  21251. /**
  21252. * Unbinds the material from the mesh
  21253. */
  21254. unbind(): void;
  21255. /**
  21256. * Gets the active textures from the material
  21257. * @returns an array of textures
  21258. */
  21259. getActiveTextures(): BaseTexture[];
  21260. /**
  21261. * Specifies if the material uses a texture
  21262. * @param texture defines the texture to check against the material
  21263. * @returns a boolean specifying if the material uses the texture
  21264. */
  21265. hasTexture(texture: BaseTexture): boolean;
  21266. /**
  21267. * Makes a duplicate of the material, and gives it a new name
  21268. * @param name defines the new name for the duplicated material
  21269. * @returns the cloned material
  21270. */
  21271. clone(name: string): Nullable<Material>;
  21272. /**
  21273. * Gets the meshes bound to the material
  21274. * @returns an array of meshes bound to the material
  21275. */
  21276. getBindedMeshes(): AbstractMesh[];
  21277. /**
  21278. * Force shader compilation
  21279. * @param mesh defines the mesh associated with this material
  21280. * @param onCompiled defines a function to execute once the material is compiled
  21281. * @param options defines the options to configure the compilation
  21282. */
  21283. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21284. clipPlane: boolean;
  21285. }>): void;
  21286. /**
  21287. * Force shader compilation
  21288. * @param mesh defines the mesh that will use this material
  21289. * @param options defines additional options for compiling the shaders
  21290. * @returns a promise that resolves when the compilation completes
  21291. */
  21292. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21293. clipPlane: boolean;
  21294. }>): Promise<void>;
  21295. private static readonly _AllDirtyCallBack;
  21296. private static readonly _ImageProcessingDirtyCallBack;
  21297. private static readonly _TextureDirtyCallBack;
  21298. private static readonly _FresnelDirtyCallBack;
  21299. private static readonly _MiscDirtyCallBack;
  21300. private static readonly _LightsDirtyCallBack;
  21301. private static readonly _AttributeDirtyCallBack;
  21302. private static _FresnelAndMiscDirtyCallBack;
  21303. private static _TextureAndMiscDirtyCallBack;
  21304. private static readonly _DirtyCallbackArray;
  21305. private static readonly _RunDirtyCallBacks;
  21306. /**
  21307. * Marks a define in the material to indicate that it needs to be re-computed
  21308. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21309. */
  21310. markAsDirty(flag: number): void;
  21311. /**
  21312. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21313. * @param func defines a function which checks material defines against the submeshes
  21314. */
  21315. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21316. /**
  21317. * Indicates that we need to re-calculated for all submeshes
  21318. */
  21319. protected _markAllSubMeshesAsAllDirty(): void;
  21320. /**
  21321. * Indicates that image processing needs to be re-calculated for all submeshes
  21322. */
  21323. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21324. /**
  21325. * Indicates that textures need to be re-calculated for all submeshes
  21326. */
  21327. protected _markAllSubMeshesAsTexturesDirty(): void;
  21328. /**
  21329. * Indicates that fresnel needs to be re-calculated for all submeshes
  21330. */
  21331. protected _markAllSubMeshesAsFresnelDirty(): void;
  21332. /**
  21333. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21334. */
  21335. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21336. /**
  21337. * Indicates that lights need to be re-calculated for all submeshes
  21338. */
  21339. protected _markAllSubMeshesAsLightsDirty(): void;
  21340. /**
  21341. * Indicates that attributes need to be re-calculated for all submeshes
  21342. */
  21343. protected _markAllSubMeshesAsAttributesDirty(): void;
  21344. /**
  21345. * Indicates that misc needs to be re-calculated for all submeshes
  21346. */
  21347. protected _markAllSubMeshesAsMiscDirty(): void;
  21348. /**
  21349. * Indicates that textures and misc need to be re-calculated for all submeshes
  21350. */
  21351. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21352. /**
  21353. * Disposes the material
  21354. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21355. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21356. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21357. */
  21358. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21359. /** @hidden */
  21360. private releaseVertexArrayObject;
  21361. /**
  21362. * Serializes this material
  21363. * @returns the serialized material object
  21364. */
  21365. serialize(): any;
  21366. /**
  21367. * Creates a material from parsed material data
  21368. * @param parsedMaterial defines parsed material data
  21369. * @param scene defines the hosting scene
  21370. * @param rootUrl defines the root URL to use to load textures
  21371. * @returns a new material
  21372. */
  21373. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21374. }
  21375. }
  21376. declare module "babylonjs/Materials/multiMaterial" {
  21377. import { Nullable } from "babylonjs/types";
  21378. import { Scene } from "babylonjs/scene";
  21379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21380. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21382. import { Material } from "babylonjs/Materials/material";
  21383. /**
  21384. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21385. * separate meshes. This can be use to improve performances.
  21386. * @see http://doc.babylonjs.com/how_to/multi_materials
  21387. */
  21388. export class MultiMaterial extends Material {
  21389. private _subMaterials;
  21390. /**
  21391. * Gets or Sets the list of Materials used within the multi material.
  21392. * They need to be ordered according to the submeshes order in the associated mesh
  21393. */
  21394. subMaterials: Nullable<Material>[];
  21395. /**
  21396. * Function used to align with Node.getChildren()
  21397. * @returns the list of Materials used within the multi material
  21398. */
  21399. getChildren(): Nullable<Material>[];
  21400. /**
  21401. * Instantiates a new Multi Material
  21402. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21403. * separate meshes. This can be use to improve performances.
  21404. * @see http://doc.babylonjs.com/how_to/multi_materials
  21405. * @param name Define the name in the scene
  21406. * @param scene Define the scene the material belongs to
  21407. */
  21408. constructor(name: string, scene: Scene);
  21409. private _hookArray;
  21410. /**
  21411. * Get one of the submaterial by its index in the submaterials array
  21412. * @param index The index to look the sub material at
  21413. * @returns The Material if the index has been defined
  21414. */
  21415. getSubMaterial(index: number): Nullable<Material>;
  21416. /**
  21417. * Get the list of active textures for the whole sub materials list.
  21418. * @returns All the textures that will be used during the rendering
  21419. */
  21420. getActiveTextures(): BaseTexture[];
  21421. /**
  21422. * Gets the current class name of the material e.g. "MultiMaterial"
  21423. * Mainly use in serialization.
  21424. * @returns the class name
  21425. */
  21426. getClassName(): string;
  21427. /**
  21428. * Checks if the material is ready to render the requested sub mesh
  21429. * @param mesh Define the mesh the submesh belongs to
  21430. * @param subMesh Define the sub mesh to look readyness for
  21431. * @param useInstances Define whether or not the material is used with instances
  21432. * @returns true if ready, otherwise false
  21433. */
  21434. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21435. /**
  21436. * Clones the current material and its related sub materials
  21437. * @param name Define the name of the newly cloned material
  21438. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21439. * @returns the cloned material
  21440. */
  21441. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21442. /**
  21443. * Serializes the materials into a JSON representation.
  21444. * @returns the JSON representation
  21445. */
  21446. serialize(): any;
  21447. /**
  21448. * Dispose the material and release its associated resources
  21449. * @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)
  21450. * @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)
  21451. * @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)
  21452. */
  21453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21454. /**
  21455. * Creates a MultiMaterial from parsed MultiMaterial data.
  21456. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21457. * @param scene defines the hosting scene
  21458. * @returns a new MultiMaterial
  21459. */
  21460. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21461. }
  21462. }
  21463. declare module "babylonjs/Meshes/subMesh" {
  21464. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21465. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21466. import { Engine } from "babylonjs/Engines/engine";
  21467. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21468. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21469. import { Effect } from "babylonjs/Materials/effect";
  21470. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21471. import { Plane } from "babylonjs/Maths/math.plane";
  21472. import { Collider } from "babylonjs/Collisions/collider";
  21473. import { Material } from "babylonjs/Materials/material";
  21474. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21476. import { Mesh } from "babylonjs/Meshes/mesh";
  21477. import { Ray } from "babylonjs/Culling/ray";
  21478. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21479. /**
  21480. * Base class for submeshes
  21481. */
  21482. export class BaseSubMesh {
  21483. /** @hidden */
  21484. _materialDefines: Nullable<MaterialDefines>;
  21485. /** @hidden */
  21486. _materialEffect: Nullable<Effect>;
  21487. /**
  21488. * Gets associated effect
  21489. */
  21490. readonly effect: Nullable<Effect>;
  21491. /**
  21492. * Sets associated effect (effect used to render this submesh)
  21493. * @param effect defines the effect to associate with
  21494. * @param defines defines the set of defines used to compile this effect
  21495. */
  21496. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21497. }
  21498. /**
  21499. * Defines a subdivision inside a mesh
  21500. */
  21501. export class SubMesh extends BaseSubMesh implements ICullable {
  21502. /** the material index to use */
  21503. materialIndex: number;
  21504. /** vertex index start */
  21505. verticesStart: number;
  21506. /** vertices count */
  21507. verticesCount: number;
  21508. /** index start */
  21509. indexStart: number;
  21510. /** indices count */
  21511. indexCount: number;
  21512. /** @hidden */
  21513. _linesIndexCount: number;
  21514. private _mesh;
  21515. private _renderingMesh;
  21516. private _boundingInfo;
  21517. private _linesIndexBuffer;
  21518. /** @hidden */
  21519. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21520. /** @hidden */
  21521. _trianglePlanes: Plane[];
  21522. /** @hidden */
  21523. _lastColliderTransformMatrix: Nullable<Matrix>;
  21524. /** @hidden */
  21525. _renderId: number;
  21526. /** @hidden */
  21527. _alphaIndex: number;
  21528. /** @hidden */
  21529. _distanceToCamera: number;
  21530. /** @hidden */
  21531. _id: number;
  21532. private _currentMaterial;
  21533. /**
  21534. * Add a new submesh to a mesh
  21535. * @param materialIndex defines the material index to use
  21536. * @param verticesStart defines vertex index start
  21537. * @param verticesCount defines vertices count
  21538. * @param indexStart defines index start
  21539. * @param indexCount defines indices count
  21540. * @param mesh defines the parent mesh
  21541. * @param renderingMesh defines an optional rendering mesh
  21542. * @param createBoundingBox defines if bounding box should be created for this submesh
  21543. * @returns the new submesh
  21544. */
  21545. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21546. /**
  21547. * Creates a new submesh
  21548. * @param materialIndex defines the material index to use
  21549. * @param verticesStart defines vertex index start
  21550. * @param verticesCount defines vertices count
  21551. * @param indexStart defines index start
  21552. * @param indexCount defines indices count
  21553. * @param mesh defines the parent mesh
  21554. * @param renderingMesh defines an optional rendering mesh
  21555. * @param createBoundingBox defines if bounding box should be created for this submesh
  21556. */
  21557. constructor(
  21558. /** the material index to use */
  21559. materialIndex: number,
  21560. /** vertex index start */
  21561. verticesStart: number,
  21562. /** vertices count */
  21563. verticesCount: number,
  21564. /** index start */
  21565. indexStart: number,
  21566. /** indices count */
  21567. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21568. /**
  21569. * Returns true if this submesh covers the entire parent mesh
  21570. * @ignorenaming
  21571. */
  21572. readonly IsGlobal: boolean;
  21573. /**
  21574. * Returns the submesh BoudingInfo object
  21575. * @returns current bounding info (or mesh's one if the submesh is global)
  21576. */
  21577. getBoundingInfo(): BoundingInfo;
  21578. /**
  21579. * Sets the submesh BoundingInfo
  21580. * @param boundingInfo defines the new bounding info to use
  21581. * @returns the SubMesh
  21582. */
  21583. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21584. /**
  21585. * Returns the mesh of the current submesh
  21586. * @return the parent mesh
  21587. */
  21588. getMesh(): AbstractMesh;
  21589. /**
  21590. * Returns the rendering mesh of the submesh
  21591. * @returns the rendering mesh (could be different from parent mesh)
  21592. */
  21593. getRenderingMesh(): Mesh;
  21594. /**
  21595. * Returns the submesh material
  21596. * @returns null or the current material
  21597. */
  21598. getMaterial(): Nullable<Material>;
  21599. /**
  21600. * Sets a new updated BoundingInfo object to the submesh
  21601. * @param data defines an optional position array to use to determine the bounding info
  21602. * @returns the SubMesh
  21603. */
  21604. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21605. /** @hidden */
  21606. _checkCollision(collider: Collider): boolean;
  21607. /**
  21608. * Updates the submesh BoundingInfo
  21609. * @param world defines the world matrix to use to update the bounding info
  21610. * @returns the submesh
  21611. */
  21612. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21613. /**
  21614. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21615. * @param frustumPlanes defines the frustum planes
  21616. * @returns true if the submesh is intersecting with the frustum
  21617. */
  21618. isInFrustum(frustumPlanes: Plane[]): boolean;
  21619. /**
  21620. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21621. * @param frustumPlanes defines the frustum planes
  21622. * @returns true if the submesh is inside the frustum
  21623. */
  21624. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21625. /**
  21626. * Renders the submesh
  21627. * @param enableAlphaMode defines if alpha needs to be used
  21628. * @returns the submesh
  21629. */
  21630. render(enableAlphaMode: boolean): SubMesh;
  21631. /**
  21632. * @hidden
  21633. */
  21634. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21635. /**
  21636. * Checks if the submesh intersects with a ray
  21637. * @param ray defines the ray to test
  21638. * @returns true is the passed ray intersects the submesh bounding box
  21639. */
  21640. canIntersects(ray: Ray): boolean;
  21641. /**
  21642. * Intersects current submesh with a ray
  21643. * @param ray defines the ray to test
  21644. * @param positions defines mesh's positions array
  21645. * @param indices defines mesh's indices array
  21646. * @param fastCheck defines if only bounding info should be used
  21647. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21648. * @returns intersection info or null if no intersection
  21649. */
  21650. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21651. /** @hidden */
  21652. private _intersectLines;
  21653. /** @hidden */
  21654. private _intersectUnIndexedLines;
  21655. /** @hidden */
  21656. private _intersectTriangles;
  21657. /** @hidden */
  21658. private _intersectUnIndexedTriangles;
  21659. /** @hidden */
  21660. _rebuild(): void;
  21661. /**
  21662. * Creates a new submesh from the passed mesh
  21663. * @param newMesh defines the new hosting mesh
  21664. * @param newRenderingMesh defines an optional rendering mesh
  21665. * @returns the new submesh
  21666. */
  21667. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21668. /**
  21669. * Release associated resources
  21670. */
  21671. dispose(): void;
  21672. /**
  21673. * Gets the class name
  21674. * @returns the string "SubMesh".
  21675. */
  21676. getClassName(): string;
  21677. /**
  21678. * Creates a new submesh from indices data
  21679. * @param materialIndex the index of the main mesh material
  21680. * @param startIndex the index where to start the copy in the mesh indices array
  21681. * @param indexCount the number of indices to copy then from the startIndex
  21682. * @param mesh the main mesh to create the submesh from
  21683. * @param renderingMesh the optional rendering mesh
  21684. * @returns a new submesh
  21685. */
  21686. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21687. }
  21688. }
  21689. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21690. /**
  21691. * Class used to represent data loading progression
  21692. */
  21693. export class SceneLoaderFlags {
  21694. private static _ForceFullSceneLoadingForIncremental;
  21695. private static _ShowLoadingScreen;
  21696. private static _CleanBoneMatrixWeights;
  21697. private static _loggingLevel;
  21698. /**
  21699. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21700. */
  21701. static ForceFullSceneLoadingForIncremental: boolean;
  21702. /**
  21703. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21704. */
  21705. static ShowLoadingScreen: boolean;
  21706. /**
  21707. * Defines the current logging level (while loading the scene)
  21708. * @ignorenaming
  21709. */
  21710. static loggingLevel: number;
  21711. /**
  21712. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21713. */
  21714. static CleanBoneMatrixWeights: boolean;
  21715. }
  21716. }
  21717. declare module "babylonjs/Meshes/geometry" {
  21718. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21719. import { Scene } from "babylonjs/scene";
  21720. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21721. import { Engine } from "babylonjs/Engines/engine";
  21722. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21723. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21724. import { Effect } from "babylonjs/Materials/effect";
  21725. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21726. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21727. import { Mesh } from "babylonjs/Meshes/mesh";
  21728. /**
  21729. * Class used to store geometry data (vertex buffers + index buffer)
  21730. */
  21731. export class Geometry implements IGetSetVerticesData {
  21732. /**
  21733. * Gets or sets the ID of the geometry
  21734. */
  21735. id: string;
  21736. /**
  21737. * Gets or sets the unique ID of the geometry
  21738. */
  21739. uniqueId: number;
  21740. /**
  21741. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21742. */
  21743. delayLoadState: number;
  21744. /**
  21745. * Gets the file containing the data to load when running in delay load state
  21746. */
  21747. delayLoadingFile: Nullable<string>;
  21748. /**
  21749. * Callback called when the geometry is updated
  21750. */
  21751. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21752. private _scene;
  21753. private _engine;
  21754. private _meshes;
  21755. private _totalVertices;
  21756. /** @hidden */
  21757. _indices: IndicesArray;
  21758. /** @hidden */
  21759. _vertexBuffers: {
  21760. [key: string]: VertexBuffer;
  21761. };
  21762. private _isDisposed;
  21763. private _extend;
  21764. private _boundingBias;
  21765. /** @hidden */
  21766. _delayInfo: Array<string>;
  21767. private _indexBuffer;
  21768. private _indexBufferIsUpdatable;
  21769. /** @hidden */
  21770. _boundingInfo: Nullable<BoundingInfo>;
  21771. /** @hidden */
  21772. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21773. /** @hidden */
  21774. _softwareSkinningFrameId: number;
  21775. private _vertexArrayObjects;
  21776. private _updatable;
  21777. /** @hidden */
  21778. _positions: Nullable<Vector3[]>;
  21779. /**
  21780. * 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
  21781. */
  21782. /**
  21783. * 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
  21784. */
  21785. boundingBias: Vector2;
  21786. /**
  21787. * Static function used to attach a new empty geometry to a mesh
  21788. * @param mesh defines the mesh to attach the geometry to
  21789. * @returns the new Geometry
  21790. */
  21791. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21792. /**
  21793. * Creates a new geometry
  21794. * @param id defines the unique ID
  21795. * @param scene defines the hosting scene
  21796. * @param vertexData defines the VertexData used to get geometry data
  21797. * @param updatable defines if geometry must be updatable (false by default)
  21798. * @param mesh defines the mesh that will be associated with the geometry
  21799. */
  21800. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21801. /**
  21802. * Gets the current extend of the geometry
  21803. */
  21804. readonly extend: {
  21805. minimum: Vector3;
  21806. maximum: Vector3;
  21807. };
  21808. /**
  21809. * Gets the hosting scene
  21810. * @returns the hosting Scene
  21811. */
  21812. getScene(): Scene;
  21813. /**
  21814. * Gets the hosting engine
  21815. * @returns the hosting Engine
  21816. */
  21817. getEngine(): Engine;
  21818. /**
  21819. * Defines if the geometry is ready to use
  21820. * @returns true if the geometry is ready to be used
  21821. */
  21822. isReady(): boolean;
  21823. /**
  21824. * Gets a value indicating that the geometry should not be serialized
  21825. */
  21826. readonly doNotSerialize: boolean;
  21827. /** @hidden */
  21828. _rebuild(): void;
  21829. /**
  21830. * Affects all geometry data in one call
  21831. * @param vertexData defines the geometry data
  21832. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21833. */
  21834. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21835. /**
  21836. * Set specific vertex data
  21837. * @param kind defines the data kind (Position, normal, etc...)
  21838. * @param data defines the vertex data to use
  21839. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21840. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21841. */
  21842. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21843. /**
  21844. * Removes a specific vertex data
  21845. * @param kind defines the data kind (Position, normal, etc...)
  21846. */
  21847. removeVerticesData(kind: string): void;
  21848. /**
  21849. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21850. * @param buffer defines the vertex buffer to use
  21851. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21852. */
  21853. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21854. /**
  21855. * Update a specific vertex buffer
  21856. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21857. * It will do nothing if the buffer is not updatable
  21858. * @param kind defines the data kind (Position, normal, etc...)
  21859. * @param data defines the data to use
  21860. * @param offset defines the offset in the target buffer where to store the data
  21861. * @param useBytes set to true if the offset is in bytes
  21862. */
  21863. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21864. /**
  21865. * Update a specific vertex buffer
  21866. * This function will create a new buffer if the current one is not updatable
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. * @param data defines the data to use
  21869. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21870. */
  21871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21872. private _updateBoundingInfo;
  21873. /** @hidden */
  21874. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21875. /**
  21876. * Gets total number of vertices
  21877. * @returns the total number of vertices
  21878. */
  21879. getTotalVertices(): number;
  21880. /**
  21881. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21882. * @param kind defines the data kind (Position, normal, etc...)
  21883. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21884. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21885. * @returns a float array containing vertex data
  21886. */
  21887. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21888. /**
  21889. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21890. * @param kind defines the data kind (Position, normal, etc...)
  21891. * @returns true if the vertex buffer with the specified kind is updatable
  21892. */
  21893. isVertexBufferUpdatable(kind: string): boolean;
  21894. /**
  21895. * Gets a specific vertex buffer
  21896. * @param kind defines the data kind (Position, normal, etc...)
  21897. * @returns a VertexBuffer
  21898. */
  21899. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21900. /**
  21901. * Returns all vertex buffers
  21902. * @return an object holding all vertex buffers indexed by kind
  21903. */
  21904. getVertexBuffers(): Nullable<{
  21905. [key: string]: VertexBuffer;
  21906. }>;
  21907. /**
  21908. * Gets a boolean indicating if specific vertex buffer is present
  21909. * @param kind defines the data kind (Position, normal, etc...)
  21910. * @returns true if data is present
  21911. */
  21912. isVerticesDataPresent(kind: string): boolean;
  21913. /**
  21914. * Gets a list of all attached data kinds (Position, normal, etc...)
  21915. * @returns a list of string containing all kinds
  21916. */
  21917. getVerticesDataKinds(): string[];
  21918. /**
  21919. * Update index buffer
  21920. * @param indices defines the indices to store in the index buffer
  21921. * @param offset defines the offset in the target buffer where to store the data
  21922. * @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)
  21923. */
  21924. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21925. /**
  21926. * Creates a new index buffer
  21927. * @param indices defines the indices to store in the index buffer
  21928. * @param totalVertices defines the total number of vertices (could be null)
  21929. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21930. */
  21931. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21932. /**
  21933. * Return the total number of indices
  21934. * @returns the total number of indices
  21935. */
  21936. getTotalIndices(): number;
  21937. /**
  21938. * Gets the index buffer array
  21939. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21940. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21941. * @returns the index buffer array
  21942. */
  21943. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21944. /**
  21945. * Gets the index buffer
  21946. * @return the index buffer
  21947. */
  21948. getIndexBuffer(): Nullable<DataBuffer>;
  21949. /** @hidden */
  21950. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21951. /**
  21952. * Release the associated resources for a specific mesh
  21953. * @param mesh defines the source mesh
  21954. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21955. */
  21956. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21957. /**
  21958. * Apply current geometry to a given mesh
  21959. * @param mesh defines the mesh to apply geometry to
  21960. */
  21961. applyToMesh(mesh: Mesh): void;
  21962. private _updateExtend;
  21963. private _applyToMesh;
  21964. private notifyUpdate;
  21965. /**
  21966. * Load the geometry if it was flagged as delay loaded
  21967. * @param scene defines the hosting scene
  21968. * @param onLoaded defines a callback called when the geometry is loaded
  21969. */
  21970. load(scene: Scene, onLoaded?: () => void): void;
  21971. private _queueLoad;
  21972. /**
  21973. * Invert the geometry to move from a right handed system to a left handed one.
  21974. */
  21975. toLeftHanded(): void;
  21976. /** @hidden */
  21977. _resetPointsArrayCache(): void;
  21978. /** @hidden */
  21979. _generatePointsArray(): boolean;
  21980. /**
  21981. * Gets a value indicating if the geometry is disposed
  21982. * @returns true if the geometry was disposed
  21983. */
  21984. isDisposed(): boolean;
  21985. private _disposeVertexArrayObjects;
  21986. /**
  21987. * Free all associated resources
  21988. */
  21989. dispose(): void;
  21990. /**
  21991. * Clone the current geometry into a new geometry
  21992. * @param id defines the unique ID of the new geometry
  21993. * @returns a new geometry object
  21994. */
  21995. copy(id: string): Geometry;
  21996. /**
  21997. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21998. * @return a JSON representation of the current geometry data (without the vertices data)
  21999. */
  22000. serialize(): any;
  22001. private toNumberArray;
  22002. /**
  22003. * Serialize all vertices data into a JSON oject
  22004. * @returns a JSON representation of the current geometry data
  22005. */
  22006. serializeVerticeData(): any;
  22007. /**
  22008. * Extracts a clone of a mesh geometry
  22009. * @param mesh defines the source mesh
  22010. * @param id defines the unique ID of the new geometry object
  22011. * @returns the new geometry object
  22012. */
  22013. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22014. /**
  22015. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22016. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22017. * Be aware Math.random() could cause collisions, but:
  22018. * "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"
  22019. * @returns a string containing a new GUID
  22020. */
  22021. static RandomId(): string;
  22022. /** @hidden */
  22023. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22024. private static _CleanMatricesWeights;
  22025. /**
  22026. * Create a new geometry from persisted data (Using .babylon file format)
  22027. * @param parsedVertexData defines the persisted data
  22028. * @param scene defines the hosting scene
  22029. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22030. * @returns the new geometry object
  22031. */
  22032. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22033. }
  22034. }
  22035. declare module "babylonjs/Meshes/mesh.vertexData" {
  22036. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22037. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22038. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22039. import { Geometry } from "babylonjs/Meshes/geometry";
  22040. import { Mesh } from "babylonjs/Meshes/mesh";
  22041. /**
  22042. * Define an interface for all classes that will get and set the data on vertices
  22043. */
  22044. export interface IGetSetVerticesData {
  22045. /**
  22046. * Gets a boolean indicating if specific vertex data is present
  22047. * @param kind defines the vertex data kind to use
  22048. * @returns true is data kind is present
  22049. */
  22050. isVerticesDataPresent(kind: string): boolean;
  22051. /**
  22052. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22053. * @param kind defines the data kind (Position, normal, etc...)
  22054. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22055. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22056. * @returns a float array containing vertex data
  22057. */
  22058. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22059. /**
  22060. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22061. * @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.
  22062. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22063. * @returns the indices array or an empty array if the mesh has no geometry
  22064. */
  22065. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22066. /**
  22067. * Set specific vertex data
  22068. * @param kind defines the data kind (Position, normal, etc...)
  22069. * @param data defines the vertex data to use
  22070. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22071. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22072. */
  22073. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22074. /**
  22075. * Update a specific associated vertex buffer
  22076. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22077. * - VertexBuffer.PositionKind
  22078. * - VertexBuffer.UVKind
  22079. * - VertexBuffer.UV2Kind
  22080. * - VertexBuffer.UV3Kind
  22081. * - VertexBuffer.UV4Kind
  22082. * - VertexBuffer.UV5Kind
  22083. * - VertexBuffer.UV6Kind
  22084. * - VertexBuffer.ColorKind
  22085. * - VertexBuffer.MatricesIndicesKind
  22086. * - VertexBuffer.MatricesIndicesExtraKind
  22087. * - VertexBuffer.MatricesWeightsKind
  22088. * - VertexBuffer.MatricesWeightsExtraKind
  22089. * @param data defines the data source
  22090. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22091. * @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)
  22092. */
  22093. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22094. /**
  22095. * Creates a new index buffer
  22096. * @param indices defines the indices to store in the index buffer
  22097. * @param totalVertices defines the total number of vertices (could be null)
  22098. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22099. */
  22100. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22101. }
  22102. /**
  22103. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22104. */
  22105. export class VertexData {
  22106. /**
  22107. * Mesh side orientation : usually the external or front surface
  22108. */
  22109. static readonly FRONTSIDE: number;
  22110. /**
  22111. * Mesh side orientation : usually the internal or back surface
  22112. */
  22113. static readonly BACKSIDE: number;
  22114. /**
  22115. * Mesh side orientation : both internal and external or front and back surfaces
  22116. */
  22117. static readonly DOUBLESIDE: number;
  22118. /**
  22119. * Mesh side orientation : by default, `FRONTSIDE`
  22120. */
  22121. static readonly DEFAULTSIDE: number;
  22122. /**
  22123. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22124. */
  22125. positions: Nullable<FloatArray>;
  22126. /**
  22127. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22128. */
  22129. normals: Nullable<FloatArray>;
  22130. /**
  22131. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22132. */
  22133. tangents: Nullable<FloatArray>;
  22134. /**
  22135. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22136. */
  22137. uvs: Nullable<FloatArray>;
  22138. /**
  22139. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22140. */
  22141. uvs2: Nullable<FloatArray>;
  22142. /**
  22143. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22144. */
  22145. uvs3: Nullable<FloatArray>;
  22146. /**
  22147. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22148. */
  22149. uvs4: Nullable<FloatArray>;
  22150. /**
  22151. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22152. */
  22153. uvs5: Nullable<FloatArray>;
  22154. /**
  22155. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22156. */
  22157. uvs6: Nullable<FloatArray>;
  22158. /**
  22159. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22160. */
  22161. colors: Nullable<FloatArray>;
  22162. /**
  22163. * 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).
  22164. */
  22165. matricesIndices: Nullable<FloatArray>;
  22166. /**
  22167. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22168. */
  22169. matricesWeights: Nullable<FloatArray>;
  22170. /**
  22171. * An array extending the number of possible indices
  22172. */
  22173. matricesIndicesExtra: Nullable<FloatArray>;
  22174. /**
  22175. * An array extending the number of possible weights when the number of indices is extended
  22176. */
  22177. matricesWeightsExtra: Nullable<FloatArray>;
  22178. /**
  22179. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22180. */
  22181. indices: Nullable<IndicesArray>;
  22182. /**
  22183. * Uses the passed data array to set the set the values for the specified kind of data
  22184. * @param data a linear array of floating numbers
  22185. * @param kind the type of data that is being set, eg positions, colors etc
  22186. */
  22187. set(data: FloatArray, kind: string): void;
  22188. /**
  22189. * Associates the vertexData to the passed Mesh.
  22190. * Sets it as updatable or not (default `false`)
  22191. * @param mesh the mesh the vertexData is applied to
  22192. * @param updatable when used and having the value true allows new data to update the vertexData
  22193. * @returns the VertexData
  22194. */
  22195. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22196. /**
  22197. * Associates the vertexData to the passed Geometry.
  22198. * Sets it as updatable or not (default `false`)
  22199. * @param geometry the geometry the vertexData is applied to
  22200. * @param updatable when used and having the value true allows new data to update the vertexData
  22201. * @returns VertexData
  22202. */
  22203. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22204. /**
  22205. * Updates the associated mesh
  22206. * @param mesh the mesh to be updated
  22207. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22208. * @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
  22209. * @returns VertexData
  22210. */
  22211. updateMesh(mesh: Mesh): VertexData;
  22212. /**
  22213. * Updates the associated geometry
  22214. * @param geometry the geometry to be updated
  22215. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22216. * @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
  22217. * @returns VertexData.
  22218. */
  22219. updateGeometry(geometry: Geometry): VertexData;
  22220. private _applyTo;
  22221. private _update;
  22222. /**
  22223. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22224. * @param matrix the transforming matrix
  22225. * @returns the VertexData
  22226. */
  22227. transform(matrix: Matrix): VertexData;
  22228. /**
  22229. * Merges the passed VertexData into the current one
  22230. * @param other the VertexData to be merged into the current one
  22231. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22232. * @returns the modified VertexData
  22233. */
  22234. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22235. private _mergeElement;
  22236. private _validate;
  22237. /**
  22238. * Serializes the VertexData
  22239. * @returns a serialized object
  22240. */
  22241. serialize(): any;
  22242. /**
  22243. * Extracts the vertexData from a mesh
  22244. * @param mesh the mesh from which to extract the VertexData
  22245. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22246. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22247. * @returns the object VertexData associated to the passed mesh
  22248. */
  22249. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22250. /**
  22251. * Extracts the vertexData from the geometry
  22252. * @param geometry the geometry from which to extract the VertexData
  22253. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22254. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22255. * @returns the object VertexData associated to the passed mesh
  22256. */
  22257. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22258. private static _ExtractFrom;
  22259. /**
  22260. * Creates the VertexData for a Ribbon
  22261. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22262. * * pathArray array of paths, each of which an array of successive Vector3
  22263. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22264. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22265. * * 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
  22266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22267. * * 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)
  22268. * * 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)
  22269. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22270. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22271. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22272. * @returns the VertexData of the ribbon
  22273. */
  22274. static CreateRibbon(options: {
  22275. pathArray: Vector3[][];
  22276. closeArray?: boolean;
  22277. closePath?: boolean;
  22278. offset?: number;
  22279. sideOrientation?: number;
  22280. frontUVs?: Vector4;
  22281. backUVs?: Vector4;
  22282. invertUV?: boolean;
  22283. uvs?: Vector2[];
  22284. colors?: Color4[];
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for a box
  22288. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22289. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22290. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22291. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22292. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22293. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22294. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22296. * * 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)
  22297. * * 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)
  22298. * @returns the VertexData of the box
  22299. */
  22300. static CreateBox(options: {
  22301. size?: number;
  22302. width?: number;
  22303. height?: number;
  22304. depth?: number;
  22305. faceUV?: Vector4[];
  22306. faceColors?: Color4[];
  22307. sideOrientation?: number;
  22308. frontUVs?: Vector4;
  22309. backUVs?: Vector4;
  22310. }): VertexData;
  22311. /**
  22312. * Creates the VertexData for a tiled box
  22313. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22314. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22315. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22316. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22318. * @returns the VertexData of the box
  22319. */
  22320. static CreateTiledBox(options: {
  22321. pattern?: number;
  22322. width?: number;
  22323. height?: number;
  22324. depth?: number;
  22325. tileSize?: number;
  22326. tileWidth?: number;
  22327. tileHeight?: number;
  22328. alignHorizontal?: number;
  22329. alignVertical?: number;
  22330. faceUV?: Vector4[];
  22331. faceColors?: Color4[];
  22332. sideOrientation?: number;
  22333. }): VertexData;
  22334. /**
  22335. * Creates the VertexData for a tiled plane
  22336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22337. * * pattern a limited pattern arrangement depending on the number
  22338. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22339. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22340. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22342. * * 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)
  22343. * * 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)
  22344. * @returns the VertexData of the tiled plane
  22345. */
  22346. static CreateTiledPlane(options: {
  22347. pattern?: number;
  22348. tileSize?: number;
  22349. tileWidth?: number;
  22350. tileHeight?: number;
  22351. size?: number;
  22352. width?: number;
  22353. height?: number;
  22354. alignHorizontal?: number;
  22355. alignVertical?: number;
  22356. sideOrientation?: number;
  22357. frontUVs?: Vector4;
  22358. backUVs?: Vector4;
  22359. }): VertexData;
  22360. /**
  22361. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22363. * * segments sets the number of horizontal strips optional, default 32
  22364. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22365. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22366. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22367. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22368. * * 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
  22369. * * 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
  22370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22371. * * 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)
  22372. * * 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)
  22373. * @returns the VertexData of the ellipsoid
  22374. */
  22375. static CreateSphere(options: {
  22376. segments?: number;
  22377. diameter?: number;
  22378. diameterX?: number;
  22379. diameterY?: number;
  22380. diameterZ?: number;
  22381. arc?: number;
  22382. slice?: number;
  22383. sideOrientation?: number;
  22384. frontUVs?: Vector4;
  22385. backUVs?: Vector4;
  22386. }): VertexData;
  22387. /**
  22388. * Creates the VertexData for a cylinder, cone or prism
  22389. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22390. * * height sets the height (y direction) of the cylinder, optional, default 2
  22391. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22392. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22393. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22394. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22395. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22396. * * 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
  22397. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22398. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22399. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22400. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22402. * * 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)
  22403. * * 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)
  22404. * @returns the VertexData of the cylinder, cone or prism
  22405. */
  22406. static CreateCylinder(options: {
  22407. height?: number;
  22408. diameterTop?: number;
  22409. diameterBottom?: number;
  22410. diameter?: number;
  22411. tessellation?: number;
  22412. subdivisions?: number;
  22413. arc?: number;
  22414. faceColors?: Color4[];
  22415. faceUV?: Vector4[];
  22416. hasRings?: boolean;
  22417. enclose?: boolean;
  22418. sideOrientation?: number;
  22419. frontUVs?: Vector4;
  22420. backUVs?: Vector4;
  22421. }): VertexData;
  22422. /**
  22423. * Creates the VertexData for a torus
  22424. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22425. * * diameter the diameter of the torus, optional default 1
  22426. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22427. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22429. * * 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)
  22430. * * 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)
  22431. * @returns the VertexData of the torus
  22432. */
  22433. static CreateTorus(options: {
  22434. diameter?: number;
  22435. thickness?: number;
  22436. tessellation?: number;
  22437. sideOrientation?: number;
  22438. frontUVs?: Vector4;
  22439. backUVs?: Vector4;
  22440. }): VertexData;
  22441. /**
  22442. * Creates the VertexData of the LineSystem
  22443. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22444. * - lines an array of lines, each line being an array of successive Vector3
  22445. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22446. * @returns the VertexData of the LineSystem
  22447. */
  22448. static CreateLineSystem(options: {
  22449. lines: Vector3[][];
  22450. colors?: Nullable<Color4[][]>;
  22451. }): VertexData;
  22452. /**
  22453. * Create the VertexData for a DashedLines
  22454. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22455. * - points an array successive Vector3
  22456. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22457. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22458. * - dashNb the intended total number of dashes, optional, default 200
  22459. * @returns the VertexData for the DashedLines
  22460. */
  22461. static CreateDashedLines(options: {
  22462. points: Vector3[];
  22463. dashSize?: number;
  22464. gapSize?: number;
  22465. dashNb?: number;
  22466. }): VertexData;
  22467. /**
  22468. * Creates the VertexData for a Ground
  22469. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22470. * - width the width (x direction) of the ground, optional, default 1
  22471. * - height the height (z direction) of the ground, optional, default 1
  22472. * - subdivisions the number of subdivisions per side, optional, default 1
  22473. * @returns the VertexData of the Ground
  22474. */
  22475. static CreateGround(options: {
  22476. width?: number;
  22477. height?: number;
  22478. subdivisions?: number;
  22479. subdivisionsX?: number;
  22480. subdivisionsY?: number;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22484. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22485. * * xmin the ground minimum X coordinate, optional, default -1
  22486. * * zmin the ground minimum Z coordinate, optional, default -1
  22487. * * xmax the ground maximum X coordinate, optional, default 1
  22488. * * zmax the ground maximum Z coordinate, optional, default 1
  22489. * * 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}
  22490. * * 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}
  22491. * @returns the VertexData of the TiledGround
  22492. */
  22493. static CreateTiledGround(options: {
  22494. xmin: number;
  22495. zmin: number;
  22496. xmax: number;
  22497. zmax: number;
  22498. subdivisions?: {
  22499. w: number;
  22500. h: number;
  22501. };
  22502. precision?: {
  22503. w: number;
  22504. h: number;
  22505. };
  22506. }): VertexData;
  22507. /**
  22508. * Creates the VertexData of the Ground designed from a heightmap
  22509. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22510. * * width the width (x direction) of the ground
  22511. * * height the height (z direction) of the ground
  22512. * * subdivisions the number of subdivisions per side
  22513. * * minHeight the minimum altitude on the ground, optional, default 0
  22514. * * maxHeight the maximum altitude on the ground, optional default 1
  22515. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22516. * * buffer the array holding the image color data
  22517. * * bufferWidth the width of image
  22518. * * bufferHeight the height of image
  22519. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22520. * @returns the VertexData of the Ground designed from a heightmap
  22521. */
  22522. static CreateGroundFromHeightMap(options: {
  22523. width: number;
  22524. height: number;
  22525. subdivisions: number;
  22526. minHeight: number;
  22527. maxHeight: number;
  22528. colorFilter: Color3;
  22529. buffer: Uint8Array;
  22530. bufferWidth: number;
  22531. bufferHeight: number;
  22532. alphaFilter: number;
  22533. }): VertexData;
  22534. /**
  22535. * Creates the VertexData for a Plane
  22536. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22537. * * size sets the width and height of the plane to the value of size, optional default 1
  22538. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22539. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22541. * * 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)
  22542. * * 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)
  22543. * @returns the VertexData of the box
  22544. */
  22545. static CreatePlane(options: {
  22546. size?: number;
  22547. width?: number;
  22548. height?: number;
  22549. sideOrientation?: number;
  22550. frontUVs?: Vector4;
  22551. backUVs?: Vector4;
  22552. }): VertexData;
  22553. /**
  22554. * Creates the VertexData of the Disc or regular Polygon
  22555. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22556. * * radius the radius of the disc, optional default 0.5
  22557. * * tessellation the number of polygon sides, optional, default 64
  22558. * * 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
  22559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22560. * * 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)
  22561. * * 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)
  22562. * @returns the VertexData of the box
  22563. */
  22564. static CreateDisc(options: {
  22565. radius?: number;
  22566. tessellation?: number;
  22567. arc?: number;
  22568. sideOrientation?: number;
  22569. frontUVs?: Vector4;
  22570. backUVs?: Vector4;
  22571. }): VertexData;
  22572. /**
  22573. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22574. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22575. * @param polygon a mesh built from polygonTriangulation.build()
  22576. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22577. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22578. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22579. * @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)
  22580. * @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)
  22581. * @returns the VertexData of the Polygon
  22582. */
  22583. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22584. /**
  22585. * Creates the VertexData of the IcoSphere
  22586. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22587. * * radius the radius of the IcoSphere, optional default 1
  22588. * * radiusX allows stretching in the x direction, optional, default radius
  22589. * * radiusY allows stretching in the y direction, optional, default radius
  22590. * * radiusZ allows stretching in the z direction, optional, default radius
  22591. * * flat when true creates a flat shaded mesh, optional, default true
  22592. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22593. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22594. * * 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)
  22595. * * 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)
  22596. * @returns the VertexData of the IcoSphere
  22597. */
  22598. static CreateIcoSphere(options: {
  22599. radius?: number;
  22600. radiusX?: number;
  22601. radiusY?: number;
  22602. radiusZ?: number;
  22603. flat?: boolean;
  22604. subdivisions?: number;
  22605. sideOrientation?: number;
  22606. frontUVs?: Vector4;
  22607. backUVs?: Vector4;
  22608. }): VertexData;
  22609. /**
  22610. * Creates the VertexData for a Polyhedron
  22611. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22612. * * type provided types are:
  22613. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22614. * * 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)
  22615. * * size the size of the IcoSphere, optional default 1
  22616. * * sizeX allows stretching in the x direction, optional, default size
  22617. * * sizeY allows stretching in the y direction, optional, default size
  22618. * * sizeZ allows stretching in the z direction, optional, default size
  22619. * * 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
  22620. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22621. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22622. * * flat when true creates a flat shaded mesh, optional, default true
  22623. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22625. * * 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)
  22626. * * 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)
  22627. * @returns the VertexData of the Polyhedron
  22628. */
  22629. static CreatePolyhedron(options: {
  22630. type?: number;
  22631. size?: number;
  22632. sizeX?: number;
  22633. sizeY?: number;
  22634. sizeZ?: number;
  22635. custom?: any;
  22636. faceUV?: Vector4[];
  22637. faceColors?: Color4[];
  22638. flat?: boolean;
  22639. sideOrientation?: number;
  22640. frontUVs?: Vector4;
  22641. backUVs?: Vector4;
  22642. }): VertexData;
  22643. /**
  22644. * Creates the VertexData for a TorusKnot
  22645. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22646. * * radius the radius of the torus knot, optional, default 2
  22647. * * tube the thickness of the tube, optional, default 0.5
  22648. * * radialSegments the number of sides on each tube segments, optional, default 32
  22649. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22650. * * p the number of windings around the z axis, optional, default 2
  22651. * * q the number of windings around the x axis, optional, default 3
  22652. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22653. * * 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)
  22654. * * 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)
  22655. * @returns the VertexData of the Torus Knot
  22656. */
  22657. static CreateTorusKnot(options: {
  22658. radius?: number;
  22659. tube?: number;
  22660. radialSegments?: number;
  22661. tubularSegments?: number;
  22662. p?: number;
  22663. q?: number;
  22664. sideOrientation?: number;
  22665. frontUVs?: Vector4;
  22666. backUVs?: Vector4;
  22667. }): VertexData;
  22668. /**
  22669. * Compute normals for given positions and indices
  22670. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22671. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22672. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22673. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22674. * * facetNormals : optional array of facet normals (vector3)
  22675. * * facetPositions : optional array of facet positions (vector3)
  22676. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22677. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22678. * * bInfo : optional bounding info, required for facetPartitioning computation
  22679. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22680. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22681. * * useRightHandedSystem: optional boolean to for right handed system computation
  22682. * * depthSort : optional boolean to enable the facet depth sort computation
  22683. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22684. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22685. */
  22686. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22687. facetNormals?: any;
  22688. facetPositions?: any;
  22689. facetPartitioning?: any;
  22690. ratio?: number;
  22691. bInfo?: any;
  22692. bbSize?: Vector3;
  22693. subDiv?: any;
  22694. useRightHandedSystem?: boolean;
  22695. depthSort?: boolean;
  22696. distanceTo?: Vector3;
  22697. depthSortedFacets?: any;
  22698. }): void;
  22699. /** @hidden */
  22700. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22701. /**
  22702. * Applies VertexData created from the imported parameters to the geometry
  22703. * @param parsedVertexData the parsed data from an imported file
  22704. * @param geometry the geometry to apply the VertexData to
  22705. */
  22706. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22707. }
  22708. }
  22709. declare module "babylonjs/Morph/morphTarget" {
  22710. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22711. import { Observable } from "babylonjs/Misc/observable";
  22712. import { Nullable, FloatArray } from "babylonjs/types";
  22713. import { Scene } from "babylonjs/scene";
  22714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22715. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22716. /**
  22717. * Defines a target to use with MorphTargetManager
  22718. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22719. */
  22720. export class MorphTarget implements IAnimatable {
  22721. /** defines the name of the target */
  22722. name: string;
  22723. /**
  22724. * Gets or sets the list of animations
  22725. */
  22726. animations: import("babylonjs/Animations/animation").Animation[];
  22727. private _scene;
  22728. private _positions;
  22729. private _normals;
  22730. private _tangents;
  22731. private _uvs;
  22732. private _influence;
  22733. /**
  22734. * Observable raised when the influence changes
  22735. */
  22736. onInfluenceChanged: Observable<boolean>;
  22737. /** @hidden */
  22738. _onDataLayoutChanged: Observable<void>;
  22739. /**
  22740. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22741. */
  22742. influence: number;
  22743. /**
  22744. * Gets or sets the id of the morph Target
  22745. */
  22746. id: string;
  22747. private _animationPropertiesOverride;
  22748. /**
  22749. * Gets or sets the animation properties override
  22750. */
  22751. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22752. /**
  22753. * Creates a new MorphTarget
  22754. * @param name defines the name of the target
  22755. * @param influence defines the influence to use
  22756. * @param scene defines the scene the morphtarget belongs to
  22757. */
  22758. constructor(
  22759. /** defines the name of the target */
  22760. name: string, influence?: number, scene?: Nullable<Scene>);
  22761. /**
  22762. * Gets a boolean defining if the target contains position data
  22763. */
  22764. readonly hasPositions: boolean;
  22765. /**
  22766. * Gets a boolean defining if the target contains normal data
  22767. */
  22768. readonly hasNormals: boolean;
  22769. /**
  22770. * Gets a boolean defining if the target contains tangent data
  22771. */
  22772. readonly hasTangents: boolean;
  22773. /**
  22774. * Gets a boolean defining if the target contains texture coordinates data
  22775. */
  22776. readonly hasUVs: boolean;
  22777. /**
  22778. * Affects position data to this target
  22779. * @param data defines the position data to use
  22780. */
  22781. setPositions(data: Nullable<FloatArray>): void;
  22782. /**
  22783. * Gets the position data stored in this target
  22784. * @returns a FloatArray containing the position data (or null if not present)
  22785. */
  22786. getPositions(): Nullable<FloatArray>;
  22787. /**
  22788. * Affects normal data to this target
  22789. * @param data defines the normal data to use
  22790. */
  22791. setNormals(data: Nullable<FloatArray>): void;
  22792. /**
  22793. * Gets the normal data stored in this target
  22794. * @returns a FloatArray containing the normal data (or null if not present)
  22795. */
  22796. getNormals(): Nullable<FloatArray>;
  22797. /**
  22798. * Affects tangent data to this target
  22799. * @param data defines the tangent data to use
  22800. */
  22801. setTangents(data: Nullable<FloatArray>): void;
  22802. /**
  22803. * Gets the tangent data stored in this target
  22804. * @returns a FloatArray containing the tangent data (or null if not present)
  22805. */
  22806. getTangents(): Nullable<FloatArray>;
  22807. /**
  22808. * Affects texture coordinates data to this target
  22809. * @param data defines the texture coordinates data to use
  22810. */
  22811. setUVs(data: Nullable<FloatArray>): void;
  22812. /**
  22813. * Gets the texture coordinates data stored in this target
  22814. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22815. */
  22816. getUVs(): Nullable<FloatArray>;
  22817. /**
  22818. * Serializes the current target into a Serialization object
  22819. * @returns the serialized object
  22820. */
  22821. serialize(): any;
  22822. /**
  22823. * Returns the string "MorphTarget"
  22824. * @returns "MorphTarget"
  22825. */
  22826. getClassName(): string;
  22827. /**
  22828. * Creates a new target from serialized data
  22829. * @param serializationObject defines the serialized data to use
  22830. * @returns a new MorphTarget
  22831. */
  22832. static Parse(serializationObject: any): MorphTarget;
  22833. /**
  22834. * Creates a MorphTarget from mesh data
  22835. * @param mesh defines the source mesh
  22836. * @param name defines the name to use for the new target
  22837. * @param influence defines the influence to attach to the target
  22838. * @returns a new MorphTarget
  22839. */
  22840. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22841. }
  22842. }
  22843. declare module "babylonjs/Morph/morphTargetManager" {
  22844. import { Nullable } from "babylonjs/types";
  22845. import { Scene } from "babylonjs/scene";
  22846. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22847. /**
  22848. * This class is used to deform meshes using morphing between different targets
  22849. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22850. */
  22851. export class MorphTargetManager {
  22852. private _targets;
  22853. private _targetInfluenceChangedObservers;
  22854. private _targetDataLayoutChangedObservers;
  22855. private _activeTargets;
  22856. private _scene;
  22857. private _influences;
  22858. private _supportsNormals;
  22859. private _supportsTangents;
  22860. private _supportsUVs;
  22861. private _vertexCount;
  22862. private _uniqueId;
  22863. private _tempInfluences;
  22864. /**
  22865. * Gets or sets a boolean indicating if normals must be morphed
  22866. */
  22867. enableNormalMorphing: boolean;
  22868. /**
  22869. * Gets or sets a boolean indicating if tangents must be morphed
  22870. */
  22871. enableTangentMorphing: boolean;
  22872. /**
  22873. * Gets or sets a boolean indicating if UV must be morphed
  22874. */
  22875. enableUVMorphing: boolean;
  22876. /**
  22877. * Creates a new MorphTargetManager
  22878. * @param scene defines the current scene
  22879. */
  22880. constructor(scene?: Nullable<Scene>);
  22881. /**
  22882. * Gets the unique ID of this manager
  22883. */
  22884. readonly uniqueId: number;
  22885. /**
  22886. * Gets the number of vertices handled by this manager
  22887. */
  22888. readonly vertexCount: number;
  22889. /**
  22890. * Gets a boolean indicating if this manager supports morphing of normals
  22891. */
  22892. readonly supportsNormals: boolean;
  22893. /**
  22894. * Gets a boolean indicating if this manager supports morphing of tangents
  22895. */
  22896. readonly supportsTangents: boolean;
  22897. /**
  22898. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22899. */
  22900. readonly supportsUVs: boolean;
  22901. /**
  22902. * Gets the number of targets stored in this manager
  22903. */
  22904. readonly numTargets: number;
  22905. /**
  22906. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22907. */
  22908. readonly numInfluencers: number;
  22909. /**
  22910. * Gets the list of influences (one per target)
  22911. */
  22912. readonly influences: Float32Array;
  22913. /**
  22914. * Gets the active target at specified index. An active target is a target with an influence > 0
  22915. * @param index defines the index to check
  22916. * @returns the requested target
  22917. */
  22918. getActiveTarget(index: number): MorphTarget;
  22919. /**
  22920. * Gets the target at specified index
  22921. * @param index defines the index to check
  22922. * @returns the requested target
  22923. */
  22924. getTarget(index: number): MorphTarget;
  22925. /**
  22926. * Add a new target to this manager
  22927. * @param target defines the target to add
  22928. */
  22929. addTarget(target: MorphTarget): void;
  22930. /**
  22931. * Removes a target from the manager
  22932. * @param target defines the target to remove
  22933. */
  22934. removeTarget(target: MorphTarget): void;
  22935. /**
  22936. * Serializes the current manager into a Serialization object
  22937. * @returns the serialized object
  22938. */
  22939. serialize(): any;
  22940. private _syncActiveTargets;
  22941. /**
  22942. * Syncrhonize the targets with all the meshes using this morph target manager
  22943. */
  22944. synchronize(): void;
  22945. /**
  22946. * Creates a new MorphTargetManager from serialized data
  22947. * @param serializationObject defines the serialized data
  22948. * @param scene defines the hosting scene
  22949. * @returns the new MorphTargetManager
  22950. */
  22951. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22952. }
  22953. }
  22954. declare module "babylonjs/Meshes/meshLODLevel" {
  22955. import { Mesh } from "babylonjs/Meshes/mesh";
  22956. import { Nullable } from "babylonjs/types";
  22957. /**
  22958. * Class used to represent a specific level of detail of a mesh
  22959. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22960. */
  22961. export class MeshLODLevel {
  22962. /** Defines the distance where this level should start being displayed */
  22963. distance: number;
  22964. /** Defines the mesh to use to render this level */
  22965. mesh: Nullable<Mesh>;
  22966. /**
  22967. * Creates a new LOD level
  22968. * @param distance defines the distance where this level should star being displayed
  22969. * @param mesh defines the mesh to use to render this level
  22970. */
  22971. constructor(
  22972. /** Defines the distance where this level should start being displayed */
  22973. distance: number,
  22974. /** Defines the mesh to use to render this level */
  22975. mesh: Nullable<Mesh>);
  22976. }
  22977. }
  22978. declare module "babylonjs/Meshes/groundMesh" {
  22979. import { Scene } from "babylonjs/scene";
  22980. import { Vector3 } from "babylonjs/Maths/math.vector";
  22981. import { Mesh } from "babylonjs/Meshes/mesh";
  22982. /**
  22983. * Mesh representing the gorund
  22984. */
  22985. export class GroundMesh extends Mesh {
  22986. /** If octree should be generated */
  22987. generateOctree: boolean;
  22988. private _heightQuads;
  22989. /** @hidden */
  22990. _subdivisionsX: number;
  22991. /** @hidden */
  22992. _subdivisionsY: number;
  22993. /** @hidden */
  22994. _width: number;
  22995. /** @hidden */
  22996. _height: number;
  22997. /** @hidden */
  22998. _minX: number;
  22999. /** @hidden */
  23000. _maxX: number;
  23001. /** @hidden */
  23002. _minZ: number;
  23003. /** @hidden */
  23004. _maxZ: number;
  23005. constructor(name: string, scene: Scene);
  23006. /**
  23007. * "GroundMesh"
  23008. * @returns "GroundMesh"
  23009. */
  23010. getClassName(): string;
  23011. /**
  23012. * The minimum of x and y subdivisions
  23013. */
  23014. readonly subdivisions: number;
  23015. /**
  23016. * X subdivisions
  23017. */
  23018. readonly subdivisionsX: number;
  23019. /**
  23020. * Y subdivisions
  23021. */
  23022. readonly subdivisionsY: number;
  23023. /**
  23024. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23025. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23026. * @param chunksCount the number of subdivisions for x and y
  23027. * @param octreeBlocksSize (Default: 32)
  23028. */
  23029. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23030. /**
  23031. * Returns a height (y) value in the Worl system :
  23032. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23033. * @param x x coordinate
  23034. * @param z z coordinate
  23035. * @returns the ground y position if (x, z) are outside the ground surface.
  23036. */
  23037. getHeightAtCoordinates(x: number, z: number): number;
  23038. /**
  23039. * Returns a normalized vector (Vector3) orthogonal to the ground
  23040. * at the ground coordinates (x, z) expressed in the World system.
  23041. * @param x x coordinate
  23042. * @param z z coordinate
  23043. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23044. */
  23045. getNormalAtCoordinates(x: number, z: number): Vector3;
  23046. /**
  23047. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23048. * at the ground coordinates (x, z) expressed in the World system.
  23049. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23050. * @param x x coordinate
  23051. * @param z z coordinate
  23052. * @param ref vector to store the result
  23053. * @returns the GroundMesh.
  23054. */
  23055. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23056. /**
  23057. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23058. * if the ground has been updated.
  23059. * This can be used in the render loop.
  23060. * @returns the GroundMesh.
  23061. */
  23062. updateCoordinateHeights(): GroundMesh;
  23063. private _getFacetAt;
  23064. private _initHeightQuads;
  23065. private _computeHeightQuads;
  23066. /**
  23067. * Serializes this ground mesh
  23068. * @param serializationObject object to write serialization to
  23069. */
  23070. serialize(serializationObject: any): void;
  23071. /**
  23072. * Parses a serialized ground mesh
  23073. * @param parsedMesh the serialized mesh
  23074. * @param scene the scene to create the ground mesh in
  23075. * @returns the created ground mesh
  23076. */
  23077. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23078. }
  23079. }
  23080. declare module "babylonjs/Physics/physicsJoint" {
  23081. import { Vector3 } from "babylonjs/Maths/math.vector";
  23082. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23083. /**
  23084. * Interface for Physics-Joint data
  23085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23086. */
  23087. export interface PhysicsJointData {
  23088. /**
  23089. * The main pivot of the joint
  23090. */
  23091. mainPivot?: Vector3;
  23092. /**
  23093. * The connected pivot of the joint
  23094. */
  23095. connectedPivot?: Vector3;
  23096. /**
  23097. * The main axis of the joint
  23098. */
  23099. mainAxis?: Vector3;
  23100. /**
  23101. * The connected axis of the joint
  23102. */
  23103. connectedAxis?: Vector3;
  23104. /**
  23105. * The collision of the joint
  23106. */
  23107. collision?: boolean;
  23108. /**
  23109. * Native Oimo/Cannon/Energy data
  23110. */
  23111. nativeParams?: any;
  23112. }
  23113. /**
  23114. * This is a holder class for the physics joint created by the physics plugin
  23115. * It holds a set of functions to control the underlying joint
  23116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23117. */
  23118. export class PhysicsJoint {
  23119. /**
  23120. * The type of the physics joint
  23121. */
  23122. type: number;
  23123. /**
  23124. * The data for the physics joint
  23125. */
  23126. jointData: PhysicsJointData;
  23127. private _physicsJoint;
  23128. protected _physicsPlugin: IPhysicsEnginePlugin;
  23129. /**
  23130. * Initializes the physics joint
  23131. * @param type The type of the physics joint
  23132. * @param jointData The data for the physics joint
  23133. */
  23134. constructor(
  23135. /**
  23136. * The type of the physics joint
  23137. */
  23138. type: number,
  23139. /**
  23140. * The data for the physics joint
  23141. */
  23142. jointData: PhysicsJointData);
  23143. /**
  23144. * Gets the physics joint
  23145. */
  23146. /**
  23147. * Sets the physics joint
  23148. */
  23149. physicsJoint: any;
  23150. /**
  23151. * Sets the physics plugin
  23152. */
  23153. physicsPlugin: IPhysicsEnginePlugin;
  23154. /**
  23155. * Execute a function that is physics-plugin specific.
  23156. * @param {Function} func the function that will be executed.
  23157. * It accepts two parameters: the physics world and the physics joint
  23158. */
  23159. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23160. /**
  23161. * Distance-Joint type
  23162. */
  23163. static DistanceJoint: number;
  23164. /**
  23165. * Hinge-Joint type
  23166. */
  23167. static HingeJoint: number;
  23168. /**
  23169. * Ball-and-Socket joint type
  23170. */
  23171. static BallAndSocketJoint: number;
  23172. /**
  23173. * Wheel-Joint type
  23174. */
  23175. static WheelJoint: number;
  23176. /**
  23177. * Slider-Joint type
  23178. */
  23179. static SliderJoint: number;
  23180. /**
  23181. * Prismatic-Joint type
  23182. */
  23183. static PrismaticJoint: number;
  23184. /**
  23185. * Universal-Joint type
  23186. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23187. */
  23188. static UniversalJoint: number;
  23189. /**
  23190. * Hinge-Joint 2 type
  23191. */
  23192. static Hinge2Joint: number;
  23193. /**
  23194. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23195. */
  23196. static PointToPointJoint: number;
  23197. /**
  23198. * Spring-Joint type
  23199. */
  23200. static SpringJoint: number;
  23201. /**
  23202. * Lock-Joint type
  23203. */
  23204. static LockJoint: number;
  23205. }
  23206. /**
  23207. * A class representing a physics distance joint
  23208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23209. */
  23210. export class DistanceJoint extends PhysicsJoint {
  23211. /**
  23212. *
  23213. * @param jointData The data for the Distance-Joint
  23214. */
  23215. constructor(jointData: DistanceJointData);
  23216. /**
  23217. * Update the predefined distance.
  23218. * @param maxDistance The maximum preferred distance
  23219. * @param minDistance The minimum preferred distance
  23220. */
  23221. updateDistance(maxDistance: number, minDistance?: number): void;
  23222. }
  23223. /**
  23224. * Represents a Motor-Enabled Joint
  23225. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23226. */
  23227. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23228. /**
  23229. * Initializes the Motor-Enabled Joint
  23230. * @param type The type of the joint
  23231. * @param jointData The physica joint data for the joint
  23232. */
  23233. constructor(type: number, jointData: PhysicsJointData);
  23234. /**
  23235. * Set the motor values.
  23236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23237. * @param force the force to apply
  23238. * @param maxForce max force for this motor.
  23239. */
  23240. setMotor(force?: number, maxForce?: number): void;
  23241. /**
  23242. * Set the motor's limits.
  23243. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23244. * @param upperLimit The upper limit of the motor
  23245. * @param lowerLimit The lower limit of the motor
  23246. */
  23247. setLimit(upperLimit: number, lowerLimit?: number): void;
  23248. }
  23249. /**
  23250. * This class represents a single physics Hinge-Joint
  23251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23252. */
  23253. export class HingeJoint extends MotorEnabledJoint {
  23254. /**
  23255. * Initializes the Hinge-Joint
  23256. * @param jointData The joint data for the Hinge-Joint
  23257. */
  23258. constructor(jointData: PhysicsJointData);
  23259. /**
  23260. * Set the motor values.
  23261. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23262. * @param {number} force the force to apply
  23263. * @param {number} maxForce max force for this motor.
  23264. */
  23265. setMotor(force?: number, maxForce?: number): void;
  23266. /**
  23267. * Set the motor's limits.
  23268. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23269. * @param upperLimit The upper limit of the motor
  23270. * @param lowerLimit The lower limit of the motor
  23271. */
  23272. setLimit(upperLimit: number, lowerLimit?: number): void;
  23273. }
  23274. /**
  23275. * This class represents a dual hinge physics joint (same as wheel joint)
  23276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23277. */
  23278. export class Hinge2Joint extends MotorEnabledJoint {
  23279. /**
  23280. * Initializes the Hinge2-Joint
  23281. * @param jointData The joint data for the Hinge2-Joint
  23282. */
  23283. constructor(jointData: PhysicsJointData);
  23284. /**
  23285. * Set the motor values.
  23286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23287. * @param {number} targetSpeed the speed the motor is to reach
  23288. * @param {number} maxForce max force for this motor.
  23289. * @param {motorIndex} the motor's index, 0 or 1.
  23290. */
  23291. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23292. /**
  23293. * Set the motor limits.
  23294. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23295. * @param {number} upperLimit the upper limit
  23296. * @param {number} lowerLimit lower limit
  23297. * @param {motorIndex} the motor's index, 0 or 1.
  23298. */
  23299. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23300. }
  23301. /**
  23302. * Interface for a motor enabled joint
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface IMotorEnabledJoint {
  23306. /**
  23307. * Physics joint
  23308. */
  23309. physicsJoint: any;
  23310. /**
  23311. * Sets the motor of the motor-enabled joint
  23312. * @param force The force of the motor
  23313. * @param maxForce The maximum force of the motor
  23314. * @param motorIndex The index of the motor
  23315. */
  23316. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23317. /**
  23318. * Sets the limit of the motor
  23319. * @param upperLimit The upper limit of the motor
  23320. * @param lowerLimit The lower limit of the motor
  23321. * @param motorIndex The index of the motor
  23322. */
  23323. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23324. }
  23325. /**
  23326. * Joint data for a Distance-Joint
  23327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23328. */
  23329. export interface DistanceJointData extends PhysicsJointData {
  23330. /**
  23331. * Max distance the 2 joint objects can be apart
  23332. */
  23333. maxDistance: number;
  23334. }
  23335. /**
  23336. * Joint data from a spring joint
  23337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23338. */
  23339. export interface SpringJointData extends PhysicsJointData {
  23340. /**
  23341. * Length of the spring
  23342. */
  23343. length: number;
  23344. /**
  23345. * Stiffness of the spring
  23346. */
  23347. stiffness: number;
  23348. /**
  23349. * Damping of the spring
  23350. */
  23351. damping: number;
  23352. /** this callback will be called when applying the force to the impostors. */
  23353. forceApplicationCallback: () => void;
  23354. }
  23355. }
  23356. declare module "babylonjs/Physics/physicsRaycastResult" {
  23357. import { Vector3 } from "babylonjs/Maths/math.vector";
  23358. /**
  23359. * Holds the data for the raycast result
  23360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23361. */
  23362. export class PhysicsRaycastResult {
  23363. private _hasHit;
  23364. private _hitDistance;
  23365. private _hitNormalWorld;
  23366. private _hitPointWorld;
  23367. private _rayFromWorld;
  23368. private _rayToWorld;
  23369. /**
  23370. * Gets if there was a hit
  23371. */
  23372. readonly hasHit: boolean;
  23373. /**
  23374. * Gets the distance from the hit
  23375. */
  23376. readonly hitDistance: number;
  23377. /**
  23378. * Gets the hit normal/direction in the world
  23379. */
  23380. readonly hitNormalWorld: Vector3;
  23381. /**
  23382. * Gets the hit point in the world
  23383. */
  23384. readonly hitPointWorld: Vector3;
  23385. /**
  23386. * Gets the ray "start point" of the ray in the world
  23387. */
  23388. readonly rayFromWorld: Vector3;
  23389. /**
  23390. * Gets the ray "end point" of the ray in the world
  23391. */
  23392. readonly rayToWorld: Vector3;
  23393. /**
  23394. * Sets the hit data (normal & point in world space)
  23395. * @param hitNormalWorld defines the normal in world space
  23396. * @param hitPointWorld defines the point in world space
  23397. */
  23398. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23399. /**
  23400. * Sets the distance from the start point to the hit point
  23401. * @param distance
  23402. */
  23403. setHitDistance(distance: number): void;
  23404. /**
  23405. * Calculates the distance manually
  23406. */
  23407. calculateHitDistance(): void;
  23408. /**
  23409. * Resets all the values to default
  23410. * @param from The from point on world space
  23411. * @param to The to point on world space
  23412. */
  23413. reset(from?: Vector3, to?: Vector3): void;
  23414. }
  23415. /**
  23416. * Interface for the size containing width and height
  23417. */
  23418. interface IXYZ {
  23419. /**
  23420. * X
  23421. */
  23422. x: number;
  23423. /**
  23424. * Y
  23425. */
  23426. y: number;
  23427. /**
  23428. * Z
  23429. */
  23430. z: number;
  23431. }
  23432. }
  23433. declare module "babylonjs/Physics/IPhysicsEngine" {
  23434. import { Nullable } from "babylonjs/types";
  23435. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23437. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23438. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23439. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23440. /**
  23441. * Interface used to describe a physics joint
  23442. */
  23443. export interface PhysicsImpostorJoint {
  23444. /** Defines the main impostor to which the joint is linked */
  23445. mainImpostor: PhysicsImpostor;
  23446. /** Defines the impostor that is connected to the main impostor using this joint */
  23447. connectedImpostor: PhysicsImpostor;
  23448. /** Defines the joint itself */
  23449. joint: PhysicsJoint;
  23450. }
  23451. /** @hidden */
  23452. export interface IPhysicsEnginePlugin {
  23453. world: any;
  23454. name: string;
  23455. setGravity(gravity: Vector3): void;
  23456. setTimeStep(timeStep: number): void;
  23457. getTimeStep(): number;
  23458. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23459. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23460. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23461. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23462. removePhysicsBody(impostor: PhysicsImpostor): void;
  23463. generateJoint(joint: PhysicsImpostorJoint): void;
  23464. removeJoint(joint: PhysicsImpostorJoint): void;
  23465. isSupported(): boolean;
  23466. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23467. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23468. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23469. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23470. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23471. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23472. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23473. getBodyMass(impostor: PhysicsImpostor): number;
  23474. getBodyFriction(impostor: PhysicsImpostor): number;
  23475. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23476. getBodyRestitution(impostor: PhysicsImpostor): number;
  23477. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23478. getBodyPressure?(impostor: PhysicsImpostor): number;
  23479. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23480. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23481. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23482. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23483. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23484. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23485. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23486. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23487. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23488. sleepBody(impostor: PhysicsImpostor): void;
  23489. wakeUpBody(impostor: PhysicsImpostor): void;
  23490. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23491. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23492. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23493. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23494. getRadius(impostor: PhysicsImpostor): number;
  23495. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23496. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23497. dispose(): void;
  23498. }
  23499. /**
  23500. * Interface used to define a physics engine
  23501. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23502. */
  23503. export interface IPhysicsEngine {
  23504. /**
  23505. * Gets the gravity vector used by the simulation
  23506. */
  23507. gravity: Vector3;
  23508. /**
  23509. * Sets the gravity vector used by the simulation
  23510. * @param gravity defines the gravity vector to use
  23511. */
  23512. setGravity(gravity: Vector3): void;
  23513. /**
  23514. * Set the time step of the physics engine.
  23515. * Default is 1/60.
  23516. * To slow it down, enter 1/600 for example.
  23517. * To speed it up, 1/30
  23518. * @param newTimeStep the new timestep to apply to this world.
  23519. */
  23520. setTimeStep(newTimeStep: number): void;
  23521. /**
  23522. * Get the time step of the physics engine.
  23523. * @returns the current time step
  23524. */
  23525. getTimeStep(): number;
  23526. /**
  23527. * Release all resources
  23528. */
  23529. dispose(): void;
  23530. /**
  23531. * Gets the name of the current physics plugin
  23532. * @returns the name of the plugin
  23533. */
  23534. getPhysicsPluginName(): string;
  23535. /**
  23536. * Adding a new impostor for the impostor tracking.
  23537. * This will be done by the impostor itself.
  23538. * @param impostor the impostor to add
  23539. */
  23540. addImpostor(impostor: PhysicsImpostor): void;
  23541. /**
  23542. * Remove an impostor from the engine.
  23543. * This impostor and its mesh will not longer be updated by the physics engine.
  23544. * @param impostor the impostor to remove
  23545. */
  23546. removeImpostor(impostor: PhysicsImpostor): void;
  23547. /**
  23548. * Add a joint to the physics engine
  23549. * @param mainImpostor defines the main impostor to which the joint is added.
  23550. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23551. * @param joint defines the joint that will connect both impostors.
  23552. */
  23553. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23554. /**
  23555. * Removes a joint from the simulation
  23556. * @param mainImpostor defines the impostor used with the joint
  23557. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23558. * @param joint defines the joint to remove
  23559. */
  23560. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23561. /**
  23562. * Gets the current plugin used to run the simulation
  23563. * @returns current plugin
  23564. */
  23565. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23566. /**
  23567. * Gets the list of physic impostors
  23568. * @returns an array of PhysicsImpostor
  23569. */
  23570. getImpostors(): Array<PhysicsImpostor>;
  23571. /**
  23572. * Gets the impostor for a physics enabled object
  23573. * @param object defines the object impersonated by the impostor
  23574. * @returns the PhysicsImpostor or null if not found
  23575. */
  23576. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23577. /**
  23578. * Gets the impostor for a physics body object
  23579. * @param body defines physics body used by the impostor
  23580. * @returns the PhysicsImpostor or null if not found
  23581. */
  23582. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23583. /**
  23584. * Does a raycast in the physics world
  23585. * @param from when should the ray start?
  23586. * @param to when should the ray end?
  23587. * @returns PhysicsRaycastResult
  23588. */
  23589. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23590. /**
  23591. * Called by the scene. No need to call it.
  23592. * @param delta defines the timespam between frames
  23593. */
  23594. _step(delta: number): void;
  23595. }
  23596. }
  23597. declare module "babylonjs/Physics/physicsImpostor" {
  23598. import { Nullable, IndicesArray } from "babylonjs/types";
  23599. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23600. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23602. import { Scene } from "babylonjs/scene";
  23603. import { Bone } from "babylonjs/Bones/bone";
  23604. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23605. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23606. import { Space } from "babylonjs/Maths/math.axis";
  23607. /**
  23608. * The interface for the physics imposter parameters
  23609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23610. */
  23611. export interface PhysicsImpostorParameters {
  23612. /**
  23613. * The mass of the physics imposter
  23614. */
  23615. mass: number;
  23616. /**
  23617. * The friction of the physics imposter
  23618. */
  23619. friction?: number;
  23620. /**
  23621. * The coefficient of restitution of the physics imposter
  23622. */
  23623. restitution?: number;
  23624. /**
  23625. * The native options of the physics imposter
  23626. */
  23627. nativeOptions?: any;
  23628. /**
  23629. * Specifies if the parent should be ignored
  23630. */
  23631. ignoreParent?: boolean;
  23632. /**
  23633. * Specifies if bi-directional transformations should be disabled
  23634. */
  23635. disableBidirectionalTransformation?: boolean;
  23636. /**
  23637. * The pressure inside the physics imposter, soft object only
  23638. */
  23639. pressure?: number;
  23640. /**
  23641. * The stiffness the physics imposter, soft object only
  23642. */
  23643. stiffness?: number;
  23644. /**
  23645. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23646. */
  23647. velocityIterations?: number;
  23648. /**
  23649. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23650. */
  23651. positionIterations?: number;
  23652. /**
  23653. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23654. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23655. * Add to fix multiple points
  23656. */
  23657. fixedPoints?: number;
  23658. /**
  23659. * The collision margin around a soft object
  23660. */
  23661. margin?: number;
  23662. /**
  23663. * The collision margin around a soft object
  23664. */
  23665. damping?: number;
  23666. /**
  23667. * The path for a rope based on an extrusion
  23668. */
  23669. path?: any;
  23670. /**
  23671. * The shape of an extrusion used for a rope based on an extrusion
  23672. */
  23673. shape?: any;
  23674. }
  23675. /**
  23676. * Interface for a physics-enabled object
  23677. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23678. */
  23679. export interface IPhysicsEnabledObject {
  23680. /**
  23681. * The position of the physics-enabled object
  23682. */
  23683. position: Vector3;
  23684. /**
  23685. * The rotation of the physics-enabled object
  23686. */
  23687. rotationQuaternion: Nullable<Quaternion>;
  23688. /**
  23689. * The scale of the physics-enabled object
  23690. */
  23691. scaling: Vector3;
  23692. /**
  23693. * The rotation of the physics-enabled object
  23694. */
  23695. rotation?: Vector3;
  23696. /**
  23697. * The parent of the physics-enabled object
  23698. */
  23699. parent?: any;
  23700. /**
  23701. * The bounding info of the physics-enabled object
  23702. * @returns The bounding info of the physics-enabled object
  23703. */
  23704. getBoundingInfo(): BoundingInfo;
  23705. /**
  23706. * Computes the world matrix
  23707. * @param force Specifies if the world matrix should be computed by force
  23708. * @returns A world matrix
  23709. */
  23710. computeWorldMatrix(force: boolean): Matrix;
  23711. /**
  23712. * Gets the world matrix
  23713. * @returns A world matrix
  23714. */
  23715. getWorldMatrix?(): Matrix;
  23716. /**
  23717. * Gets the child meshes
  23718. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23719. * @returns An array of abstract meshes
  23720. */
  23721. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23722. /**
  23723. * Gets the vertex data
  23724. * @param kind The type of vertex data
  23725. * @returns A nullable array of numbers, or a float32 array
  23726. */
  23727. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23728. /**
  23729. * Gets the indices from the mesh
  23730. * @returns A nullable array of index arrays
  23731. */
  23732. getIndices?(): Nullable<IndicesArray>;
  23733. /**
  23734. * Gets the scene from the mesh
  23735. * @returns the indices array or null
  23736. */
  23737. getScene?(): Scene;
  23738. /**
  23739. * Gets the absolute position from the mesh
  23740. * @returns the absolute position
  23741. */
  23742. getAbsolutePosition(): Vector3;
  23743. /**
  23744. * Gets the absolute pivot point from the mesh
  23745. * @returns the absolute pivot point
  23746. */
  23747. getAbsolutePivotPoint(): Vector3;
  23748. /**
  23749. * Rotates the mesh
  23750. * @param axis The axis of rotation
  23751. * @param amount The amount of rotation
  23752. * @param space The space of the rotation
  23753. * @returns The rotation transform node
  23754. */
  23755. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23756. /**
  23757. * Translates the mesh
  23758. * @param axis The axis of translation
  23759. * @param distance The distance of translation
  23760. * @param space The space of the translation
  23761. * @returns The transform node
  23762. */
  23763. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23764. /**
  23765. * Sets the absolute position of the mesh
  23766. * @param absolutePosition The absolute position of the mesh
  23767. * @returns The transform node
  23768. */
  23769. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23770. /**
  23771. * Gets the class name of the mesh
  23772. * @returns The class name
  23773. */
  23774. getClassName(): string;
  23775. }
  23776. /**
  23777. * Represents a physics imposter
  23778. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23779. */
  23780. export class PhysicsImpostor {
  23781. /**
  23782. * The physics-enabled object used as the physics imposter
  23783. */
  23784. object: IPhysicsEnabledObject;
  23785. /**
  23786. * The type of the physics imposter
  23787. */
  23788. type: number;
  23789. private _options;
  23790. private _scene?;
  23791. /**
  23792. * The default object size of the imposter
  23793. */
  23794. static DEFAULT_OBJECT_SIZE: Vector3;
  23795. /**
  23796. * The identity quaternion of the imposter
  23797. */
  23798. static IDENTITY_QUATERNION: Quaternion;
  23799. /** @hidden */
  23800. _pluginData: any;
  23801. private _physicsEngine;
  23802. private _physicsBody;
  23803. private _bodyUpdateRequired;
  23804. private _onBeforePhysicsStepCallbacks;
  23805. private _onAfterPhysicsStepCallbacks;
  23806. /** @hidden */
  23807. _onPhysicsCollideCallbacks: Array<{
  23808. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23809. otherImpostors: Array<PhysicsImpostor>;
  23810. }>;
  23811. private _deltaPosition;
  23812. private _deltaRotation;
  23813. private _deltaRotationConjugated;
  23814. /** @hidden */
  23815. _isFromLine: boolean;
  23816. private _parent;
  23817. private _isDisposed;
  23818. private static _tmpVecs;
  23819. private static _tmpQuat;
  23820. /**
  23821. * Specifies if the physics imposter is disposed
  23822. */
  23823. readonly isDisposed: boolean;
  23824. /**
  23825. * Gets the mass of the physics imposter
  23826. */
  23827. mass: number;
  23828. /**
  23829. * Gets the coefficient of friction
  23830. */
  23831. /**
  23832. * Sets the coefficient of friction
  23833. */
  23834. friction: number;
  23835. /**
  23836. * Gets the coefficient of restitution
  23837. */
  23838. /**
  23839. * Sets the coefficient of restitution
  23840. */
  23841. restitution: number;
  23842. /**
  23843. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23844. */
  23845. /**
  23846. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23847. */
  23848. pressure: number;
  23849. /**
  23850. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23851. */
  23852. /**
  23853. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23854. */
  23855. stiffness: number;
  23856. /**
  23857. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23858. */
  23859. /**
  23860. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23861. */
  23862. velocityIterations: number;
  23863. /**
  23864. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23865. */
  23866. /**
  23867. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23868. */
  23869. positionIterations: number;
  23870. /**
  23871. * The unique id of the physics imposter
  23872. * set by the physics engine when adding this impostor to the array
  23873. */
  23874. uniqueId: number;
  23875. /**
  23876. * @hidden
  23877. */
  23878. soft: boolean;
  23879. /**
  23880. * @hidden
  23881. */
  23882. segments: number;
  23883. private _joints;
  23884. /**
  23885. * Initializes the physics imposter
  23886. * @param object The physics-enabled object used as the physics imposter
  23887. * @param type The type of the physics imposter
  23888. * @param _options The options for the physics imposter
  23889. * @param _scene The Babylon scene
  23890. */
  23891. constructor(
  23892. /**
  23893. * The physics-enabled object used as the physics imposter
  23894. */
  23895. object: IPhysicsEnabledObject,
  23896. /**
  23897. * The type of the physics imposter
  23898. */
  23899. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23900. /**
  23901. * This function will completly initialize this impostor.
  23902. * It will create a new body - but only if this mesh has no parent.
  23903. * If it has, this impostor will not be used other than to define the impostor
  23904. * of the child mesh.
  23905. * @hidden
  23906. */
  23907. _init(): void;
  23908. private _getPhysicsParent;
  23909. /**
  23910. * Should a new body be generated.
  23911. * @returns boolean specifying if body initialization is required
  23912. */
  23913. isBodyInitRequired(): boolean;
  23914. /**
  23915. * Sets the updated scaling
  23916. * @param updated Specifies if the scaling is updated
  23917. */
  23918. setScalingUpdated(): void;
  23919. /**
  23920. * Force a regeneration of this or the parent's impostor's body.
  23921. * Use under cautious - This will remove all joints already implemented.
  23922. */
  23923. forceUpdate(): void;
  23924. /**
  23925. * Gets the body that holds this impostor. Either its own, or its parent.
  23926. */
  23927. /**
  23928. * Set the physics body. Used mainly by the physics engine/plugin
  23929. */
  23930. physicsBody: any;
  23931. /**
  23932. * Get the parent of the physics imposter
  23933. * @returns Physics imposter or null
  23934. */
  23935. /**
  23936. * Sets the parent of the physics imposter
  23937. */
  23938. parent: Nullable<PhysicsImpostor>;
  23939. /**
  23940. * Resets the update flags
  23941. */
  23942. resetUpdateFlags(): void;
  23943. /**
  23944. * Gets the object extend size
  23945. * @returns the object extend size
  23946. */
  23947. getObjectExtendSize(): Vector3;
  23948. /**
  23949. * Gets the object center
  23950. * @returns The object center
  23951. */
  23952. getObjectCenter(): Vector3;
  23953. /**
  23954. * Get a specific parametes from the options parameter
  23955. * @param paramName The object parameter name
  23956. * @returns The object parameter
  23957. */
  23958. getParam(paramName: string): any;
  23959. /**
  23960. * Sets a specific parameter in the options given to the physics plugin
  23961. * @param paramName The parameter name
  23962. * @param value The value of the parameter
  23963. */
  23964. setParam(paramName: string, value: number): void;
  23965. /**
  23966. * Specifically change the body's mass option. Won't recreate the physics body object
  23967. * @param mass The mass of the physics imposter
  23968. */
  23969. setMass(mass: number): void;
  23970. /**
  23971. * Gets the linear velocity
  23972. * @returns linear velocity or null
  23973. */
  23974. getLinearVelocity(): Nullable<Vector3>;
  23975. /**
  23976. * Sets the linear velocity
  23977. * @param velocity linear velocity or null
  23978. */
  23979. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23980. /**
  23981. * Gets the angular velocity
  23982. * @returns angular velocity or null
  23983. */
  23984. getAngularVelocity(): Nullable<Vector3>;
  23985. /**
  23986. * Sets the angular velocity
  23987. * @param velocity The velocity or null
  23988. */
  23989. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23990. /**
  23991. * Execute a function with the physics plugin native code
  23992. * Provide a function the will have two variables - the world object and the physics body object
  23993. * @param func The function to execute with the physics plugin native code
  23994. */
  23995. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23996. /**
  23997. * Register a function that will be executed before the physics world is stepping forward
  23998. * @param func The function to execute before the physics world is stepped forward
  23999. */
  24000. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24001. /**
  24002. * Unregister a function that will be executed before the physics world is stepping forward
  24003. * @param func The function to execute before the physics world is stepped forward
  24004. */
  24005. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24006. /**
  24007. * Register a function that will be executed after the physics step
  24008. * @param func The function to execute after physics step
  24009. */
  24010. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24011. /**
  24012. * Unregisters a function that will be executed after the physics step
  24013. * @param func The function to execute after physics step
  24014. */
  24015. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24016. /**
  24017. * register a function that will be executed when this impostor collides against a different body
  24018. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24019. * @param func Callback that is executed on collision
  24020. */
  24021. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24022. /**
  24023. * Unregisters the physics imposter on contact
  24024. * @param collideAgainst The physics object to collide against
  24025. * @param func Callback to execute on collision
  24026. */
  24027. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24028. private _tmpQuat;
  24029. private _tmpQuat2;
  24030. /**
  24031. * Get the parent rotation
  24032. * @returns The parent rotation
  24033. */
  24034. getParentsRotation(): Quaternion;
  24035. /**
  24036. * this function is executed by the physics engine.
  24037. */
  24038. beforeStep: () => void;
  24039. /**
  24040. * this function is executed by the physics engine
  24041. */
  24042. afterStep: () => void;
  24043. /**
  24044. * Legacy collision detection event support
  24045. */
  24046. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24047. /**
  24048. * event and body object due to cannon's event-based architecture.
  24049. */
  24050. onCollide: (e: {
  24051. body: any;
  24052. }) => void;
  24053. /**
  24054. * Apply a force
  24055. * @param force The force to apply
  24056. * @param contactPoint The contact point for the force
  24057. * @returns The physics imposter
  24058. */
  24059. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24060. /**
  24061. * Apply an impulse
  24062. * @param force The impulse force
  24063. * @param contactPoint The contact point for the impulse force
  24064. * @returns The physics imposter
  24065. */
  24066. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24067. /**
  24068. * A help function to create a joint
  24069. * @param otherImpostor A physics imposter used to create a joint
  24070. * @param jointType The type of joint
  24071. * @param jointData The data for the joint
  24072. * @returns The physics imposter
  24073. */
  24074. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24075. /**
  24076. * Add a joint to this impostor with a different impostor
  24077. * @param otherImpostor A physics imposter used to add a joint
  24078. * @param joint The joint to add
  24079. * @returns The physics imposter
  24080. */
  24081. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24082. /**
  24083. * Add an anchor to a cloth impostor
  24084. * @param otherImpostor rigid impostor to anchor to
  24085. * @param width ratio across width from 0 to 1
  24086. * @param height ratio up height from 0 to 1
  24087. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24088. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24089. * @returns impostor the soft imposter
  24090. */
  24091. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24092. /**
  24093. * Add a hook to a rope impostor
  24094. * @param otherImpostor rigid impostor to anchor to
  24095. * @param length ratio across rope from 0 to 1
  24096. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24097. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24098. * @returns impostor the rope imposter
  24099. */
  24100. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24101. /**
  24102. * Will keep this body still, in a sleep mode.
  24103. * @returns the physics imposter
  24104. */
  24105. sleep(): PhysicsImpostor;
  24106. /**
  24107. * Wake the body up.
  24108. * @returns The physics imposter
  24109. */
  24110. wakeUp(): PhysicsImpostor;
  24111. /**
  24112. * Clones the physics imposter
  24113. * @param newObject The physics imposter clones to this physics-enabled object
  24114. * @returns A nullable physics imposter
  24115. */
  24116. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24117. /**
  24118. * Disposes the physics imposter
  24119. */
  24120. dispose(): void;
  24121. /**
  24122. * Sets the delta position
  24123. * @param position The delta position amount
  24124. */
  24125. setDeltaPosition(position: Vector3): void;
  24126. /**
  24127. * Sets the delta rotation
  24128. * @param rotation The delta rotation amount
  24129. */
  24130. setDeltaRotation(rotation: Quaternion): void;
  24131. /**
  24132. * Gets the box size of the physics imposter and stores the result in the input parameter
  24133. * @param result Stores the box size
  24134. * @returns The physics imposter
  24135. */
  24136. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24137. /**
  24138. * Gets the radius of the physics imposter
  24139. * @returns Radius of the physics imposter
  24140. */
  24141. getRadius(): number;
  24142. /**
  24143. * Sync a bone with this impostor
  24144. * @param bone The bone to sync to the impostor.
  24145. * @param boneMesh The mesh that the bone is influencing.
  24146. * @param jointPivot The pivot of the joint / bone in local space.
  24147. * @param distToJoint Optional distance from the impostor to the joint.
  24148. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24149. */
  24150. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24151. /**
  24152. * Sync impostor to a bone
  24153. * @param bone The bone that the impostor will be synced to.
  24154. * @param boneMesh The mesh that the bone is influencing.
  24155. * @param jointPivot The pivot of the joint / bone in local space.
  24156. * @param distToJoint Optional distance from the impostor to the joint.
  24157. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24158. * @param boneAxis Optional vector3 axis the bone is aligned with
  24159. */
  24160. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24161. /**
  24162. * No-Imposter type
  24163. */
  24164. static NoImpostor: number;
  24165. /**
  24166. * Sphere-Imposter type
  24167. */
  24168. static SphereImpostor: number;
  24169. /**
  24170. * Box-Imposter type
  24171. */
  24172. static BoxImpostor: number;
  24173. /**
  24174. * Plane-Imposter type
  24175. */
  24176. static PlaneImpostor: number;
  24177. /**
  24178. * Mesh-imposter type
  24179. */
  24180. static MeshImpostor: number;
  24181. /**
  24182. * Capsule-Impostor type (Ammo.js plugin only)
  24183. */
  24184. static CapsuleImpostor: number;
  24185. /**
  24186. * Cylinder-Imposter type
  24187. */
  24188. static CylinderImpostor: number;
  24189. /**
  24190. * Particle-Imposter type
  24191. */
  24192. static ParticleImpostor: number;
  24193. /**
  24194. * Heightmap-Imposter type
  24195. */
  24196. static HeightmapImpostor: number;
  24197. /**
  24198. * ConvexHull-Impostor type (Ammo.js plugin only)
  24199. */
  24200. static ConvexHullImpostor: number;
  24201. /**
  24202. * Rope-Imposter type
  24203. */
  24204. static RopeImpostor: number;
  24205. /**
  24206. * Cloth-Imposter type
  24207. */
  24208. static ClothImpostor: number;
  24209. /**
  24210. * Softbody-Imposter type
  24211. */
  24212. static SoftbodyImpostor: number;
  24213. }
  24214. }
  24215. declare module "babylonjs/Meshes/mesh" {
  24216. import { Observable } from "babylonjs/Misc/observable";
  24217. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24218. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24219. import { Camera } from "babylonjs/Cameras/camera";
  24220. import { Scene } from "babylonjs/scene";
  24221. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24222. import { Color4 } from "babylonjs/Maths/math.color";
  24223. import { Engine } from "babylonjs/Engines/engine";
  24224. import { Node } from "babylonjs/node";
  24225. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24226. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24227. import { Buffer } from "babylonjs/Meshes/buffer";
  24228. import { Geometry } from "babylonjs/Meshes/geometry";
  24229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24230. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24231. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24232. import { Effect } from "babylonjs/Materials/effect";
  24233. import { Material } from "babylonjs/Materials/material";
  24234. import { Skeleton } from "babylonjs/Bones/skeleton";
  24235. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24236. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24237. import { Path3D } from "babylonjs/Maths/math.path";
  24238. import { Plane } from "babylonjs/Maths/math.plane";
  24239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24240. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24241. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24242. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24243. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24244. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24245. /**
  24246. * @hidden
  24247. **/
  24248. export class _CreationDataStorage {
  24249. closePath?: boolean;
  24250. closeArray?: boolean;
  24251. idx: number[];
  24252. dashSize: number;
  24253. gapSize: number;
  24254. path3D: Path3D;
  24255. pathArray: Vector3[][];
  24256. arc: number;
  24257. radius: number;
  24258. cap: number;
  24259. tessellation: number;
  24260. }
  24261. /**
  24262. * @hidden
  24263. **/
  24264. class _InstanceDataStorage {
  24265. visibleInstances: any;
  24266. batchCache: _InstancesBatch;
  24267. instancesBufferSize: number;
  24268. instancesBuffer: Nullable<Buffer>;
  24269. instancesData: Float32Array;
  24270. overridenInstanceCount: number;
  24271. isFrozen: boolean;
  24272. previousBatch: Nullable<_InstancesBatch>;
  24273. hardwareInstancedRendering: boolean;
  24274. sideOrientation: number;
  24275. }
  24276. /**
  24277. * @hidden
  24278. **/
  24279. export class _InstancesBatch {
  24280. mustReturn: boolean;
  24281. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24282. renderSelf: boolean[];
  24283. hardwareInstancedRendering: boolean[];
  24284. }
  24285. /**
  24286. * Class used to represent renderable models
  24287. */
  24288. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24289. /**
  24290. * Mesh side orientation : usually the external or front surface
  24291. */
  24292. static readonly FRONTSIDE: number;
  24293. /**
  24294. * Mesh side orientation : usually the internal or back surface
  24295. */
  24296. static readonly BACKSIDE: number;
  24297. /**
  24298. * Mesh side orientation : both internal and external or front and back surfaces
  24299. */
  24300. static readonly DOUBLESIDE: number;
  24301. /**
  24302. * Mesh side orientation : by default, `FRONTSIDE`
  24303. */
  24304. static readonly DEFAULTSIDE: number;
  24305. /**
  24306. * Mesh cap setting : no cap
  24307. */
  24308. static readonly NO_CAP: number;
  24309. /**
  24310. * Mesh cap setting : one cap at the beginning of the mesh
  24311. */
  24312. static readonly CAP_START: number;
  24313. /**
  24314. * Mesh cap setting : one cap at the end of the mesh
  24315. */
  24316. static readonly CAP_END: number;
  24317. /**
  24318. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24319. */
  24320. static readonly CAP_ALL: number;
  24321. /**
  24322. * Mesh pattern setting : no flip or rotate
  24323. */
  24324. static readonly NO_FLIP: number;
  24325. /**
  24326. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24327. */
  24328. static readonly FLIP_TILE: number;
  24329. /**
  24330. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24331. */
  24332. static readonly ROTATE_TILE: number;
  24333. /**
  24334. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24335. */
  24336. static readonly FLIP_ROW: number;
  24337. /**
  24338. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24339. */
  24340. static readonly ROTATE_ROW: number;
  24341. /**
  24342. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24343. */
  24344. static readonly FLIP_N_ROTATE_TILE: number;
  24345. /**
  24346. * Mesh pattern setting : rotate pattern and rotate
  24347. */
  24348. static readonly FLIP_N_ROTATE_ROW: number;
  24349. /**
  24350. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24351. */
  24352. static readonly CENTER: number;
  24353. /**
  24354. * Mesh tile positioning : part tiles on left
  24355. */
  24356. static readonly LEFT: number;
  24357. /**
  24358. * Mesh tile positioning : part tiles on right
  24359. */
  24360. static readonly RIGHT: number;
  24361. /**
  24362. * Mesh tile positioning : part tiles on top
  24363. */
  24364. static readonly TOP: number;
  24365. /**
  24366. * Mesh tile positioning : part tiles on bottom
  24367. */
  24368. static readonly BOTTOM: number;
  24369. /**
  24370. * Gets the default side orientation.
  24371. * @param orientation the orientation to value to attempt to get
  24372. * @returns the default orientation
  24373. * @hidden
  24374. */
  24375. static _GetDefaultSideOrientation(orientation?: number): number;
  24376. private _internalMeshDataInfo;
  24377. /**
  24378. * An event triggered before rendering the mesh
  24379. */
  24380. readonly onBeforeRenderObservable: Observable<Mesh>;
  24381. /**
  24382. * An event triggered before binding the mesh
  24383. */
  24384. readonly onBeforeBindObservable: Observable<Mesh>;
  24385. /**
  24386. * An event triggered after rendering the mesh
  24387. */
  24388. readonly onAfterRenderObservable: Observable<Mesh>;
  24389. /**
  24390. * An event triggered before drawing the mesh
  24391. */
  24392. readonly onBeforeDrawObservable: Observable<Mesh>;
  24393. private _onBeforeDrawObserver;
  24394. /**
  24395. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24396. */
  24397. onBeforeDraw: () => void;
  24398. readonly hasInstances: boolean;
  24399. /**
  24400. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24401. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24402. */
  24403. delayLoadState: number;
  24404. /**
  24405. * Gets the list of instances created from this mesh
  24406. * it is not supposed to be modified manually.
  24407. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24408. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24409. */
  24410. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24411. /**
  24412. * Gets the file containing delay loading data for this mesh
  24413. */
  24414. delayLoadingFile: string;
  24415. /** @hidden */
  24416. _binaryInfo: any;
  24417. /**
  24418. * User defined function used to change how LOD level selection is done
  24419. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24420. */
  24421. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24422. /**
  24423. * Gets or sets the morph target manager
  24424. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24425. */
  24426. morphTargetManager: Nullable<MorphTargetManager>;
  24427. /** @hidden */
  24428. _creationDataStorage: Nullable<_CreationDataStorage>;
  24429. /** @hidden */
  24430. _geometry: Nullable<Geometry>;
  24431. /** @hidden */
  24432. _delayInfo: Array<string>;
  24433. /** @hidden */
  24434. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24435. /** @hidden */
  24436. _instanceDataStorage: _InstanceDataStorage;
  24437. private _effectiveMaterial;
  24438. /** @hidden */
  24439. _shouldGenerateFlatShading: boolean;
  24440. /** @hidden */
  24441. _originalBuilderSideOrientation: number;
  24442. /**
  24443. * Use this property to change the original side orientation defined at construction time
  24444. */
  24445. overrideMaterialSideOrientation: Nullable<number>;
  24446. /**
  24447. * Gets the source mesh (the one used to clone this one from)
  24448. */
  24449. readonly source: Nullable<Mesh>;
  24450. /**
  24451. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24452. */
  24453. isUnIndexed: boolean;
  24454. /**
  24455. * @constructor
  24456. * @param name The value used by scene.getMeshByName() to do a lookup.
  24457. * @param scene The scene to add this mesh to.
  24458. * @param parent The parent of this mesh, if it has one
  24459. * @param source An optional Mesh from which geometry is shared, cloned.
  24460. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24461. * When false, achieved by calling a clone(), also passing False.
  24462. * This will make creation of children, recursive.
  24463. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24464. */
  24465. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24466. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24467. /**
  24468. * Gets the class name
  24469. * @returns the string "Mesh".
  24470. */
  24471. getClassName(): string;
  24472. /** @hidden */
  24473. readonly _isMesh: boolean;
  24474. /**
  24475. * Returns a description of this mesh
  24476. * @param fullDetails define if full details about this mesh must be used
  24477. * @returns a descriptive string representing this mesh
  24478. */
  24479. toString(fullDetails?: boolean): string;
  24480. /** @hidden */
  24481. _unBindEffect(): void;
  24482. /**
  24483. * Gets a boolean indicating if this mesh has LOD
  24484. */
  24485. readonly hasLODLevels: boolean;
  24486. /**
  24487. * Gets the list of MeshLODLevel associated with the current mesh
  24488. * @returns an array of MeshLODLevel
  24489. */
  24490. getLODLevels(): MeshLODLevel[];
  24491. private _sortLODLevels;
  24492. /**
  24493. * Add a mesh as LOD level triggered at the given distance.
  24494. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24495. * @param distance The distance from the center of the object to show this level
  24496. * @param mesh The mesh to be added as LOD level (can be null)
  24497. * @return This mesh (for chaining)
  24498. */
  24499. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24500. /**
  24501. * Returns the LOD level mesh at the passed distance or null if not found.
  24502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24503. * @param distance The distance from the center of the object to show this level
  24504. * @returns a Mesh or `null`
  24505. */
  24506. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24507. /**
  24508. * Remove a mesh from the LOD array
  24509. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24510. * @param mesh defines the mesh to be removed
  24511. * @return This mesh (for chaining)
  24512. */
  24513. removeLODLevel(mesh: Mesh): Mesh;
  24514. /**
  24515. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24517. * @param camera defines the camera to use to compute distance
  24518. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24519. * @return This mesh (for chaining)
  24520. */
  24521. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24522. /**
  24523. * Gets the mesh internal Geometry object
  24524. */
  24525. readonly geometry: Nullable<Geometry>;
  24526. /**
  24527. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24528. * @returns the total number of vertices
  24529. */
  24530. getTotalVertices(): number;
  24531. /**
  24532. * Returns the content of an associated vertex buffer
  24533. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24534. * - VertexBuffer.PositionKind
  24535. * - VertexBuffer.UVKind
  24536. * - VertexBuffer.UV2Kind
  24537. * - VertexBuffer.UV3Kind
  24538. * - VertexBuffer.UV4Kind
  24539. * - VertexBuffer.UV5Kind
  24540. * - VertexBuffer.UV6Kind
  24541. * - VertexBuffer.ColorKind
  24542. * - VertexBuffer.MatricesIndicesKind
  24543. * - VertexBuffer.MatricesIndicesExtraKind
  24544. * - VertexBuffer.MatricesWeightsKind
  24545. * - VertexBuffer.MatricesWeightsExtraKind
  24546. * @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
  24547. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24548. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24549. */
  24550. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24551. /**
  24552. * Returns the mesh VertexBuffer object from the requested `kind`
  24553. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24554. * - VertexBuffer.PositionKind
  24555. * - VertexBuffer.NormalKind
  24556. * - VertexBuffer.UVKind
  24557. * - VertexBuffer.UV2Kind
  24558. * - VertexBuffer.UV3Kind
  24559. * - VertexBuffer.UV4Kind
  24560. * - VertexBuffer.UV5Kind
  24561. * - VertexBuffer.UV6Kind
  24562. * - VertexBuffer.ColorKind
  24563. * - VertexBuffer.MatricesIndicesKind
  24564. * - VertexBuffer.MatricesIndicesExtraKind
  24565. * - VertexBuffer.MatricesWeightsKind
  24566. * - VertexBuffer.MatricesWeightsExtraKind
  24567. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24568. */
  24569. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24570. /**
  24571. * Tests if a specific vertex buffer is associated with this mesh
  24572. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24573. * - VertexBuffer.PositionKind
  24574. * - VertexBuffer.NormalKind
  24575. * - VertexBuffer.UVKind
  24576. * - VertexBuffer.UV2Kind
  24577. * - VertexBuffer.UV3Kind
  24578. * - VertexBuffer.UV4Kind
  24579. * - VertexBuffer.UV5Kind
  24580. * - VertexBuffer.UV6Kind
  24581. * - VertexBuffer.ColorKind
  24582. * - VertexBuffer.MatricesIndicesKind
  24583. * - VertexBuffer.MatricesIndicesExtraKind
  24584. * - VertexBuffer.MatricesWeightsKind
  24585. * - VertexBuffer.MatricesWeightsExtraKind
  24586. * @returns a boolean
  24587. */
  24588. isVerticesDataPresent(kind: string): boolean;
  24589. /**
  24590. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24591. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24592. * - VertexBuffer.PositionKind
  24593. * - VertexBuffer.UVKind
  24594. * - VertexBuffer.UV2Kind
  24595. * - VertexBuffer.UV3Kind
  24596. * - VertexBuffer.UV4Kind
  24597. * - VertexBuffer.UV5Kind
  24598. * - VertexBuffer.UV6Kind
  24599. * - VertexBuffer.ColorKind
  24600. * - VertexBuffer.MatricesIndicesKind
  24601. * - VertexBuffer.MatricesIndicesExtraKind
  24602. * - VertexBuffer.MatricesWeightsKind
  24603. * - VertexBuffer.MatricesWeightsExtraKind
  24604. * @returns a boolean
  24605. */
  24606. isVertexBufferUpdatable(kind: string): boolean;
  24607. /**
  24608. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24609. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24610. * - VertexBuffer.PositionKind
  24611. * - VertexBuffer.NormalKind
  24612. * - VertexBuffer.UVKind
  24613. * - VertexBuffer.UV2Kind
  24614. * - VertexBuffer.UV3Kind
  24615. * - VertexBuffer.UV4Kind
  24616. * - VertexBuffer.UV5Kind
  24617. * - VertexBuffer.UV6Kind
  24618. * - VertexBuffer.ColorKind
  24619. * - VertexBuffer.MatricesIndicesKind
  24620. * - VertexBuffer.MatricesIndicesExtraKind
  24621. * - VertexBuffer.MatricesWeightsKind
  24622. * - VertexBuffer.MatricesWeightsExtraKind
  24623. * @returns an array of strings
  24624. */
  24625. getVerticesDataKinds(): string[];
  24626. /**
  24627. * Returns a positive integer : the total number of indices in this mesh geometry.
  24628. * @returns the numner of indices or zero if the mesh has no geometry.
  24629. */
  24630. getTotalIndices(): number;
  24631. /**
  24632. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24633. * @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.
  24634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24635. * @returns the indices array or an empty array if the mesh has no geometry
  24636. */
  24637. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24638. readonly isBlocked: boolean;
  24639. /**
  24640. * Determine if the current mesh is ready to be rendered
  24641. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24642. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24643. * @returns true if all associated assets are ready (material, textures, shaders)
  24644. */
  24645. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24646. /**
  24647. * 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.
  24648. */
  24649. readonly areNormalsFrozen: boolean;
  24650. /**
  24651. * 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.
  24652. * @returns the current mesh
  24653. */
  24654. freezeNormals(): Mesh;
  24655. /**
  24656. * 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
  24657. * @returns the current mesh
  24658. */
  24659. unfreezeNormals(): Mesh;
  24660. /**
  24661. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24662. */
  24663. overridenInstanceCount: number;
  24664. /** @hidden */
  24665. _preActivate(): Mesh;
  24666. /** @hidden */
  24667. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24668. /** @hidden */
  24669. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24670. /**
  24671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24672. * This means the mesh underlying bounding box and sphere are recomputed.
  24673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24674. * @returns the current mesh
  24675. */
  24676. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24677. /** @hidden */
  24678. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24679. /**
  24680. * This function will subdivide the mesh into multiple submeshes
  24681. * @param count defines the expected number of submeshes
  24682. */
  24683. subdivide(count: number): void;
  24684. /**
  24685. * Copy a FloatArray into a specific associated vertex buffer
  24686. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24687. * - VertexBuffer.PositionKind
  24688. * - VertexBuffer.UVKind
  24689. * - VertexBuffer.UV2Kind
  24690. * - VertexBuffer.UV3Kind
  24691. * - VertexBuffer.UV4Kind
  24692. * - VertexBuffer.UV5Kind
  24693. * - VertexBuffer.UV6Kind
  24694. * - VertexBuffer.ColorKind
  24695. * - VertexBuffer.MatricesIndicesKind
  24696. * - VertexBuffer.MatricesIndicesExtraKind
  24697. * - VertexBuffer.MatricesWeightsKind
  24698. * - VertexBuffer.MatricesWeightsExtraKind
  24699. * @param data defines the data source
  24700. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24701. * @param stride defines the data stride size (can be null)
  24702. * @returns the current mesh
  24703. */
  24704. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24705. /**
  24706. * Flags an associated vertex buffer as updatable
  24707. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24708. * - VertexBuffer.PositionKind
  24709. * - VertexBuffer.UVKind
  24710. * - VertexBuffer.UV2Kind
  24711. * - VertexBuffer.UV3Kind
  24712. * - VertexBuffer.UV4Kind
  24713. * - VertexBuffer.UV5Kind
  24714. * - VertexBuffer.UV6Kind
  24715. * - VertexBuffer.ColorKind
  24716. * - VertexBuffer.MatricesIndicesKind
  24717. * - VertexBuffer.MatricesIndicesExtraKind
  24718. * - VertexBuffer.MatricesWeightsKind
  24719. * - VertexBuffer.MatricesWeightsExtraKind
  24720. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24721. */
  24722. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24723. /**
  24724. * Sets the mesh global Vertex Buffer
  24725. * @param buffer defines the buffer to use
  24726. * @returns the current mesh
  24727. */
  24728. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24729. /**
  24730. * Update a specific associated vertex buffer
  24731. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24732. * - VertexBuffer.PositionKind
  24733. * - VertexBuffer.UVKind
  24734. * - VertexBuffer.UV2Kind
  24735. * - VertexBuffer.UV3Kind
  24736. * - VertexBuffer.UV4Kind
  24737. * - VertexBuffer.UV5Kind
  24738. * - VertexBuffer.UV6Kind
  24739. * - VertexBuffer.ColorKind
  24740. * - VertexBuffer.MatricesIndicesKind
  24741. * - VertexBuffer.MatricesIndicesExtraKind
  24742. * - VertexBuffer.MatricesWeightsKind
  24743. * - VertexBuffer.MatricesWeightsExtraKind
  24744. * @param data defines the data source
  24745. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24746. * @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)
  24747. * @returns the current mesh
  24748. */
  24749. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24750. /**
  24751. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24752. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24753. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24754. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24755. * @returns the current mesh
  24756. */
  24757. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24758. /**
  24759. * Creates a un-shared specific occurence of the geometry for the mesh.
  24760. * @returns the current mesh
  24761. */
  24762. makeGeometryUnique(): Mesh;
  24763. /**
  24764. * Set the index buffer of this mesh
  24765. * @param indices defines the source data
  24766. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24767. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24768. * @returns the current mesh
  24769. */
  24770. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24771. /**
  24772. * Update the current index buffer
  24773. * @param indices defines the source data
  24774. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24775. * @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)
  24776. * @returns the current mesh
  24777. */
  24778. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24779. /**
  24780. * Invert the geometry to move from a right handed system to a left handed one.
  24781. * @returns the current mesh
  24782. */
  24783. toLeftHanded(): Mesh;
  24784. /** @hidden */
  24785. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24786. /** @hidden */
  24787. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24788. /**
  24789. * Registers for this mesh a javascript function called just before the rendering process
  24790. * @param func defines the function to call before rendering this mesh
  24791. * @returns the current mesh
  24792. */
  24793. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24794. /**
  24795. * Disposes a previously registered javascript function called before the rendering
  24796. * @param func defines the function to remove
  24797. * @returns the current mesh
  24798. */
  24799. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24800. /**
  24801. * Registers for this mesh a javascript function called just after the rendering is complete
  24802. * @param func defines the function to call after rendering this mesh
  24803. * @returns the current mesh
  24804. */
  24805. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24806. /**
  24807. * Disposes a previously registered javascript function called after the rendering.
  24808. * @param func defines the function to remove
  24809. * @returns the current mesh
  24810. */
  24811. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24812. /** @hidden */
  24813. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24814. /** @hidden */
  24815. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24816. /** @hidden */
  24817. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24818. /** @hidden */
  24819. _rebuild(): void;
  24820. /** @hidden */
  24821. _freeze(): void;
  24822. /** @hidden */
  24823. _unFreeze(): void;
  24824. /**
  24825. * 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
  24826. * @param subMesh defines the subMesh to render
  24827. * @param enableAlphaMode defines if alpha mode can be changed
  24828. * @returns the current mesh
  24829. */
  24830. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24831. private _onBeforeDraw;
  24832. /**
  24833. * Renormalize the mesh and patch it up if there are no weights
  24834. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24835. * However in the case of zero weights then we set just a single influence to 1.
  24836. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24837. */
  24838. cleanMatrixWeights(): void;
  24839. private normalizeSkinFourWeights;
  24840. private normalizeSkinWeightsAndExtra;
  24841. /**
  24842. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24843. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24844. * the user know there was an issue with importing the mesh
  24845. * @returns a validation object with skinned, valid and report string
  24846. */
  24847. validateSkinning(): {
  24848. skinned: boolean;
  24849. valid: boolean;
  24850. report: string;
  24851. };
  24852. /** @hidden */
  24853. _checkDelayState(): Mesh;
  24854. private _queueLoad;
  24855. /**
  24856. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24857. * A mesh is in the frustum if its bounding box intersects the frustum
  24858. * @param frustumPlanes defines the frustum to test
  24859. * @returns true if the mesh is in the frustum planes
  24860. */
  24861. isInFrustum(frustumPlanes: Plane[]): boolean;
  24862. /**
  24863. * Sets the mesh material by the material or multiMaterial `id` property
  24864. * @param id is a string identifying the material or the multiMaterial
  24865. * @returns the current mesh
  24866. */
  24867. setMaterialByID(id: string): Mesh;
  24868. /**
  24869. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24870. * @returns an array of IAnimatable
  24871. */
  24872. getAnimatables(): IAnimatable[];
  24873. /**
  24874. * Modifies the mesh geometry according to the passed transformation matrix.
  24875. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24876. * The mesh normals are modified using the same transformation.
  24877. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24878. * @param transform defines the transform matrix to use
  24879. * @see http://doc.babylonjs.com/resources/baking_transformations
  24880. * @returns the current mesh
  24881. */
  24882. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24883. /**
  24884. * Modifies the mesh geometry according to its own current World Matrix.
  24885. * The mesh World Matrix is then reset.
  24886. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24887. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24888. * @see http://doc.babylonjs.com/resources/baking_transformations
  24889. * @returns the current mesh
  24890. */
  24891. bakeCurrentTransformIntoVertices(): Mesh;
  24892. /** @hidden */
  24893. readonly _positions: Nullable<Vector3[]>;
  24894. /** @hidden */
  24895. _resetPointsArrayCache(): Mesh;
  24896. /** @hidden */
  24897. _generatePointsArray(): boolean;
  24898. /**
  24899. * Returns a new Mesh object generated from the current mesh properties.
  24900. * This method must not get confused with createInstance()
  24901. * @param name is a string, the name given to the new mesh
  24902. * @param newParent can be any Node object (default `null`)
  24903. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24904. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24905. * @returns a new mesh
  24906. */
  24907. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24908. /**
  24909. * Releases resources associated with this mesh.
  24910. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24911. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24912. */
  24913. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24914. /**
  24915. * Modifies the mesh geometry according to a displacement map.
  24916. * 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.
  24917. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24918. * @param url is a string, the URL from the image file is to be downloaded.
  24919. * @param minHeight is the lower limit of the displacement.
  24920. * @param maxHeight is the upper limit of the displacement.
  24921. * @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.
  24922. * @param uvOffset is an optional vector2 used to offset UV.
  24923. * @param uvScale is an optional vector2 used to scale UV.
  24924. * @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.
  24925. * @returns the Mesh.
  24926. */
  24927. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24928. /**
  24929. * Modifies the mesh geometry according to a displacementMap buffer.
  24930. * 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.
  24931. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24932. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24933. * @param heightMapWidth is the width of the buffer image.
  24934. * @param heightMapHeight is the height of the buffer image.
  24935. * @param minHeight is the lower limit of the displacement.
  24936. * @param maxHeight is the upper limit of the displacement.
  24937. * @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.
  24938. * @param uvOffset is an optional vector2 used to offset UV.
  24939. * @param uvScale is an optional vector2 used to scale UV.
  24940. * @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.
  24941. * @returns the Mesh.
  24942. */
  24943. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24944. /**
  24945. * Modify the mesh to get a flat shading rendering.
  24946. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24947. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24948. * @returns current mesh
  24949. */
  24950. convertToFlatShadedMesh(): Mesh;
  24951. /**
  24952. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24953. * In other words, more vertices, no more indices and a single bigger VBO.
  24954. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24955. * @returns current mesh
  24956. */
  24957. convertToUnIndexedMesh(): Mesh;
  24958. /**
  24959. * Inverses facet orientations.
  24960. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24961. * @param flipNormals will also inverts the normals
  24962. * @returns current mesh
  24963. */
  24964. flipFaces(flipNormals?: boolean): Mesh;
  24965. /**
  24966. * Increase the number of facets and hence vertices in a mesh
  24967. * Vertex normals are interpolated from existing vertex normals
  24968. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24969. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24970. */
  24971. increaseVertices(numberPerEdge: number): void;
  24972. /**
  24973. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24974. * This will undo any application of covertToFlatShadedMesh
  24975. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24976. */
  24977. forceSharedVertices(): void;
  24978. /** @hidden */
  24979. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24980. /** @hidden */
  24981. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24982. /**
  24983. * Creates a new InstancedMesh object from the mesh model.
  24984. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24985. * @param name defines the name of the new instance
  24986. * @returns a new InstancedMesh
  24987. */
  24988. createInstance(name: string): InstancedMesh;
  24989. /**
  24990. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24991. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24992. * @returns the current mesh
  24993. */
  24994. synchronizeInstances(): Mesh;
  24995. /**
  24996. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24997. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24998. * This should be used together with the simplification to avoid disappearing triangles.
  24999. * @param successCallback an optional success callback to be called after the optimization finished.
  25000. * @returns the current mesh
  25001. */
  25002. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25003. /**
  25004. * Serialize current mesh
  25005. * @param serializationObject defines the object which will receive the serialization data
  25006. */
  25007. serialize(serializationObject: any): void;
  25008. /** @hidden */
  25009. _syncGeometryWithMorphTargetManager(): void;
  25010. /** @hidden */
  25011. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25012. /**
  25013. * Returns a new Mesh object parsed from the source provided.
  25014. * @param parsedMesh is the source
  25015. * @param scene defines the hosting scene
  25016. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25017. * @returns a new Mesh
  25018. */
  25019. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25020. /**
  25021. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25022. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25023. * @param name defines the name of the mesh to create
  25024. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25025. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25026. * @param closePath creates a seam between the first and the last points of each path of the path array
  25027. * @param offset is taken in account only if the `pathArray` is containing a single path
  25028. * @param scene defines the hosting scene
  25029. * @param updatable defines if the mesh must be flagged as updatable
  25030. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25031. * @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)
  25032. * @returns a new Mesh
  25033. */
  25034. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25035. /**
  25036. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25037. * @param name defines the name of the mesh to create
  25038. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25039. * @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
  25040. * @param scene defines the hosting scene
  25041. * @param updatable defines if the mesh must be flagged as updatable
  25042. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25043. * @returns a new Mesh
  25044. */
  25045. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25046. /**
  25047. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25048. * @param name defines the name of the mesh to create
  25049. * @param size sets the size (float) of each box side (default 1)
  25050. * @param scene defines the hosting scene
  25051. * @param updatable defines if the mesh must be flagged as updatable
  25052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25053. * @returns a new Mesh
  25054. */
  25055. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25056. /**
  25057. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25058. * @param name defines the name of the mesh to create
  25059. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25060. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25067. /**
  25068. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25069. * @param name defines the name of the mesh to create
  25070. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25071. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25072. * @param scene defines the hosting scene
  25073. * @returns a new Mesh
  25074. */
  25075. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25076. /**
  25077. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25078. * @param name defines the name of the mesh to create
  25079. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25080. * @param diameterTop set the top cap diameter (floats, default 1)
  25081. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25082. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25083. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25087. * @returns a new Mesh
  25088. */
  25089. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25090. /**
  25091. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25092. * @param name defines the name of the mesh to create
  25093. * @param diameter sets the diameter size (float) of the torus (default 1)
  25094. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25095. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25096. * @param scene defines the hosting scene
  25097. * @param updatable defines if the mesh must be flagged as updatable
  25098. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25099. * @returns a new Mesh
  25100. */
  25101. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25102. /**
  25103. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25104. * @param name defines the name of the mesh to create
  25105. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25106. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25107. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25108. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25109. * @param p the number of windings on X axis (positive integers, default 2)
  25110. * @param q the number of windings on Y axis (positive integers, default 3)
  25111. * @param scene defines the hosting scene
  25112. * @param updatable defines if the mesh must be flagged as updatable
  25113. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25114. * @returns a new Mesh
  25115. */
  25116. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25117. /**
  25118. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25119. * @param name defines the name of the mesh to create
  25120. * @param points is an array successive Vector3
  25121. * @param scene defines the hosting scene
  25122. * @param updatable defines if the mesh must be flagged as updatable
  25123. * @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).
  25124. * @returns a new Mesh
  25125. */
  25126. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25127. /**
  25128. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25129. * @param name defines the name of the mesh to create
  25130. * @param points is an array successive Vector3
  25131. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25132. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25133. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25134. * @param scene defines the hosting scene
  25135. * @param updatable defines if the mesh must be flagged as updatable
  25136. * @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)
  25137. * @returns a new Mesh
  25138. */
  25139. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25140. /**
  25141. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25142. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25143. * 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.
  25144. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25145. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25146. * Remember you can only change the shape positions, not their number when updating a polygon.
  25147. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25148. * @param name defines the name of the mesh to create
  25149. * @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
  25150. * @param scene defines the hosting scene
  25151. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25152. * @param updatable defines if the mesh must be flagged as updatable
  25153. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25154. * @param earcutInjection can be used to inject your own earcut reference
  25155. * @returns a new Mesh
  25156. */
  25157. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25158. /**
  25159. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25160. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25161. * @param name defines the name of the mesh to create
  25162. * @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
  25163. * @param depth defines the height of extrusion
  25164. * @param scene defines the hosting scene
  25165. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25166. * @param updatable defines if the mesh must be flagged as updatable
  25167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25168. * @param earcutInjection can be used to inject your own earcut reference
  25169. * @returns a new Mesh
  25170. */
  25171. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25172. /**
  25173. * Creates an extruded shape mesh.
  25174. * 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
  25175. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25176. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25177. * @param name defines the name of the mesh to create
  25178. * @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
  25179. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25180. * @param scale is the value to scale the shape
  25181. * @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
  25182. * @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
  25183. * @param scene defines the hosting scene
  25184. * @param updatable defines if the mesh must be flagged as updatable
  25185. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25186. * @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)
  25187. * @returns a new Mesh
  25188. */
  25189. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25190. /**
  25191. * Creates an custom extruded shape mesh.
  25192. * The custom extrusion is a parametric shape.
  25193. * It has no predefined shape. Its final shape will depend on the input parameters.
  25194. * Please consider using the same method from the MeshBuilder class instead
  25195. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25196. * @param name defines the name of the mesh to create
  25197. * @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
  25198. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25199. * @param scaleFunction is a custom Javascript function called on each path point
  25200. * @param rotationFunction is a custom Javascript function called on each path point
  25201. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25202. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25203. * @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
  25204. * @param scene defines the hosting scene
  25205. * @param updatable defines if the mesh must be flagged as updatable
  25206. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25207. * @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)
  25208. * @returns a new Mesh
  25209. */
  25210. 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;
  25211. /**
  25212. * Creates lathe mesh.
  25213. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25214. * Please consider using the same method from the MeshBuilder class instead
  25215. * @param name defines the name of the mesh to create
  25216. * @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
  25217. * @param radius is the radius value of the lathe
  25218. * @param tessellation is the side number of the lathe.
  25219. * @param scene defines the hosting scene
  25220. * @param updatable defines if the mesh must be flagged as updatable
  25221. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25222. * @returns a new Mesh
  25223. */
  25224. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25225. /**
  25226. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25227. * @param name defines the name of the mesh to create
  25228. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25232. * @returns a new Mesh
  25233. */
  25234. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25235. /**
  25236. * Creates a ground mesh.
  25237. * Please consider using the same method from the MeshBuilder class instead
  25238. * @param name defines the name of the mesh to create
  25239. * @param width set the width of the ground
  25240. * @param height set the height of the ground
  25241. * @param subdivisions sets the number of subdivisions per side
  25242. * @param scene defines the hosting scene
  25243. * @param updatable defines if the mesh must be flagged as updatable
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25247. /**
  25248. * Creates a tiled ground mesh.
  25249. * Please consider using the same method from the MeshBuilder class instead
  25250. * @param name defines the name of the mesh to create
  25251. * @param xmin set the ground minimum X coordinate
  25252. * @param zmin set the ground minimum Y coordinate
  25253. * @param xmax set the ground maximum X coordinate
  25254. * @param zmax set the ground maximum Z coordinate
  25255. * @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
  25256. * @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
  25257. * @param scene defines the hosting scene
  25258. * @param updatable defines if the mesh must be flagged as updatable
  25259. * @returns a new Mesh
  25260. */
  25261. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25262. w: number;
  25263. h: number;
  25264. }, precision: {
  25265. w: number;
  25266. h: number;
  25267. }, scene: Scene, updatable?: boolean): Mesh;
  25268. /**
  25269. * Creates a ground mesh from a height map.
  25270. * Please consider using the same method from the MeshBuilder class instead
  25271. * @see http://doc.babylonjs.com/babylon101/height_map
  25272. * @param name defines the name of the mesh to create
  25273. * @param url sets the URL of the height map image resource
  25274. * @param width set the ground width size
  25275. * @param height set the ground height size
  25276. * @param subdivisions sets the number of subdivision per side
  25277. * @param minHeight is the minimum altitude on the ground
  25278. * @param maxHeight is the maximum altitude on the ground
  25279. * @param scene defines the hosting scene
  25280. * @param updatable defines if the mesh must be flagged as updatable
  25281. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25282. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25283. * @returns a new Mesh
  25284. */
  25285. 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;
  25286. /**
  25287. * Creates a tube mesh.
  25288. * The tube is a parametric shape.
  25289. * It has no predefined shape. Its final shape will depend on the input parameters.
  25290. * Please consider using the same method from the MeshBuilder class instead
  25291. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25292. * @param name defines the name of the mesh to create
  25293. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25294. * @param radius sets the tube radius size
  25295. * @param tessellation is the number of sides on the tubular surface
  25296. * @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
  25297. * @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
  25298. * @param scene defines the hosting scene
  25299. * @param updatable defines if the mesh must be flagged as updatable
  25300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25301. * @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)
  25302. * @returns a new Mesh
  25303. */
  25304. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25305. (i: number, distance: number): number;
  25306. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25307. /**
  25308. * Creates a polyhedron mesh.
  25309. * Please consider using the same method from the MeshBuilder class instead.
  25310. * * 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
  25311. * * The parameter `size` (positive float, default 1) sets the polygon size
  25312. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25313. * * 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`
  25314. * * 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
  25315. * * 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)`)
  25316. * * 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
  25317. * * 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
  25318. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25319. * * If you create a double-sided mesh, you can choose what parts of 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
  25320. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25321. * @param name defines the name of the mesh to create
  25322. * @param options defines the options used to create the mesh
  25323. * @param scene defines the hosting scene
  25324. * @returns a new Mesh
  25325. */
  25326. static CreatePolyhedron(name: string, options: {
  25327. type?: number;
  25328. size?: number;
  25329. sizeX?: number;
  25330. sizeY?: number;
  25331. sizeZ?: number;
  25332. custom?: any;
  25333. faceUV?: Vector4[];
  25334. faceColors?: Color4[];
  25335. updatable?: boolean;
  25336. sideOrientation?: number;
  25337. }, scene: Scene): Mesh;
  25338. /**
  25339. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25340. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25341. * * 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`)
  25342. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25343. * * 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
  25344. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25345. * * If you create a double-sided mesh, you can choose what parts of 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
  25346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25347. * @param name defines the name of the mesh
  25348. * @param options defines the options used to create the mesh
  25349. * @param scene defines the hosting scene
  25350. * @returns a new Mesh
  25351. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25352. */
  25353. static CreateIcoSphere(name: string, options: {
  25354. radius?: number;
  25355. flat?: boolean;
  25356. subdivisions?: number;
  25357. sideOrientation?: number;
  25358. updatable?: boolean;
  25359. }, scene: Scene): Mesh;
  25360. /**
  25361. * Creates a decal mesh.
  25362. * Please consider using the same method from the MeshBuilder class instead.
  25363. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25364. * @param name defines the name of the mesh
  25365. * @param sourceMesh defines the mesh receiving the decal
  25366. * @param position sets the position of the decal in world coordinates
  25367. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25368. * @param size sets the decal scaling
  25369. * @param angle sets the angle to rotate the decal
  25370. * @returns a new Mesh
  25371. */
  25372. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25373. /**
  25374. * Prepare internal position array for software CPU skinning
  25375. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25376. */
  25377. setPositionsForCPUSkinning(): Float32Array;
  25378. /**
  25379. * Prepare internal normal array for software CPU skinning
  25380. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25381. */
  25382. setNormalsForCPUSkinning(): Float32Array;
  25383. /**
  25384. * Updates the vertex buffer by applying transformation from the bones
  25385. * @param skeleton defines the skeleton to apply to current mesh
  25386. * @returns the current mesh
  25387. */
  25388. applySkeleton(skeleton: Skeleton): Mesh;
  25389. /**
  25390. * 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
  25391. * @param meshes defines the list of meshes to scan
  25392. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25393. */
  25394. static MinMax(meshes: AbstractMesh[]): {
  25395. min: Vector3;
  25396. max: Vector3;
  25397. };
  25398. /**
  25399. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25400. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25401. * @returns a vector3
  25402. */
  25403. static Center(meshesOrMinMaxVector: {
  25404. min: Vector3;
  25405. max: Vector3;
  25406. } | AbstractMesh[]): Vector3;
  25407. /**
  25408. * Merge the array of meshes into a single mesh for performance reasons.
  25409. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25410. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25411. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25412. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25413. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25414. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25415. * @returns a new mesh
  25416. */
  25417. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25418. /** @hidden */
  25419. addInstance(instance: InstancedMesh): void;
  25420. /** @hidden */
  25421. removeInstance(instance: InstancedMesh): void;
  25422. }
  25423. }
  25424. declare module "babylonjs/Cameras/camera" {
  25425. import { SmartArray } from "babylonjs/Misc/smartArray";
  25426. import { Observable } from "babylonjs/Misc/observable";
  25427. import { Nullable } from "babylonjs/types";
  25428. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25429. import { Scene } from "babylonjs/scene";
  25430. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25431. import { Node } from "babylonjs/node";
  25432. import { Mesh } from "babylonjs/Meshes/mesh";
  25433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25434. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25435. import { Viewport } from "babylonjs/Maths/math.viewport";
  25436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25438. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25439. import { Ray } from "babylonjs/Culling/ray";
  25440. /**
  25441. * This is the base class of all the camera used in the application.
  25442. * @see http://doc.babylonjs.com/features/cameras
  25443. */
  25444. export class Camera extends Node {
  25445. /** @hidden */
  25446. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25447. /**
  25448. * This is the default projection mode used by the cameras.
  25449. * It helps recreating a feeling of perspective and better appreciate depth.
  25450. * This is the best way to simulate real life cameras.
  25451. */
  25452. static readonly PERSPECTIVE_CAMERA: number;
  25453. /**
  25454. * This helps creating camera with an orthographic mode.
  25455. * 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.
  25456. */
  25457. static readonly ORTHOGRAPHIC_CAMERA: number;
  25458. /**
  25459. * This is the default FOV mode for perspective cameras.
  25460. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25461. */
  25462. static readonly FOVMODE_VERTICAL_FIXED: number;
  25463. /**
  25464. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25465. */
  25466. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25467. /**
  25468. * This specifies ther is no need for a camera rig.
  25469. * Basically only one eye is rendered corresponding to the camera.
  25470. */
  25471. static readonly RIG_MODE_NONE: number;
  25472. /**
  25473. * Simulates a camera Rig with one blue eye and one red eye.
  25474. * This can be use with 3d blue and red glasses.
  25475. */
  25476. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25477. /**
  25478. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25479. */
  25480. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25481. /**
  25482. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25483. */
  25484. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25485. /**
  25486. * Defines that both eyes of the camera will be rendered over under each other.
  25487. */
  25488. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25489. /**
  25490. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25491. */
  25492. static readonly RIG_MODE_VR: number;
  25493. /**
  25494. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25495. */
  25496. static readonly RIG_MODE_WEBVR: number;
  25497. /**
  25498. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25499. */
  25500. static readonly RIG_MODE_CUSTOM: number;
  25501. /**
  25502. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25503. */
  25504. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25505. /**
  25506. * Define the input manager associated with the camera.
  25507. */
  25508. inputs: CameraInputsManager<Camera>;
  25509. /** @hidden */
  25510. _position: Vector3;
  25511. /**
  25512. * Define the current local position of the camera in the scene
  25513. */
  25514. position: Vector3;
  25515. /**
  25516. * The vector the camera should consider as up.
  25517. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25518. */
  25519. upVector: Vector3;
  25520. /**
  25521. * Define the current limit on the left side for an orthographic camera
  25522. * In scene unit
  25523. */
  25524. orthoLeft: Nullable<number>;
  25525. /**
  25526. * Define the current limit on the right side for an orthographic camera
  25527. * In scene unit
  25528. */
  25529. orthoRight: Nullable<number>;
  25530. /**
  25531. * Define the current limit on the bottom side for an orthographic camera
  25532. * In scene unit
  25533. */
  25534. orthoBottom: Nullable<number>;
  25535. /**
  25536. * Define the current limit on the top side for an orthographic camera
  25537. * In scene unit
  25538. */
  25539. orthoTop: Nullable<number>;
  25540. /**
  25541. * Field Of View is set in Radians. (default is 0.8)
  25542. */
  25543. fov: number;
  25544. /**
  25545. * Define the minimum distance the camera can see from.
  25546. * This is important to note that the depth buffer are not infinite and the closer it starts
  25547. * the more your scene might encounter depth fighting issue.
  25548. */
  25549. minZ: number;
  25550. /**
  25551. * Define the maximum distance the camera can see to.
  25552. * This is important to note that the depth buffer are not infinite and the further it end
  25553. * the more your scene might encounter depth fighting issue.
  25554. */
  25555. maxZ: number;
  25556. /**
  25557. * Define the default inertia of the camera.
  25558. * This helps giving a smooth feeling to the camera movement.
  25559. */
  25560. inertia: number;
  25561. /**
  25562. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25563. */
  25564. mode: number;
  25565. /**
  25566. * Define wether the camera is intermediate.
  25567. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25568. */
  25569. isIntermediate: boolean;
  25570. /**
  25571. * Define the viewport of the camera.
  25572. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25573. */
  25574. viewport: Viewport;
  25575. /**
  25576. * Restricts the camera to viewing objects with the same layerMask.
  25577. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25578. */
  25579. layerMask: number;
  25580. /**
  25581. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25582. */
  25583. fovMode: number;
  25584. /**
  25585. * Rig mode of the camera.
  25586. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25587. * This is normally controlled byt the camera themselves as internal use.
  25588. */
  25589. cameraRigMode: number;
  25590. /**
  25591. * Defines the distance between both "eyes" in case of a RIG
  25592. */
  25593. interaxialDistance: number;
  25594. /**
  25595. * Defines if stereoscopic rendering is done side by side or over under.
  25596. */
  25597. isStereoscopicSideBySide: boolean;
  25598. /**
  25599. * 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
  25600. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25601. * else in the scene. (Eg. security camera)
  25602. *
  25603. * 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)
  25604. */
  25605. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25606. /**
  25607. * When set, the camera will render to this render target instead of the default canvas
  25608. *
  25609. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25610. */
  25611. outputRenderTarget: Nullable<RenderTargetTexture>;
  25612. /**
  25613. * Observable triggered when the camera view matrix has changed.
  25614. */
  25615. onViewMatrixChangedObservable: Observable<Camera>;
  25616. /**
  25617. * Observable triggered when the camera Projection matrix has changed.
  25618. */
  25619. onProjectionMatrixChangedObservable: Observable<Camera>;
  25620. /**
  25621. * Observable triggered when the inputs have been processed.
  25622. */
  25623. onAfterCheckInputsObservable: Observable<Camera>;
  25624. /**
  25625. * Observable triggered when reset has been called and applied to the camera.
  25626. */
  25627. onRestoreStateObservable: Observable<Camera>;
  25628. /** @hidden */
  25629. _cameraRigParams: any;
  25630. /** @hidden */
  25631. _rigCameras: Camera[];
  25632. /** @hidden */
  25633. _rigPostProcess: Nullable<PostProcess>;
  25634. protected _webvrViewMatrix: Matrix;
  25635. /** @hidden */
  25636. _skipRendering: boolean;
  25637. /** @hidden */
  25638. _projectionMatrix: Matrix;
  25639. /** @hidden */
  25640. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25641. /** @hidden */
  25642. _activeMeshes: SmartArray<AbstractMesh>;
  25643. protected _globalPosition: Vector3;
  25644. /** @hidden */
  25645. _computedViewMatrix: Matrix;
  25646. private _doNotComputeProjectionMatrix;
  25647. private _transformMatrix;
  25648. private _frustumPlanes;
  25649. private _refreshFrustumPlanes;
  25650. private _storedFov;
  25651. private _stateStored;
  25652. /**
  25653. * Instantiates a new camera object.
  25654. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25655. * @see http://doc.babylonjs.com/features/cameras
  25656. * @param name Defines the name of the camera in the scene
  25657. * @param position Defines the position of the camera
  25658. * @param scene Defines the scene the camera belongs too
  25659. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25660. */
  25661. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25662. /**
  25663. * Store current camera state (fov, position, etc..)
  25664. * @returns the camera
  25665. */
  25666. storeState(): Camera;
  25667. /**
  25668. * Restores the camera state values if it has been stored. You must call storeState() first
  25669. */
  25670. protected _restoreStateValues(): boolean;
  25671. /**
  25672. * Restored camera state. You must call storeState() first.
  25673. * @returns true if restored and false otherwise
  25674. */
  25675. restoreState(): boolean;
  25676. /**
  25677. * Gets the class name of the camera.
  25678. * @returns the class name
  25679. */
  25680. getClassName(): string;
  25681. /** @hidden */
  25682. readonly _isCamera: boolean;
  25683. /**
  25684. * Gets a string representation of the camera useful for debug purpose.
  25685. * @param fullDetails Defines that a more verboe level of logging is required
  25686. * @returns the string representation
  25687. */
  25688. toString(fullDetails?: boolean): string;
  25689. /**
  25690. * Gets the current world space position of the camera.
  25691. */
  25692. readonly globalPosition: Vector3;
  25693. /**
  25694. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25695. * @returns the active meshe list
  25696. */
  25697. getActiveMeshes(): SmartArray<AbstractMesh>;
  25698. /**
  25699. * Check wether a mesh is part of the current active mesh list of the camera
  25700. * @param mesh Defines the mesh to check
  25701. * @returns true if active, false otherwise
  25702. */
  25703. isActiveMesh(mesh: Mesh): boolean;
  25704. /**
  25705. * Is this camera ready to be used/rendered
  25706. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25707. * @return true if the camera is ready
  25708. */
  25709. isReady(completeCheck?: boolean): boolean;
  25710. /** @hidden */
  25711. _initCache(): void;
  25712. /** @hidden */
  25713. _updateCache(ignoreParentClass?: boolean): void;
  25714. /** @hidden */
  25715. _isSynchronized(): boolean;
  25716. /** @hidden */
  25717. _isSynchronizedViewMatrix(): boolean;
  25718. /** @hidden */
  25719. _isSynchronizedProjectionMatrix(): boolean;
  25720. /**
  25721. * Attach the input controls to a specific dom element to get the input from.
  25722. * @param element Defines the element the controls should be listened from
  25723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25724. */
  25725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25726. /**
  25727. * Detach the current controls from the specified dom element.
  25728. * @param element Defines the element to stop listening the inputs from
  25729. */
  25730. detachControl(element: HTMLElement): void;
  25731. /**
  25732. * Update the camera state according to the different inputs gathered during the frame.
  25733. */
  25734. update(): void;
  25735. /** @hidden */
  25736. _checkInputs(): void;
  25737. /** @hidden */
  25738. readonly rigCameras: Camera[];
  25739. /**
  25740. * Gets the post process used by the rig cameras
  25741. */
  25742. readonly rigPostProcess: Nullable<PostProcess>;
  25743. /**
  25744. * Internal, gets the first post proces.
  25745. * @returns the first post process to be run on this camera.
  25746. */
  25747. _getFirstPostProcess(): Nullable<PostProcess>;
  25748. private _cascadePostProcessesToRigCams;
  25749. /**
  25750. * Attach a post process to the camera.
  25751. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25752. * @param postProcess The post process to attach to the camera
  25753. * @param insertAt The position of the post process in case several of them are in use in the scene
  25754. * @returns the position the post process has been inserted at
  25755. */
  25756. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25757. /**
  25758. * Detach a post process to the camera.
  25759. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25760. * @param postProcess The post process to detach from the camera
  25761. */
  25762. detachPostProcess(postProcess: PostProcess): void;
  25763. /**
  25764. * Gets the current world matrix of the camera
  25765. */
  25766. getWorldMatrix(): Matrix;
  25767. /** @hidden */
  25768. _getViewMatrix(): Matrix;
  25769. /**
  25770. * Gets the current view matrix of the camera.
  25771. * @param force forces the camera to recompute the matrix without looking at the cached state
  25772. * @returns the view matrix
  25773. */
  25774. getViewMatrix(force?: boolean): Matrix;
  25775. /**
  25776. * Freeze the projection matrix.
  25777. * It will prevent the cache check of the camera projection compute and can speed up perf
  25778. * if no parameter of the camera are meant to change
  25779. * @param projection Defines manually a projection if necessary
  25780. */
  25781. freezeProjectionMatrix(projection?: Matrix): void;
  25782. /**
  25783. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25784. */
  25785. unfreezeProjectionMatrix(): void;
  25786. /**
  25787. * Gets the current projection matrix of the camera.
  25788. * @param force forces the camera to recompute the matrix without looking at the cached state
  25789. * @returns the projection matrix
  25790. */
  25791. getProjectionMatrix(force?: boolean): Matrix;
  25792. /**
  25793. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25794. * @returns a Matrix
  25795. */
  25796. getTransformationMatrix(): Matrix;
  25797. private _updateFrustumPlanes;
  25798. /**
  25799. * Checks if a cullable object (mesh...) is in the camera frustum
  25800. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25801. * @param target The object to check
  25802. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25803. * @returns true if the object is in frustum otherwise false
  25804. */
  25805. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25806. /**
  25807. * Checks if a cullable object (mesh...) is in the camera frustum
  25808. * Unlike isInFrustum this cheks the full bounding box
  25809. * @param target The object to check
  25810. * @returns true if the object is in frustum otherwise false
  25811. */
  25812. isCompletelyInFrustum(target: ICullable): boolean;
  25813. /**
  25814. * Gets a ray in the forward direction from the camera.
  25815. * @param length Defines the length of the ray to create
  25816. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25817. * @param origin Defines the start point of the ray which defaults to the camera position
  25818. * @returns the forward ray
  25819. */
  25820. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25821. /**
  25822. * Releases resources associated with this node.
  25823. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25824. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25825. */
  25826. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25827. /** @hidden */
  25828. _isLeftCamera: boolean;
  25829. /**
  25830. * Gets the left camera of a rig setup in case of Rigged Camera
  25831. */
  25832. readonly isLeftCamera: boolean;
  25833. /** @hidden */
  25834. _isRightCamera: boolean;
  25835. /**
  25836. * Gets the right camera of a rig setup in case of Rigged Camera
  25837. */
  25838. readonly isRightCamera: boolean;
  25839. /**
  25840. * Gets the left camera of a rig setup in case of Rigged Camera
  25841. */
  25842. readonly leftCamera: Nullable<FreeCamera>;
  25843. /**
  25844. * Gets the right camera of a rig setup in case of Rigged Camera
  25845. */
  25846. readonly rightCamera: Nullable<FreeCamera>;
  25847. /**
  25848. * Gets the left camera target of a rig setup in case of Rigged Camera
  25849. * @returns the target position
  25850. */
  25851. getLeftTarget(): Nullable<Vector3>;
  25852. /**
  25853. * Gets the right camera target of a rig setup in case of Rigged Camera
  25854. * @returns the target position
  25855. */
  25856. getRightTarget(): Nullable<Vector3>;
  25857. /**
  25858. * @hidden
  25859. */
  25860. setCameraRigMode(mode: number, rigParams: any): void;
  25861. /** @hidden */
  25862. static _setStereoscopicRigMode(camera: Camera): void;
  25863. /** @hidden */
  25864. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25865. /** @hidden */
  25866. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25867. /** @hidden */
  25868. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25869. /** @hidden */
  25870. _getVRProjectionMatrix(): Matrix;
  25871. protected _updateCameraRotationMatrix(): void;
  25872. protected _updateWebVRCameraRotationMatrix(): void;
  25873. /**
  25874. * This function MUST be overwritten by the different WebVR cameras available.
  25875. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25876. * @hidden
  25877. */
  25878. _getWebVRProjectionMatrix(): Matrix;
  25879. /**
  25880. * This function MUST be overwritten by the different WebVR cameras available.
  25881. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25882. * @hidden
  25883. */
  25884. _getWebVRViewMatrix(): Matrix;
  25885. /** @hidden */
  25886. setCameraRigParameter(name: string, value: any): void;
  25887. /**
  25888. * needs to be overridden by children so sub has required properties to be copied
  25889. * @hidden
  25890. */
  25891. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25892. /**
  25893. * May need to be overridden by children
  25894. * @hidden
  25895. */
  25896. _updateRigCameras(): void;
  25897. /** @hidden */
  25898. _setupInputs(): void;
  25899. /**
  25900. * Serialiaze the camera setup to a json represention
  25901. * @returns the JSON representation
  25902. */
  25903. serialize(): any;
  25904. /**
  25905. * Clones the current camera.
  25906. * @param name The cloned camera name
  25907. * @returns the cloned camera
  25908. */
  25909. clone(name: string): Camera;
  25910. /**
  25911. * Gets the direction of the camera relative to a given local axis.
  25912. * @param localAxis Defines the reference axis to provide a relative direction.
  25913. * @return the direction
  25914. */
  25915. getDirection(localAxis: Vector3): Vector3;
  25916. /**
  25917. * Returns the current camera absolute rotation
  25918. */
  25919. readonly absoluteRotation: Quaternion;
  25920. /**
  25921. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25922. * @param localAxis Defines the reference axis to provide a relative direction.
  25923. * @param result Defines the vector to store the result in
  25924. */
  25925. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25926. /**
  25927. * Gets a camera constructor for a given camera type
  25928. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25929. * @param name The name of the camera the result will be able to instantiate
  25930. * @param scene The scene the result will construct the camera in
  25931. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25932. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25933. * @returns a factory method to construc the camera
  25934. */
  25935. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25936. /**
  25937. * Compute the world matrix of the camera.
  25938. * @returns the camera workd matrix
  25939. */
  25940. computeWorldMatrix(): Matrix;
  25941. /**
  25942. * Parse a JSON and creates the camera from the parsed information
  25943. * @param parsedCamera The JSON to parse
  25944. * @param scene The scene to instantiate the camera in
  25945. * @returns the newly constructed camera
  25946. */
  25947. static Parse(parsedCamera: any, scene: Scene): Camera;
  25948. }
  25949. }
  25950. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25951. import { Nullable } from "babylonjs/types";
  25952. import { Scene } from "babylonjs/scene";
  25953. import { Vector4 } from "babylonjs/Maths/math.vector";
  25954. import { Mesh } from "babylonjs/Meshes/mesh";
  25955. /**
  25956. * Class containing static functions to help procedurally build meshes
  25957. */
  25958. export class DiscBuilder {
  25959. /**
  25960. * Creates a plane polygonal mesh. By default, this is a disc
  25961. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25962. * * 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
  25963. * * 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
  25964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25965. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25967. * @param name defines the name of the mesh
  25968. * @param options defines the options used to create the mesh
  25969. * @param scene defines the hosting scene
  25970. * @returns the plane polygonal mesh
  25971. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25972. */
  25973. static CreateDisc(name: string, options: {
  25974. radius?: number;
  25975. tessellation?: number;
  25976. arc?: number;
  25977. updatable?: boolean;
  25978. sideOrientation?: number;
  25979. frontUVs?: Vector4;
  25980. backUVs?: Vector4;
  25981. }, scene?: Nullable<Scene>): Mesh;
  25982. }
  25983. }
  25984. declare module "babylonjs/Particles/solidParticleSystem" {
  25985. import { Vector3 } from "babylonjs/Maths/math.vector";
  25986. import { Mesh } from "babylonjs/Meshes/mesh";
  25987. import { Scene, IDisposable } from "babylonjs/scene";
  25988. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25989. /**
  25990. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25991. *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.
  25992. * The SPS is also a particle system. It provides some methods to manage the particles.
  25993. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25994. *
  25995. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25996. */
  25997. export class SolidParticleSystem implements IDisposable {
  25998. /**
  25999. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26000. * Example : var p = SPS.particles[i];
  26001. */
  26002. particles: SolidParticle[];
  26003. /**
  26004. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26005. */
  26006. nbParticles: number;
  26007. /**
  26008. * If the particles must ever face the camera (default false). Useful for planar particles.
  26009. */
  26010. billboard: boolean;
  26011. /**
  26012. * Recompute normals when adding a shape
  26013. */
  26014. recomputeNormals: boolean;
  26015. /**
  26016. * This a counter ofr your own usage. It's not set by any SPS functions.
  26017. */
  26018. counter: number;
  26019. /**
  26020. * The SPS name. This name is also given to the underlying mesh.
  26021. */
  26022. name: string;
  26023. /**
  26024. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26025. */
  26026. mesh: Mesh;
  26027. /**
  26028. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26029. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26030. */
  26031. vars: any;
  26032. /**
  26033. * This array is populated when the SPS is set as 'pickable'.
  26034. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26035. * Each element of this array is an object `{idx: int, faceId: int}`.
  26036. * `idx` is the picked particle index in the `SPS.particles` array
  26037. * `faceId` is the picked face index counted within this particle.
  26038. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26039. */
  26040. pickedParticles: {
  26041. idx: number;
  26042. faceId: number;
  26043. }[];
  26044. /**
  26045. * This array is populated when `enableDepthSort` is set to true.
  26046. * Each element of this array is an instance of the class DepthSortedParticle.
  26047. */
  26048. depthSortedParticles: DepthSortedParticle[];
  26049. /**
  26050. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26051. * @hidden
  26052. */
  26053. _bSphereOnly: boolean;
  26054. /**
  26055. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26056. * @hidden
  26057. */
  26058. _bSphereRadiusFactor: number;
  26059. private _scene;
  26060. private _positions;
  26061. private _indices;
  26062. private _normals;
  26063. private _colors;
  26064. private _uvs;
  26065. private _indices32;
  26066. private _positions32;
  26067. private _normals32;
  26068. private _fixedNormal32;
  26069. private _colors32;
  26070. private _uvs32;
  26071. private _index;
  26072. private _updatable;
  26073. private _pickable;
  26074. private _isVisibilityBoxLocked;
  26075. private _alwaysVisible;
  26076. private _depthSort;
  26077. private _shapeCounter;
  26078. private _copy;
  26079. private _color;
  26080. private _computeParticleColor;
  26081. private _computeParticleTexture;
  26082. private _computeParticleRotation;
  26083. private _computeParticleVertex;
  26084. private _computeBoundingBox;
  26085. private _depthSortParticles;
  26086. private _camera;
  26087. private _mustUnrotateFixedNormals;
  26088. private _particlesIntersect;
  26089. private _needs32Bits;
  26090. /**
  26091. * Creates a SPS (Solid Particle System) object.
  26092. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26093. * @param scene (Scene) is the scene in which the SPS is added.
  26094. * @param options defines the options of the sps e.g.
  26095. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26096. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26097. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26098. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26099. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26100. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26101. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26102. */
  26103. constructor(name: string, scene: Scene, options?: {
  26104. updatable?: boolean;
  26105. isPickable?: boolean;
  26106. enableDepthSort?: boolean;
  26107. particleIntersection?: boolean;
  26108. boundingSphereOnly?: boolean;
  26109. bSphereRadiusFactor?: number;
  26110. });
  26111. /**
  26112. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26113. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26114. * @returns the created mesh
  26115. */
  26116. buildMesh(): Mesh;
  26117. /**
  26118. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26119. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26120. * Thus the particles generated from `digest()` have their property `position` set yet.
  26121. * @param mesh ( Mesh ) is the mesh to be digested
  26122. * @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
  26123. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26124. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26125. * @returns the current SPS
  26126. */
  26127. digest(mesh: Mesh, options?: {
  26128. facetNb?: number;
  26129. number?: number;
  26130. delta?: number;
  26131. }): SolidParticleSystem;
  26132. private _unrotateFixedNormals;
  26133. private _resetCopy;
  26134. private _meshBuilder;
  26135. private _posToShape;
  26136. private _uvsToShapeUV;
  26137. private _addParticle;
  26138. /**
  26139. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26140. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26141. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26142. * @param nb (positive integer) the number of particles to be created from this model
  26143. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26144. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26145. * @returns the number of shapes in the system
  26146. */
  26147. addShape(mesh: Mesh, nb: number, options?: {
  26148. positionFunction?: any;
  26149. vertexFunction?: any;
  26150. }): number;
  26151. private _rebuildParticle;
  26152. /**
  26153. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26154. * @returns the SPS.
  26155. */
  26156. rebuildMesh(): SolidParticleSystem;
  26157. /**
  26158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26159. * This method calls `updateParticle()` for each particle of the SPS.
  26160. * For an animated SPS, it is usually called within the render loop.
  26161. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26162. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26163. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26164. * @returns the SPS.
  26165. */
  26166. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26167. /**
  26168. * Disposes the SPS.
  26169. */
  26170. dispose(): void;
  26171. /**
  26172. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26173. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26174. * @returns the SPS.
  26175. */
  26176. refreshVisibleSize(): SolidParticleSystem;
  26177. /**
  26178. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26179. * @param size the size (float) of the visibility box
  26180. * note : this doesn't lock the SPS mesh bounding box.
  26181. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26182. */
  26183. setVisibilityBox(size: number): void;
  26184. /**
  26185. * Gets whether the SPS as always visible or not
  26186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26187. */
  26188. /**
  26189. * Sets the SPS as always visible or not
  26190. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26191. */
  26192. isAlwaysVisible: boolean;
  26193. /**
  26194. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26196. */
  26197. /**
  26198. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26199. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26200. */
  26201. isVisibilityBoxLocked: boolean;
  26202. /**
  26203. * Tells to `setParticles()` to compute the particle rotations or not.
  26204. * Default value : true. The SPS is faster when it's set to false.
  26205. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26206. */
  26207. /**
  26208. * Gets if `setParticles()` computes the particle rotations or not.
  26209. * Default value : true. The SPS is faster when it's set to false.
  26210. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26211. */
  26212. computeParticleRotation: boolean;
  26213. /**
  26214. * Tells to `setParticles()` to compute the particle colors or not.
  26215. * Default value : true. The SPS is faster when it's set to false.
  26216. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26217. */
  26218. /**
  26219. * Gets if `setParticles()` computes the particle colors or not.
  26220. * Default value : true. The SPS is faster when it's set to false.
  26221. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26222. */
  26223. computeParticleColor: boolean;
  26224. /**
  26225. * Gets if `setParticles()` computes the particle textures or not.
  26226. * Default value : true. The SPS is faster when it's set to false.
  26227. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26228. */
  26229. computeParticleTexture: boolean;
  26230. /**
  26231. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26232. * Default value : false. The SPS is faster when it's set to false.
  26233. * Note : the particle custom vertex positions aren't stored values.
  26234. */
  26235. /**
  26236. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26237. * Default value : false. The SPS is faster when it's set to false.
  26238. * Note : the particle custom vertex positions aren't stored values.
  26239. */
  26240. computeParticleVertex: boolean;
  26241. /**
  26242. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26243. */
  26244. /**
  26245. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26246. */
  26247. computeBoundingBox: boolean;
  26248. /**
  26249. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26250. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26251. * Default : `true`
  26252. */
  26253. /**
  26254. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26255. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26256. * Default : `true`
  26257. */
  26258. depthSortParticles: boolean;
  26259. /**
  26260. * This function does nothing. It may be overwritten to set all the particle first values.
  26261. * The SPS doesn't call this function, you may have to call it by your own.
  26262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26263. */
  26264. initParticles(): void;
  26265. /**
  26266. * This function does nothing. It may be overwritten to recycle a particle.
  26267. * The SPS doesn't call this function, you may have to call it by your own.
  26268. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26269. * @param particle The particle to recycle
  26270. * @returns the recycled particle
  26271. */
  26272. recycleParticle(particle: SolidParticle): SolidParticle;
  26273. /**
  26274. * Updates a particle : this function should be overwritten by the user.
  26275. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26276. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26277. * @example : just set a particle position or velocity and recycle conditions
  26278. * @param particle The particle to update
  26279. * @returns the updated particle
  26280. */
  26281. updateParticle(particle: SolidParticle): SolidParticle;
  26282. /**
  26283. * Updates a vertex of a particle : it can be overwritten by the user.
  26284. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26285. * @param particle the current particle
  26286. * @param vertex the current index of the current particle
  26287. * @param pt the index of the current vertex in the particle shape
  26288. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26289. * @example : just set a vertex particle position
  26290. * @returns the updated vertex
  26291. */
  26292. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26293. /**
  26294. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26295. * This does nothing and may be overwritten by the user.
  26296. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26298. * @param update the boolean update value actually passed to setParticles()
  26299. */
  26300. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26301. /**
  26302. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26303. * This will be passed three parameters.
  26304. * This does nothing and may be overwritten by the user.
  26305. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26306. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26307. * @param update the boolean update value actually passed to setParticles()
  26308. */
  26309. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26310. }
  26311. }
  26312. declare module "babylonjs/Particles/solidParticle" {
  26313. import { Nullable } from "babylonjs/types";
  26314. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26315. import { Color4 } from "babylonjs/Maths/math.color";
  26316. import { Mesh } from "babylonjs/Meshes/mesh";
  26317. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26318. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26319. import { Plane } from "babylonjs/Maths/math.plane";
  26320. /**
  26321. * Represents one particle of a solid particle system.
  26322. */
  26323. export class SolidParticle {
  26324. /**
  26325. * particle global index
  26326. */
  26327. idx: number;
  26328. /**
  26329. * The color of the particle
  26330. */
  26331. color: Nullable<Color4>;
  26332. /**
  26333. * The world space position of the particle.
  26334. */
  26335. position: Vector3;
  26336. /**
  26337. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26338. */
  26339. rotation: Vector3;
  26340. /**
  26341. * The world space rotation quaternion of the particle.
  26342. */
  26343. rotationQuaternion: Nullable<Quaternion>;
  26344. /**
  26345. * The scaling of the particle.
  26346. */
  26347. scaling: Vector3;
  26348. /**
  26349. * The uvs of the particle.
  26350. */
  26351. uvs: Vector4;
  26352. /**
  26353. * The current speed of the particle.
  26354. */
  26355. velocity: Vector3;
  26356. /**
  26357. * The pivot point in the particle local space.
  26358. */
  26359. pivot: Vector3;
  26360. /**
  26361. * Must the particle be translated from its pivot point in its local space ?
  26362. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26363. * Default : false
  26364. */
  26365. translateFromPivot: boolean;
  26366. /**
  26367. * Is the particle active or not ?
  26368. */
  26369. alive: boolean;
  26370. /**
  26371. * Is the particle visible or not ?
  26372. */
  26373. isVisible: boolean;
  26374. /**
  26375. * Index of this particle in the global "positions" array (Internal use)
  26376. * @hidden
  26377. */
  26378. _pos: number;
  26379. /**
  26380. * @hidden Index of this particle in the global "indices" array (Internal use)
  26381. */
  26382. _ind: number;
  26383. /**
  26384. * @hidden ModelShape of this particle (Internal use)
  26385. */
  26386. _model: ModelShape;
  26387. /**
  26388. * ModelShape id of this particle
  26389. */
  26390. shapeId: number;
  26391. /**
  26392. * Index of the particle in its shape id
  26393. */
  26394. idxInShape: number;
  26395. /**
  26396. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26397. */
  26398. _modelBoundingInfo: BoundingInfo;
  26399. /**
  26400. * @hidden Particle BoundingInfo object (Internal use)
  26401. */
  26402. _boundingInfo: BoundingInfo;
  26403. /**
  26404. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26405. */
  26406. _sps: SolidParticleSystem;
  26407. /**
  26408. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26409. */
  26410. _stillInvisible: boolean;
  26411. /**
  26412. * @hidden Last computed particle rotation matrix
  26413. */
  26414. _rotationMatrix: number[];
  26415. /**
  26416. * Parent particle Id, if any.
  26417. * Default null.
  26418. */
  26419. parentId: Nullable<number>;
  26420. /**
  26421. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26422. * The possible values are :
  26423. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26424. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26425. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26426. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26427. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26428. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26429. * */
  26430. cullingStrategy: number;
  26431. /**
  26432. * @hidden Internal global position in the SPS.
  26433. */
  26434. _globalPosition: Vector3;
  26435. /**
  26436. * Creates a Solid Particle object.
  26437. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26438. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26439. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26440. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26441. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26442. * @param shapeId (integer) is the model shape identifier in the SPS.
  26443. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26444. * @param sps defines the sps it is associated to
  26445. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26446. */
  26447. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26448. /**
  26449. * Legacy support, changed scale to scaling
  26450. */
  26451. /**
  26452. * Legacy support, changed scale to scaling
  26453. */
  26454. scale: Vector3;
  26455. /**
  26456. * Legacy support, changed quaternion to rotationQuaternion
  26457. */
  26458. /**
  26459. * Legacy support, changed quaternion to rotationQuaternion
  26460. */
  26461. quaternion: Nullable<Quaternion>;
  26462. /**
  26463. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26464. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26465. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26466. * @returns true if it intersects
  26467. */
  26468. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26469. /**
  26470. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26471. * A particle is in the frustum if its bounding box intersects the frustum
  26472. * @param frustumPlanes defines the frustum to test
  26473. * @returns true if the particle is in the frustum planes
  26474. */
  26475. isInFrustum(frustumPlanes: Plane[]): boolean;
  26476. /**
  26477. * get the rotation matrix of the particle
  26478. * @hidden
  26479. */
  26480. getRotationMatrix(m: Matrix): void;
  26481. }
  26482. /**
  26483. * Represents the shape of the model used by one particle of a solid particle system.
  26484. * SPS internal tool, don't use it manually.
  26485. */
  26486. export class ModelShape {
  26487. /**
  26488. * The shape id
  26489. * @hidden
  26490. */
  26491. shapeID: number;
  26492. /**
  26493. * flat array of model positions (internal use)
  26494. * @hidden
  26495. */
  26496. _shape: Vector3[];
  26497. /**
  26498. * flat array of model UVs (internal use)
  26499. * @hidden
  26500. */
  26501. _shapeUV: number[];
  26502. /**
  26503. * length of the shape in the model indices array (internal use)
  26504. * @hidden
  26505. */
  26506. _indicesLength: number;
  26507. /**
  26508. * Custom position function (internal use)
  26509. * @hidden
  26510. */
  26511. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26512. /**
  26513. * Custom vertex function (internal use)
  26514. * @hidden
  26515. */
  26516. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26517. /**
  26518. * 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.
  26519. * SPS internal tool, don't use it manually.
  26520. * @hidden
  26521. */
  26522. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26523. }
  26524. /**
  26525. * Represents a Depth Sorted Particle in the solid particle system.
  26526. */
  26527. export class DepthSortedParticle {
  26528. /**
  26529. * Index of the particle in the "indices" array
  26530. */
  26531. ind: number;
  26532. /**
  26533. * Length of the particle shape in the "indices" array
  26534. */
  26535. indicesLength: number;
  26536. /**
  26537. * Squared distance from the particle to the camera
  26538. */
  26539. sqDistance: number;
  26540. }
  26541. }
  26542. declare module "babylonjs/Collisions/meshCollisionData" {
  26543. import { Collider } from "babylonjs/Collisions/collider";
  26544. import { Vector3 } from "babylonjs/Maths/math.vector";
  26545. import { Nullable } from "babylonjs/types";
  26546. import { Observer } from "babylonjs/Misc/observable";
  26547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26548. /**
  26549. * @hidden
  26550. */
  26551. export class _MeshCollisionData {
  26552. _checkCollisions: boolean;
  26553. _collisionMask: number;
  26554. _collisionGroup: number;
  26555. _collider: Nullable<Collider>;
  26556. _oldPositionForCollisions: Vector3;
  26557. _diffPositionForCollisions: Vector3;
  26558. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26559. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26560. }
  26561. }
  26562. declare module "babylonjs/Meshes/abstractMesh" {
  26563. import { Observable } from "babylonjs/Misc/observable";
  26564. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26565. import { Camera } from "babylonjs/Cameras/camera";
  26566. import { Scene, IDisposable } from "babylonjs/scene";
  26567. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26568. import { Node } from "babylonjs/node";
  26569. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26570. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26571. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26573. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26574. import { Material } from "babylonjs/Materials/material";
  26575. import { Light } from "babylonjs/Lights/light";
  26576. import { Skeleton } from "babylonjs/Bones/skeleton";
  26577. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26578. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26579. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26580. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26581. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26582. import { Plane } from "babylonjs/Maths/math.plane";
  26583. import { Ray } from "babylonjs/Culling/ray";
  26584. import { Collider } from "babylonjs/Collisions/collider";
  26585. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26586. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26587. /** @hidden */
  26588. class _FacetDataStorage {
  26589. facetPositions: Vector3[];
  26590. facetNormals: Vector3[];
  26591. facetPartitioning: number[][];
  26592. facetNb: number;
  26593. partitioningSubdivisions: number;
  26594. partitioningBBoxRatio: number;
  26595. facetDataEnabled: boolean;
  26596. facetParameters: any;
  26597. bbSize: Vector3;
  26598. subDiv: {
  26599. max: number;
  26600. X: number;
  26601. Y: number;
  26602. Z: number;
  26603. };
  26604. facetDepthSort: boolean;
  26605. facetDepthSortEnabled: boolean;
  26606. depthSortedIndices: IndicesArray;
  26607. depthSortedFacets: {
  26608. ind: number;
  26609. sqDistance: number;
  26610. }[];
  26611. facetDepthSortFunction: (f1: {
  26612. ind: number;
  26613. sqDistance: number;
  26614. }, f2: {
  26615. ind: number;
  26616. sqDistance: number;
  26617. }) => number;
  26618. facetDepthSortFrom: Vector3;
  26619. facetDepthSortOrigin: Vector3;
  26620. invertedMatrix: Matrix;
  26621. }
  26622. /**
  26623. * @hidden
  26624. **/
  26625. class _InternalAbstractMeshDataInfo {
  26626. _hasVertexAlpha: boolean;
  26627. _useVertexColors: boolean;
  26628. _numBoneInfluencers: number;
  26629. _applyFog: boolean;
  26630. _receiveShadows: boolean;
  26631. _facetData: _FacetDataStorage;
  26632. _visibility: number;
  26633. _skeleton: Nullable<Skeleton>;
  26634. _layerMask: number;
  26635. _computeBonesUsingShaders: boolean;
  26636. _isActive: boolean;
  26637. _onlyForInstances: boolean;
  26638. _isActiveIntermediate: boolean;
  26639. _onlyForInstancesIntermediate: boolean;
  26640. }
  26641. /**
  26642. * Class used to store all common mesh properties
  26643. */
  26644. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26645. /** No occlusion */
  26646. static OCCLUSION_TYPE_NONE: number;
  26647. /** Occlusion set to optimisitic */
  26648. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26649. /** Occlusion set to strict */
  26650. static OCCLUSION_TYPE_STRICT: number;
  26651. /** Use an accurante occlusion algorithm */
  26652. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26653. /** Use a conservative occlusion algorithm */
  26654. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26655. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26656. * Test order :
  26657. * Is the bounding sphere outside the frustum ?
  26658. * If not, are the bounding box vertices outside the frustum ?
  26659. * It not, then the cullable object is in the frustum.
  26660. */
  26661. static readonly CULLINGSTRATEGY_STANDARD: number;
  26662. /** Culling strategy : Bounding Sphere Only.
  26663. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26664. * It's also less accurate than the standard because some not visible objects can still be selected.
  26665. * Test : is the bounding sphere outside the frustum ?
  26666. * If not, then the cullable object is in the frustum.
  26667. */
  26668. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26669. /** Culling strategy : Optimistic Inclusion.
  26670. * This in an inclusion test first, then the standard exclusion test.
  26671. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26672. * 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.
  26673. * Anyway, it's as accurate as the standard strategy.
  26674. * Test :
  26675. * Is the cullable object bounding sphere center in the frustum ?
  26676. * If not, apply the default culling strategy.
  26677. */
  26678. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26679. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26680. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26681. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26682. * 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.
  26683. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26684. * Test :
  26685. * Is the cullable object bounding sphere center in the frustum ?
  26686. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26687. */
  26688. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26689. /**
  26690. * No billboard
  26691. */
  26692. static readonly BILLBOARDMODE_NONE: number;
  26693. /** Billboard on X axis */
  26694. static readonly BILLBOARDMODE_X: number;
  26695. /** Billboard on Y axis */
  26696. static readonly BILLBOARDMODE_Y: number;
  26697. /** Billboard on Z axis */
  26698. static readonly BILLBOARDMODE_Z: number;
  26699. /** Billboard on all axes */
  26700. static readonly BILLBOARDMODE_ALL: number;
  26701. /** Billboard on using position instead of orientation */
  26702. static readonly BILLBOARDMODE_USE_POSITION: number;
  26703. /** @hidden */
  26704. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26705. /**
  26706. * The culling strategy to use to check whether the mesh must be rendered or not.
  26707. * This value can be changed at any time and will be used on the next render mesh selection.
  26708. * The possible values are :
  26709. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26710. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26711. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26713. * Please read each static variable documentation to get details about the culling process.
  26714. * */
  26715. cullingStrategy: number;
  26716. /**
  26717. * Gets the number of facets in the mesh
  26718. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26719. */
  26720. readonly facetNb: number;
  26721. /**
  26722. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26724. */
  26725. partitioningSubdivisions: number;
  26726. /**
  26727. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26728. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26730. */
  26731. partitioningBBoxRatio: number;
  26732. /**
  26733. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26734. * Works only for updatable meshes.
  26735. * Doesn't work with multi-materials
  26736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26737. */
  26738. mustDepthSortFacets: boolean;
  26739. /**
  26740. * The location (Vector3) where the facet depth sort must be computed from.
  26741. * By default, the active camera position.
  26742. * Used only when facet depth sort is enabled
  26743. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26744. */
  26745. facetDepthSortFrom: Vector3;
  26746. /**
  26747. * gets a boolean indicating if facetData is enabled
  26748. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26749. */
  26750. readonly isFacetDataEnabled: boolean;
  26751. /** @hidden */
  26752. _updateNonUniformScalingState(value: boolean): boolean;
  26753. /**
  26754. * An event triggered when this mesh collides with another one
  26755. */
  26756. onCollideObservable: Observable<AbstractMesh>;
  26757. /** Set a function to call when this mesh collides with another one */
  26758. onCollide: () => void;
  26759. /**
  26760. * An event triggered when the collision's position changes
  26761. */
  26762. onCollisionPositionChangeObservable: Observable<Vector3>;
  26763. /** Set a function to call when the collision's position changes */
  26764. onCollisionPositionChange: () => void;
  26765. /**
  26766. * An event triggered when material is changed
  26767. */
  26768. onMaterialChangedObservable: Observable<AbstractMesh>;
  26769. /**
  26770. * Gets or sets the orientation for POV movement & rotation
  26771. */
  26772. definedFacingForward: boolean;
  26773. /** @hidden */
  26774. _occlusionQuery: Nullable<WebGLQuery>;
  26775. /** @hidden */
  26776. _renderingGroup: Nullable<RenderingGroup>;
  26777. /**
  26778. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26779. */
  26780. /**
  26781. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26782. */
  26783. visibility: number;
  26784. /** Gets or sets the alpha index used to sort transparent meshes
  26785. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26786. */
  26787. alphaIndex: number;
  26788. /**
  26789. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26790. */
  26791. isVisible: boolean;
  26792. /**
  26793. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26794. */
  26795. isPickable: boolean;
  26796. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26797. showSubMeshesBoundingBox: boolean;
  26798. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26799. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26800. */
  26801. isBlocker: boolean;
  26802. /**
  26803. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26804. */
  26805. enablePointerMoveEvents: boolean;
  26806. /**
  26807. * Specifies the rendering group id for this mesh (0 by default)
  26808. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26809. */
  26810. renderingGroupId: number;
  26811. private _material;
  26812. /** Gets or sets current material */
  26813. material: Nullable<Material>;
  26814. /**
  26815. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26816. * @see http://doc.babylonjs.com/babylon101/shadows
  26817. */
  26818. receiveShadows: boolean;
  26819. /** Defines color to use when rendering outline */
  26820. outlineColor: Color3;
  26821. /** Define width to use when rendering outline */
  26822. outlineWidth: number;
  26823. /** Defines color to use when rendering overlay */
  26824. overlayColor: Color3;
  26825. /** Defines alpha to use when rendering overlay */
  26826. overlayAlpha: number;
  26827. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26828. hasVertexAlpha: boolean;
  26829. /** 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) */
  26830. useVertexColors: boolean;
  26831. /**
  26832. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26833. */
  26834. computeBonesUsingShaders: boolean;
  26835. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26836. numBoneInfluencers: number;
  26837. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26838. applyFog: boolean;
  26839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26840. useOctreeForRenderingSelection: boolean;
  26841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26842. useOctreeForPicking: boolean;
  26843. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26844. useOctreeForCollisions: boolean;
  26845. /**
  26846. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26847. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26848. */
  26849. layerMask: number;
  26850. /**
  26851. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26852. */
  26853. alwaysSelectAsActiveMesh: boolean;
  26854. /**
  26855. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26856. */
  26857. doNotSyncBoundingInfo: boolean;
  26858. /**
  26859. * Gets or sets the current action manager
  26860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26861. */
  26862. actionManager: Nullable<AbstractActionManager>;
  26863. private _meshCollisionData;
  26864. /**
  26865. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26866. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26867. */
  26868. ellipsoid: Vector3;
  26869. /**
  26870. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26872. */
  26873. ellipsoidOffset: Vector3;
  26874. /**
  26875. * Gets or sets a collision mask used to mask collisions (default is -1).
  26876. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26877. */
  26878. collisionMask: number;
  26879. /**
  26880. * Gets or sets the current collision group mask (-1 by default).
  26881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26882. */
  26883. collisionGroup: number;
  26884. /**
  26885. * Defines edge width used when edgesRenderer is enabled
  26886. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26887. */
  26888. edgesWidth: number;
  26889. /**
  26890. * Defines edge color used when edgesRenderer is enabled
  26891. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26892. */
  26893. edgesColor: Color4;
  26894. /** @hidden */
  26895. _edgesRenderer: Nullable<IEdgesRenderer>;
  26896. /** @hidden */
  26897. _masterMesh: Nullable<AbstractMesh>;
  26898. /** @hidden */
  26899. _boundingInfo: Nullable<BoundingInfo>;
  26900. /** @hidden */
  26901. _renderId: number;
  26902. /**
  26903. * Gets or sets the list of subMeshes
  26904. * @see http://doc.babylonjs.com/how_to/multi_materials
  26905. */
  26906. subMeshes: SubMesh[];
  26907. /** @hidden */
  26908. _intersectionsInProgress: AbstractMesh[];
  26909. /** @hidden */
  26910. _unIndexed: boolean;
  26911. /** @hidden */
  26912. _lightSources: Light[];
  26913. /** Gets the list of lights affecting that mesh */
  26914. readonly lightSources: Light[];
  26915. /** @hidden */
  26916. readonly _positions: Nullable<Vector3[]>;
  26917. /** @hidden */
  26918. _waitingData: {
  26919. lods: Nullable<any>;
  26920. actions: Nullable<any>;
  26921. freezeWorldMatrix: Nullable<boolean>;
  26922. };
  26923. /** @hidden */
  26924. _bonesTransformMatrices: Nullable<Float32Array>;
  26925. /** @hidden */
  26926. _transformMatrixTexture: Nullable<RawTexture>;
  26927. /**
  26928. * Gets or sets a skeleton to apply skining transformations
  26929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26930. */
  26931. skeleton: Nullable<Skeleton>;
  26932. /**
  26933. * An event triggered when the mesh is rebuilt.
  26934. */
  26935. onRebuildObservable: Observable<AbstractMesh>;
  26936. /**
  26937. * Creates a new AbstractMesh
  26938. * @param name defines the name of the mesh
  26939. * @param scene defines the hosting scene
  26940. */
  26941. constructor(name: string, scene?: Nullable<Scene>);
  26942. /**
  26943. * Returns the string "AbstractMesh"
  26944. * @returns "AbstractMesh"
  26945. */
  26946. getClassName(): string;
  26947. /**
  26948. * Gets a string representation of the current mesh
  26949. * @param fullDetails defines a boolean indicating if full details must be included
  26950. * @returns a string representation of the current mesh
  26951. */
  26952. toString(fullDetails?: boolean): string;
  26953. /**
  26954. * @hidden
  26955. */
  26956. protected _getEffectiveParent(): Nullable<Node>;
  26957. /** @hidden */
  26958. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26959. /** @hidden */
  26960. _rebuild(): void;
  26961. /** @hidden */
  26962. _resyncLightSources(): void;
  26963. /** @hidden */
  26964. _resyncLighSource(light: Light): void;
  26965. /** @hidden */
  26966. _unBindEffect(): void;
  26967. /** @hidden */
  26968. _removeLightSource(light: Light, dispose: boolean): void;
  26969. private _markSubMeshesAsDirty;
  26970. /** @hidden */
  26971. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26972. /** @hidden */
  26973. _markSubMeshesAsAttributesDirty(): void;
  26974. /** @hidden */
  26975. _markSubMeshesAsMiscDirty(): void;
  26976. /**
  26977. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26978. */
  26979. scaling: Vector3;
  26980. /**
  26981. * Returns true if the mesh is blocked. Implemented by child classes
  26982. */
  26983. readonly isBlocked: boolean;
  26984. /**
  26985. * Returns the mesh itself by default. Implemented by child classes
  26986. * @param camera defines the camera to use to pick the right LOD level
  26987. * @returns the currentAbstractMesh
  26988. */
  26989. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26990. /**
  26991. * Returns 0 by default. Implemented by child classes
  26992. * @returns an integer
  26993. */
  26994. getTotalVertices(): number;
  26995. /**
  26996. * Returns a positive integer : the total number of indices in this mesh geometry.
  26997. * @returns the numner of indices or zero if the mesh has no geometry.
  26998. */
  26999. getTotalIndices(): number;
  27000. /**
  27001. * Returns null by default. Implemented by child classes
  27002. * @returns null
  27003. */
  27004. getIndices(): Nullable<IndicesArray>;
  27005. /**
  27006. * Returns the array of the requested vertex data kind. Implemented by child classes
  27007. * @param kind defines the vertex data kind to use
  27008. * @returns null
  27009. */
  27010. getVerticesData(kind: string): Nullable<FloatArray>;
  27011. /**
  27012. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27013. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27014. * Note that a new underlying VertexBuffer object is created each call.
  27015. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27016. * @param kind defines vertex data kind:
  27017. * * VertexBuffer.PositionKind
  27018. * * VertexBuffer.UVKind
  27019. * * VertexBuffer.UV2Kind
  27020. * * VertexBuffer.UV3Kind
  27021. * * VertexBuffer.UV4Kind
  27022. * * VertexBuffer.UV5Kind
  27023. * * VertexBuffer.UV6Kind
  27024. * * VertexBuffer.ColorKind
  27025. * * VertexBuffer.MatricesIndicesKind
  27026. * * VertexBuffer.MatricesIndicesExtraKind
  27027. * * VertexBuffer.MatricesWeightsKind
  27028. * * VertexBuffer.MatricesWeightsExtraKind
  27029. * @param data defines the data source
  27030. * @param updatable defines if the data must be flagged as updatable (or static)
  27031. * @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
  27032. * @returns the current mesh
  27033. */
  27034. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27035. /**
  27036. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27037. * If the mesh has no geometry, it is simply returned as it is.
  27038. * @param kind defines vertex data kind:
  27039. * * VertexBuffer.PositionKind
  27040. * * VertexBuffer.UVKind
  27041. * * VertexBuffer.UV2Kind
  27042. * * VertexBuffer.UV3Kind
  27043. * * VertexBuffer.UV4Kind
  27044. * * VertexBuffer.UV5Kind
  27045. * * VertexBuffer.UV6Kind
  27046. * * VertexBuffer.ColorKind
  27047. * * VertexBuffer.MatricesIndicesKind
  27048. * * VertexBuffer.MatricesIndicesExtraKind
  27049. * * VertexBuffer.MatricesWeightsKind
  27050. * * VertexBuffer.MatricesWeightsExtraKind
  27051. * @param data defines the data source
  27052. * @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
  27053. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27054. * @returns the current mesh
  27055. */
  27056. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27057. /**
  27058. * Sets the mesh indices,
  27059. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27060. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27061. * @param totalVertices Defines the total number of vertices
  27062. * @returns the current mesh
  27063. */
  27064. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27065. /**
  27066. * Gets a boolean indicating if specific vertex data is present
  27067. * @param kind defines the vertex data kind to use
  27068. * @returns true is data kind is present
  27069. */
  27070. isVerticesDataPresent(kind: string): boolean;
  27071. /**
  27072. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27073. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27074. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27075. * @returns a BoundingInfo
  27076. */
  27077. getBoundingInfo(): BoundingInfo;
  27078. /**
  27079. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27080. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27081. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27082. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27083. * @returns the current mesh
  27084. */
  27085. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27086. /**
  27087. * Overwrite the current bounding info
  27088. * @param boundingInfo defines the new bounding info
  27089. * @returns the current mesh
  27090. */
  27091. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27092. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27093. readonly useBones: boolean;
  27094. /** @hidden */
  27095. _preActivate(): void;
  27096. /** @hidden */
  27097. _preActivateForIntermediateRendering(renderId: number): void;
  27098. /** @hidden */
  27099. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27100. /** @hidden */
  27101. _postActivate(): void;
  27102. /** @hidden */
  27103. _freeze(): void;
  27104. /** @hidden */
  27105. _unFreeze(): void;
  27106. /**
  27107. * Gets the current world matrix
  27108. * @returns a Matrix
  27109. */
  27110. getWorldMatrix(): Matrix;
  27111. /** @hidden */
  27112. _getWorldMatrixDeterminant(): number;
  27113. /**
  27114. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27115. */
  27116. readonly isAnInstance: boolean;
  27117. /**
  27118. * Gets a boolean indicating if this mesh has instances
  27119. */
  27120. readonly hasInstances: boolean;
  27121. /**
  27122. * Perform relative position change from the point of view of behind the front of the mesh.
  27123. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27124. * Supports definition of mesh facing forward or backward
  27125. * @param amountRight defines the distance on the right axis
  27126. * @param amountUp defines the distance on the up axis
  27127. * @param amountForward defines the distance on the forward axis
  27128. * @returns the current mesh
  27129. */
  27130. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27131. /**
  27132. * Calculate relative position change from the point of view of behind the front of the mesh.
  27133. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27134. * Supports definition of mesh facing forward or backward
  27135. * @param amountRight defines the distance on the right axis
  27136. * @param amountUp defines the distance on the up axis
  27137. * @param amountForward defines the distance on the forward axis
  27138. * @returns the new displacement vector
  27139. */
  27140. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27141. /**
  27142. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27143. * Supports definition of mesh facing forward or backward
  27144. * @param flipBack defines the flip
  27145. * @param twirlClockwise defines the twirl
  27146. * @param tiltRight defines the tilt
  27147. * @returns the current mesh
  27148. */
  27149. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27150. /**
  27151. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27152. * Supports definition of mesh facing forward or backward.
  27153. * @param flipBack defines the flip
  27154. * @param twirlClockwise defines the twirl
  27155. * @param tiltRight defines the tilt
  27156. * @returns the new rotation vector
  27157. */
  27158. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27159. /**
  27160. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27161. * This means the mesh underlying bounding box and sphere are recomputed.
  27162. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27163. * @returns the current mesh
  27164. */
  27165. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27166. /** @hidden */
  27167. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27168. /** @hidden */
  27169. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27170. /** @hidden */
  27171. _updateBoundingInfo(): AbstractMesh;
  27172. /** @hidden */
  27173. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27174. /** @hidden */
  27175. protected _afterComputeWorldMatrix(): void;
  27176. /** @hidden */
  27177. readonly _effectiveMesh: AbstractMesh;
  27178. /**
  27179. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27180. * A mesh is in the frustum if its bounding box intersects the frustum
  27181. * @param frustumPlanes defines the frustum to test
  27182. * @returns true if the mesh is in the frustum planes
  27183. */
  27184. isInFrustum(frustumPlanes: Plane[]): boolean;
  27185. /**
  27186. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27187. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27188. * @param frustumPlanes defines the frustum to test
  27189. * @returns true if the mesh is completely in the frustum planes
  27190. */
  27191. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27192. /**
  27193. * True if the mesh intersects another mesh or a SolidParticle object
  27194. * @param mesh defines a target mesh or SolidParticle to test
  27195. * @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)
  27196. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27197. * @returns true if there is an intersection
  27198. */
  27199. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27200. /**
  27201. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27202. * @param point defines the point to test
  27203. * @returns true if there is an intersection
  27204. */
  27205. intersectsPoint(point: Vector3): boolean;
  27206. /**
  27207. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27209. */
  27210. checkCollisions: boolean;
  27211. /**
  27212. * Gets Collider object used to compute collisions (not physics)
  27213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27214. */
  27215. readonly collider: Nullable<Collider>;
  27216. /**
  27217. * Move the mesh using collision engine
  27218. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27219. * @param displacement defines the requested displacement vector
  27220. * @returns the current mesh
  27221. */
  27222. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27223. private _onCollisionPositionChange;
  27224. /** @hidden */
  27225. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27226. /** @hidden */
  27227. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27228. /** @hidden */
  27229. _checkCollision(collider: Collider): AbstractMesh;
  27230. /** @hidden */
  27231. _generatePointsArray(): boolean;
  27232. /**
  27233. * Checks if the passed Ray intersects with the mesh
  27234. * @param ray defines the ray to use
  27235. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27236. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27237. * @returns the picking info
  27238. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27239. */
  27240. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27241. /**
  27242. * Clones the current mesh
  27243. * @param name defines the mesh name
  27244. * @param newParent defines the new mesh parent
  27245. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27246. * @returns the new mesh
  27247. */
  27248. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27249. /**
  27250. * Disposes all the submeshes of the current meshnp
  27251. * @returns the current mesh
  27252. */
  27253. releaseSubMeshes(): AbstractMesh;
  27254. /**
  27255. * Releases resources associated with this abstract mesh.
  27256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27258. */
  27259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27260. /**
  27261. * Adds the passed mesh as a child to the current mesh
  27262. * @param mesh defines the child mesh
  27263. * @returns the current mesh
  27264. */
  27265. addChild(mesh: AbstractMesh): AbstractMesh;
  27266. /**
  27267. * Removes the passed mesh from the current mesh children list
  27268. * @param mesh defines the child mesh
  27269. * @returns the current mesh
  27270. */
  27271. removeChild(mesh: AbstractMesh): AbstractMesh;
  27272. /** @hidden */
  27273. private _initFacetData;
  27274. /**
  27275. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27276. * This method can be called within the render loop.
  27277. * 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
  27278. * @returns the current mesh
  27279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27280. */
  27281. updateFacetData(): AbstractMesh;
  27282. /**
  27283. * Returns the facetLocalNormals array.
  27284. * The normals are expressed in the mesh local spac
  27285. * @returns an array of Vector3
  27286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27287. */
  27288. getFacetLocalNormals(): Vector3[];
  27289. /**
  27290. * Returns the facetLocalPositions array.
  27291. * The facet positions are expressed in the mesh local space
  27292. * @returns an array of Vector3
  27293. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27294. */
  27295. getFacetLocalPositions(): Vector3[];
  27296. /**
  27297. * Returns the facetLocalPartioning array
  27298. * @returns an array of array of numbers
  27299. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27300. */
  27301. getFacetLocalPartitioning(): number[][];
  27302. /**
  27303. * Returns the i-th facet position in the world system.
  27304. * This method allocates a new Vector3 per call
  27305. * @param i defines the facet index
  27306. * @returns a new Vector3
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27308. */
  27309. getFacetPosition(i: number): Vector3;
  27310. /**
  27311. * Sets the reference Vector3 with the i-th facet position in the world system
  27312. * @param i defines the facet index
  27313. * @param ref defines the target vector
  27314. * @returns the current mesh
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27316. */
  27317. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27318. /**
  27319. * Returns the i-th facet normal in the world system.
  27320. * This method allocates a new Vector3 per call
  27321. * @param i defines the facet index
  27322. * @returns a new Vector3
  27323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27324. */
  27325. getFacetNormal(i: number): Vector3;
  27326. /**
  27327. * Sets the reference Vector3 with the i-th facet normal in the world system
  27328. * @param i defines the facet index
  27329. * @param ref defines the target vector
  27330. * @returns the current mesh
  27331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27332. */
  27333. getFacetNormalToRef(i: number, ref: Vector3): this;
  27334. /**
  27335. * 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)
  27336. * @param x defines x coordinate
  27337. * @param y defines y coordinate
  27338. * @param z defines z coordinate
  27339. * @returns the array of facet indexes
  27340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27341. */
  27342. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27343. /**
  27344. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27345. * @param projected sets as the (x,y,z) world projection on the facet
  27346. * @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
  27347. * @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
  27348. * @param x defines x coordinate
  27349. * @param y defines y coordinate
  27350. * @param z defines z coordinate
  27351. * @returns the face index if found (or null instead)
  27352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27353. */
  27354. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27355. /**
  27356. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27357. * @param projected sets as the (x,y,z) local projection on the facet
  27358. * @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
  27359. * @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
  27360. * @param x defines x coordinate
  27361. * @param y defines y coordinate
  27362. * @param z defines z coordinate
  27363. * @returns the face index if found (or null instead)
  27364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27365. */
  27366. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27367. /**
  27368. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27369. * @returns the parameters
  27370. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27371. */
  27372. getFacetDataParameters(): any;
  27373. /**
  27374. * Disables the feature FacetData and frees the related memory
  27375. * @returns the current mesh
  27376. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27377. */
  27378. disableFacetData(): AbstractMesh;
  27379. /**
  27380. * Updates the AbstractMesh indices array
  27381. * @param indices defines the data source
  27382. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27383. * @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)
  27384. * @returns the current mesh
  27385. */
  27386. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27387. /**
  27388. * Creates new normals data for the mesh
  27389. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27390. * @returns the current mesh
  27391. */
  27392. createNormals(updatable: boolean): AbstractMesh;
  27393. /**
  27394. * Align the mesh with a normal
  27395. * @param normal defines the normal to use
  27396. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27397. * @returns the current mesh
  27398. */
  27399. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27400. /** @hidden */
  27401. _checkOcclusionQuery(): boolean;
  27402. /**
  27403. * Disables the mesh edge rendering mode
  27404. * @returns the currentAbstractMesh
  27405. */
  27406. disableEdgesRendering(): AbstractMesh;
  27407. /**
  27408. * Enables the edge rendering mode on the mesh.
  27409. * This mode makes the mesh edges visible
  27410. * @param epsilon defines the maximal distance between two angles to detect a face
  27411. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27412. * @returns the currentAbstractMesh
  27413. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27414. */
  27415. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27416. }
  27417. }
  27418. declare module "babylonjs/Actions/actionEvent" {
  27419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27420. import { Nullable } from "babylonjs/types";
  27421. import { Sprite } from "babylonjs/Sprites/sprite";
  27422. import { Scene } from "babylonjs/scene";
  27423. import { Vector2 } from "babylonjs/Maths/math.vector";
  27424. /**
  27425. * Interface used to define ActionEvent
  27426. */
  27427. export interface IActionEvent {
  27428. /** The mesh or sprite that triggered the action */
  27429. source: any;
  27430. /** The X mouse cursor position at the time of the event */
  27431. pointerX: number;
  27432. /** The Y mouse cursor position at the time of the event */
  27433. pointerY: number;
  27434. /** The mesh that is currently pointed at (can be null) */
  27435. meshUnderPointer: Nullable<AbstractMesh>;
  27436. /** the original (browser) event that triggered the ActionEvent */
  27437. sourceEvent?: any;
  27438. /** additional data for the event */
  27439. additionalData?: any;
  27440. }
  27441. /**
  27442. * ActionEvent is the event being sent when an action is triggered.
  27443. */
  27444. export class ActionEvent implements IActionEvent {
  27445. /** The mesh or sprite that triggered the action */
  27446. source: any;
  27447. /** The X mouse cursor position at the time of the event */
  27448. pointerX: number;
  27449. /** The Y mouse cursor position at the time of the event */
  27450. pointerY: number;
  27451. /** The mesh that is currently pointed at (can be null) */
  27452. meshUnderPointer: Nullable<AbstractMesh>;
  27453. /** the original (browser) event that triggered the ActionEvent */
  27454. sourceEvent?: any;
  27455. /** additional data for the event */
  27456. additionalData?: any;
  27457. /**
  27458. * Creates a new ActionEvent
  27459. * @param source The mesh or sprite that triggered the action
  27460. * @param pointerX The X mouse cursor position at the time of the event
  27461. * @param pointerY The Y mouse cursor position at the time of the event
  27462. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27463. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27464. * @param additionalData additional data for the event
  27465. */
  27466. constructor(
  27467. /** The mesh or sprite that triggered the action */
  27468. source: any,
  27469. /** The X mouse cursor position at the time of the event */
  27470. pointerX: number,
  27471. /** The Y mouse cursor position at the time of the event */
  27472. pointerY: number,
  27473. /** The mesh that is currently pointed at (can be null) */
  27474. meshUnderPointer: Nullable<AbstractMesh>,
  27475. /** the original (browser) event that triggered the ActionEvent */
  27476. sourceEvent?: any,
  27477. /** additional data for the event */
  27478. additionalData?: any);
  27479. /**
  27480. * Helper function to auto-create an ActionEvent from a source mesh.
  27481. * @param source The source mesh that triggered the event
  27482. * @param evt The original (browser) event
  27483. * @param additionalData additional data for the event
  27484. * @returns the new ActionEvent
  27485. */
  27486. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27487. /**
  27488. * Helper function to auto-create an ActionEvent from a source sprite
  27489. * @param source The source sprite that triggered the event
  27490. * @param scene Scene associated with the sprite
  27491. * @param evt The original (browser) event
  27492. * @param additionalData additional data for the event
  27493. * @returns the new ActionEvent
  27494. */
  27495. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27496. /**
  27497. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27498. * @param scene the scene where the event occurred
  27499. * @param evt The original (browser) event
  27500. * @returns the new ActionEvent
  27501. */
  27502. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27503. /**
  27504. * Helper function to auto-create an ActionEvent from a primitive
  27505. * @param prim defines the target primitive
  27506. * @param pointerPos defines the pointer position
  27507. * @param evt The original (browser) event
  27508. * @param additionalData additional data for the event
  27509. * @returns the new ActionEvent
  27510. */
  27511. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27512. }
  27513. }
  27514. declare module "babylonjs/Actions/abstractActionManager" {
  27515. import { IDisposable } from "babylonjs/scene";
  27516. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27517. import { IAction } from "babylonjs/Actions/action";
  27518. import { Nullable } from "babylonjs/types";
  27519. /**
  27520. * Abstract class used to decouple action Manager from scene and meshes.
  27521. * Do not instantiate.
  27522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27523. */
  27524. export abstract class AbstractActionManager implements IDisposable {
  27525. /** Gets the list of active triggers */
  27526. static Triggers: {
  27527. [key: string]: number;
  27528. };
  27529. /** Gets the cursor to use when hovering items */
  27530. hoverCursor: string;
  27531. /** Gets the list of actions */
  27532. actions: IAction[];
  27533. /**
  27534. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27535. */
  27536. isRecursive: boolean;
  27537. /**
  27538. * Releases all associated resources
  27539. */
  27540. abstract dispose(): void;
  27541. /**
  27542. * Does this action manager has pointer triggers
  27543. */
  27544. abstract readonly hasPointerTriggers: boolean;
  27545. /**
  27546. * Does this action manager has pick triggers
  27547. */
  27548. abstract readonly hasPickTriggers: boolean;
  27549. /**
  27550. * Process a specific trigger
  27551. * @param trigger defines the trigger to process
  27552. * @param evt defines the event details to be processed
  27553. */
  27554. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27555. /**
  27556. * Does this action manager handles actions of any of the given triggers
  27557. * @param triggers defines the triggers to be tested
  27558. * @return a boolean indicating whether one (or more) of the triggers is handled
  27559. */
  27560. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27561. /**
  27562. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27563. * speed.
  27564. * @param triggerA defines the trigger to be tested
  27565. * @param triggerB defines the trigger to be tested
  27566. * @return a boolean indicating whether one (or more) of the triggers is handled
  27567. */
  27568. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27569. /**
  27570. * Does this action manager handles actions of a given trigger
  27571. * @param trigger defines the trigger to be tested
  27572. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27573. * @return whether the trigger is handled
  27574. */
  27575. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27576. /**
  27577. * Serialize this manager to a JSON object
  27578. * @param name defines the property name to store this manager
  27579. * @returns a JSON representation of this manager
  27580. */
  27581. abstract serialize(name: string): any;
  27582. /**
  27583. * Registers an action to this action manager
  27584. * @param action defines the action to be registered
  27585. * @return the action amended (prepared) after registration
  27586. */
  27587. abstract registerAction(action: IAction): Nullable<IAction>;
  27588. /**
  27589. * Unregisters an action to this action manager
  27590. * @param action defines the action to be unregistered
  27591. * @return a boolean indicating whether the action has been unregistered
  27592. */
  27593. abstract unregisterAction(action: IAction): Boolean;
  27594. /**
  27595. * Does exist one action manager with at least one trigger
  27596. **/
  27597. static readonly HasTriggers: boolean;
  27598. /**
  27599. * Does exist one action manager with at least one pick trigger
  27600. **/
  27601. static readonly HasPickTriggers: boolean;
  27602. /**
  27603. * Does exist one action manager that handles actions of a given trigger
  27604. * @param trigger defines the trigger to be tested
  27605. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27606. **/
  27607. static HasSpecificTrigger(trigger: number): boolean;
  27608. }
  27609. }
  27610. declare module "babylonjs/node" {
  27611. import { Scene } from "babylonjs/scene";
  27612. import { Nullable } from "babylonjs/types";
  27613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27614. import { Engine } from "babylonjs/Engines/engine";
  27615. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27616. import { Observable } from "babylonjs/Misc/observable";
  27617. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27618. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27619. import { Animatable } from "babylonjs/Animations/animatable";
  27620. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27621. import { Animation } from "babylonjs/Animations/animation";
  27622. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27624. /**
  27625. * Defines how a node can be built from a string name.
  27626. */
  27627. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27628. /**
  27629. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27630. */
  27631. export class Node implements IBehaviorAware<Node> {
  27632. /** @hidden */
  27633. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27634. private static _NodeConstructors;
  27635. /**
  27636. * Add a new node constructor
  27637. * @param type defines the type name of the node to construct
  27638. * @param constructorFunc defines the constructor function
  27639. */
  27640. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27641. /**
  27642. * Returns a node constructor based on type name
  27643. * @param type defines the type name
  27644. * @param name defines the new node name
  27645. * @param scene defines the hosting scene
  27646. * @param options defines optional options to transmit to constructors
  27647. * @returns the new constructor or null
  27648. */
  27649. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27650. /**
  27651. * Gets or sets the name of the node
  27652. */
  27653. name: string;
  27654. /**
  27655. * Gets or sets the id of the node
  27656. */
  27657. id: string;
  27658. /**
  27659. * Gets or sets the unique id of the node
  27660. */
  27661. uniqueId: number;
  27662. /**
  27663. * Gets or sets a string used to store user defined state for the node
  27664. */
  27665. state: string;
  27666. /**
  27667. * Gets or sets an object used to store user defined information for the node
  27668. */
  27669. metadata: any;
  27670. /**
  27671. * For internal use only. Please do not use.
  27672. */
  27673. reservedDataStore: any;
  27674. /**
  27675. * List of inspectable custom properties (used by the Inspector)
  27676. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27677. */
  27678. inspectableCustomProperties: IInspectable[];
  27679. /**
  27680. * Gets or sets a boolean used to define if the node must be serialized
  27681. */
  27682. doNotSerialize: boolean;
  27683. /** @hidden */
  27684. _isDisposed: boolean;
  27685. /**
  27686. * Gets a list of Animations associated with the node
  27687. */
  27688. animations: import("babylonjs/Animations/animation").Animation[];
  27689. protected _ranges: {
  27690. [name: string]: Nullable<AnimationRange>;
  27691. };
  27692. /**
  27693. * Callback raised when the node is ready to be used
  27694. */
  27695. onReady: Nullable<(node: Node) => void>;
  27696. private _isEnabled;
  27697. private _isParentEnabled;
  27698. private _isReady;
  27699. /** @hidden */
  27700. _currentRenderId: number;
  27701. private _parentUpdateId;
  27702. /** @hidden */
  27703. _childUpdateId: number;
  27704. /** @hidden */
  27705. _waitingParentId: Nullable<string>;
  27706. /** @hidden */
  27707. _scene: Scene;
  27708. /** @hidden */
  27709. _cache: any;
  27710. private _parentNode;
  27711. private _children;
  27712. /** @hidden */
  27713. _worldMatrix: Matrix;
  27714. /** @hidden */
  27715. _worldMatrixDeterminant: number;
  27716. /** @hidden */
  27717. _worldMatrixDeterminantIsDirty: boolean;
  27718. /** @hidden */
  27719. private _sceneRootNodesIndex;
  27720. /**
  27721. * Gets a boolean indicating if the node has been disposed
  27722. * @returns true if the node was disposed
  27723. */
  27724. isDisposed(): boolean;
  27725. /**
  27726. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27727. * @see https://doc.babylonjs.com/how_to/parenting
  27728. */
  27729. parent: Nullable<Node>;
  27730. private addToSceneRootNodes;
  27731. private removeFromSceneRootNodes;
  27732. private _animationPropertiesOverride;
  27733. /**
  27734. * Gets or sets the animation properties override
  27735. */
  27736. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27737. /**
  27738. * Gets a string idenfifying the name of the class
  27739. * @returns "Node" string
  27740. */
  27741. getClassName(): string;
  27742. /** @hidden */
  27743. readonly _isNode: boolean;
  27744. /**
  27745. * An event triggered when the mesh is disposed
  27746. */
  27747. onDisposeObservable: Observable<Node>;
  27748. private _onDisposeObserver;
  27749. /**
  27750. * Sets a callback that will be raised when the node will be disposed
  27751. */
  27752. onDispose: () => void;
  27753. /**
  27754. * Creates a new Node
  27755. * @param name the name and id to be given to this node
  27756. * @param scene the scene this node will be added to
  27757. * @param addToRootNodes the node will be added to scene.rootNodes
  27758. */
  27759. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27760. /**
  27761. * Gets the scene of the node
  27762. * @returns a scene
  27763. */
  27764. getScene(): Scene;
  27765. /**
  27766. * Gets the engine of the node
  27767. * @returns a Engine
  27768. */
  27769. getEngine(): Engine;
  27770. private _behaviors;
  27771. /**
  27772. * Attach a behavior to the node
  27773. * @see http://doc.babylonjs.com/features/behaviour
  27774. * @param behavior defines the behavior to attach
  27775. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27776. * @returns the current Node
  27777. */
  27778. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27779. /**
  27780. * Remove an attached behavior
  27781. * @see http://doc.babylonjs.com/features/behaviour
  27782. * @param behavior defines the behavior to attach
  27783. * @returns the current Node
  27784. */
  27785. removeBehavior(behavior: Behavior<Node>): Node;
  27786. /**
  27787. * Gets the list of attached behaviors
  27788. * @see http://doc.babylonjs.com/features/behaviour
  27789. */
  27790. readonly behaviors: Behavior<Node>[];
  27791. /**
  27792. * Gets an attached behavior by name
  27793. * @param name defines the name of the behavior to look for
  27794. * @see http://doc.babylonjs.com/features/behaviour
  27795. * @returns null if behavior was not found else the requested behavior
  27796. */
  27797. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27798. /**
  27799. * Returns the latest update of the World matrix
  27800. * @returns a Matrix
  27801. */
  27802. getWorldMatrix(): Matrix;
  27803. /** @hidden */
  27804. _getWorldMatrixDeterminant(): number;
  27805. /**
  27806. * Returns directly the latest state of the mesh World matrix.
  27807. * A Matrix is returned.
  27808. */
  27809. readonly worldMatrixFromCache: Matrix;
  27810. /** @hidden */
  27811. _initCache(): void;
  27812. /** @hidden */
  27813. updateCache(force?: boolean): void;
  27814. /** @hidden */
  27815. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27816. /** @hidden */
  27817. _updateCache(ignoreParentClass?: boolean): void;
  27818. /** @hidden */
  27819. _isSynchronized(): boolean;
  27820. /** @hidden */
  27821. _markSyncedWithParent(): void;
  27822. /** @hidden */
  27823. isSynchronizedWithParent(): boolean;
  27824. /** @hidden */
  27825. isSynchronized(): boolean;
  27826. /**
  27827. * Is this node ready to be used/rendered
  27828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27829. * @return true if the node is ready
  27830. */
  27831. isReady(completeCheck?: boolean): boolean;
  27832. /**
  27833. * Is this node enabled?
  27834. * 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
  27835. * @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
  27836. * @return whether this node (and its parent) is enabled
  27837. */
  27838. isEnabled(checkAncestors?: boolean): boolean;
  27839. /** @hidden */
  27840. protected _syncParentEnabledState(): void;
  27841. /**
  27842. * Set the enabled state of this node
  27843. * @param value defines the new enabled state
  27844. */
  27845. setEnabled(value: boolean): void;
  27846. /**
  27847. * Is this node a descendant of the given node?
  27848. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27849. * @param ancestor defines the parent node to inspect
  27850. * @returns a boolean indicating if this node is a descendant of the given node
  27851. */
  27852. isDescendantOf(ancestor: Node): boolean;
  27853. /** @hidden */
  27854. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27855. /**
  27856. * Will return all nodes that have this node as ascendant
  27857. * @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
  27858. * @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
  27859. * @return all children nodes of all types
  27860. */
  27861. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27862. /**
  27863. * Get all child-meshes of this node
  27864. * @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)
  27865. * @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
  27866. * @returns an array of AbstractMesh
  27867. */
  27868. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27869. /**
  27870. * Get all direct children of this node
  27871. * @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
  27872. * @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)
  27873. * @returns an array of Node
  27874. */
  27875. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27876. /** @hidden */
  27877. _setReady(state: boolean): void;
  27878. /**
  27879. * Get an animation by name
  27880. * @param name defines the name of the animation to look for
  27881. * @returns null if not found else the requested animation
  27882. */
  27883. getAnimationByName(name: string): Nullable<Animation>;
  27884. /**
  27885. * Creates an animation range for this node
  27886. * @param name defines the name of the range
  27887. * @param from defines the starting key
  27888. * @param to defines the end key
  27889. */
  27890. createAnimationRange(name: string, from: number, to: number): void;
  27891. /**
  27892. * Delete a specific animation range
  27893. * @param name defines the name of the range to delete
  27894. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27895. */
  27896. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27897. /**
  27898. * Get an animation range by name
  27899. * @param name defines the name of the animation range to look for
  27900. * @returns null if not found else the requested animation range
  27901. */
  27902. getAnimationRange(name: string): Nullable<AnimationRange>;
  27903. /**
  27904. * Gets the list of all animation ranges defined on this node
  27905. * @returns an array
  27906. */
  27907. getAnimationRanges(): Nullable<AnimationRange>[];
  27908. /**
  27909. * Will start the animation sequence
  27910. * @param name defines the range frames for animation sequence
  27911. * @param loop defines if the animation should loop (false by default)
  27912. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27913. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27914. * @returns the object created for this animation. If range does not exist, it will return null
  27915. */
  27916. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27917. /**
  27918. * Serialize animation ranges into a JSON compatible object
  27919. * @returns serialization object
  27920. */
  27921. serializeAnimationRanges(): any;
  27922. /**
  27923. * Computes the world matrix of the node
  27924. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27925. * @returns the world matrix
  27926. */
  27927. computeWorldMatrix(force?: boolean): Matrix;
  27928. /**
  27929. * Releases resources associated with this node.
  27930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27932. */
  27933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27934. /**
  27935. * Parse animation range data from a serialization object and store them into a given node
  27936. * @param node defines where to store the animation ranges
  27937. * @param parsedNode defines the serialization object to read data from
  27938. * @param scene defines the hosting scene
  27939. */
  27940. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27941. /**
  27942. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27943. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27944. * @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
  27945. * @returns the new bounding vectors
  27946. */
  27947. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27948. min: Vector3;
  27949. max: Vector3;
  27950. };
  27951. }
  27952. }
  27953. declare module "babylonjs/Animations/animation" {
  27954. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27955. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27956. import { Color3 } from "babylonjs/Maths/math.color";
  27957. import { Nullable } from "babylonjs/types";
  27958. import { Scene } from "babylonjs/scene";
  27959. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27960. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27961. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27962. import { Node } from "babylonjs/node";
  27963. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27964. import { Size } from "babylonjs/Maths/math.size";
  27965. import { Animatable } from "babylonjs/Animations/animatable";
  27966. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27967. /**
  27968. * @hidden
  27969. */
  27970. export class _IAnimationState {
  27971. key: number;
  27972. repeatCount: number;
  27973. workValue?: any;
  27974. loopMode?: number;
  27975. offsetValue?: any;
  27976. highLimitValue?: any;
  27977. }
  27978. /**
  27979. * Class used to store any kind of animation
  27980. */
  27981. export class Animation {
  27982. /**Name of the animation */
  27983. name: string;
  27984. /**Property to animate */
  27985. targetProperty: string;
  27986. /**The frames per second of the animation */
  27987. framePerSecond: number;
  27988. /**The data type of the animation */
  27989. dataType: number;
  27990. /**The loop mode of the animation */
  27991. loopMode?: number | undefined;
  27992. /**Specifies if blending should be enabled */
  27993. enableBlending?: boolean | undefined;
  27994. /**
  27995. * Use matrix interpolation instead of using direct key value when animating matrices
  27996. */
  27997. static AllowMatricesInterpolation: boolean;
  27998. /**
  27999. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28000. */
  28001. static AllowMatrixDecomposeForInterpolation: boolean;
  28002. /**
  28003. * Stores the key frames of the animation
  28004. */
  28005. private _keys;
  28006. /**
  28007. * Stores the easing function of the animation
  28008. */
  28009. private _easingFunction;
  28010. /**
  28011. * @hidden Internal use only
  28012. */
  28013. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28014. /**
  28015. * The set of event that will be linked to this animation
  28016. */
  28017. private _events;
  28018. /**
  28019. * Stores an array of target property paths
  28020. */
  28021. targetPropertyPath: string[];
  28022. /**
  28023. * Stores the blending speed of the animation
  28024. */
  28025. blendingSpeed: number;
  28026. /**
  28027. * Stores the animation ranges for the animation
  28028. */
  28029. private _ranges;
  28030. /**
  28031. * @hidden Internal use
  28032. */
  28033. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28034. /**
  28035. * Sets up an animation
  28036. * @param property The property to animate
  28037. * @param animationType The animation type to apply
  28038. * @param framePerSecond The frames per second of the animation
  28039. * @param easingFunction The easing function used in the animation
  28040. * @returns The created animation
  28041. */
  28042. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28043. /**
  28044. * Create and start an animation on a node
  28045. * @param name defines the name of the global animation that will be run on all nodes
  28046. * @param node defines the root node where the animation will take place
  28047. * @param targetProperty defines property to animate
  28048. * @param framePerSecond defines the number of frame per second yo use
  28049. * @param totalFrame defines the number of frames in total
  28050. * @param from defines the initial value
  28051. * @param to defines the final value
  28052. * @param loopMode defines which loop mode you want to use (off by default)
  28053. * @param easingFunction defines the easing function to use (linear by default)
  28054. * @param onAnimationEnd defines the callback to call when animation end
  28055. * @returns the animatable created for this animation
  28056. */
  28057. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28058. /**
  28059. * Create and start an animation on a node and its descendants
  28060. * @param name defines the name of the global animation that will be run on all nodes
  28061. * @param node defines the root node where the animation will take place
  28062. * @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
  28063. * @param targetProperty defines property to animate
  28064. * @param framePerSecond defines the number of frame per second to use
  28065. * @param totalFrame defines the number of frames in total
  28066. * @param from defines the initial value
  28067. * @param to defines the final value
  28068. * @param loopMode defines which loop mode you want to use (off by default)
  28069. * @param easingFunction defines the easing function to use (linear by default)
  28070. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28071. * @returns the list of animatables created for all nodes
  28072. * @example https://www.babylonjs-playground.com/#MH0VLI
  28073. */
  28074. 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[]>;
  28075. /**
  28076. * Creates a new animation, merges it with the existing animations and starts it
  28077. * @param name Name of the animation
  28078. * @param node Node which contains the scene that begins the animations
  28079. * @param targetProperty Specifies which property to animate
  28080. * @param framePerSecond The frames per second of the animation
  28081. * @param totalFrame The total number of frames
  28082. * @param from The frame at the beginning of the animation
  28083. * @param to The frame at the end of the animation
  28084. * @param loopMode Specifies the loop mode of the animation
  28085. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28086. * @param onAnimationEnd Callback to run once the animation is complete
  28087. * @returns Nullable animation
  28088. */
  28089. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28090. /**
  28091. * Transition property of an host to the target Value
  28092. * @param property The property to transition
  28093. * @param targetValue The target Value of the property
  28094. * @param host The object where the property to animate belongs
  28095. * @param scene Scene used to run the animation
  28096. * @param frameRate Framerate (in frame/s) to use
  28097. * @param transition The transition type we want to use
  28098. * @param duration The duration of the animation, in milliseconds
  28099. * @param onAnimationEnd Callback trigger at the end of the animation
  28100. * @returns Nullable animation
  28101. */
  28102. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28103. /**
  28104. * Return the array of runtime animations currently using this animation
  28105. */
  28106. readonly runtimeAnimations: RuntimeAnimation[];
  28107. /**
  28108. * Specifies if any of the runtime animations are currently running
  28109. */
  28110. readonly hasRunningRuntimeAnimations: boolean;
  28111. /**
  28112. * Initializes the animation
  28113. * @param name Name of the animation
  28114. * @param targetProperty Property to animate
  28115. * @param framePerSecond The frames per second of the animation
  28116. * @param dataType The data type of the animation
  28117. * @param loopMode The loop mode of the animation
  28118. * @param enableBlending Specifies if blending should be enabled
  28119. */
  28120. constructor(
  28121. /**Name of the animation */
  28122. name: string,
  28123. /**Property to animate */
  28124. targetProperty: string,
  28125. /**The frames per second of the animation */
  28126. framePerSecond: number,
  28127. /**The data type of the animation */
  28128. dataType: number,
  28129. /**The loop mode of the animation */
  28130. loopMode?: number | undefined,
  28131. /**Specifies if blending should be enabled */
  28132. enableBlending?: boolean | undefined);
  28133. /**
  28134. * Converts the animation to a string
  28135. * @param fullDetails support for multiple levels of logging within scene loading
  28136. * @returns String form of the animation
  28137. */
  28138. toString(fullDetails?: boolean): string;
  28139. /**
  28140. * Add an event to this animation
  28141. * @param event Event to add
  28142. */
  28143. addEvent(event: AnimationEvent): void;
  28144. /**
  28145. * Remove all events found at the given frame
  28146. * @param frame The frame to remove events from
  28147. */
  28148. removeEvents(frame: number): void;
  28149. /**
  28150. * Retrieves all the events from the animation
  28151. * @returns Events from the animation
  28152. */
  28153. getEvents(): AnimationEvent[];
  28154. /**
  28155. * Creates an animation range
  28156. * @param name Name of the animation range
  28157. * @param from Starting frame of the animation range
  28158. * @param to Ending frame of the animation
  28159. */
  28160. createRange(name: string, from: number, to: number): void;
  28161. /**
  28162. * Deletes an animation range by name
  28163. * @param name Name of the animation range to delete
  28164. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28165. */
  28166. deleteRange(name: string, deleteFrames?: boolean): void;
  28167. /**
  28168. * Gets the animation range by name, or null if not defined
  28169. * @param name Name of the animation range
  28170. * @returns Nullable animation range
  28171. */
  28172. getRange(name: string): Nullable<AnimationRange>;
  28173. /**
  28174. * Gets the key frames from the animation
  28175. * @returns The key frames of the animation
  28176. */
  28177. getKeys(): Array<IAnimationKey>;
  28178. /**
  28179. * Gets the highest frame rate of the animation
  28180. * @returns Highest frame rate of the animation
  28181. */
  28182. getHighestFrame(): number;
  28183. /**
  28184. * Gets the easing function of the animation
  28185. * @returns Easing function of the animation
  28186. */
  28187. getEasingFunction(): IEasingFunction;
  28188. /**
  28189. * Sets the easing function of the animation
  28190. * @param easingFunction A custom mathematical formula for animation
  28191. */
  28192. setEasingFunction(easingFunction: EasingFunction): void;
  28193. /**
  28194. * Interpolates a scalar linearly
  28195. * @param startValue Start value of the animation curve
  28196. * @param endValue End value of the animation curve
  28197. * @param gradient Scalar amount to interpolate
  28198. * @returns Interpolated scalar value
  28199. */
  28200. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28201. /**
  28202. * Interpolates a scalar cubically
  28203. * @param startValue Start value of the animation curve
  28204. * @param outTangent End tangent of the animation
  28205. * @param endValue End value of the animation curve
  28206. * @param inTangent Start tangent of the animation curve
  28207. * @param gradient Scalar amount to interpolate
  28208. * @returns Interpolated scalar value
  28209. */
  28210. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28211. /**
  28212. * Interpolates a quaternion using a spherical linear interpolation
  28213. * @param startValue Start value of the animation curve
  28214. * @param endValue End value of the animation curve
  28215. * @param gradient Scalar amount to interpolate
  28216. * @returns Interpolated quaternion value
  28217. */
  28218. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28219. /**
  28220. * Interpolates a quaternion cubically
  28221. * @param startValue Start value of the animation curve
  28222. * @param outTangent End tangent of the animation curve
  28223. * @param endValue End value of the animation curve
  28224. * @param inTangent Start tangent of the animation curve
  28225. * @param gradient Scalar amount to interpolate
  28226. * @returns Interpolated quaternion value
  28227. */
  28228. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28229. /**
  28230. * Interpolates a Vector3 linearl
  28231. * @param startValue Start value of the animation curve
  28232. * @param endValue End value of the animation curve
  28233. * @param gradient Scalar amount to interpolate
  28234. * @returns Interpolated scalar value
  28235. */
  28236. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28237. /**
  28238. * Interpolates a Vector3 cubically
  28239. * @param startValue Start value of the animation curve
  28240. * @param outTangent End tangent of the animation
  28241. * @param endValue End value of the animation curve
  28242. * @param inTangent Start tangent of the animation curve
  28243. * @param gradient Scalar amount to interpolate
  28244. * @returns InterpolatedVector3 value
  28245. */
  28246. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28247. /**
  28248. * Interpolates a Vector2 linearly
  28249. * @param startValue Start value of the animation curve
  28250. * @param endValue End value of the animation curve
  28251. * @param gradient Scalar amount to interpolate
  28252. * @returns Interpolated Vector2 value
  28253. */
  28254. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28255. /**
  28256. * Interpolates a Vector2 cubically
  28257. * @param startValue Start value of the animation curve
  28258. * @param outTangent End tangent of the animation
  28259. * @param endValue End value of the animation curve
  28260. * @param inTangent Start tangent of the animation curve
  28261. * @param gradient Scalar amount to interpolate
  28262. * @returns Interpolated Vector2 value
  28263. */
  28264. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28265. /**
  28266. * Interpolates a size linearly
  28267. * @param startValue Start value of the animation curve
  28268. * @param endValue End value of the animation curve
  28269. * @param gradient Scalar amount to interpolate
  28270. * @returns Interpolated Size value
  28271. */
  28272. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28273. /**
  28274. * Interpolates a Color3 linearly
  28275. * @param startValue Start value of the animation curve
  28276. * @param endValue End value of the animation curve
  28277. * @param gradient Scalar amount to interpolate
  28278. * @returns Interpolated Color3 value
  28279. */
  28280. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28281. /**
  28282. * @hidden Internal use only
  28283. */
  28284. _getKeyValue(value: any): any;
  28285. /**
  28286. * @hidden Internal use only
  28287. */
  28288. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28289. /**
  28290. * Defines the function to use to interpolate matrices
  28291. * @param startValue defines the start matrix
  28292. * @param endValue defines the end matrix
  28293. * @param gradient defines the gradient between both matrices
  28294. * @param result defines an optional target matrix where to store the interpolation
  28295. * @returns the interpolated matrix
  28296. */
  28297. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28298. /**
  28299. * Makes a copy of the animation
  28300. * @returns Cloned animation
  28301. */
  28302. clone(): Animation;
  28303. /**
  28304. * Sets the key frames of the animation
  28305. * @param values The animation key frames to set
  28306. */
  28307. setKeys(values: Array<IAnimationKey>): void;
  28308. /**
  28309. * Serializes the animation to an object
  28310. * @returns Serialized object
  28311. */
  28312. serialize(): any;
  28313. /**
  28314. * Float animation type
  28315. */
  28316. private static _ANIMATIONTYPE_FLOAT;
  28317. /**
  28318. * Vector3 animation type
  28319. */
  28320. private static _ANIMATIONTYPE_VECTOR3;
  28321. /**
  28322. * Quaternion animation type
  28323. */
  28324. private static _ANIMATIONTYPE_QUATERNION;
  28325. /**
  28326. * Matrix animation type
  28327. */
  28328. private static _ANIMATIONTYPE_MATRIX;
  28329. /**
  28330. * Color3 animation type
  28331. */
  28332. private static _ANIMATIONTYPE_COLOR3;
  28333. /**
  28334. * Vector2 animation type
  28335. */
  28336. private static _ANIMATIONTYPE_VECTOR2;
  28337. /**
  28338. * Size animation type
  28339. */
  28340. private static _ANIMATIONTYPE_SIZE;
  28341. /**
  28342. * Relative Loop Mode
  28343. */
  28344. private static _ANIMATIONLOOPMODE_RELATIVE;
  28345. /**
  28346. * Cycle Loop Mode
  28347. */
  28348. private static _ANIMATIONLOOPMODE_CYCLE;
  28349. /**
  28350. * Constant Loop Mode
  28351. */
  28352. private static _ANIMATIONLOOPMODE_CONSTANT;
  28353. /**
  28354. * Get the float animation type
  28355. */
  28356. static readonly ANIMATIONTYPE_FLOAT: number;
  28357. /**
  28358. * Get the Vector3 animation type
  28359. */
  28360. static readonly ANIMATIONTYPE_VECTOR3: number;
  28361. /**
  28362. * Get the Vector2 animation type
  28363. */
  28364. static readonly ANIMATIONTYPE_VECTOR2: number;
  28365. /**
  28366. * Get the Size animation type
  28367. */
  28368. static readonly ANIMATIONTYPE_SIZE: number;
  28369. /**
  28370. * Get the Quaternion animation type
  28371. */
  28372. static readonly ANIMATIONTYPE_QUATERNION: number;
  28373. /**
  28374. * Get the Matrix animation type
  28375. */
  28376. static readonly ANIMATIONTYPE_MATRIX: number;
  28377. /**
  28378. * Get the Color3 animation type
  28379. */
  28380. static readonly ANIMATIONTYPE_COLOR3: number;
  28381. /**
  28382. * Get the Relative Loop Mode
  28383. */
  28384. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28385. /**
  28386. * Get the Cycle Loop Mode
  28387. */
  28388. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28389. /**
  28390. * Get the Constant Loop Mode
  28391. */
  28392. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28393. /** @hidden */
  28394. static _UniversalLerp(left: any, right: any, amount: number): any;
  28395. /**
  28396. * Parses an animation object and creates an animation
  28397. * @param parsedAnimation Parsed animation object
  28398. * @returns Animation object
  28399. */
  28400. static Parse(parsedAnimation: any): Animation;
  28401. /**
  28402. * Appends the serialized animations from the source animations
  28403. * @param source Source containing the animations
  28404. * @param destination Target to store the animations
  28405. */
  28406. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28407. }
  28408. }
  28409. declare module "babylonjs/Animations/animatable.interface" {
  28410. import { Nullable } from "babylonjs/types";
  28411. import { Animation } from "babylonjs/Animations/animation";
  28412. /**
  28413. * Interface containing an array of animations
  28414. */
  28415. export interface IAnimatable {
  28416. /**
  28417. * Array of animations
  28418. */
  28419. animations: Nullable<Array<Animation>>;
  28420. }
  28421. }
  28422. declare module "babylonjs/Materials/fresnelParameters" {
  28423. import { Color3 } from "babylonjs/Maths/math.color";
  28424. /**
  28425. * This represents all the required information to add a fresnel effect on a material:
  28426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28427. */
  28428. export class FresnelParameters {
  28429. private _isEnabled;
  28430. /**
  28431. * Define if the fresnel effect is enable or not.
  28432. */
  28433. isEnabled: boolean;
  28434. /**
  28435. * Define the color used on edges (grazing angle)
  28436. */
  28437. leftColor: Color3;
  28438. /**
  28439. * Define the color used on center
  28440. */
  28441. rightColor: Color3;
  28442. /**
  28443. * Define bias applied to computed fresnel term
  28444. */
  28445. bias: number;
  28446. /**
  28447. * Defined the power exponent applied to fresnel term
  28448. */
  28449. power: number;
  28450. /**
  28451. * Clones the current fresnel and its valuues
  28452. * @returns a clone fresnel configuration
  28453. */
  28454. clone(): FresnelParameters;
  28455. /**
  28456. * Serializes the current fresnel parameters to a JSON representation.
  28457. * @return the JSON serialization
  28458. */
  28459. serialize(): any;
  28460. /**
  28461. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28462. * @param parsedFresnelParameters Define the JSON representation
  28463. * @returns the parsed parameters
  28464. */
  28465. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28466. }
  28467. }
  28468. declare module "babylonjs/Misc/decorators" {
  28469. import { Nullable } from "babylonjs/types";
  28470. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28471. import { Scene } from "babylonjs/scene";
  28472. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28473. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28474. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28475. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28476. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28477. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28478. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28479. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28480. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28481. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28482. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28483. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28484. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28485. /**
  28486. * Decorator used to define property that can be serialized as reference to a camera
  28487. * @param sourceName defines the name of the property to decorate
  28488. */
  28489. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28490. /**
  28491. * Class used to help serialization objects
  28492. */
  28493. export class SerializationHelper {
  28494. /** @hidden */
  28495. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28496. /** @hidden */
  28497. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28498. /** @hidden */
  28499. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28500. /** @hidden */
  28501. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28502. /**
  28503. * Appends the serialized animations from the source animations
  28504. * @param source Source containing the animations
  28505. * @param destination Target to store the animations
  28506. */
  28507. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28508. /**
  28509. * Static function used to serialized a specific entity
  28510. * @param entity defines the entity to serialize
  28511. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28512. * @returns a JSON compatible object representing the serialization of the entity
  28513. */
  28514. static Serialize<T>(entity: T, serializationObject?: any): any;
  28515. /**
  28516. * Creates a new entity from a serialization data object
  28517. * @param creationFunction defines a function used to instanciated the new entity
  28518. * @param source defines the source serialization data
  28519. * @param scene defines the hosting scene
  28520. * @param rootUrl defines the root url for resources
  28521. * @returns a new entity
  28522. */
  28523. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28524. /**
  28525. * Clones an object
  28526. * @param creationFunction defines the function used to instanciate the new object
  28527. * @param source defines the source object
  28528. * @returns the cloned object
  28529. */
  28530. static Clone<T>(creationFunction: () => T, source: T): T;
  28531. /**
  28532. * Instanciates a new object based on a source one (some data will be shared between both object)
  28533. * @param creationFunction defines the function used to instanciate the new object
  28534. * @param source defines the source object
  28535. * @returns the new object
  28536. */
  28537. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28538. }
  28539. }
  28540. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28541. import { Nullable } from "babylonjs/types";
  28542. /**
  28543. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28544. */
  28545. export interface CubeMapInfo {
  28546. /**
  28547. * The pixel array for the front face.
  28548. * This is stored in format, left to right, up to down format.
  28549. */
  28550. front: Nullable<ArrayBufferView>;
  28551. /**
  28552. * The pixel array for the back face.
  28553. * This is stored in format, left to right, up to down format.
  28554. */
  28555. back: Nullable<ArrayBufferView>;
  28556. /**
  28557. * The pixel array for the left face.
  28558. * This is stored in format, left to right, up to down format.
  28559. */
  28560. left: Nullable<ArrayBufferView>;
  28561. /**
  28562. * The pixel array for the right face.
  28563. * This is stored in format, left to right, up to down format.
  28564. */
  28565. right: Nullable<ArrayBufferView>;
  28566. /**
  28567. * The pixel array for the up face.
  28568. * This is stored in format, left to right, up to down format.
  28569. */
  28570. up: Nullable<ArrayBufferView>;
  28571. /**
  28572. * The pixel array for the down face.
  28573. * This is stored in format, left to right, up to down format.
  28574. */
  28575. down: Nullable<ArrayBufferView>;
  28576. /**
  28577. * The size of the cubemap stored.
  28578. *
  28579. * Each faces will be size * size pixels.
  28580. */
  28581. size: number;
  28582. /**
  28583. * The format of the texture.
  28584. *
  28585. * RGBA, RGB.
  28586. */
  28587. format: number;
  28588. /**
  28589. * The type of the texture data.
  28590. *
  28591. * UNSIGNED_INT, FLOAT.
  28592. */
  28593. type: number;
  28594. /**
  28595. * Specifies whether the texture is in gamma space.
  28596. */
  28597. gammaSpace: boolean;
  28598. }
  28599. /**
  28600. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28601. */
  28602. export class PanoramaToCubeMapTools {
  28603. private static FACE_FRONT;
  28604. private static FACE_BACK;
  28605. private static FACE_RIGHT;
  28606. private static FACE_LEFT;
  28607. private static FACE_DOWN;
  28608. private static FACE_UP;
  28609. /**
  28610. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28611. *
  28612. * @param float32Array The source data.
  28613. * @param inputWidth The width of the input panorama.
  28614. * @param inputHeight The height of the input panorama.
  28615. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28616. * @return The cubemap data
  28617. */
  28618. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28619. private static CreateCubemapTexture;
  28620. private static CalcProjectionSpherical;
  28621. }
  28622. }
  28623. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28624. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28625. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28626. import { Nullable } from "babylonjs/types";
  28627. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28628. /**
  28629. * Helper class dealing with the extraction of spherical polynomial dataArray
  28630. * from a cube map.
  28631. */
  28632. export class CubeMapToSphericalPolynomialTools {
  28633. private static FileFaces;
  28634. /**
  28635. * Converts a texture to the according Spherical Polynomial data.
  28636. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28637. *
  28638. * @param texture The texture to extract the information from.
  28639. * @return The Spherical Polynomial data.
  28640. */
  28641. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28642. /**
  28643. * Converts a cubemap to the according Spherical Polynomial data.
  28644. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28645. *
  28646. * @param cubeInfo The Cube map to extract the information from.
  28647. * @return The Spherical Polynomial data.
  28648. */
  28649. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28650. }
  28651. }
  28652. declare module "babylonjs/Misc/guid" {
  28653. /**
  28654. * Class used to manipulate GUIDs
  28655. */
  28656. export class GUID {
  28657. /**
  28658. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28659. * Be aware Math.random() could cause collisions, but:
  28660. * "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"
  28661. * @returns a pseudo random id
  28662. */
  28663. static RandomId(): string;
  28664. }
  28665. }
  28666. declare module "babylonjs/Materials/Textures/baseTexture" {
  28667. import { Observable } from "babylonjs/Misc/observable";
  28668. import { Nullable } from "babylonjs/types";
  28669. import { Scene } from "babylonjs/scene";
  28670. import { Matrix } from "babylonjs/Maths/math.vector";
  28671. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28672. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28673. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28674. import { ISize } from "babylonjs/Maths/math.size";
  28675. /**
  28676. * Base class of all the textures in babylon.
  28677. * It groups all the common properties the materials, post process, lights... might need
  28678. * in order to make a correct use of the texture.
  28679. */
  28680. export class BaseTexture implements IAnimatable {
  28681. /**
  28682. * Default anisotropic filtering level for the application.
  28683. * It is set to 4 as a good tradeoff between perf and quality.
  28684. */
  28685. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28686. /**
  28687. * Gets or sets the unique id of the texture
  28688. */
  28689. uniqueId: number;
  28690. /**
  28691. * Define the name of the texture.
  28692. */
  28693. name: string;
  28694. /**
  28695. * Gets or sets an object used to store user defined information.
  28696. */
  28697. metadata: any;
  28698. /**
  28699. * For internal use only. Please do not use.
  28700. */
  28701. reservedDataStore: any;
  28702. private _hasAlpha;
  28703. /**
  28704. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28705. */
  28706. hasAlpha: boolean;
  28707. /**
  28708. * Defines if the alpha value should be determined via the rgb values.
  28709. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28710. */
  28711. getAlphaFromRGB: boolean;
  28712. /**
  28713. * Intensity or strength of the texture.
  28714. * It is commonly used by materials to fine tune the intensity of the texture
  28715. */
  28716. level: number;
  28717. /**
  28718. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28719. * This is part of the texture as textures usually maps to one uv set.
  28720. */
  28721. coordinatesIndex: number;
  28722. private _coordinatesMode;
  28723. /**
  28724. * How a texture is mapped.
  28725. *
  28726. * | Value | Type | Description |
  28727. * | ----- | ----------------------------------- | ----------- |
  28728. * | 0 | EXPLICIT_MODE | |
  28729. * | 1 | SPHERICAL_MODE | |
  28730. * | 2 | PLANAR_MODE | |
  28731. * | 3 | CUBIC_MODE | |
  28732. * | 4 | PROJECTION_MODE | |
  28733. * | 5 | SKYBOX_MODE | |
  28734. * | 6 | INVCUBIC_MODE | |
  28735. * | 7 | EQUIRECTANGULAR_MODE | |
  28736. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28737. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28738. */
  28739. coordinatesMode: number;
  28740. /**
  28741. * | Value | Type | Description |
  28742. * | ----- | ------------------ | ----------- |
  28743. * | 0 | CLAMP_ADDRESSMODE | |
  28744. * | 1 | WRAP_ADDRESSMODE | |
  28745. * | 2 | MIRROR_ADDRESSMODE | |
  28746. */
  28747. wrapU: number;
  28748. /**
  28749. * | Value | Type | Description |
  28750. * | ----- | ------------------ | ----------- |
  28751. * | 0 | CLAMP_ADDRESSMODE | |
  28752. * | 1 | WRAP_ADDRESSMODE | |
  28753. * | 2 | MIRROR_ADDRESSMODE | |
  28754. */
  28755. wrapV: number;
  28756. /**
  28757. * | Value | Type | Description |
  28758. * | ----- | ------------------ | ----------- |
  28759. * | 0 | CLAMP_ADDRESSMODE | |
  28760. * | 1 | WRAP_ADDRESSMODE | |
  28761. * | 2 | MIRROR_ADDRESSMODE | |
  28762. */
  28763. wrapR: number;
  28764. /**
  28765. * With compliant hardware and browser (supporting anisotropic filtering)
  28766. * this defines the level of anisotropic filtering in the texture.
  28767. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28768. */
  28769. anisotropicFilteringLevel: number;
  28770. /**
  28771. * Define if the texture is a cube texture or if false a 2d texture.
  28772. */
  28773. isCube: boolean;
  28774. /**
  28775. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28776. */
  28777. is3D: boolean;
  28778. /**
  28779. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28780. * HDR texture are usually stored in linear space.
  28781. * This only impacts the PBR and Background materials
  28782. */
  28783. gammaSpace: boolean;
  28784. /**
  28785. * Gets or sets whether or not the texture contains RGBD data.
  28786. */
  28787. isRGBD: boolean;
  28788. /**
  28789. * Is Z inverted in the texture (useful in a cube texture).
  28790. */
  28791. invertZ: boolean;
  28792. /**
  28793. * Are mip maps generated for this texture or not.
  28794. */
  28795. readonly noMipmap: boolean;
  28796. /**
  28797. * @hidden
  28798. */
  28799. lodLevelInAlpha: boolean;
  28800. /**
  28801. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28802. */
  28803. lodGenerationOffset: number;
  28804. /**
  28805. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28806. */
  28807. lodGenerationScale: number;
  28808. /**
  28809. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28810. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28811. * average roughness values.
  28812. */
  28813. linearSpecularLOD: boolean;
  28814. /**
  28815. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28816. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28817. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28818. */
  28819. irradianceTexture: Nullable<BaseTexture>;
  28820. /**
  28821. * Define if the texture is a render target.
  28822. */
  28823. isRenderTarget: boolean;
  28824. /**
  28825. * Define the unique id of the texture in the scene.
  28826. */
  28827. readonly uid: string;
  28828. /**
  28829. * Return a string representation of the texture.
  28830. * @returns the texture as a string
  28831. */
  28832. toString(): string;
  28833. /**
  28834. * Get the class name of the texture.
  28835. * @returns "BaseTexture"
  28836. */
  28837. getClassName(): string;
  28838. /**
  28839. * Define the list of animation attached to the texture.
  28840. */
  28841. animations: import("babylonjs/Animations/animation").Animation[];
  28842. /**
  28843. * An event triggered when the texture is disposed.
  28844. */
  28845. onDisposeObservable: Observable<BaseTexture>;
  28846. private _onDisposeObserver;
  28847. /**
  28848. * Callback triggered when the texture has been disposed.
  28849. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28850. */
  28851. onDispose: () => void;
  28852. /**
  28853. * Define the current state of the loading sequence when in delayed load mode.
  28854. */
  28855. delayLoadState: number;
  28856. private _scene;
  28857. /** @hidden */
  28858. _texture: Nullable<InternalTexture>;
  28859. private _uid;
  28860. /**
  28861. * Define if the texture is preventinga material to render or not.
  28862. * If not and the texture is not ready, the engine will use a default black texture instead.
  28863. */
  28864. readonly isBlocking: boolean;
  28865. /**
  28866. * Instantiates a new BaseTexture.
  28867. * Base class of all the textures in babylon.
  28868. * It groups all the common properties the materials, post process, lights... might need
  28869. * in order to make a correct use of the texture.
  28870. * @param scene Define the scene the texture blongs to
  28871. */
  28872. constructor(scene: Nullable<Scene>);
  28873. /**
  28874. * Get the scene the texture belongs to.
  28875. * @returns the scene or null if undefined
  28876. */
  28877. getScene(): Nullable<Scene>;
  28878. /**
  28879. * Get the texture transform matrix used to offset tile the texture for istance.
  28880. * @returns the transformation matrix
  28881. */
  28882. getTextureMatrix(): Matrix;
  28883. /**
  28884. * Get the texture reflection matrix used to rotate/transform the reflection.
  28885. * @returns the reflection matrix
  28886. */
  28887. getReflectionTextureMatrix(): Matrix;
  28888. /**
  28889. * Get the underlying lower level texture from Babylon.
  28890. * @returns the insternal texture
  28891. */
  28892. getInternalTexture(): Nullable<InternalTexture>;
  28893. /**
  28894. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28895. * @returns true if ready or not blocking
  28896. */
  28897. isReadyOrNotBlocking(): boolean;
  28898. /**
  28899. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28900. * @returns true if fully ready
  28901. */
  28902. isReady(): boolean;
  28903. private _cachedSize;
  28904. /**
  28905. * Get the size of the texture.
  28906. * @returns the texture size.
  28907. */
  28908. getSize(): ISize;
  28909. /**
  28910. * Get the base size of the texture.
  28911. * It can be different from the size if the texture has been resized for POT for instance
  28912. * @returns the base size
  28913. */
  28914. getBaseSize(): ISize;
  28915. /**
  28916. * Update the sampling mode of the texture.
  28917. * Default is Trilinear mode.
  28918. *
  28919. * | Value | Type | Description |
  28920. * | ----- | ------------------ | ----------- |
  28921. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28922. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28923. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28924. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28925. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28926. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28927. * | 7 | NEAREST_LINEAR | |
  28928. * | 8 | NEAREST_NEAREST | |
  28929. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28930. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28931. * | 11 | LINEAR_LINEAR | |
  28932. * | 12 | LINEAR_NEAREST | |
  28933. *
  28934. * > _mag_: magnification filter (close to the viewer)
  28935. * > _min_: minification filter (far from the viewer)
  28936. * > _mip_: filter used between mip map levels
  28937. *@param samplingMode Define the new sampling mode of the texture
  28938. */
  28939. updateSamplingMode(samplingMode: number): void;
  28940. /**
  28941. * Scales the texture if is `canRescale()`
  28942. * @param ratio the resize factor we want to use to rescale
  28943. */
  28944. scale(ratio: number): void;
  28945. /**
  28946. * Get if the texture can rescale.
  28947. */
  28948. readonly canRescale: boolean;
  28949. /** @hidden */
  28950. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28951. /** @hidden */
  28952. _rebuild(): void;
  28953. /**
  28954. * Triggers the load sequence in delayed load mode.
  28955. */
  28956. delayLoad(): void;
  28957. /**
  28958. * Clones the texture.
  28959. * @returns the cloned texture
  28960. */
  28961. clone(): Nullable<BaseTexture>;
  28962. /**
  28963. * Get the texture underlying type (INT, FLOAT...)
  28964. */
  28965. readonly textureType: number;
  28966. /**
  28967. * Get the texture underlying format (RGB, RGBA...)
  28968. */
  28969. readonly textureFormat: number;
  28970. /**
  28971. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28972. * This will returns an RGBA array buffer containing either in values (0-255) or
  28973. * float values (0-1) depending of the underlying buffer type.
  28974. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28975. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28976. * @param buffer defines a user defined buffer to fill with data (can be null)
  28977. * @returns The Array buffer containing the pixels data.
  28978. */
  28979. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28980. /**
  28981. * Release and destroy the underlying lower level texture aka internalTexture.
  28982. */
  28983. releaseInternalTexture(): void;
  28984. /**
  28985. * Get the polynomial representation of the texture data.
  28986. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28987. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28988. */
  28989. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28990. /** @hidden */
  28991. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28992. /** @hidden */
  28993. readonly _lodTextureMid: Nullable<BaseTexture>;
  28994. /** @hidden */
  28995. readonly _lodTextureLow: Nullable<BaseTexture>;
  28996. /**
  28997. * Dispose the texture and release its associated resources.
  28998. */
  28999. dispose(): void;
  29000. /**
  29001. * Serialize the texture into a JSON representation that can be parsed later on.
  29002. * @returns the JSON representation of the texture
  29003. */
  29004. serialize(): any;
  29005. /**
  29006. * Helper function to be called back once a list of texture contains only ready textures.
  29007. * @param textures Define the list of textures to wait for
  29008. * @param callback Define the callback triggered once the entire list will be ready
  29009. */
  29010. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29011. }
  29012. }
  29013. declare module "babylonjs/Materials/effect" {
  29014. import { Observable } from "babylonjs/Misc/observable";
  29015. import { Nullable } from "babylonjs/types";
  29016. import { IDisposable } from "babylonjs/scene";
  29017. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29018. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29019. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29020. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29021. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29022. import { Engine } from "babylonjs/Engines/engine";
  29023. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29024. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29025. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29026. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29027. /**
  29028. * Options to be used when creating an effect.
  29029. */
  29030. export class EffectCreationOptions {
  29031. /**
  29032. * Atrributes that will be used in the shader.
  29033. */
  29034. attributes: string[];
  29035. /**
  29036. * Uniform varible names that will be set in the shader.
  29037. */
  29038. uniformsNames: string[];
  29039. /**
  29040. * Uniform buffer varible names that will be set in the shader.
  29041. */
  29042. uniformBuffersNames: string[];
  29043. /**
  29044. * Sampler texture variable names that will be set in the shader.
  29045. */
  29046. samplers: string[];
  29047. /**
  29048. * Define statements that will be set in the shader.
  29049. */
  29050. defines: any;
  29051. /**
  29052. * Possible fallbacks for this effect to improve performance when needed.
  29053. */
  29054. fallbacks: Nullable<IEffectFallbacks>;
  29055. /**
  29056. * Callback that will be called when the shader is compiled.
  29057. */
  29058. onCompiled: Nullable<(effect: Effect) => void>;
  29059. /**
  29060. * Callback that will be called if an error occurs during shader compilation.
  29061. */
  29062. onError: Nullable<(effect: Effect, errors: string) => void>;
  29063. /**
  29064. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29065. */
  29066. indexParameters?: any;
  29067. /**
  29068. * Max number of lights that can be used in the shader.
  29069. */
  29070. maxSimultaneousLights?: number;
  29071. /**
  29072. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29073. */
  29074. transformFeedbackVaryings?: Nullable<string[]>;
  29075. }
  29076. /**
  29077. * Effect containing vertex and fragment shader that can be executed on an object.
  29078. */
  29079. export class Effect implements IDisposable {
  29080. /**
  29081. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29082. */
  29083. static ShadersRepository: string;
  29084. /**
  29085. * Name of the effect.
  29086. */
  29087. name: any;
  29088. /**
  29089. * String container all the define statements that should be set on the shader.
  29090. */
  29091. defines: string;
  29092. /**
  29093. * Callback that will be called when the shader is compiled.
  29094. */
  29095. onCompiled: Nullable<(effect: Effect) => void>;
  29096. /**
  29097. * Callback that will be called if an error occurs during shader compilation.
  29098. */
  29099. onError: Nullable<(effect: Effect, errors: string) => void>;
  29100. /**
  29101. * Callback that will be called when effect is bound.
  29102. */
  29103. onBind: Nullable<(effect: Effect) => void>;
  29104. /**
  29105. * Unique ID of the effect.
  29106. */
  29107. uniqueId: number;
  29108. /**
  29109. * Observable that will be called when the shader is compiled.
  29110. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29111. */
  29112. onCompileObservable: Observable<Effect>;
  29113. /**
  29114. * Observable that will be called if an error occurs during shader compilation.
  29115. */
  29116. onErrorObservable: Observable<Effect>;
  29117. /** @hidden */
  29118. _onBindObservable: Nullable<Observable<Effect>>;
  29119. /**
  29120. * Observable that will be called when effect is bound.
  29121. */
  29122. readonly onBindObservable: Observable<Effect>;
  29123. /** @hidden */
  29124. _bonesComputationForcedToCPU: boolean;
  29125. private static _uniqueIdSeed;
  29126. private _engine;
  29127. private _uniformBuffersNames;
  29128. private _uniformsNames;
  29129. private _samplerList;
  29130. private _samplers;
  29131. private _isReady;
  29132. private _compilationError;
  29133. private _attributesNames;
  29134. private _attributes;
  29135. private _uniforms;
  29136. /**
  29137. * Key for the effect.
  29138. * @hidden
  29139. */
  29140. _key: string;
  29141. private _indexParameters;
  29142. private _fallbacks;
  29143. private _vertexSourceCode;
  29144. private _fragmentSourceCode;
  29145. private _vertexSourceCodeOverride;
  29146. private _fragmentSourceCodeOverride;
  29147. private _transformFeedbackVaryings;
  29148. /**
  29149. * Compiled shader to webGL program.
  29150. * @hidden
  29151. */
  29152. _pipelineContext: Nullable<IPipelineContext>;
  29153. private _valueCache;
  29154. private static _baseCache;
  29155. /**
  29156. * Instantiates an effect.
  29157. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29158. * @param baseName Name of the effect.
  29159. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29160. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29161. * @param samplers List of sampler variables that will be passed to the shader.
  29162. * @param engine Engine to be used to render the effect
  29163. * @param defines Define statements to be added to the shader.
  29164. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29165. * @param onCompiled Callback that will be called when the shader is compiled.
  29166. * @param onError Callback that will be called if an error occurs during shader compilation.
  29167. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29168. */
  29169. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  29170. private _useFinalCode;
  29171. /**
  29172. * Unique key for this effect
  29173. */
  29174. readonly key: string;
  29175. /**
  29176. * If the effect has been compiled and prepared.
  29177. * @returns if the effect is compiled and prepared.
  29178. */
  29179. isReady(): boolean;
  29180. private _isReadyInternal;
  29181. /**
  29182. * The engine the effect was initialized with.
  29183. * @returns the engine.
  29184. */
  29185. getEngine(): Engine;
  29186. /**
  29187. * The pipeline context for this effect
  29188. * @returns the associated pipeline context
  29189. */
  29190. getPipelineContext(): Nullable<IPipelineContext>;
  29191. /**
  29192. * The set of names of attribute variables for the shader.
  29193. * @returns An array of attribute names.
  29194. */
  29195. getAttributesNames(): string[];
  29196. /**
  29197. * Returns the attribute at the given index.
  29198. * @param index The index of the attribute.
  29199. * @returns The location of the attribute.
  29200. */
  29201. getAttributeLocation(index: number): number;
  29202. /**
  29203. * Returns the attribute based on the name of the variable.
  29204. * @param name of the attribute to look up.
  29205. * @returns the attribute location.
  29206. */
  29207. getAttributeLocationByName(name: string): number;
  29208. /**
  29209. * The number of attributes.
  29210. * @returns the numnber of attributes.
  29211. */
  29212. getAttributesCount(): number;
  29213. /**
  29214. * Gets the index of a uniform variable.
  29215. * @param uniformName of the uniform to look up.
  29216. * @returns the index.
  29217. */
  29218. getUniformIndex(uniformName: string): number;
  29219. /**
  29220. * Returns the attribute based on the name of the variable.
  29221. * @param uniformName of the uniform to look up.
  29222. * @returns the location of the uniform.
  29223. */
  29224. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29225. /**
  29226. * Returns an array of sampler variable names
  29227. * @returns The array of sampler variable neames.
  29228. */
  29229. getSamplers(): string[];
  29230. /**
  29231. * The error from the last compilation.
  29232. * @returns the error string.
  29233. */
  29234. getCompilationError(): string;
  29235. /**
  29236. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29237. * @param func The callback to be used.
  29238. */
  29239. executeWhenCompiled(func: (effect: Effect) => void): void;
  29240. private _checkIsReady;
  29241. /** @hidden */
  29242. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29243. /** @hidden */
  29244. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29245. /** @hidden */
  29246. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29247. /**
  29248. * Recompiles the webGL program
  29249. * @param vertexSourceCode The source code for the vertex shader.
  29250. * @param fragmentSourceCode The source code for the fragment shader.
  29251. * @param onCompiled Callback called when completed.
  29252. * @param onError Callback called on error.
  29253. * @hidden
  29254. */
  29255. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29256. /**
  29257. * Prepares the effect
  29258. * @hidden
  29259. */
  29260. _prepareEffect(): void;
  29261. private _processCompilationErrors;
  29262. /**
  29263. * Checks if the effect is supported. (Must be called after compilation)
  29264. */
  29265. readonly isSupported: boolean;
  29266. /**
  29267. * Binds a texture to the engine to be used as output of the shader.
  29268. * @param channel Name of the output variable.
  29269. * @param texture Texture to bind.
  29270. * @hidden
  29271. */
  29272. _bindTexture(channel: string, texture: InternalTexture): void;
  29273. /**
  29274. * Sets a texture on the engine to be used in the shader.
  29275. * @param channel Name of the sampler variable.
  29276. * @param texture Texture to set.
  29277. */
  29278. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29279. /**
  29280. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29281. * @param channel Name of the sampler variable.
  29282. * @param texture Texture to set.
  29283. */
  29284. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29285. /**
  29286. * Sets an array of textures on the engine to be used in the shader.
  29287. * @param channel Name of the variable.
  29288. * @param textures Textures to set.
  29289. */
  29290. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29291. /**
  29292. * 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)
  29293. * @param channel Name of the sampler variable.
  29294. * @param postProcess Post process to get the input texture from.
  29295. */
  29296. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29297. /**
  29298. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29299. * 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)
  29300. * @param channel Name of the sampler variable.
  29301. * @param postProcess Post process to get the output texture from.
  29302. */
  29303. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29304. /** @hidden */
  29305. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29306. /** @hidden */
  29307. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29308. /** @hidden */
  29309. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29310. /** @hidden */
  29311. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29312. /**
  29313. * Binds a buffer to a uniform.
  29314. * @param buffer Buffer to bind.
  29315. * @param name Name of the uniform variable to bind to.
  29316. */
  29317. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29318. /**
  29319. * Binds block to a uniform.
  29320. * @param blockName Name of the block to bind.
  29321. * @param index Index to bind.
  29322. */
  29323. bindUniformBlock(blockName: string, index: number): void;
  29324. /**
  29325. * Sets an interger value on a uniform variable.
  29326. * @param uniformName Name of the variable.
  29327. * @param value Value to be set.
  29328. * @returns this effect.
  29329. */
  29330. setInt(uniformName: string, value: number): Effect;
  29331. /**
  29332. * Sets an int array on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param array array to be set.
  29335. * @returns this effect.
  29336. */
  29337. setIntArray(uniformName: string, array: Int32Array): Effect;
  29338. /**
  29339. * 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)
  29340. * @param uniformName Name of the variable.
  29341. * @param array array to be set.
  29342. * @returns this effect.
  29343. */
  29344. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29345. /**
  29346. * 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)
  29347. * @param uniformName Name of the variable.
  29348. * @param array array to be set.
  29349. * @returns this effect.
  29350. */
  29351. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29352. /**
  29353. * 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)
  29354. * @param uniformName Name of the variable.
  29355. * @param array array to be set.
  29356. * @returns this effect.
  29357. */
  29358. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29359. /**
  29360. * Sets an float array on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param array array to be set.
  29363. * @returns this effect.
  29364. */
  29365. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29366. /**
  29367. * 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)
  29368. * @param uniformName Name of the variable.
  29369. * @param array array to be set.
  29370. * @returns this effect.
  29371. */
  29372. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29373. /**
  29374. * 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)
  29375. * @param uniformName Name of the variable.
  29376. * @param array array to be set.
  29377. * @returns this effect.
  29378. */
  29379. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29380. /**
  29381. * 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)
  29382. * @param uniformName Name of the variable.
  29383. * @param array array to be set.
  29384. * @returns this effect.
  29385. */
  29386. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29387. /**
  29388. * Sets an array on a uniform variable.
  29389. * @param uniformName Name of the variable.
  29390. * @param array array to be set.
  29391. * @returns this effect.
  29392. */
  29393. setArray(uniformName: string, array: number[]): Effect;
  29394. /**
  29395. * 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)
  29396. * @param uniformName Name of the variable.
  29397. * @param array array to be set.
  29398. * @returns this effect.
  29399. */
  29400. setArray2(uniformName: string, array: number[]): Effect;
  29401. /**
  29402. * 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)
  29403. * @param uniformName Name of the variable.
  29404. * @param array array to be set.
  29405. * @returns this effect.
  29406. */
  29407. setArray3(uniformName: string, array: number[]): Effect;
  29408. /**
  29409. * 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)
  29410. * @param uniformName Name of the variable.
  29411. * @param array array to be set.
  29412. * @returns this effect.
  29413. */
  29414. setArray4(uniformName: string, array: number[]): Effect;
  29415. /**
  29416. * Sets matrices on a uniform variable.
  29417. * @param uniformName Name of the variable.
  29418. * @param matrices matrices to be set.
  29419. * @returns this effect.
  29420. */
  29421. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29422. /**
  29423. * Sets matrix on a uniform variable.
  29424. * @param uniformName Name of the variable.
  29425. * @param matrix matrix to be set.
  29426. * @returns this effect.
  29427. */
  29428. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29429. /**
  29430. * 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)
  29431. * @param uniformName Name of the variable.
  29432. * @param matrix matrix to be set.
  29433. * @returns this effect.
  29434. */
  29435. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29436. /**
  29437. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29438. * @param uniformName Name of the variable.
  29439. * @param matrix matrix to be set.
  29440. * @returns this effect.
  29441. */
  29442. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29443. /**
  29444. * Sets a float on a uniform variable.
  29445. * @param uniformName Name of the variable.
  29446. * @param value value to be set.
  29447. * @returns this effect.
  29448. */
  29449. setFloat(uniformName: string, value: number): Effect;
  29450. /**
  29451. * Sets a boolean on a uniform variable.
  29452. * @param uniformName Name of the variable.
  29453. * @param bool value to be set.
  29454. * @returns this effect.
  29455. */
  29456. setBool(uniformName: string, bool: boolean): Effect;
  29457. /**
  29458. * Sets a Vector2 on a uniform variable.
  29459. * @param uniformName Name of the variable.
  29460. * @param vector2 vector2 to be set.
  29461. * @returns this effect.
  29462. */
  29463. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29464. /**
  29465. * Sets a float2 on a uniform variable.
  29466. * @param uniformName Name of the variable.
  29467. * @param x First float in float2.
  29468. * @param y Second float in float2.
  29469. * @returns this effect.
  29470. */
  29471. setFloat2(uniformName: string, x: number, y: number): Effect;
  29472. /**
  29473. * Sets a Vector3 on a uniform variable.
  29474. * @param uniformName Name of the variable.
  29475. * @param vector3 Value to be set.
  29476. * @returns this effect.
  29477. */
  29478. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29479. /**
  29480. * Sets a float3 on a uniform variable.
  29481. * @param uniformName Name of the variable.
  29482. * @param x First float in float3.
  29483. * @param y Second float in float3.
  29484. * @param z Third float in float3.
  29485. * @returns this effect.
  29486. */
  29487. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29488. /**
  29489. * Sets a Vector4 on a uniform variable.
  29490. * @param uniformName Name of the variable.
  29491. * @param vector4 Value to be set.
  29492. * @returns this effect.
  29493. */
  29494. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29495. /**
  29496. * Sets a float4 on a uniform variable.
  29497. * @param uniformName Name of the variable.
  29498. * @param x First float in float4.
  29499. * @param y Second float in float4.
  29500. * @param z Third float in float4.
  29501. * @param w Fourth float in float4.
  29502. * @returns this effect.
  29503. */
  29504. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29505. /**
  29506. * Sets a Color3 on a uniform variable.
  29507. * @param uniformName Name of the variable.
  29508. * @param color3 Value to be set.
  29509. * @returns this effect.
  29510. */
  29511. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29512. /**
  29513. * Sets a Color4 on a uniform variable.
  29514. * @param uniformName Name of the variable.
  29515. * @param color3 Value to be set.
  29516. * @param alpha Alpha value to be set.
  29517. * @returns this effect.
  29518. */
  29519. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29520. /**
  29521. * Sets a Color4 on a uniform variable
  29522. * @param uniformName defines the name of the variable
  29523. * @param color4 defines the value to be set
  29524. * @returns this effect.
  29525. */
  29526. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29527. /** Release all associated resources */
  29528. dispose(): void;
  29529. /**
  29530. * This function will add a new shader to the shader store
  29531. * @param name the name of the shader
  29532. * @param pixelShader optional pixel shader content
  29533. * @param vertexShader optional vertex shader content
  29534. */
  29535. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29536. /**
  29537. * Store of each shader (The can be looked up using effect.key)
  29538. */
  29539. static ShadersStore: {
  29540. [key: string]: string;
  29541. };
  29542. /**
  29543. * Store of each included file for a shader (The can be looked up using effect.key)
  29544. */
  29545. static IncludesShadersStore: {
  29546. [key: string]: string;
  29547. };
  29548. /**
  29549. * Resets the cache of effects.
  29550. */
  29551. static ResetCache(): void;
  29552. }
  29553. }
  29554. declare module "babylonjs/Engines/engineCapabilities" {
  29555. import { Nullable } from "babylonjs/types";
  29556. /**
  29557. * Class used to describe the capabilities of the engine relatively to the current browser
  29558. */
  29559. export class EngineCapabilities {
  29560. /** Maximum textures units per fragment shader */
  29561. maxTexturesImageUnits: number;
  29562. /** Maximum texture units per vertex shader */
  29563. maxVertexTextureImageUnits: number;
  29564. /** Maximum textures units in the entire pipeline */
  29565. maxCombinedTexturesImageUnits: number;
  29566. /** Maximum texture size */
  29567. maxTextureSize: number;
  29568. /** Maximum cube texture size */
  29569. maxCubemapTextureSize: number;
  29570. /** Maximum render texture size */
  29571. maxRenderTextureSize: number;
  29572. /** Maximum number of vertex attributes */
  29573. maxVertexAttribs: number;
  29574. /** Maximum number of varyings */
  29575. maxVaryingVectors: number;
  29576. /** Maximum number of uniforms per vertex shader */
  29577. maxVertexUniformVectors: number;
  29578. /** Maximum number of uniforms per fragment shader */
  29579. maxFragmentUniformVectors: number;
  29580. /** Defines if standard derivates (dx/dy) are supported */
  29581. standardDerivatives: boolean;
  29582. /** Defines if s3tc texture compression is supported */
  29583. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29584. /** Defines if pvrtc texture compression is supported */
  29585. pvrtc: any;
  29586. /** Defines if etc1 texture compression is supported */
  29587. etc1: any;
  29588. /** Defines if etc2 texture compression is supported */
  29589. etc2: any;
  29590. /** Defines if astc texture compression is supported */
  29591. astc: any;
  29592. /** Defines if float textures are supported */
  29593. textureFloat: boolean;
  29594. /** Defines if vertex array objects are supported */
  29595. vertexArrayObject: boolean;
  29596. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29597. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29598. /** Gets the maximum level of anisotropy supported */
  29599. maxAnisotropy: number;
  29600. /** Defines if instancing is supported */
  29601. instancedArrays: boolean;
  29602. /** Defines if 32 bits indices are supported */
  29603. uintIndices: boolean;
  29604. /** Defines if high precision shaders are supported */
  29605. highPrecisionShaderSupported: boolean;
  29606. /** Defines if depth reading in the fragment shader is supported */
  29607. fragmentDepthSupported: boolean;
  29608. /** Defines if float texture linear filtering is supported*/
  29609. textureFloatLinearFiltering: boolean;
  29610. /** Defines if rendering to float textures is supported */
  29611. textureFloatRender: boolean;
  29612. /** Defines if half float textures are supported*/
  29613. textureHalfFloat: boolean;
  29614. /** Defines if half float texture linear filtering is supported*/
  29615. textureHalfFloatLinearFiltering: boolean;
  29616. /** Defines if rendering to half float textures is supported */
  29617. textureHalfFloatRender: boolean;
  29618. /** Defines if textureLOD shader command is supported */
  29619. textureLOD: boolean;
  29620. /** Defines if draw buffers extension is supported */
  29621. drawBuffersExtension: boolean;
  29622. /** Defines if depth textures are supported */
  29623. depthTextureExtension: boolean;
  29624. /** Defines if float color buffer are supported */
  29625. colorBufferFloat: boolean;
  29626. /** Gets disjoint timer query extension (null if not supported) */
  29627. timerQuery: EXT_disjoint_timer_query;
  29628. /** Defines if timestamp can be used with timer query */
  29629. canUseTimestampForTimerQuery: boolean;
  29630. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29631. multiview: any;
  29632. /** Function used to let the system compiles shaders in background */
  29633. parallelShaderCompile: {
  29634. COMPLETION_STATUS_KHR: number;
  29635. };
  29636. /** Max number of texture samples for MSAA */
  29637. maxMSAASamples: number;
  29638. /** Defines if the blend min max extension is supported */
  29639. blendMinMax: boolean;
  29640. }
  29641. }
  29642. declare module "babylonjs/Misc/perfCounter" {
  29643. /**
  29644. * This class is used to track a performance counter which is number based.
  29645. * The user has access to many properties which give statistics of different nature.
  29646. *
  29647. * The implementer can track two kinds of Performance Counter: time and count.
  29648. * 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.
  29649. * 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.
  29650. */
  29651. export class PerfCounter {
  29652. /**
  29653. * Gets or sets a global boolean to turn on and off all the counters
  29654. */
  29655. static Enabled: boolean;
  29656. /**
  29657. * Returns the smallest value ever
  29658. */
  29659. readonly min: number;
  29660. /**
  29661. * Returns the biggest value ever
  29662. */
  29663. readonly max: number;
  29664. /**
  29665. * Returns the average value since the performance counter is running
  29666. */
  29667. readonly average: number;
  29668. /**
  29669. * Returns the average value of the last second the counter was monitored
  29670. */
  29671. readonly lastSecAverage: number;
  29672. /**
  29673. * Returns the current value
  29674. */
  29675. readonly current: number;
  29676. /**
  29677. * Gets the accumulated total
  29678. */
  29679. readonly total: number;
  29680. /**
  29681. * Gets the total value count
  29682. */
  29683. readonly count: number;
  29684. /**
  29685. * Creates a new counter
  29686. */
  29687. constructor();
  29688. /**
  29689. * Call this method to start monitoring a new frame.
  29690. * 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.
  29691. */
  29692. fetchNewFrame(): void;
  29693. /**
  29694. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29695. * @param newCount the count value to add to the monitored count
  29696. * @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.
  29697. */
  29698. addCount(newCount: number, fetchResult: boolean): void;
  29699. /**
  29700. * Start monitoring this performance counter
  29701. */
  29702. beginMonitoring(): void;
  29703. /**
  29704. * Compute the time lapsed since the previous beginMonitoring() call.
  29705. * @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
  29706. */
  29707. endMonitoring(newFrame?: boolean): void;
  29708. private _fetchResult;
  29709. private _startMonitoringTime;
  29710. private _min;
  29711. private _max;
  29712. private _average;
  29713. private _current;
  29714. private _totalValueCount;
  29715. private _totalAccumulated;
  29716. private _lastSecAverage;
  29717. private _lastSecAccumulated;
  29718. private _lastSecTime;
  29719. private _lastSecValueCount;
  29720. }
  29721. }
  29722. declare module "babylonjs/States/depthCullingState" {
  29723. import { Nullable } from "babylonjs/types";
  29724. /**
  29725. * @hidden
  29726. **/
  29727. export class DepthCullingState {
  29728. private _isDepthTestDirty;
  29729. private _isDepthMaskDirty;
  29730. private _isDepthFuncDirty;
  29731. private _isCullFaceDirty;
  29732. private _isCullDirty;
  29733. private _isZOffsetDirty;
  29734. private _isFrontFaceDirty;
  29735. private _depthTest;
  29736. private _depthMask;
  29737. private _depthFunc;
  29738. private _cull;
  29739. private _cullFace;
  29740. private _zOffset;
  29741. private _frontFace;
  29742. /**
  29743. * Initializes the state.
  29744. */
  29745. constructor();
  29746. readonly isDirty: boolean;
  29747. zOffset: number;
  29748. cullFace: Nullable<number>;
  29749. cull: Nullable<boolean>;
  29750. depthFunc: Nullable<number>;
  29751. depthMask: boolean;
  29752. depthTest: boolean;
  29753. frontFace: Nullable<number>;
  29754. reset(): void;
  29755. apply(gl: WebGLRenderingContext): void;
  29756. }
  29757. }
  29758. declare module "babylonjs/States/stencilState" {
  29759. /**
  29760. * @hidden
  29761. **/
  29762. export class StencilState {
  29763. /** 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 */
  29764. static readonly ALWAYS: number;
  29765. /** Passed to stencilOperation to specify that stencil value must be kept */
  29766. static readonly KEEP: number;
  29767. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29768. static readonly REPLACE: number;
  29769. private _isStencilTestDirty;
  29770. private _isStencilMaskDirty;
  29771. private _isStencilFuncDirty;
  29772. private _isStencilOpDirty;
  29773. private _stencilTest;
  29774. private _stencilMask;
  29775. private _stencilFunc;
  29776. private _stencilFuncRef;
  29777. private _stencilFuncMask;
  29778. private _stencilOpStencilFail;
  29779. private _stencilOpDepthFail;
  29780. private _stencilOpStencilDepthPass;
  29781. readonly isDirty: boolean;
  29782. stencilFunc: number;
  29783. stencilFuncRef: number;
  29784. stencilFuncMask: number;
  29785. stencilOpStencilFail: number;
  29786. stencilOpDepthFail: number;
  29787. stencilOpStencilDepthPass: number;
  29788. stencilMask: number;
  29789. stencilTest: boolean;
  29790. constructor();
  29791. reset(): void;
  29792. apply(gl: WebGLRenderingContext): void;
  29793. }
  29794. }
  29795. declare module "babylonjs/States/alphaCullingState" {
  29796. /**
  29797. * @hidden
  29798. **/
  29799. export class AlphaState {
  29800. private _isAlphaBlendDirty;
  29801. private _isBlendFunctionParametersDirty;
  29802. private _isBlendEquationParametersDirty;
  29803. private _isBlendConstantsDirty;
  29804. private _alphaBlend;
  29805. private _blendFunctionParameters;
  29806. private _blendEquationParameters;
  29807. private _blendConstants;
  29808. /**
  29809. * Initializes the state.
  29810. */
  29811. constructor();
  29812. readonly isDirty: boolean;
  29813. alphaBlend: boolean;
  29814. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29815. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29816. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29817. reset(): void;
  29818. apply(gl: WebGLRenderingContext): void;
  29819. }
  29820. }
  29821. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29822. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29823. /** @hidden */
  29824. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29825. attributeProcessor(attribute: string): string;
  29826. varyingProcessor(varying: string, isFragment: boolean): string;
  29827. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29828. }
  29829. }
  29830. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29831. /**
  29832. * Interface for attribute information associated with buffer instanciation
  29833. */
  29834. export class InstancingAttributeInfo {
  29835. /**
  29836. * Index/offset of the attribute in the vertex shader
  29837. */
  29838. index: number;
  29839. /**
  29840. * size of the attribute, 1, 2, 3 or 4
  29841. */
  29842. attributeSize: number;
  29843. /**
  29844. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29845. * default is FLOAT
  29846. */
  29847. attribyteType: number;
  29848. /**
  29849. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29850. */
  29851. normalized: boolean;
  29852. /**
  29853. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29854. */
  29855. offset: number;
  29856. /**
  29857. * Name of the GLSL attribute, for debugging purpose only
  29858. */
  29859. attributeName: string;
  29860. }
  29861. }
  29862. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29864. import { Nullable } from "babylonjs/types";
  29865. module "babylonjs/Engines/thinEngine" {
  29866. interface ThinEngine {
  29867. /**
  29868. * Update a video texture
  29869. * @param texture defines the texture to update
  29870. * @param video defines the video element to use
  29871. * @param invertY defines if data must be stored with Y axis inverted
  29872. */
  29873. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29874. }
  29875. }
  29876. }
  29877. declare module "babylonjs/Materials/Textures/videoTexture" {
  29878. import { Observable } from "babylonjs/Misc/observable";
  29879. import { Nullable } from "babylonjs/types";
  29880. import { Scene } from "babylonjs/scene";
  29881. import { Texture } from "babylonjs/Materials/Textures/texture";
  29882. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29883. /**
  29884. * Settings for finer control over video usage
  29885. */
  29886. export interface VideoTextureSettings {
  29887. /**
  29888. * Applies `autoplay` to video, if specified
  29889. */
  29890. autoPlay?: boolean;
  29891. /**
  29892. * Applies `loop` to video, if specified
  29893. */
  29894. loop?: boolean;
  29895. /**
  29896. * Automatically updates internal texture from video at every frame in the render loop
  29897. */
  29898. autoUpdateTexture: boolean;
  29899. /**
  29900. * Image src displayed during the video loading or until the user interacts with the video.
  29901. */
  29902. poster?: string;
  29903. }
  29904. /**
  29905. * If you want to display a video in your scene, this is the special texture for that.
  29906. * This special texture works similar to other textures, with the exception of a few parameters.
  29907. * @see https://doc.babylonjs.com/how_to/video_texture
  29908. */
  29909. export class VideoTexture extends Texture {
  29910. /**
  29911. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29912. */
  29913. readonly autoUpdateTexture: boolean;
  29914. /**
  29915. * The video instance used by the texture internally
  29916. */
  29917. readonly video: HTMLVideoElement;
  29918. private _onUserActionRequestedObservable;
  29919. /**
  29920. * Event triggerd when a dom action is required by the user to play the video.
  29921. * This happens due to recent changes in browser policies preventing video to auto start.
  29922. */
  29923. readonly onUserActionRequestedObservable: Observable<Texture>;
  29924. private _generateMipMaps;
  29925. private _engine;
  29926. private _stillImageCaptured;
  29927. private _displayingPosterTexture;
  29928. private _settings;
  29929. private _createInternalTextureOnEvent;
  29930. private _frameId;
  29931. /**
  29932. * Creates a video texture.
  29933. * If you want to display a video in your scene, this is the special texture for that.
  29934. * This special texture works similar to other textures, with the exception of a few parameters.
  29935. * @see https://doc.babylonjs.com/how_to/video_texture
  29936. * @param name optional name, will detect from video source, if not defined
  29937. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29938. * @param scene is obviously the current scene.
  29939. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29940. * @param invertY is false by default but can be used to invert video on Y axis
  29941. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29942. * @param settings allows finer control over video usage
  29943. */
  29944. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29945. private _getName;
  29946. private _getVideo;
  29947. private _createInternalTexture;
  29948. private reset;
  29949. /**
  29950. * @hidden Internal method to initiate `update`.
  29951. */
  29952. _rebuild(): void;
  29953. /**
  29954. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29955. */
  29956. update(): void;
  29957. /**
  29958. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29959. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29960. */
  29961. updateTexture(isVisible: boolean): void;
  29962. protected _updateInternalTexture: () => void;
  29963. /**
  29964. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29965. * @param url New url.
  29966. */
  29967. updateURL(url: string): void;
  29968. /**
  29969. * Dispose the texture and release its associated resources.
  29970. */
  29971. dispose(): void;
  29972. /**
  29973. * Creates a video texture straight from a stream.
  29974. * @param scene Define the scene the texture should be created in
  29975. * @param stream Define the stream the texture should be created from
  29976. * @returns The created video texture as a promise
  29977. */
  29978. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29979. /**
  29980. * Creates a video texture straight from your WebCam video feed.
  29981. * @param scene Define the scene the texture should be created in
  29982. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29983. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29984. * @returns The created video texture as a promise
  29985. */
  29986. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29987. minWidth: number;
  29988. maxWidth: number;
  29989. minHeight: number;
  29990. maxHeight: number;
  29991. deviceId: string;
  29992. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29993. /**
  29994. * Creates a video texture straight from your WebCam video feed.
  29995. * @param scene Define the scene the texture should be created in
  29996. * @param onReady Define a callback to triggered once the texture will be ready
  29997. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29998. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29999. */
  30000. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30001. minWidth: number;
  30002. maxWidth: number;
  30003. minHeight: number;
  30004. maxHeight: number;
  30005. deviceId: string;
  30006. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30007. }
  30008. }
  30009. declare module "babylonjs/Engines/thinEngine" {
  30010. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30011. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  30012. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30013. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30014. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30015. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30016. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30017. import { Observable } from "babylonjs/Misc/observable";
  30018. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30019. import { StencilState } from "babylonjs/States/stencilState";
  30020. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30021. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30022. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30024. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30025. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30026. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30027. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30028. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30029. import { WebRequest } from "babylonjs/Misc/webRequest";
  30030. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  30031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30032. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30033. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30034. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30035. /**
  30036. * Defines the interface used by objects working like Scene
  30037. * @hidden
  30038. */
  30039. interface ISceneLike {
  30040. _addPendingData(data: any): void;
  30041. _removePendingData(data: any): void;
  30042. offlineProvider: IOfflineProvider;
  30043. }
  30044. /** Interface defining initialization parameters for Engine class */
  30045. export interface EngineOptions extends WebGLContextAttributes {
  30046. /**
  30047. * Defines if the engine should no exceed a specified device ratio
  30048. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30049. */
  30050. limitDeviceRatio?: number;
  30051. /**
  30052. * Defines if webvr should be enabled automatically
  30053. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30054. */
  30055. autoEnableWebVR?: boolean;
  30056. /**
  30057. * Defines if webgl2 should be turned off even if supported
  30058. * @see http://doc.babylonjs.com/features/webgl2
  30059. */
  30060. disableWebGL2Support?: boolean;
  30061. /**
  30062. * Defines if webaudio should be initialized as well
  30063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30064. */
  30065. audioEngine?: boolean;
  30066. /**
  30067. * Defines if animations should run using a deterministic lock step
  30068. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30069. */
  30070. deterministicLockstep?: boolean;
  30071. /** Defines the maximum steps to use with deterministic lock step mode */
  30072. lockstepMaxSteps?: number;
  30073. /**
  30074. * Defines that engine should ignore context lost events
  30075. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30076. */
  30077. doNotHandleContextLost?: boolean;
  30078. /**
  30079. * Defines that engine should ignore modifying touch action attribute and style
  30080. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30081. */
  30082. doNotHandleTouchAction?: boolean;
  30083. /**
  30084. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30085. */
  30086. useHighPrecisionFloats?: boolean;
  30087. }
  30088. /**
  30089. * The base engine class (root of all engines)
  30090. */
  30091. export class ThinEngine {
  30092. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30093. static ExceptionList: ({
  30094. key: string;
  30095. capture: string;
  30096. captureConstraint: number;
  30097. targets: string[];
  30098. } | {
  30099. key: string;
  30100. capture: null;
  30101. captureConstraint: null;
  30102. targets: string[];
  30103. })[];
  30104. /** @hidden */
  30105. static _TextureLoaders: IInternalTextureLoader[];
  30106. /**
  30107. * Returns the current npm package of the sdk
  30108. */
  30109. static readonly NpmPackage: string;
  30110. /**
  30111. * Returns the current version of the framework
  30112. */
  30113. static readonly Version: string;
  30114. /**
  30115. * Returns a string describing the current engine
  30116. */
  30117. readonly description: string;
  30118. /**
  30119. * Gets or sets the epsilon value used by collision engine
  30120. */
  30121. static CollisionsEpsilon: number;
  30122. /**
  30123. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30124. */
  30125. static ShadersRepository: string;
  30126. /** @hidden */
  30127. _shaderProcessor: IShaderProcessor;
  30128. /**
  30129. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30130. */
  30131. forcePOTTextures: boolean;
  30132. /**
  30133. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30134. */
  30135. isFullscreen: boolean;
  30136. /**
  30137. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30138. */
  30139. cullBackFaces: boolean;
  30140. /**
  30141. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30142. */
  30143. renderEvenInBackground: boolean;
  30144. /**
  30145. * Gets or sets a boolean indicating that cache can be kept between frames
  30146. */
  30147. preventCacheWipeBetweenFrames: boolean;
  30148. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30149. validateShaderPrograms: boolean;
  30150. /**
  30151. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30152. */
  30153. disableUniformBuffers: boolean;
  30154. /** @hidden */
  30155. _uniformBuffers: UniformBuffer[];
  30156. /**
  30157. * Gets a boolean indicating that the engine supports uniform buffers
  30158. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30159. */
  30160. readonly supportsUniformBuffers: boolean;
  30161. /** @hidden */
  30162. _gl: WebGLRenderingContext;
  30163. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30164. protected _windowIsBackground: boolean;
  30165. protected _webGLVersion: number;
  30166. protected _highPrecisionShadersAllowed: boolean;
  30167. /** @hidden */
  30168. readonly _shouldUseHighPrecisionShader: boolean;
  30169. /**
  30170. * Gets a boolean indicating that only power of 2 textures are supported
  30171. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30172. */
  30173. readonly needPOTTextures: boolean;
  30174. /** @hidden */
  30175. _badOS: boolean;
  30176. /** @hidden */
  30177. _badDesktopOS: boolean;
  30178. private _hardwareScalingLevel;
  30179. /** @hidden */
  30180. _caps: EngineCapabilities;
  30181. private _isStencilEnable;
  30182. protected _colorWrite: boolean;
  30183. /** @hidden */
  30184. _drawCalls: PerfCounter;
  30185. private _glVersion;
  30186. private _glRenderer;
  30187. private _glVendor;
  30188. /** @hidden */
  30189. _videoTextureSupported: boolean;
  30190. protected _renderingQueueLaunched: boolean;
  30191. protected _activeRenderLoops: (() => void)[];
  30192. /**
  30193. * Observable signaled when a context lost event is raised
  30194. */
  30195. onContextLostObservable: Observable<ThinEngine>;
  30196. /**
  30197. * Observable signaled when a context restored event is raised
  30198. */
  30199. onContextRestoredObservable: Observable<ThinEngine>;
  30200. private _onContextLost;
  30201. private _onContextRestored;
  30202. protected _contextWasLost: boolean;
  30203. /** @hidden */
  30204. _doNotHandleContextLost: boolean;
  30205. /**
  30206. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30208. */
  30209. doNotHandleContextLost: boolean;
  30210. /**
  30211. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30212. */
  30213. disableVertexArrayObjects: boolean;
  30214. /** @hidden */
  30215. protected _depthCullingState: DepthCullingState;
  30216. /** @hidden */
  30217. protected _stencilState: StencilState;
  30218. /** @hidden */
  30219. protected _alphaState: AlphaState;
  30220. /** @hidden */
  30221. _internalTexturesCache: InternalTexture[];
  30222. /** @hidden */
  30223. protected _activeChannel: number;
  30224. private _currentTextureChannel;
  30225. /** @hidden */
  30226. protected _boundTexturesCache: {
  30227. [key: string]: Nullable<InternalTexture>;
  30228. };
  30229. /** @hidden */
  30230. protected _currentEffect: Nullable<Effect>;
  30231. /** @hidden */
  30232. protected _currentProgram: Nullable<WebGLProgram>;
  30233. private _compiledEffects;
  30234. private _vertexAttribArraysEnabled;
  30235. /** @hidden */
  30236. protected _cachedViewport: Nullable<IViewportLike>;
  30237. private _cachedVertexArrayObject;
  30238. /** @hidden */
  30239. protected _cachedVertexBuffers: any;
  30240. /** @hidden */
  30241. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30242. /** @hidden */
  30243. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30244. /** @hidden */
  30245. _currentRenderTarget: Nullable<InternalTexture>;
  30246. private _uintIndicesCurrentlySet;
  30247. private _currentBoundBuffer;
  30248. /** @hidden */
  30249. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30250. private _currentBufferPointers;
  30251. private _currentInstanceLocations;
  30252. private _currentInstanceBuffers;
  30253. private _textureUnits;
  30254. /** @hidden */
  30255. _workingCanvas: Nullable<HTMLCanvasElement>;
  30256. /** @hidden */
  30257. _workingContext: Nullable<CanvasRenderingContext2D>;
  30258. /** @hidden */
  30259. _bindedRenderFunction: any;
  30260. private _vaoRecordInProgress;
  30261. private _mustWipeVertexAttributes;
  30262. private _emptyTexture;
  30263. private _emptyCubeTexture;
  30264. private _emptyTexture3D;
  30265. /** @hidden */
  30266. _frameHandler: number;
  30267. private _nextFreeTextureSlots;
  30268. private _maxSimultaneousTextures;
  30269. private _activeRequests;
  30270. protected _texturesSupported: string[];
  30271. /** @hidden */
  30272. _textureFormatInUse: Nullable<string>;
  30273. protected readonly _supportsHardwareTextureRescaling: boolean;
  30274. /**
  30275. * Gets the list of texture formats supported
  30276. */
  30277. readonly texturesSupported: Array<string>;
  30278. /**
  30279. * Gets the list of texture formats in use
  30280. */
  30281. readonly textureFormatInUse: Nullable<string>;
  30282. /**
  30283. * Gets the current viewport
  30284. */
  30285. readonly currentViewport: Nullable<IViewportLike>;
  30286. /**
  30287. * Gets the default empty texture
  30288. */
  30289. readonly emptyTexture: InternalTexture;
  30290. /**
  30291. * Gets the default empty 3D texture
  30292. */
  30293. readonly emptyTexture3D: InternalTexture;
  30294. /**
  30295. * Gets the default empty cube texture
  30296. */
  30297. readonly emptyCubeTexture: InternalTexture;
  30298. /**
  30299. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30300. */
  30301. readonly premultipliedAlpha: boolean;
  30302. /**
  30303. * Creates a new engine
  30304. * @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
  30305. * @param antialias defines enable antialiasing (default: false)
  30306. * @param options defines further options to be sent to the getContext() function
  30307. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30308. */
  30309. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30310. private _rebuildInternalTextures;
  30311. private _rebuildEffects;
  30312. /**
  30313. * Gets a boolean indicating if all created effects are ready
  30314. * @returns true if all effects are ready
  30315. */
  30316. areAllEffectsReady(): boolean;
  30317. protected _rebuildBuffers(): void;
  30318. private _initGLContext;
  30319. /**
  30320. * Gets version of the current webGL context
  30321. */
  30322. readonly webGLVersion: number;
  30323. /**
  30324. * Gets a string idenfifying the name of the class
  30325. * @returns "Engine" string
  30326. */
  30327. getClassName(): string;
  30328. /**
  30329. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30330. */
  30331. readonly isStencilEnable: boolean;
  30332. /** @hidden */
  30333. _prepareWorkingCanvas(): void;
  30334. /**
  30335. * Reset the texture cache to empty state
  30336. */
  30337. resetTextureCache(): void;
  30338. /**
  30339. * Gets an object containing information about the current webGL context
  30340. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30341. */
  30342. getGlInfo(): {
  30343. vendor: string;
  30344. renderer: string;
  30345. version: string;
  30346. };
  30347. /**
  30348. * Defines the hardware scaling level.
  30349. * By default the hardware scaling level is computed from the window device ratio.
  30350. * 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.
  30351. * @param level defines the level to use
  30352. */
  30353. setHardwareScalingLevel(level: number): void;
  30354. /**
  30355. * Gets the current hardware scaling level.
  30356. * By default the hardware scaling level is computed from the window device ratio.
  30357. * 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.
  30358. * @returns a number indicating the current hardware scaling level
  30359. */
  30360. getHardwareScalingLevel(): number;
  30361. /**
  30362. * Gets the list of loaded textures
  30363. * @returns an array containing all loaded textures
  30364. */
  30365. getLoadedTexturesCache(): InternalTexture[];
  30366. /**
  30367. * Gets the object containing all engine capabilities
  30368. * @returns the EngineCapabilities object
  30369. */
  30370. getCaps(): EngineCapabilities;
  30371. /**
  30372. * stop executing a render loop function and remove it from the execution array
  30373. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30374. */
  30375. stopRenderLoop(renderFunction?: () => void): void;
  30376. /** @hidden */
  30377. _renderLoop(): void;
  30378. /**
  30379. * Gets the HTML canvas attached with the current webGL context
  30380. * @returns a HTML canvas
  30381. */
  30382. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30383. /**
  30384. * Gets host window
  30385. * @returns the host window object
  30386. */
  30387. getHostWindow(): Window;
  30388. /**
  30389. * Gets the current render width
  30390. * @param useScreen defines if screen size must be used (or the current render target if any)
  30391. * @returns a number defining the current render width
  30392. */
  30393. getRenderWidth(useScreen?: boolean): number;
  30394. /**
  30395. * Gets the current render height
  30396. * @param useScreen defines if screen size must be used (or the current render target if any)
  30397. * @returns a number defining the current render height
  30398. */
  30399. getRenderHeight(useScreen?: boolean): number;
  30400. /**
  30401. * Can be used to override the current requestAnimationFrame requester.
  30402. * @hidden
  30403. */
  30404. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30405. /**
  30406. * Register and execute a render loop. The engine can have more than one render function
  30407. * @param renderFunction defines the function to continuously execute
  30408. */
  30409. runRenderLoop(renderFunction: () => void): void;
  30410. /**
  30411. * Clear the current render buffer or the current render target (if any is set up)
  30412. * @param color defines the color to use
  30413. * @param backBuffer defines if the back buffer must be cleared
  30414. * @param depth defines if the depth buffer must be cleared
  30415. * @param stencil defines if the stencil buffer must be cleared
  30416. */
  30417. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30418. private _viewportCached;
  30419. /** @hidden */
  30420. _viewport(x: number, y: number, width: number, height: number): void;
  30421. /**
  30422. * Set the WebGL's viewport
  30423. * @param viewport defines the viewport element to be used
  30424. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30425. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30426. */
  30427. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30428. /**
  30429. * Begin a new frame
  30430. */
  30431. beginFrame(): void;
  30432. /**
  30433. * Enf the current frame
  30434. */
  30435. endFrame(): void;
  30436. /**
  30437. * Resize the view according to the canvas' size
  30438. */
  30439. resize(): void;
  30440. /**
  30441. * Force a specific size of the canvas
  30442. * @param width defines the new canvas' width
  30443. * @param height defines the new canvas' height
  30444. */
  30445. setSize(width: number, height: number): void;
  30446. /**
  30447. * Binds the frame buffer to the specified texture.
  30448. * @param texture The texture to render to or null for the default canvas
  30449. * @param faceIndex The face of the texture to render to in case of cube texture
  30450. * @param requiredWidth The width of the target to render to
  30451. * @param requiredHeight The height of the target to render to
  30452. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30453. * @param depthStencilTexture The depth stencil texture to use to render
  30454. * @param lodLevel defines le lod level to bind to the frame buffer
  30455. */
  30456. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30457. /** @hidden */
  30458. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30459. /**
  30460. * Unbind the current render target texture from the webGL context
  30461. * @param texture defines the render target texture to unbind
  30462. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30463. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30464. */
  30465. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30466. /**
  30467. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30468. */
  30469. flushFramebuffer(): void;
  30470. /**
  30471. * Unbind the current render target and bind the default framebuffer
  30472. */
  30473. restoreDefaultFramebuffer(): void;
  30474. private _resetVertexBufferBinding;
  30475. /**
  30476. * Creates a vertex buffer
  30477. * @param data the data for the vertex buffer
  30478. * @returns the new WebGL static buffer
  30479. */
  30480. createVertexBuffer(data: DataArray): DataBuffer;
  30481. private _createVertexBuffer;
  30482. /**
  30483. * Creates a dynamic vertex buffer
  30484. * @param data the data for the dynamic vertex buffer
  30485. * @returns the new WebGL dynamic buffer
  30486. */
  30487. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30488. /**
  30489. * Update a dynamic index buffer
  30490. * @param indexBuffer defines the target index buffer
  30491. * @param indices defines the data to update
  30492. * @param offset defines the offset in the target index buffer where update should start
  30493. */
  30494. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30495. /**
  30496. * Updates a dynamic vertex buffer.
  30497. * @param vertexBuffer the vertex buffer to update
  30498. * @param data the data used to update the vertex buffer
  30499. * @param byteOffset the byte offset of the data
  30500. * @param byteLength the byte length of the data
  30501. */
  30502. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30503. private _resetIndexBufferBinding;
  30504. /**
  30505. * Creates a new index buffer
  30506. * @param indices defines the content of the index buffer
  30507. * @param updatable defines if the index buffer must be updatable
  30508. * @returns a new webGL buffer
  30509. */
  30510. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30511. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30512. /**
  30513. * Bind a webGL buffer to the webGL context
  30514. * @param buffer defines the buffer to bind
  30515. */
  30516. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30517. private bindIndexBuffer;
  30518. private bindBuffer;
  30519. /**
  30520. * update the bound buffer with the given data
  30521. * @param data defines the data to update
  30522. */
  30523. updateArrayBuffer(data: Float32Array): void;
  30524. private _vertexAttribPointer;
  30525. private _bindIndexBufferWithCache;
  30526. private _bindVertexBuffersAttributes;
  30527. /**
  30528. * Records a vertex array object
  30529. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30530. * @param vertexBuffers defines the list of vertex buffers to store
  30531. * @param indexBuffer defines the index buffer to store
  30532. * @param effect defines the effect to store
  30533. * @returns the new vertex array object
  30534. */
  30535. recordVertexArrayObject(vertexBuffers: {
  30536. [key: string]: VertexBuffer;
  30537. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30538. /**
  30539. * Bind a specific vertex array object
  30540. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30541. * @param vertexArrayObject defines the vertex array object to bind
  30542. * @param indexBuffer defines the index buffer to bind
  30543. */
  30544. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30545. /**
  30546. * Bind webGl buffers directly to the webGL context
  30547. * @param vertexBuffer defines the vertex buffer to bind
  30548. * @param indexBuffer defines the index buffer to bind
  30549. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30550. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30551. * @param effect defines the effect associated with the vertex buffer
  30552. */
  30553. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30554. private _unbindVertexArrayObject;
  30555. /**
  30556. * Bind a list of vertex buffers to the webGL context
  30557. * @param vertexBuffers defines the list of vertex buffers to bind
  30558. * @param indexBuffer defines the index buffer to bind
  30559. * @param effect defines the effect associated with the vertex buffers
  30560. */
  30561. bindBuffers(vertexBuffers: {
  30562. [key: string]: Nullable<VertexBuffer>;
  30563. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30564. /**
  30565. * Unbind all instance attributes
  30566. */
  30567. unbindInstanceAttributes(): void;
  30568. /**
  30569. * Release and free the memory of a vertex array object
  30570. * @param vao defines the vertex array object to delete
  30571. */
  30572. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30573. /** @hidden */
  30574. _releaseBuffer(buffer: DataBuffer): boolean;
  30575. protected _deleteBuffer(buffer: DataBuffer): void;
  30576. /**
  30577. * Creates a webGL buffer to use with instanciation
  30578. * @param capacity defines the size of the buffer
  30579. * @returns the webGL buffer
  30580. */
  30581. createInstancesBuffer(capacity: number): DataBuffer;
  30582. /**
  30583. * Delete a webGL buffer used with instanciation
  30584. * @param buffer defines the webGL buffer to delete
  30585. */
  30586. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30587. /**
  30588. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30589. * @param instancesBuffer defines the webGL buffer to update and bind
  30590. * @param data defines the data to store in the buffer
  30591. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30592. */
  30593. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30594. /**
  30595. * Apply all cached states (depth, culling, stencil and alpha)
  30596. */
  30597. applyStates(): void;
  30598. /**
  30599. * Send a draw order
  30600. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30601. * @param indexStart defines the starting index
  30602. * @param indexCount defines the number of index to draw
  30603. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30604. */
  30605. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30606. /**
  30607. * Draw a list of points
  30608. * @param verticesStart defines the index of first vertex to draw
  30609. * @param verticesCount defines the count of vertices to draw
  30610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30611. */
  30612. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30613. /**
  30614. * Draw a list of unindexed primitives
  30615. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30616. * @param verticesStart defines the index of first vertex to draw
  30617. * @param verticesCount defines the count of vertices to draw
  30618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30619. */
  30620. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30621. /**
  30622. * Draw a list of indexed primitives
  30623. * @param fillMode defines the primitive to use
  30624. * @param indexStart defines the starting index
  30625. * @param indexCount defines the number of index to draw
  30626. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30627. */
  30628. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30629. /**
  30630. * Draw a list of unindexed primitives
  30631. * @param fillMode defines the primitive to use
  30632. * @param verticesStart defines the index of first vertex to draw
  30633. * @param verticesCount defines the count of vertices to draw
  30634. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30635. */
  30636. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30637. private _drawMode;
  30638. /** @hidden */
  30639. _releaseEffect(effect: Effect): void;
  30640. /** @hidden */
  30641. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30642. /**
  30643. * Create a new effect (used to store vertex/fragment shaders)
  30644. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30645. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30646. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30647. * @param samplers defines an array of string used to represent textures
  30648. * @param defines defines the string containing the defines to use to compile the shaders
  30649. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30650. * @param onCompiled defines a function to call when the effect creation is successful
  30651. * @param onError defines a function to call when the effect creation has failed
  30652. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30653. * @returns the new Effect
  30654. */
  30655. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30656. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30657. private _compileShader;
  30658. private _compileRawShader;
  30659. /**
  30660. * Directly creates a webGL program
  30661. * @param pipelineContext defines the pipeline context to attach to
  30662. * @param vertexCode defines the vertex shader code to use
  30663. * @param fragmentCode defines the fragment shader code to use
  30664. * @param context defines the webGL context to use (if not set, the current one will be used)
  30665. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30666. * @returns the new webGL program
  30667. */
  30668. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30669. /**
  30670. * Creates a webGL program
  30671. * @param pipelineContext defines the pipeline context to attach to
  30672. * @param vertexCode defines the vertex shader code to use
  30673. * @param fragmentCode defines the fragment shader code to use
  30674. * @param defines defines the string containing the defines to use to compile the shaders
  30675. * @param context defines the webGL context to use (if not set, the current one will be used)
  30676. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30677. * @returns the new webGL program
  30678. */
  30679. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30680. /**
  30681. * Creates a new pipeline context
  30682. * @returns the new pipeline
  30683. */
  30684. createPipelineContext(): IPipelineContext;
  30685. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30686. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30687. /** @hidden */
  30688. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30689. /** @hidden */
  30690. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30691. /** @hidden */
  30692. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30693. /**
  30694. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30695. * @param pipelineContext defines the pipeline context to use
  30696. * @param uniformsNames defines the list of uniform names
  30697. * @returns an array of webGL uniform locations
  30698. */
  30699. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30700. /**
  30701. * Gets the lsit of active attributes for a given webGL program
  30702. * @param pipelineContext defines the pipeline context to use
  30703. * @param attributesNames defines the list of attribute names to get
  30704. * @returns an array of indices indicating the offset of each attribute
  30705. */
  30706. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30707. /**
  30708. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30709. * @param effect defines the effect to activate
  30710. */
  30711. enableEffect(effect: Nullable<Effect>): void;
  30712. /**
  30713. * Set the value of an uniform to an array of int32
  30714. * @param uniform defines the webGL uniform location where to store the value
  30715. * @param array defines the array of int32 to store
  30716. */
  30717. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30718. /**
  30719. * Set the value of an uniform to an array of int32 (stored as vec2)
  30720. * @param uniform defines the webGL uniform location where to store the value
  30721. * @param array defines the array of int32 to store
  30722. */
  30723. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30724. /**
  30725. * Set the value of an uniform to an array of int32 (stored as vec3)
  30726. * @param uniform defines the webGL uniform location where to store the value
  30727. * @param array defines the array of int32 to store
  30728. */
  30729. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30730. /**
  30731. * Set the value of an uniform to an array of int32 (stored as vec4)
  30732. * @param uniform defines the webGL uniform location where to store the value
  30733. * @param array defines the array of int32 to store
  30734. */
  30735. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30736. /**
  30737. * Set the value of an uniform to an array of float32
  30738. * @param uniform defines the webGL uniform location where to store the value
  30739. * @param array defines the array of float32 to store
  30740. */
  30741. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30742. /**
  30743. * Set the value of an uniform to an array of float32 (stored as vec2)
  30744. * @param uniform defines the webGL uniform location where to store the value
  30745. * @param array defines the array of float32 to store
  30746. */
  30747. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30748. /**
  30749. * Set the value of an uniform to an array of float32 (stored as vec3)
  30750. * @param uniform defines the webGL uniform location where to store the value
  30751. * @param array defines the array of float32 to store
  30752. */
  30753. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30754. /**
  30755. * Set the value of an uniform to an array of float32 (stored as vec4)
  30756. * @param uniform defines the webGL uniform location where to store the value
  30757. * @param array defines the array of float32 to store
  30758. */
  30759. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30760. /**
  30761. * Set the value of an uniform to an array of number
  30762. * @param uniform defines the webGL uniform location where to store the value
  30763. * @param array defines the array of number to store
  30764. */
  30765. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30766. /**
  30767. * Set the value of an uniform to an array of number (stored as vec2)
  30768. * @param uniform defines the webGL uniform location where to store the value
  30769. * @param array defines the array of number to store
  30770. */
  30771. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30772. /**
  30773. * Set the value of an uniform to an array of number (stored as vec3)
  30774. * @param uniform defines the webGL uniform location where to store the value
  30775. * @param array defines the array of number to store
  30776. */
  30777. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30778. /**
  30779. * Set the value of an uniform to an array of number (stored as vec4)
  30780. * @param uniform defines the webGL uniform location where to store the value
  30781. * @param array defines the array of number to store
  30782. */
  30783. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30784. /**
  30785. * Set the value of an uniform to an array of float32 (stored as matrices)
  30786. * @param uniform defines the webGL uniform location where to store the value
  30787. * @param matrices defines the array of float32 to store
  30788. */
  30789. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30790. /**
  30791. * Set the value of an uniform to a matrix (3x3)
  30792. * @param uniform defines the webGL uniform location where to store the value
  30793. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30794. */
  30795. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30796. /**
  30797. * Set the value of an uniform to a matrix (2x2)
  30798. * @param uniform defines the webGL uniform location where to store the value
  30799. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30800. */
  30801. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30802. /**
  30803. * Set the value of an uniform to a number (int)
  30804. * @param uniform defines the webGL uniform location where to store the value
  30805. * @param value defines the int number to store
  30806. */
  30807. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30808. /**
  30809. * Set the value of an uniform to a number (float)
  30810. * @param uniform defines the webGL uniform location where to store the value
  30811. * @param value defines the float number to store
  30812. */
  30813. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30814. /**
  30815. * Set the value of an uniform to a vec2
  30816. * @param uniform defines the webGL uniform location where to store the value
  30817. * @param x defines the 1st component of the value
  30818. * @param y defines the 2nd component of the value
  30819. */
  30820. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30821. /**
  30822. * Set the value of an uniform to a vec3
  30823. * @param uniform defines the webGL uniform location where to store the value
  30824. * @param x defines the 1st component of the value
  30825. * @param y defines the 2nd component of the value
  30826. * @param z defines the 3rd component of the value
  30827. */
  30828. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30829. /**
  30830. * Set the value of an uniform to a boolean
  30831. * @param uniform defines the webGL uniform location where to store the value
  30832. * @param bool defines the boolean to store
  30833. */
  30834. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30835. /**
  30836. * Set the value of an uniform to a vec4
  30837. * @param uniform defines the webGL uniform location where to store the value
  30838. * @param x defines the 1st component of the value
  30839. * @param y defines the 2nd component of the value
  30840. * @param z defines the 3rd component of the value
  30841. * @param w defines the 4th component of the value
  30842. */
  30843. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30844. /**
  30845. * Sets a Color4 on a uniform variable
  30846. * @param uniform defines the uniform location
  30847. * @param color4 defines the value to be set
  30848. */
  30849. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30850. /**
  30851. * Gets the depth culling state manager
  30852. */
  30853. readonly depthCullingState: DepthCullingState;
  30854. /**
  30855. * Gets the alpha state manager
  30856. */
  30857. readonly alphaState: AlphaState;
  30858. /**
  30859. * Gets the stencil state manager
  30860. */
  30861. readonly stencilState: StencilState;
  30862. /**
  30863. * Clears the list of texture accessible through engine.
  30864. * This can help preventing texture load conflict due to name collision.
  30865. */
  30866. clearInternalTexturesCache(): void;
  30867. /**
  30868. * Force the entire cache to be cleared
  30869. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30870. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30871. */
  30872. wipeCaches(bruteForce?: boolean): void;
  30873. /** @hidden */
  30874. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30875. min: number;
  30876. mag: number;
  30877. };
  30878. /** @hidden */
  30879. _createTexture(): WebGLTexture;
  30880. /**
  30881. * Usually called from Texture.ts.
  30882. * Passed information to create a WebGLTexture
  30883. * @param urlArg defines a value which contains one of the following:
  30884. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30885. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30886. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30887. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30888. * @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)
  30889. * @param scene needed for loading to the correct scene
  30890. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30891. * @param onLoad optional callback to be called upon successful completion
  30892. * @param onError optional callback to be called upon failure
  30893. * @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
  30894. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30895. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30896. * @param forcedExtension defines the extension to use to pick the right loader
  30897. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30898. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30899. */
  30900. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30901. /**
  30902. * @hidden
  30903. */
  30904. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30905. /**
  30906. * Creates a raw texture
  30907. * @param data defines the data to store in the texture
  30908. * @param width defines the width of the texture
  30909. * @param height defines the height of the texture
  30910. * @param format defines the format of the data
  30911. * @param generateMipMaps defines if the engine should generate the mip levels
  30912. * @param invertY defines if data must be stored with Y axis inverted
  30913. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30914. * @param compression defines the compression used (null by default)
  30915. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30916. * @returns the raw texture inside an InternalTexture
  30917. */
  30918. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30919. /**
  30920. * Creates a new raw cube texture
  30921. * @param data defines the array of data to use to create each face
  30922. * @param size defines the size of the textures
  30923. * @param format defines the format of the data
  30924. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30925. * @param generateMipMaps defines if the engine should generate the mip levels
  30926. * @param invertY defines if data must be stored with Y axis inverted
  30927. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30928. * @param compression defines the compression used (null by default)
  30929. * @returns the cube texture as an InternalTexture
  30930. */
  30931. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30932. /**
  30933. * Creates a new raw 3D texture
  30934. * @param data defines the data used to create the texture
  30935. * @param width defines the width of the texture
  30936. * @param height defines the height of the texture
  30937. * @param depth defines the depth of the texture
  30938. * @param format defines the format of the texture
  30939. * @param generateMipMaps defines if the engine must generate mip levels
  30940. * @param invertY defines if data must be stored with Y axis inverted
  30941. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30942. * @param compression defines the compressed used (can be null)
  30943. * @param textureType defines the compressed used (can be null)
  30944. * @returns a new raw 3D texture (stored in an InternalTexture)
  30945. */
  30946. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30947. private _unpackFlipYCached;
  30948. /**
  30949. * In case you are sharing the context with other applications, it might
  30950. * be interested to not cache the unpack flip y state to ensure a consistent
  30951. * value would be set.
  30952. */
  30953. enableUnpackFlipYCached: boolean;
  30954. /** @hidden */
  30955. _unpackFlipY(value: boolean): void;
  30956. /** @hidden */
  30957. _getUnpackAlignement(): number;
  30958. /**
  30959. * Update the sampling mode of a given texture
  30960. * @param samplingMode defines the required sampling mode
  30961. * @param texture defines the texture to update
  30962. */
  30963. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30964. /**
  30965. * Updates a depth texture Comparison Mode and Function.
  30966. * If the comparison Function is equal to 0, the mode will be set to none.
  30967. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30968. * @param texture The texture to set the comparison function for
  30969. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30970. */
  30971. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30972. /** @hidden */
  30973. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30974. width: number;
  30975. height: number;
  30976. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30977. /**
  30978. * Creates a depth stencil texture.
  30979. * This is only available in WebGL 2 or with the depth texture extension available.
  30980. * @param size The size of face edge in the texture.
  30981. * @param options The options defining the texture.
  30982. * @returns The texture
  30983. */
  30984. createDepthStencilTexture(size: number | {
  30985. width: number;
  30986. height: number;
  30987. }, options: DepthTextureCreationOptions): InternalTexture;
  30988. /**
  30989. * Creates a depth stencil texture.
  30990. * This is only available in WebGL 2 or with the depth texture extension available.
  30991. * @param size The size of face edge in the texture.
  30992. * @param options The options defining the texture.
  30993. * @returns The texture
  30994. */
  30995. private _createDepthStencilTexture;
  30996. /**
  30997. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30998. * @param renderTarget The render target to set the frame buffer for
  30999. */
  31000. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31001. /** @hidden */
  31002. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31003. /** @hidden */
  31004. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31005. /** @hidden */
  31006. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31007. /** @hidden */
  31008. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31009. /** @hidden */
  31010. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31011. /**
  31012. * @hidden
  31013. */
  31014. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31015. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31016. private _prepareWebGLTexture;
  31017. /** @hidden */
  31018. _releaseFramebufferObjects(texture: InternalTexture): void;
  31019. /** @hidden */
  31020. _releaseTexture(texture: InternalTexture): void;
  31021. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31022. protected _setProgram(program: WebGLProgram): void;
  31023. protected _boundUniforms: {
  31024. [key: number]: WebGLUniformLocation;
  31025. };
  31026. /**
  31027. * Binds an effect to the webGL context
  31028. * @param effect defines the effect to bind
  31029. */
  31030. bindSamplers(effect: Effect): void;
  31031. private _activateCurrentTexture;
  31032. /** @hidden */
  31033. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31034. /** @hidden */
  31035. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31036. /**
  31037. * Unbind all textures from the webGL context
  31038. */
  31039. unbindAllTextures(): void;
  31040. /**
  31041. * Sets a texture to the according uniform.
  31042. * @param channel The texture channel
  31043. * @param uniform The uniform to set
  31044. * @param texture The texture to apply
  31045. */
  31046. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31047. private _bindSamplerUniformToChannel;
  31048. private _getTextureWrapMode;
  31049. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31050. /**
  31051. * Sets an array of texture to the webGL context
  31052. * @param channel defines the channel where the texture array must be set
  31053. * @param uniform defines the associated uniform location
  31054. * @param textures defines the array of textures to bind
  31055. */
  31056. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31057. /** @hidden */
  31058. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31059. private _setTextureParameterFloat;
  31060. private _setTextureParameterInteger;
  31061. /**
  31062. * Unbind all vertex attributes from the webGL context
  31063. */
  31064. unbindAllAttributes(): void;
  31065. /**
  31066. * 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
  31067. */
  31068. releaseEffects(): void;
  31069. /**
  31070. * Dispose and release all associated resources
  31071. */
  31072. dispose(): void;
  31073. /**
  31074. * Attach a new callback raised when context lost event is fired
  31075. * @param callback defines the callback to call
  31076. */
  31077. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31078. /**
  31079. * Attach a new callback raised when context restored event is fired
  31080. * @param callback defines the callback to call
  31081. */
  31082. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31083. /**
  31084. * Get the current error code of the webGL context
  31085. * @returns the error code
  31086. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31087. */
  31088. getError(): number;
  31089. private _canRenderToFloatFramebuffer;
  31090. private _canRenderToHalfFloatFramebuffer;
  31091. private _canRenderToFramebuffer;
  31092. /** @hidden */
  31093. _getWebGLTextureType(type: number): number;
  31094. /** @hidden */
  31095. _getInternalFormat(format: number): number;
  31096. /** @hidden */
  31097. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31098. /** @hidden */
  31099. _getRGBAMultiSampleBufferFormat(type: number): number;
  31100. /** @hidden */
  31101. _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;
  31102. /**
  31103. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31104. * @returns true if the engine can be created
  31105. * @ignorenaming
  31106. */
  31107. static isSupported(): boolean;
  31108. /**
  31109. * Find the next highest power of two.
  31110. * @param x Number to start search from.
  31111. * @return Next highest power of two.
  31112. */
  31113. static CeilingPOT(x: number): number;
  31114. /**
  31115. * Find the next lowest power of two.
  31116. * @param x Number to start search from.
  31117. * @return Next lowest power of two.
  31118. */
  31119. static FloorPOT(x: number): number;
  31120. /**
  31121. * Find the nearest power of two.
  31122. * @param x Number to start search from.
  31123. * @return Next nearest power of two.
  31124. */
  31125. static NearestPOT(x: number): number;
  31126. /**
  31127. * Get the closest exponent of two
  31128. * @param value defines the value to approximate
  31129. * @param max defines the maximum value to return
  31130. * @param mode defines how to define the closest value
  31131. * @returns closest exponent of two of the given value
  31132. */
  31133. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31134. /**
  31135. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31136. * @param func - the function to be called
  31137. * @param requester - the object that will request the next frame. Falls back to window.
  31138. * @returns frame number
  31139. */
  31140. static QueueNewFrame(func: () => void, requester?: any): number;
  31141. }
  31142. }
  31143. declare module "babylonjs/Materials/Textures/internalTexture" {
  31144. import { Observable } from "babylonjs/Misc/observable";
  31145. import { Nullable, int } from "babylonjs/types";
  31146. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31147. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31148. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31149. /**
  31150. * Class used to store data associated with WebGL texture data for the engine
  31151. * This class should not be used directly
  31152. */
  31153. export class InternalTexture {
  31154. /** @hidden */
  31155. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31156. /**
  31157. * The source of the texture data is unknown
  31158. */
  31159. static DATASOURCE_UNKNOWN: number;
  31160. /**
  31161. * Texture data comes from an URL
  31162. */
  31163. static DATASOURCE_URL: number;
  31164. /**
  31165. * Texture data is only used for temporary storage
  31166. */
  31167. static DATASOURCE_TEMP: number;
  31168. /**
  31169. * Texture data comes from raw data (ArrayBuffer)
  31170. */
  31171. static DATASOURCE_RAW: number;
  31172. /**
  31173. * Texture content is dynamic (video or dynamic texture)
  31174. */
  31175. static DATASOURCE_DYNAMIC: number;
  31176. /**
  31177. * Texture content is generated by rendering to it
  31178. */
  31179. static DATASOURCE_RENDERTARGET: number;
  31180. /**
  31181. * Texture content is part of a multi render target process
  31182. */
  31183. static DATASOURCE_MULTIRENDERTARGET: number;
  31184. /**
  31185. * Texture data comes from a cube data file
  31186. */
  31187. static DATASOURCE_CUBE: number;
  31188. /**
  31189. * Texture data comes from a raw cube data
  31190. */
  31191. static DATASOURCE_CUBERAW: number;
  31192. /**
  31193. * Texture data come from a prefiltered cube data file
  31194. */
  31195. static DATASOURCE_CUBEPREFILTERED: number;
  31196. /**
  31197. * Texture content is raw 3D data
  31198. */
  31199. static DATASOURCE_RAW3D: number;
  31200. /**
  31201. * Texture content is a depth texture
  31202. */
  31203. static DATASOURCE_DEPTHTEXTURE: number;
  31204. /**
  31205. * Texture data comes from a raw cube data encoded with RGBD
  31206. */
  31207. static DATASOURCE_CUBERAW_RGBD: number;
  31208. /**
  31209. * Defines if the texture is ready
  31210. */
  31211. isReady: boolean;
  31212. /**
  31213. * Defines if the texture is a cube texture
  31214. */
  31215. isCube: boolean;
  31216. /**
  31217. * Defines if the texture contains 3D data
  31218. */
  31219. is3D: boolean;
  31220. /**
  31221. * Defines if the texture contains multiview data
  31222. */
  31223. isMultiview: boolean;
  31224. /**
  31225. * Gets the URL used to load this texture
  31226. */
  31227. url: string;
  31228. /**
  31229. * Gets the sampling mode of the texture
  31230. */
  31231. samplingMode: number;
  31232. /**
  31233. * Gets a boolean indicating if the texture needs mipmaps generation
  31234. */
  31235. generateMipMaps: boolean;
  31236. /**
  31237. * Gets the number of samples used by the texture (WebGL2+ only)
  31238. */
  31239. samples: number;
  31240. /**
  31241. * Gets the type of the texture (int, float...)
  31242. */
  31243. type: number;
  31244. /**
  31245. * Gets the format of the texture (RGB, RGBA...)
  31246. */
  31247. format: number;
  31248. /**
  31249. * Observable called when the texture is loaded
  31250. */
  31251. onLoadedObservable: Observable<InternalTexture>;
  31252. /**
  31253. * Gets the width of the texture
  31254. */
  31255. width: number;
  31256. /**
  31257. * Gets the height of the texture
  31258. */
  31259. height: number;
  31260. /**
  31261. * Gets the depth of the texture
  31262. */
  31263. depth: number;
  31264. /**
  31265. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31266. */
  31267. baseWidth: number;
  31268. /**
  31269. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31270. */
  31271. baseHeight: number;
  31272. /**
  31273. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31274. */
  31275. baseDepth: number;
  31276. /**
  31277. * Gets a boolean indicating if the texture is inverted on Y axis
  31278. */
  31279. invertY: boolean;
  31280. /** @hidden */
  31281. _invertVScale: boolean;
  31282. /** @hidden */
  31283. _associatedChannel: number;
  31284. /** @hidden */
  31285. _dataSource: number;
  31286. /** @hidden */
  31287. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31288. /** @hidden */
  31289. _bufferView: Nullable<ArrayBufferView>;
  31290. /** @hidden */
  31291. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31292. /** @hidden */
  31293. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31294. /** @hidden */
  31295. _size: number;
  31296. /** @hidden */
  31297. _extension: string;
  31298. /** @hidden */
  31299. _files: Nullable<string[]>;
  31300. /** @hidden */
  31301. _workingCanvas: Nullable<HTMLCanvasElement>;
  31302. /** @hidden */
  31303. _workingContext: Nullable<CanvasRenderingContext2D>;
  31304. /** @hidden */
  31305. _framebuffer: Nullable<WebGLFramebuffer>;
  31306. /** @hidden */
  31307. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31308. /** @hidden */
  31309. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31310. /** @hidden */
  31311. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31312. /** @hidden */
  31313. _attachments: Nullable<number[]>;
  31314. /** @hidden */
  31315. _cachedCoordinatesMode: Nullable<number>;
  31316. /** @hidden */
  31317. _cachedWrapU: Nullable<number>;
  31318. /** @hidden */
  31319. _cachedWrapV: Nullable<number>;
  31320. /** @hidden */
  31321. _cachedWrapR: Nullable<number>;
  31322. /** @hidden */
  31323. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31324. /** @hidden */
  31325. _isDisabled: boolean;
  31326. /** @hidden */
  31327. _compression: Nullable<string>;
  31328. /** @hidden */
  31329. _generateStencilBuffer: boolean;
  31330. /** @hidden */
  31331. _generateDepthBuffer: boolean;
  31332. /** @hidden */
  31333. _comparisonFunction: number;
  31334. /** @hidden */
  31335. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31336. /** @hidden */
  31337. _lodGenerationScale: number;
  31338. /** @hidden */
  31339. _lodGenerationOffset: number;
  31340. /** @hidden */
  31341. _colorTextureArray: Nullable<WebGLTexture>;
  31342. /** @hidden */
  31343. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31344. /** @hidden */
  31345. _lodTextureHigh: Nullable<BaseTexture>;
  31346. /** @hidden */
  31347. _lodTextureMid: Nullable<BaseTexture>;
  31348. /** @hidden */
  31349. _lodTextureLow: Nullable<BaseTexture>;
  31350. /** @hidden */
  31351. _isRGBD: boolean;
  31352. /** @hidden */
  31353. _linearSpecularLOD: boolean;
  31354. /** @hidden */
  31355. _irradianceTexture: Nullable<BaseTexture>;
  31356. /** @hidden */
  31357. _webGLTexture: Nullable<WebGLTexture>;
  31358. /** @hidden */
  31359. _references: number;
  31360. private _engine;
  31361. /**
  31362. * Gets the Engine the texture belongs to.
  31363. * @returns The babylon engine
  31364. */
  31365. getEngine(): ThinEngine;
  31366. /**
  31367. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  31368. */
  31369. readonly dataSource: number;
  31370. /**
  31371. * Creates a new InternalTexture
  31372. * @param engine defines the engine to use
  31373. * @param dataSource defines the type of data that will be used
  31374. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31375. */
  31376. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  31377. /**
  31378. * Increments the number of references (ie. the number of Texture that point to it)
  31379. */
  31380. incrementReferences(): void;
  31381. /**
  31382. * Change the size of the texture (not the size of the content)
  31383. * @param width defines the new width
  31384. * @param height defines the new height
  31385. * @param depth defines the new depth (1 by default)
  31386. */
  31387. updateSize(width: int, height: int, depth?: int): void;
  31388. /** @hidden */
  31389. _rebuild(): void;
  31390. /** @hidden */
  31391. _swapAndDie(target: InternalTexture): void;
  31392. /**
  31393. * Dispose the current allocated resources
  31394. */
  31395. dispose(): void;
  31396. }
  31397. }
  31398. declare module "babylonjs/Audio/analyser" {
  31399. import { Scene } from "babylonjs/scene";
  31400. /**
  31401. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31402. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31403. */
  31404. export class Analyser {
  31405. /**
  31406. * Gets or sets the smoothing
  31407. * @ignorenaming
  31408. */
  31409. SMOOTHING: number;
  31410. /**
  31411. * Gets or sets the FFT table size
  31412. * @ignorenaming
  31413. */
  31414. FFT_SIZE: number;
  31415. /**
  31416. * Gets or sets the bar graph amplitude
  31417. * @ignorenaming
  31418. */
  31419. BARGRAPHAMPLITUDE: number;
  31420. /**
  31421. * Gets or sets the position of the debug canvas
  31422. * @ignorenaming
  31423. */
  31424. DEBUGCANVASPOS: {
  31425. x: number;
  31426. y: number;
  31427. };
  31428. /**
  31429. * Gets or sets the debug canvas size
  31430. * @ignorenaming
  31431. */
  31432. DEBUGCANVASSIZE: {
  31433. width: number;
  31434. height: number;
  31435. };
  31436. private _byteFreqs;
  31437. private _byteTime;
  31438. private _floatFreqs;
  31439. private _webAudioAnalyser;
  31440. private _debugCanvas;
  31441. private _debugCanvasContext;
  31442. private _scene;
  31443. private _registerFunc;
  31444. private _audioEngine;
  31445. /**
  31446. * Creates a new analyser
  31447. * @param scene defines hosting scene
  31448. */
  31449. constructor(scene: Scene);
  31450. /**
  31451. * Get the number of data values you will have to play with for the visualization
  31452. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31453. * @returns a number
  31454. */
  31455. getFrequencyBinCount(): number;
  31456. /**
  31457. * Gets the current frequency data as a byte array
  31458. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31459. * @returns a Uint8Array
  31460. */
  31461. getByteFrequencyData(): Uint8Array;
  31462. /**
  31463. * Gets the current waveform as a byte array
  31464. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31465. * @returns a Uint8Array
  31466. */
  31467. getByteTimeDomainData(): Uint8Array;
  31468. /**
  31469. * Gets the current frequency data as a float array
  31470. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31471. * @returns a Float32Array
  31472. */
  31473. getFloatFrequencyData(): Float32Array;
  31474. /**
  31475. * Renders the debug canvas
  31476. */
  31477. drawDebugCanvas(): void;
  31478. /**
  31479. * Stops rendering the debug canvas and removes it
  31480. */
  31481. stopDebugCanvas(): void;
  31482. /**
  31483. * Connects two audio nodes
  31484. * @param inputAudioNode defines first node to connect
  31485. * @param outputAudioNode defines second node to connect
  31486. */
  31487. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31488. /**
  31489. * Releases all associated resources
  31490. */
  31491. dispose(): void;
  31492. }
  31493. }
  31494. declare module "babylonjs/Audio/audioEngine" {
  31495. import { IDisposable } from "babylonjs/scene";
  31496. import { Analyser } from "babylonjs/Audio/analyser";
  31497. import { Nullable } from "babylonjs/types";
  31498. import { Observable } from "babylonjs/Misc/observable";
  31499. /**
  31500. * This represents an audio engine and it is responsible
  31501. * to play, synchronize and analyse sounds throughout the application.
  31502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31503. */
  31504. export interface IAudioEngine extends IDisposable {
  31505. /**
  31506. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31507. */
  31508. readonly canUseWebAudio: boolean;
  31509. /**
  31510. * Gets the current AudioContext if available.
  31511. */
  31512. readonly audioContext: Nullable<AudioContext>;
  31513. /**
  31514. * The master gain node defines the global audio volume of your audio engine.
  31515. */
  31516. readonly masterGain: GainNode;
  31517. /**
  31518. * Gets whether or not mp3 are supported by your browser.
  31519. */
  31520. readonly isMP3supported: boolean;
  31521. /**
  31522. * Gets whether or not ogg are supported by your browser.
  31523. */
  31524. readonly isOGGsupported: boolean;
  31525. /**
  31526. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31527. * @ignoreNaming
  31528. */
  31529. WarnedWebAudioUnsupported: boolean;
  31530. /**
  31531. * Defines if the audio engine relies on a custom unlocked button.
  31532. * In this case, the embedded button will not be displayed.
  31533. */
  31534. useCustomUnlockedButton: boolean;
  31535. /**
  31536. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31537. */
  31538. readonly unlocked: boolean;
  31539. /**
  31540. * Event raised when audio has been unlocked on the browser.
  31541. */
  31542. onAudioUnlockedObservable: Observable<AudioEngine>;
  31543. /**
  31544. * Event raised when audio has been locked on the browser.
  31545. */
  31546. onAudioLockedObservable: Observable<AudioEngine>;
  31547. /**
  31548. * Flags the audio engine in Locked state.
  31549. * This happens due to new browser policies preventing audio to autoplay.
  31550. */
  31551. lock(): void;
  31552. /**
  31553. * Unlocks the audio engine once a user action has been done on the dom.
  31554. * This is helpful to resume play once browser policies have been satisfied.
  31555. */
  31556. unlock(): void;
  31557. }
  31558. /**
  31559. * This represents the default audio engine used in babylon.
  31560. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31562. */
  31563. export class AudioEngine implements IAudioEngine {
  31564. private _audioContext;
  31565. private _audioContextInitialized;
  31566. private _muteButton;
  31567. private _hostElement;
  31568. /**
  31569. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31570. */
  31571. canUseWebAudio: boolean;
  31572. /**
  31573. * The master gain node defines the global audio volume of your audio engine.
  31574. */
  31575. masterGain: GainNode;
  31576. /**
  31577. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31578. * @ignoreNaming
  31579. */
  31580. WarnedWebAudioUnsupported: boolean;
  31581. /**
  31582. * Gets whether or not mp3 are supported by your browser.
  31583. */
  31584. isMP3supported: boolean;
  31585. /**
  31586. * Gets whether or not ogg are supported by your browser.
  31587. */
  31588. isOGGsupported: boolean;
  31589. /**
  31590. * Gets whether audio has been unlocked on the device.
  31591. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31592. * a user interaction has happened.
  31593. */
  31594. unlocked: boolean;
  31595. /**
  31596. * Defines if the audio engine relies on a custom unlocked button.
  31597. * In this case, the embedded button will not be displayed.
  31598. */
  31599. useCustomUnlockedButton: boolean;
  31600. /**
  31601. * Event raised when audio has been unlocked on the browser.
  31602. */
  31603. onAudioUnlockedObservable: Observable<AudioEngine>;
  31604. /**
  31605. * Event raised when audio has been locked on the browser.
  31606. */
  31607. onAudioLockedObservable: Observable<AudioEngine>;
  31608. /**
  31609. * Gets the current AudioContext if available.
  31610. */
  31611. readonly audioContext: Nullable<AudioContext>;
  31612. private _connectedAnalyser;
  31613. /**
  31614. * Instantiates a new audio engine.
  31615. *
  31616. * There should be only one per page as some browsers restrict the number
  31617. * of audio contexts you can create.
  31618. * @param hostElement defines the host element where to display the mute icon if necessary
  31619. */
  31620. constructor(hostElement?: Nullable<HTMLElement>);
  31621. /**
  31622. * Flags the audio engine in Locked state.
  31623. * This happens due to new browser policies preventing audio to autoplay.
  31624. */
  31625. lock(): void;
  31626. /**
  31627. * Unlocks the audio engine once a user action has been done on the dom.
  31628. * This is helpful to resume play once browser policies have been satisfied.
  31629. */
  31630. unlock(): void;
  31631. private _resumeAudioContext;
  31632. private _initializeAudioContext;
  31633. private _tryToRun;
  31634. private _triggerRunningState;
  31635. private _triggerSuspendedState;
  31636. private _displayMuteButton;
  31637. private _moveButtonToTopLeft;
  31638. private _onResize;
  31639. private _hideMuteButton;
  31640. /**
  31641. * Destroy and release the resources associated with the audio ccontext.
  31642. */
  31643. dispose(): void;
  31644. /**
  31645. * Gets the global volume sets on the master gain.
  31646. * @returns the global volume if set or -1 otherwise
  31647. */
  31648. getGlobalVolume(): number;
  31649. /**
  31650. * Sets the global volume of your experience (sets on the master gain).
  31651. * @param newVolume Defines the new global volume of the application
  31652. */
  31653. setGlobalVolume(newVolume: number): void;
  31654. /**
  31655. * Connect the audio engine to an audio analyser allowing some amazing
  31656. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31657. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31658. * @param analyser The analyser to connect to the engine
  31659. */
  31660. connectToAnalyser(analyser: Analyser): void;
  31661. }
  31662. }
  31663. declare module "babylonjs/Loading/loadingScreen" {
  31664. /**
  31665. * Interface used to present a loading screen while loading a scene
  31666. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31667. */
  31668. export interface ILoadingScreen {
  31669. /**
  31670. * Function called to display the loading screen
  31671. */
  31672. displayLoadingUI: () => void;
  31673. /**
  31674. * Function called to hide the loading screen
  31675. */
  31676. hideLoadingUI: () => void;
  31677. /**
  31678. * Gets or sets the color to use for the background
  31679. */
  31680. loadingUIBackgroundColor: string;
  31681. /**
  31682. * Gets or sets the text to display while loading
  31683. */
  31684. loadingUIText: string;
  31685. }
  31686. /**
  31687. * Class used for the default loading screen
  31688. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31689. */
  31690. export class DefaultLoadingScreen implements ILoadingScreen {
  31691. private _renderingCanvas;
  31692. private _loadingText;
  31693. private _loadingDivBackgroundColor;
  31694. private _loadingDiv;
  31695. private _loadingTextDiv;
  31696. /** Gets or sets the logo url to use for the default loading screen */
  31697. static DefaultLogoUrl: string;
  31698. /** Gets or sets the spinner url to use for the default loading screen */
  31699. static DefaultSpinnerUrl: string;
  31700. /**
  31701. * Creates a new default loading screen
  31702. * @param _renderingCanvas defines the canvas used to render the scene
  31703. * @param _loadingText defines the default text to display
  31704. * @param _loadingDivBackgroundColor defines the default background color
  31705. */
  31706. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31707. /**
  31708. * Function called to display the loading screen
  31709. */
  31710. displayLoadingUI(): void;
  31711. /**
  31712. * Function called to hide the loading screen
  31713. */
  31714. hideLoadingUI(): void;
  31715. /**
  31716. * Gets or sets the text to display while loading
  31717. */
  31718. loadingUIText: string;
  31719. /**
  31720. * Gets or sets the color to use for the background
  31721. */
  31722. loadingUIBackgroundColor: string;
  31723. private _resizeLoadingUI;
  31724. }
  31725. }
  31726. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31727. /**
  31728. * Interface for any object that can request an animation frame
  31729. */
  31730. export interface ICustomAnimationFrameRequester {
  31731. /**
  31732. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31733. */
  31734. renderFunction?: Function;
  31735. /**
  31736. * Called to request the next frame to render to
  31737. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31738. */
  31739. requestAnimationFrame: Function;
  31740. /**
  31741. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31742. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31743. */
  31744. requestID?: number;
  31745. }
  31746. }
  31747. declare module "babylonjs/Misc/performanceMonitor" {
  31748. /**
  31749. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31750. */
  31751. export class PerformanceMonitor {
  31752. private _enabled;
  31753. private _rollingFrameTime;
  31754. private _lastFrameTimeMs;
  31755. /**
  31756. * constructor
  31757. * @param frameSampleSize The number of samples required to saturate the sliding window
  31758. */
  31759. constructor(frameSampleSize?: number);
  31760. /**
  31761. * Samples current frame
  31762. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31763. */
  31764. sampleFrame(timeMs?: number): void;
  31765. /**
  31766. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31767. */
  31768. readonly averageFrameTime: number;
  31769. /**
  31770. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31771. */
  31772. readonly averageFrameTimeVariance: number;
  31773. /**
  31774. * Returns the frame time of the most recent frame
  31775. */
  31776. readonly instantaneousFrameTime: number;
  31777. /**
  31778. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31779. */
  31780. readonly averageFPS: number;
  31781. /**
  31782. * Returns the average framerate in frames per second using the most recent frame time
  31783. */
  31784. readonly instantaneousFPS: number;
  31785. /**
  31786. * Returns true if enough samples have been taken to completely fill the sliding window
  31787. */
  31788. readonly isSaturated: boolean;
  31789. /**
  31790. * Enables contributions to the sliding window sample set
  31791. */
  31792. enable(): void;
  31793. /**
  31794. * Disables contributions to the sliding window sample set
  31795. * Samples will not be interpolated over the disabled period
  31796. */
  31797. disable(): void;
  31798. /**
  31799. * Returns true if sampling is enabled
  31800. */
  31801. readonly isEnabled: boolean;
  31802. /**
  31803. * Resets performance monitor
  31804. */
  31805. reset(): void;
  31806. }
  31807. /**
  31808. * RollingAverage
  31809. *
  31810. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31811. */
  31812. export class RollingAverage {
  31813. /**
  31814. * Current average
  31815. */
  31816. average: number;
  31817. /**
  31818. * Current variance
  31819. */
  31820. variance: number;
  31821. protected _samples: Array<number>;
  31822. protected _sampleCount: number;
  31823. protected _pos: number;
  31824. protected _m2: number;
  31825. /**
  31826. * constructor
  31827. * @param length The number of samples required to saturate the sliding window
  31828. */
  31829. constructor(length: number);
  31830. /**
  31831. * Adds a sample to the sample set
  31832. * @param v The sample value
  31833. */
  31834. add(v: number): void;
  31835. /**
  31836. * Returns previously added values or null if outside of history or outside the sliding window domain
  31837. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31838. * @return Value previously recorded with add() or null if outside of range
  31839. */
  31840. history(i: number): number;
  31841. /**
  31842. * Returns true if enough samples have been taken to completely fill the sliding window
  31843. * @return true if sample-set saturated
  31844. */
  31845. isSaturated(): boolean;
  31846. /**
  31847. * Resets the rolling average (equivalent to 0 samples taken so far)
  31848. */
  31849. reset(): void;
  31850. /**
  31851. * Wraps a value around the sample range boundaries
  31852. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31853. * @return Wrapped position in sample range
  31854. */
  31855. protected _wrapPosition(i: number): number;
  31856. }
  31857. }
  31858. declare module "babylonjs/Engines/engine" {
  31859. import { Observable } from "babylonjs/Misc/observable";
  31860. import { Nullable } from "babylonjs/types";
  31861. import { Scene } from "babylonjs/scene";
  31862. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31863. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31864. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31865. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31866. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31867. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31868. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31869. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31870. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31871. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31872. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31873. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31874. import { Material } from "babylonjs/Materials/material";
  31875. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31876. /**
  31877. * Defines the interface used by display changed events
  31878. */
  31879. export interface IDisplayChangedEventArgs {
  31880. /** Gets the vrDisplay object (if any) */
  31881. vrDisplay: Nullable<any>;
  31882. /** Gets a boolean indicating if webVR is supported */
  31883. vrSupported: boolean;
  31884. }
  31885. /**
  31886. * Defines the interface used by objects containing a viewport (like a camera)
  31887. */
  31888. interface IViewportOwnerLike {
  31889. /**
  31890. * Gets or sets the viewport
  31891. */
  31892. viewport: IViewportLike;
  31893. }
  31894. /**
  31895. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31896. */
  31897. export class Engine extends ThinEngine {
  31898. /** Defines that alpha blending is disabled */
  31899. static readonly ALPHA_DISABLE: number;
  31900. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31901. static readonly ALPHA_ADD: number;
  31902. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31903. static readonly ALPHA_COMBINE: number;
  31904. /** Defines that alpha blending to DEST - SRC * DEST */
  31905. static readonly ALPHA_SUBTRACT: number;
  31906. /** Defines that alpha blending to SRC * DEST */
  31907. static readonly ALPHA_MULTIPLY: number;
  31908. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31909. static readonly ALPHA_MAXIMIZED: number;
  31910. /** Defines that alpha blending to SRC + DEST */
  31911. static readonly ALPHA_ONEONE: number;
  31912. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31913. static readonly ALPHA_PREMULTIPLIED: number;
  31914. /**
  31915. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31916. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31917. */
  31918. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31919. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31920. static readonly ALPHA_INTERPOLATE: number;
  31921. /**
  31922. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31923. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31924. */
  31925. static readonly ALPHA_SCREENMODE: number;
  31926. /** Defines that the ressource is not delayed*/
  31927. static readonly DELAYLOADSTATE_NONE: number;
  31928. /** Defines that the ressource was successfully delay loaded */
  31929. static readonly DELAYLOADSTATE_LOADED: number;
  31930. /** Defines that the ressource is currently delay loading */
  31931. static readonly DELAYLOADSTATE_LOADING: number;
  31932. /** Defines that the ressource is delayed and has not started loading */
  31933. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31934. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31935. static readonly NEVER: number;
  31936. /** 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 */
  31937. static readonly ALWAYS: number;
  31938. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31939. static readonly LESS: number;
  31940. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31941. static readonly EQUAL: number;
  31942. /** 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 */
  31943. static readonly LEQUAL: number;
  31944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31945. static readonly GREATER: number;
  31946. /** 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 */
  31947. static readonly GEQUAL: number;
  31948. /** 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 */
  31949. static readonly NOTEQUAL: number;
  31950. /** Passed to stencilOperation to specify that stencil value must be kept */
  31951. static readonly KEEP: number;
  31952. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31953. static readonly REPLACE: number;
  31954. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31955. static readonly INCR: number;
  31956. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31957. static readonly DECR: number;
  31958. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31959. static readonly INVERT: number;
  31960. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31961. static readonly INCR_WRAP: number;
  31962. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31963. static readonly DECR_WRAP: number;
  31964. /** Texture is not repeating outside of 0..1 UVs */
  31965. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31966. /** Texture is repeating outside of 0..1 UVs */
  31967. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31968. /** Texture is repeating and mirrored */
  31969. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31970. /** ALPHA */
  31971. static readonly TEXTUREFORMAT_ALPHA: number;
  31972. /** LUMINANCE */
  31973. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31974. /** LUMINANCE_ALPHA */
  31975. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31976. /** RGB */
  31977. static readonly TEXTUREFORMAT_RGB: number;
  31978. /** RGBA */
  31979. static readonly TEXTUREFORMAT_RGBA: number;
  31980. /** RED */
  31981. static readonly TEXTUREFORMAT_RED: number;
  31982. /** RED (2nd reference) */
  31983. static readonly TEXTUREFORMAT_R: number;
  31984. /** RG */
  31985. static readonly TEXTUREFORMAT_RG: number;
  31986. /** RED_INTEGER */
  31987. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31988. /** RED_INTEGER (2nd reference) */
  31989. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31990. /** RG_INTEGER */
  31991. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31992. /** RGB_INTEGER */
  31993. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31994. /** RGBA_INTEGER */
  31995. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31996. /** UNSIGNED_BYTE */
  31997. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31998. /** UNSIGNED_BYTE (2nd reference) */
  31999. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32000. /** FLOAT */
  32001. static readonly TEXTURETYPE_FLOAT: number;
  32002. /** HALF_FLOAT */
  32003. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32004. /** BYTE */
  32005. static readonly TEXTURETYPE_BYTE: number;
  32006. /** SHORT */
  32007. static readonly TEXTURETYPE_SHORT: number;
  32008. /** UNSIGNED_SHORT */
  32009. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32010. /** INT */
  32011. static readonly TEXTURETYPE_INT: number;
  32012. /** UNSIGNED_INT */
  32013. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32014. /** UNSIGNED_SHORT_4_4_4_4 */
  32015. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32016. /** UNSIGNED_SHORT_5_5_5_1 */
  32017. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32018. /** UNSIGNED_SHORT_5_6_5 */
  32019. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32020. /** UNSIGNED_INT_2_10_10_10_REV */
  32021. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32022. /** UNSIGNED_INT_24_8 */
  32023. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32024. /** UNSIGNED_INT_10F_11F_11F_REV */
  32025. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32026. /** UNSIGNED_INT_5_9_9_9_REV */
  32027. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32028. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32029. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32030. /** nearest is mag = nearest and min = nearest and mip = linear */
  32031. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32032. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32033. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32034. /** Trilinear is mag = linear and min = linear and mip = linear */
  32035. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32036. /** nearest is mag = nearest and min = nearest and mip = linear */
  32037. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32038. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32039. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32040. /** Trilinear is mag = linear and min = linear and mip = linear */
  32041. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32042. /** mag = nearest and min = nearest and mip = nearest */
  32043. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32044. /** mag = nearest and min = linear and mip = nearest */
  32045. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32046. /** mag = nearest and min = linear and mip = linear */
  32047. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32048. /** mag = nearest and min = linear and mip = none */
  32049. static readonly TEXTURE_NEAREST_LINEAR: number;
  32050. /** mag = nearest and min = nearest and mip = none */
  32051. static readonly TEXTURE_NEAREST_NEAREST: number;
  32052. /** mag = linear and min = nearest and mip = nearest */
  32053. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32054. /** mag = linear and min = nearest and mip = linear */
  32055. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32056. /** mag = linear and min = linear and mip = none */
  32057. static readonly TEXTURE_LINEAR_LINEAR: number;
  32058. /** mag = linear and min = nearest and mip = none */
  32059. static readonly TEXTURE_LINEAR_NEAREST: number;
  32060. /** Explicit coordinates mode */
  32061. static readonly TEXTURE_EXPLICIT_MODE: number;
  32062. /** Spherical coordinates mode */
  32063. static readonly TEXTURE_SPHERICAL_MODE: number;
  32064. /** Planar coordinates mode */
  32065. static readonly TEXTURE_PLANAR_MODE: number;
  32066. /** Cubic coordinates mode */
  32067. static readonly TEXTURE_CUBIC_MODE: number;
  32068. /** Projection coordinates mode */
  32069. static readonly TEXTURE_PROJECTION_MODE: number;
  32070. /** Skybox coordinates mode */
  32071. static readonly TEXTURE_SKYBOX_MODE: number;
  32072. /** Inverse Cubic coordinates mode */
  32073. static readonly TEXTURE_INVCUBIC_MODE: number;
  32074. /** Equirectangular coordinates mode */
  32075. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32076. /** Equirectangular Fixed coordinates mode */
  32077. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32078. /** Equirectangular Fixed Mirrored coordinates mode */
  32079. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32080. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32081. static readonly SCALEMODE_FLOOR: number;
  32082. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32083. static readonly SCALEMODE_NEAREST: number;
  32084. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32085. static readonly SCALEMODE_CEILING: number;
  32086. /**
  32087. * Returns the current npm package of the sdk
  32088. */
  32089. static readonly NpmPackage: string;
  32090. /**
  32091. * Returns the current version of the framework
  32092. */
  32093. static readonly Version: string;
  32094. /** Gets the list of created engines */
  32095. static readonly Instances: Engine[];
  32096. /**
  32097. * Gets the latest created engine
  32098. */
  32099. static readonly LastCreatedEngine: Nullable<Engine>;
  32100. /**
  32101. * Gets the latest created scene
  32102. */
  32103. static readonly LastCreatedScene: Nullable<Scene>;
  32104. /**
  32105. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32106. * @param flag defines which part of the materials must be marked as dirty
  32107. * @param predicate defines a predicate used to filter which materials should be affected
  32108. */
  32109. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32110. /**
  32111. * Method called to create the default loading screen.
  32112. * This can be overriden in your own app.
  32113. * @param canvas The rendering canvas element
  32114. * @returns The loading screen
  32115. */
  32116. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32117. /**
  32118. * Method called to create the default rescale post process on each engine.
  32119. */
  32120. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32121. /**
  32122. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32123. **/
  32124. enableOfflineSupport: boolean;
  32125. /**
  32126. * 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)
  32127. **/
  32128. disableManifestCheck: boolean;
  32129. /**
  32130. * Gets the list of created scenes
  32131. */
  32132. scenes: Scene[];
  32133. /**
  32134. * Event raised when a new scene is created
  32135. */
  32136. onNewSceneAddedObservable: Observable<Scene>;
  32137. /**
  32138. * Gets the list of created postprocesses
  32139. */
  32140. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32141. /**
  32142. * Gets a boolean indicating if the pointer is currently locked
  32143. */
  32144. isPointerLock: boolean;
  32145. /**
  32146. * Observable event triggered each time the rendering canvas is resized
  32147. */
  32148. onResizeObservable: Observable<Engine>;
  32149. /**
  32150. * Observable event triggered each time the canvas loses focus
  32151. */
  32152. onCanvasBlurObservable: Observable<Engine>;
  32153. /**
  32154. * Observable event triggered each time the canvas gains focus
  32155. */
  32156. onCanvasFocusObservable: Observable<Engine>;
  32157. /**
  32158. * Observable event triggered each time the canvas receives pointerout event
  32159. */
  32160. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32161. /**
  32162. * Observable event triggered before each texture is initialized
  32163. */
  32164. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32165. /**
  32166. * Observable raised when the engine begins a new frame
  32167. */
  32168. onBeginFrameObservable: Observable<Engine>;
  32169. /**
  32170. * If set, will be used to request the next animation frame for the render loop
  32171. */
  32172. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32173. /**
  32174. * Observable raised when the engine ends the current frame
  32175. */
  32176. onEndFrameObservable: Observable<Engine>;
  32177. /**
  32178. * Observable raised when the engine is about to compile a shader
  32179. */
  32180. onBeforeShaderCompilationObservable: Observable<Engine>;
  32181. /**
  32182. * Observable raised when the engine has jsut compiled a shader
  32183. */
  32184. onAfterShaderCompilationObservable: Observable<Engine>;
  32185. /**
  32186. * Gets the audio engine
  32187. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32188. * @ignorenaming
  32189. */
  32190. static audioEngine: IAudioEngine;
  32191. /**
  32192. * Default AudioEngine factory responsible of creating the Audio Engine.
  32193. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32194. */
  32195. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32196. /**
  32197. * Default offline support factory responsible of creating a tool used to store data locally.
  32198. * By default, this will create a Database object if the workload has been embedded.
  32199. */
  32200. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32201. private _loadingScreen;
  32202. private _pointerLockRequested;
  32203. private _dummyFramebuffer;
  32204. private _rescalePostProcess;
  32205. /** @hidden */
  32206. protected _alphaMode: number;
  32207. /** @hidden */
  32208. protected _alphaEquation: number;
  32209. private _deterministicLockstep;
  32210. private _lockstepMaxSteps;
  32211. protected readonly _supportsHardwareTextureRescaling: boolean;
  32212. private _fps;
  32213. private _deltaTime;
  32214. /**
  32215. * Turn this value on if you want to pause FPS computation when in background
  32216. */
  32217. disablePerformanceMonitorInBackground: boolean;
  32218. private _performanceMonitor;
  32219. /**
  32220. * Gets the performance monitor attached to this engine
  32221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32222. */
  32223. readonly performanceMonitor: PerformanceMonitor;
  32224. private _onFocus;
  32225. private _onBlur;
  32226. private _onCanvasPointerOut;
  32227. private _onCanvasBlur;
  32228. private _onCanvasFocus;
  32229. private _onFullscreenChange;
  32230. private _onPointerLockChange;
  32231. /**
  32232. * Creates a new engine
  32233. * @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
  32234. * @param antialias defines enable antialiasing (default: false)
  32235. * @param options defines further options to be sent to the getContext() function
  32236. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32237. */
  32238. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32239. /**
  32240. * Gets current aspect ratio
  32241. * @param viewportOwner defines the camera to use to get the aspect ratio
  32242. * @param useScreen defines if screen size must be used (or the current render target if any)
  32243. * @returns a number defining the aspect ratio
  32244. */
  32245. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32246. /**
  32247. * Gets current screen aspect ratio
  32248. * @returns a number defining the aspect ratio
  32249. */
  32250. getScreenAspectRatio(): number;
  32251. /**
  32252. * Gets host document
  32253. * @returns the host document object
  32254. */
  32255. getHostDocument(): Document;
  32256. /**
  32257. * Gets the client rect of the HTML canvas attached with the current webGL context
  32258. * @returns a client rectanglee
  32259. */
  32260. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32261. /**
  32262. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32264. * @returns true if engine is in deterministic lock step mode
  32265. */
  32266. isDeterministicLockStep(): boolean;
  32267. /**
  32268. * Gets the max steps when engine is running in deterministic lock step
  32269. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32270. * @returns the max steps
  32271. */
  32272. getLockstepMaxSteps(): number;
  32273. /**
  32274. * Force the mipmap generation for the given render target texture
  32275. * @param texture defines the render target texture to use
  32276. */
  32277. generateMipMapsForCubemap(texture: InternalTexture): void;
  32278. /** States */
  32279. /**
  32280. * Set various states to the webGL context
  32281. * @param culling defines backface culling state
  32282. * @param zOffset defines the value to apply to zOffset (0 by default)
  32283. * @param force defines if states must be applied even if cache is up to date
  32284. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32285. */
  32286. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32287. /**
  32288. * Set the z offset to apply to current rendering
  32289. * @param value defines the offset to apply
  32290. */
  32291. setZOffset(value: number): void;
  32292. /**
  32293. * Gets the current value of the zOffset
  32294. * @returns the current zOffset state
  32295. */
  32296. getZOffset(): number;
  32297. /**
  32298. * Enable or disable depth buffering
  32299. * @param enable defines the state to set
  32300. */
  32301. setDepthBuffer(enable: boolean): void;
  32302. /**
  32303. * Gets a boolean indicating if depth writing is enabled
  32304. * @returns the current depth writing state
  32305. */
  32306. getDepthWrite(): boolean;
  32307. /**
  32308. * Enable or disable depth writing
  32309. * @param enable defines the state to set
  32310. */
  32311. setDepthWrite(enable: boolean): void;
  32312. /**
  32313. * Enable or disable color writing
  32314. * @param enable defines the state to set
  32315. */
  32316. setColorWrite(enable: boolean): void;
  32317. /**
  32318. * Gets a boolean indicating if color writing is enabled
  32319. * @returns the current color writing state
  32320. */
  32321. getColorWrite(): boolean;
  32322. /**
  32323. * Sets alpha constants used by some alpha blending modes
  32324. * @param r defines the red component
  32325. * @param g defines the green component
  32326. * @param b defines the blue component
  32327. * @param a defines the alpha component
  32328. */
  32329. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32330. /**
  32331. * Sets the current alpha mode
  32332. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32333. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32334. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32335. */
  32336. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32337. /**
  32338. * Gets the current alpha mode
  32339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32340. * @returns the current alpha mode
  32341. */
  32342. getAlphaMode(): number;
  32343. /**
  32344. * Sets the current alpha equation
  32345. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32346. */
  32347. setAlphaEquation(equation: number): void;
  32348. /**
  32349. * Gets the current alpha equation.
  32350. * @returns the current alpha equation
  32351. */
  32352. getAlphaEquation(): number;
  32353. /**
  32354. * Gets a boolean indicating if stencil buffer is enabled
  32355. * @returns the current stencil buffer state
  32356. */
  32357. getStencilBuffer(): boolean;
  32358. /**
  32359. * Enable or disable the stencil buffer
  32360. * @param enable defines if the stencil buffer must be enabled or disabled
  32361. */
  32362. setStencilBuffer(enable: boolean): void;
  32363. /**
  32364. * Gets the current stencil mask
  32365. * @returns a number defining the new stencil mask to use
  32366. */
  32367. getStencilMask(): number;
  32368. /**
  32369. * Sets the current stencil mask
  32370. * @param mask defines the new stencil mask to use
  32371. */
  32372. setStencilMask(mask: number): void;
  32373. /**
  32374. * Gets the current stencil function
  32375. * @returns a number defining the stencil function to use
  32376. */
  32377. getStencilFunction(): number;
  32378. /**
  32379. * Gets the current stencil reference value
  32380. * @returns a number defining the stencil reference value to use
  32381. */
  32382. getStencilFunctionReference(): number;
  32383. /**
  32384. * Gets the current stencil mask
  32385. * @returns a number defining the stencil mask to use
  32386. */
  32387. getStencilFunctionMask(): number;
  32388. /**
  32389. * Sets the current stencil function
  32390. * @param stencilFunc defines the new stencil function to use
  32391. */
  32392. setStencilFunction(stencilFunc: number): void;
  32393. /**
  32394. * Sets the current stencil reference
  32395. * @param reference defines the new stencil reference to use
  32396. */
  32397. setStencilFunctionReference(reference: number): void;
  32398. /**
  32399. * Sets the current stencil mask
  32400. * @param mask defines the new stencil mask to use
  32401. */
  32402. setStencilFunctionMask(mask: number): void;
  32403. /**
  32404. * Gets the current stencil operation when stencil fails
  32405. * @returns a number defining stencil operation to use when stencil fails
  32406. */
  32407. getStencilOperationFail(): number;
  32408. /**
  32409. * Gets the current stencil operation when depth fails
  32410. * @returns a number defining stencil operation to use when depth fails
  32411. */
  32412. getStencilOperationDepthFail(): number;
  32413. /**
  32414. * Gets the current stencil operation when stencil passes
  32415. * @returns a number defining stencil operation to use when stencil passes
  32416. */
  32417. getStencilOperationPass(): number;
  32418. /**
  32419. * Sets the stencil operation to use when stencil fails
  32420. * @param operation defines the stencil operation to use when stencil fails
  32421. */
  32422. setStencilOperationFail(operation: number): void;
  32423. /**
  32424. * Sets the stencil operation to use when depth fails
  32425. * @param operation defines the stencil operation to use when depth fails
  32426. */
  32427. setStencilOperationDepthFail(operation: number): void;
  32428. /**
  32429. * Sets the stencil operation to use when stencil passes
  32430. * @param operation defines the stencil operation to use when stencil passes
  32431. */
  32432. setStencilOperationPass(operation: number): void;
  32433. /**
  32434. * Sets a boolean indicating if the dithering state is enabled or disabled
  32435. * @param value defines the dithering state
  32436. */
  32437. setDitheringState(value: boolean): void;
  32438. /**
  32439. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32440. * @param value defines the rasterizer state
  32441. */
  32442. setRasterizerState(value: boolean): void;
  32443. /**
  32444. * Gets the current depth function
  32445. * @returns a number defining the depth function
  32446. */
  32447. getDepthFunction(): Nullable<number>;
  32448. /**
  32449. * Sets the current depth function
  32450. * @param depthFunc defines the function to use
  32451. */
  32452. setDepthFunction(depthFunc: number): void;
  32453. /**
  32454. * Sets the current depth function to GREATER
  32455. */
  32456. setDepthFunctionToGreater(): void;
  32457. /**
  32458. * Sets the current depth function to GEQUAL
  32459. */
  32460. setDepthFunctionToGreaterOrEqual(): void;
  32461. /**
  32462. * Sets the current depth function to LESS
  32463. */
  32464. setDepthFunctionToLess(): void;
  32465. /**
  32466. * Sets the current depth function to LEQUAL
  32467. */
  32468. setDepthFunctionToLessOrEqual(): void;
  32469. private _cachedStencilBuffer;
  32470. private _cachedStencilFunction;
  32471. private _cachedStencilMask;
  32472. private _cachedStencilOperationPass;
  32473. private _cachedStencilOperationFail;
  32474. private _cachedStencilOperationDepthFail;
  32475. private _cachedStencilReference;
  32476. /**
  32477. * Caches the the state of the stencil buffer
  32478. */
  32479. cacheStencilState(): void;
  32480. /**
  32481. * Restores the state of the stencil buffer
  32482. */
  32483. restoreStencilState(): void;
  32484. /**
  32485. * Directly set the WebGL Viewport
  32486. * @param x defines the x coordinate of the viewport (in screen space)
  32487. * @param y defines the y coordinate of the viewport (in screen space)
  32488. * @param width defines the width of the viewport (in screen space)
  32489. * @param height defines the height of the viewport (in screen space)
  32490. * @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
  32491. */
  32492. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32493. /**
  32494. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32495. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32496. * @param y defines the y-coordinate of the corner of the clear rectangle
  32497. * @param width defines the width of the clear rectangle
  32498. * @param height defines the height of the clear rectangle
  32499. * @param clearColor defines the clear color
  32500. */
  32501. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32502. /**
  32503. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32504. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32505. * @param y defines the y-coordinate of the corner of the clear rectangle
  32506. * @param width defines the width of the clear rectangle
  32507. * @param height defines the height of the clear rectangle
  32508. */
  32509. enableScissor(x: number, y: number, width: number, height: number): void;
  32510. /**
  32511. * Disable previously set scissor test rectangle
  32512. */
  32513. disableScissor(): void;
  32514. /**
  32515. * Initializes a webVR display and starts listening to display change events
  32516. * The onVRDisplayChangedObservable will be notified upon these changes
  32517. * @returns The onVRDisplayChangedObservable
  32518. */
  32519. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32520. /** @hidden */
  32521. _prepareVRComponent(): void;
  32522. /** @hidden */
  32523. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32524. /** @hidden */
  32525. _submitVRFrame(): void;
  32526. /**
  32527. * Call this function to leave webVR mode
  32528. * Will do nothing if webVR is not supported or if there is no webVR device
  32529. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32530. */
  32531. disableVR(): void;
  32532. /**
  32533. * Gets a boolean indicating that the system is in VR mode and is presenting
  32534. * @returns true if VR mode is engaged
  32535. */
  32536. isVRPresenting(): boolean;
  32537. /** @hidden */
  32538. _requestVRFrame(): void;
  32539. /** @hidden */
  32540. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32541. /**
  32542. * Gets the source code of the vertex shader associated with a specific webGL program
  32543. * @param program defines the program to use
  32544. * @returns a string containing the source code of the vertex shader associated with the program
  32545. */
  32546. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32547. /**
  32548. * Gets the source code of the fragment shader associated with a specific webGL program
  32549. * @param program defines the program to use
  32550. * @returns a string containing the source code of the fragment shader associated with the program
  32551. */
  32552. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32553. /**
  32554. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32555. * @param x defines the x coordinate of the rectangle where pixels must be read
  32556. * @param y defines the y coordinate of the rectangle where pixels must be read
  32557. * @param width defines the width of the rectangle where pixels must be read
  32558. * @param height defines the height of the rectangle where pixels must be read
  32559. * @returns a Uint8Array containing RGBA colors
  32560. */
  32561. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32562. /**
  32563. * Sets a depth stencil texture from a render target to the according uniform.
  32564. * @param channel The texture channel
  32565. * @param uniform The uniform to set
  32566. * @param texture The render target texture containing the depth stencil texture to apply
  32567. */
  32568. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32569. /**
  32570. * Sets a texture to the webGL context from a postprocess
  32571. * @param channel defines the channel to use
  32572. * @param postProcess defines the source postprocess
  32573. */
  32574. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32575. /**
  32576. * Binds the output of the passed in post process to the texture channel specified
  32577. * @param channel The channel the texture should be bound to
  32578. * @param postProcess The post process which's output should be bound
  32579. */
  32580. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32581. /** @hidden */
  32582. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32583. protected _rebuildBuffers(): void;
  32584. _renderLoop(): void;
  32585. /**
  32586. * Toggle full screen mode
  32587. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32588. */
  32589. switchFullscreen(requestPointerLock: boolean): void;
  32590. /**
  32591. * Enters full screen mode
  32592. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32593. */
  32594. enterFullscreen(requestPointerLock: boolean): void;
  32595. /**
  32596. * Exits full screen mode
  32597. */
  32598. exitFullscreen(): void;
  32599. /**
  32600. * Enters Pointerlock mode
  32601. */
  32602. enterPointerlock(): void;
  32603. /**
  32604. * Exits Pointerlock mode
  32605. */
  32606. exitPointerlock(): void;
  32607. /**
  32608. * Begin a new frame
  32609. */
  32610. beginFrame(): void;
  32611. /**
  32612. * Enf the current frame
  32613. */
  32614. endFrame(): void;
  32615. resize(): void;
  32616. /**
  32617. * Set the compressed texture format to use, based on the formats you have, and the formats
  32618. * supported by the hardware / browser.
  32619. *
  32620. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32621. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32622. * to API arguments needed to compressed textures. This puts the burden on the container
  32623. * generator to house the arcane code for determining these for current & future formats.
  32624. *
  32625. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32626. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32627. *
  32628. * Note: The result of this call is not taken into account when a texture is base64.
  32629. *
  32630. * @param formatsAvailable defines the list of those format families you have created
  32631. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32632. *
  32633. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32634. * @returns The extension selected.
  32635. */
  32636. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32637. /**
  32638. * Force a specific size of the canvas
  32639. * @param width defines the new canvas' width
  32640. * @param height defines the new canvas' height
  32641. */
  32642. setSize(width: number, height: number): void;
  32643. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32644. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32645. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32646. _releaseTexture(texture: InternalTexture): void;
  32647. /**
  32648. * @hidden
  32649. * Rescales a texture
  32650. * @param source input texutre
  32651. * @param destination destination texture
  32652. * @param scene scene to use to render the resize
  32653. * @param internalFormat format to use when resizing
  32654. * @param onComplete callback to be called when resize has completed
  32655. */
  32656. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32657. /**
  32658. * Gets the current framerate
  32659. * @returns a number representing the framerate
  32660. */
  32661. getFps(): number;
  32662. /**
  32663. * Gets the time spent between current and previous frame
  32664. * @returns a number representing the delta time in ms
  32665. */
  32666. getDeltaTime(): number;
  32667. private _measureFps;
  32668. /**
  32669. * Creates a new render target texture
  32670. * @param size defines the size of the texture
  32671. * @param options defines the options used to create the texture
  32672. * @returns a new render target texture stored in an InternalTexture
  32673. */
  32674. createRenderTargetTexture(size: number | {
  32675. width: number;
  32676. height: number;
  32677. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32678. /**
  32679. * Updates the sample count of a render target texture
  32680. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32681. * @param texture defines the texture to update
  32682. * @param samples defines the sample count to set
  32683. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32684. */
  32685. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32686. /** @hidden */
  32687. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32688. dispose(): void;
  32689. private _disableTouchAction;
  32690. /**
  32691. * Display the loading screen
  32692. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32693. */
  32694. displayLoadingUI(): void;
  32695. /**
  32696. * Hide the loading screen
  32697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32698. */
  32699. hideLoadingUI(): void;
  32700. /**
  32701. * Gets the current loading screen object
  32702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32703. */
  32704. /**
  32705. * Sets the current loading screen object
  32706. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32707. */
  32708. loadingScreen: ILoadingScreen;
  32709. /**
  32710. * Sets the current loading screen text
  32711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32712. */
  32713. loadingUIText: string;
  32714. /**
  32715. * Sets the current loading screen background color
  32716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32717. */
  32718. loadingUIBackgroundColor: string;
  32719. /** Pointerlock and fullscreen */
  32720. /**
  32721. * Ask the browser to promote the current element to pointerlock mode
  32722. * @param element defines the DOM element to promote
  32723. */
  32724. static _RequestPointerlock(element: HTMLElement): void;
  32725. /**
  32726. * Asks the browser to exit pointerlock mode
  32727. */
  32728. static _ExitPointerlock(): void;
  32729. /**
  32730. * Ask the browser to promote the current element to fullscreen rendering mode
  32731. * @param element defines the DOM element to promote
  32732. */
  32733. static _RequestFullscreen(element: HTMLElement): void;
  32734. /**
  32735. * Asks the browser to exit fullscreen mode
  32736. */
  32737. static _ExitFullscreen(): void;
  32738. }
  32739. }
  32740. declare module "babylonjs/Engines/engineStore" {
  32741. import { Nullable } from "babylonjs/types";
  32742. import { Engine } from "babylonjs/Engines/engine";
  32743. import { Scene } from "babylonjs/scene";
  32744. /**
  32745. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32746. * during the life time of the application.
  32747. */
  32748. export class EngineStore {
  32749. /** Gets the list of created engines */
  32750. static Instances: import("babylonjs/Engines/engine").Engine[];
  32751. /** @hidden */
  32752. static _LastCreatedScene: Nullable<Scene>;
  32753. /**
  32754. * Gets the latest created engine
  32755. */
  32756. static readonly LastCreatedEngine: Nullable<Engine>;
  32757. /**
  32758. * Gets the latest created scene
  32759. */
  32760. static readonly LastCreatedScene: Nullable<Scene>;
  32761. /**
  32762. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32763. * @ignorenaming
  32764. */
  32765. static UseFallbackTexture: boolean;
  32766. /**
  32767. * Texture content used if a texture cannot loaded
  32768. * @ignorenaming
  32769. */
  32770. static FallbackTexture: string;
  32771. }
  32772. }
  32773. declare module "babylonjs/Misc/promise" {
  32774. /**
  32775. * Helper class that provides a small promise polyfill
  32776. */
  32777. export class PromisePolyfill {
  32778. /**
  32779. * Static function used to check if the polyfill is required
  32780. * If this is the case then the function will inject the polyfill to window.Promise
  32781. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32782. */
  32783. static Apply(force?: boolean): void;
  32784. }
  32785. }
  32786. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32787. /**
  32788. * Interface for screenshot methods with describe argument called `size` as object with options
  32789. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32790. */
  32791. export interface IScreenshotSize {
  32792. /**
  32793. * number in pixels for canvas height
  32794. */
  32795. height?: number;
  32796. /**
  32797. * multiplier allowing render at a higher or lower resolution
  32798. * If value is defined then height and width will be ignored and taken from camera
  32799. */
  32800. precision?: number;
  32801. /**
  32802. * number in pixels for canvas width
  32803. */
  32804. width?: number;
  32805. }
  32806. }
  32807. declare module "babylonjs/Misc/tools" {
  32808. import { Nullable, float } from "babylonjs/types";
  32809. import { DomManagement } from "babylonjs/Misc/domManagement";
  32810. import { WebRequest } from "babylonjs/Misc/webRequest";
  32811. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32812. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32813. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32814. import { Camera } from "babylonjs/Cameras/camera";
  32815. import { Engine } from "babylonjs/Engines/engine";
  32816. interface IColor4Like {
  32817. r: float;
  32818. g: float;
  32819. b: float;
  32820. a: float;
  32821. }
  32822. /**
  32823. * Class containing a set of static utilities functions
  32824. */
  32825. export class Tools {
  32826. /**
  32827. * Gets or sets the base URL to use to load assets
  32828. */
  32829. static BaseUrl: string;
  32830. /**
  32831. * Enable/Disable Custom HTTP Request Headers globally.
  32832. * default = false
  32833. * @see CustomRequestHeaders
  32834. */
  32835. static UseCustomRequestHeaders: boolean;
  32836. /**
  32837. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32838. * i.e. when loading files, where the server/service expects an Authorization header
  32839. */
  32840. static CustomRequestHeaders: {
  32841. [key: string]: string;
  32842. };
  32843. /**
  32844. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32845. */
  32846. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32847. /**
  32848. * Default behaviour for cors in the application.
  32849. * It can be a string if the expected behavior is identical in the entire app.
  32850. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32851. */
  32852. static CorsBehavior: string | ((url: string | string[]) => string);
  32853. /**
  32854. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32855. * @ignorenaming
  32856. */
  32857. static UseFallbackTexture: boolean;
  32858. /**
  32859. * Use this object to register external classes like custom textures or material
  32860. * to allow the laoders to instantiate them
  32861. */
  32862. static RegisteredExternalClasses: {
  32863. [key: string]: Object;
  32864. };
  32865. /**
  32866. * Texture content used if a texture cannot loaded
  32867. * @ignorenaming
  32868. */
  32869. static fallbackTexture: string;
  32870. /**
  32871. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32872. * @param u defines the coordinate on X axis
  32873. * @param v defines the coordinate on Y axis
  32874. * @param width defines the width of the source data
  32875. * @param height defines the height of the source data
  32876. * @param pixels defines the source byte array
  32877. * @param color defines the output color
  32878. */
  32879. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32880. /**
  32881. * Interpolates between a and b via alpha
  32882. * @param a The lower value (returned when alpha = 0)
  32883. * @param b The upper value (returned when alpha = 1)
  32884. * @param alpha The interpolation-factor
  32885. * @return The mixed value
  32886. */
  32887. static Mix(a: number, b: number, alpha: number): number;
  32888. /**
  32889. * Tries to instantiate a new object from a given class name
  32890. * @param className defines the class name to instantiate
  32891. * @returns the new object or null if the system was not able to do the instantiation
  32892. */
  32893. static Instantiate(className: string): any;
  32894. /**
  32895. * Provides a slice function that will work even on IE
  32896. * @param data defines the array to slice
  32897. * @param start defines the start of the data (optional)
  32898. * @param end defines the end of the data (optional)
  32899. * @returns the new sliced array
  32900. */
  32901. static Slice<T>(data: T, start?: number, end?: number): T;
  32902. /**
  32903. * Polyfill for setImmediate
  32904. * @param action defines the action to execute after the current execution block
  32905. */
  32906. static SetImmediate(action: () => void): void;
  32907. /**
  32908. * Function indicating if a number is an exponent of 2
  32909. * @param value defines the value to test
  32910. * @returns true if the value is an exponent of 2
  32911. */
  32912. static IsExponentOfTwo(value: number): boolean;
  32913. private static _tmpFloatArray;
  32914. /**
  32915. * Returns the nearest 32-bit single precision float representation of a Number
  32916. * @param value A Number. If the parameter is of a different type, it will get converted
  32917. * to a number or to NaN if it cannot be converted
  32918. * @returns number
  32919. */
  32920. static FloatRound(value: number): number;
  32921. /**
  32922. * Extracts the filename from a path
  32923. * @param path defines the path to use
  32924. * @returns the filename
  32925. */
  32926. static GetFilename(path: string): string;
  32927. /**
  32928. * Extracts the "folder" part of a path (everything before the filename).
  32929. * @param uri The URI to extract the info from
  32930. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32931. * @returns The "folder" part of the path
  32932. */
  32933. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32934. /**
  32935. * Extracts text content from a DOM element hierarchy
  32936. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32937. */
  32938. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32939. /**
  32940. * Convert an angle in radians to degrees
  32941. * @param angle defines the angle to convert
  32942. * @returns the angle in degrees
  32943. */
  32944. static ToDegrees(angle: number): number;
  32945. /**
  32946. * Convert an angle in degrees to radians
  32947. * @param angle defines the angle to convert
  32948. * @returns the angle in radians
  32949. */
  32950. static ToRadians(angle: number): number;
  32951. /**
  32952. * Encode a buffer to a base64 string
  32953. * @param buffer defines the buffer to encode
  32954. * @returns the encoded string
  32955. */
  32956. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32957. /**
  32958. * Returns an array if obj is not an array
  32959. * @param obj defines the object to evaluate as an array
  32960. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32961. * @returns either obj directly if obj is an array or a new array containing obj
  32962. */
  32963. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32964. /**
  32965. * Gets the pointer prefix to use
  32966. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32967. */
  32968. static GetPointerPrefix(): string;
  32969. /**
  32970. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32971. * @param url define the url we are trying
  32972. * @param element define the dom element where to configure the cors policy
  32973. */
  32974. static SetCorsBehavior(url: string | string[], element: {
  32975. crossOrigin: string | null;
  32976. }): void;
  32977. /**
  32978. * Removes unwanted characters from an url
  32979. * @param url defines the url to clean
  32980. * @returns the cleaned url
  32981. */
  32982. static CleanUrl(url: string): string;
  32983. /**
  32984. * Gets or sets a function used to pre-process url before using them to load assets
  32985. */
  32986. static PreprocessUrl: (url: string) => string;
  32987. /**
  32988. * Loads an image as an HTMLImageElement.
  32989. * @param input url string, ArrayBuffer, or Blob to load
  32990. * @param onLoad callback called when the image successfully loads
  32991. * @param onError callback called when the image fails to load
  32992. * @param offlineProvider offline provider for caching
  32993. * @returns the HTMLImageElement of the loaded image
  32994. */
  32995. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32996. /**
  32997. * Loads a file
  32998. * @param url url string, ArrayBuffer, or Blob to load
  32999. * @param onSuccess callback called when the file successfully loads
  33000. * @param onProgress callback called while file is loading (if the server supports this mode)
  33001. * @param offlineProvider defines the offline provider for caching
  33002. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33003. * @param onError callback called when the file fails to load
  33004. * @returns a file request object
  33005. */
  33006. 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;
  33007. /**
  33008. * Loads a file from a url
  33009. * @param url the file url to load
  33010. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33011. */
  33012. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33013. /**
  33014. * Load a script (identified by an url). When the url returns, the
  33015. * content of this file is added into a new script element, attached to the DOM (body element)
  33016. * @param scriptUrl defines the url of the script to laod
  33017. * @param onSuccess defines the callback called when the script is loaded
  33018. * @param onError defines the callback to call if an error occurs
  33019. * @param scriptId defines the id of the script element
  33020. */
  33021. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33022. /**
  33023. * Load an asynchronous script (identified by an url). When the url returns, the
  33024. * content of this file is added into a new script element, attached to the DOM (body element)
  33025. * @param scriptUrl defines the url of the script to laod
  33026. * @param scriptId defines the id of the script element
  33027. * @returns a promise request object
  33028. */
  33029. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33030. /**
  33031. * Loads a file from a blob
  33032. * @param fileToLoad defines the blob to use
  33033. * @param callback defines the callback to call when data is loaded
  33034. * @param progressCallback defines the callback to call during loading process
  33035. * @returns a file request object
  33036. */
  33037. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33038. /**
  33039. * Loads a file
  33040. * @param fileToLoad defines the file to load
  33041. * @param callback defines the callback to call when data is loaded
  33042. * @param progressCallBack defines the callback to call during loading process
  33043. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33044. * @returns a file request object
  33045. */
  33046. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33047. /**
  33048. * Creates a data url from a given string content
  33049. * @param content defines the content to convert
  33050. * @returns the new data url link
  33051. */
  33052. static FileAsURL(content: string): string;
  33053. /**
  33054. * Format the given number to a specific decimal format
  33055. * @param value defines the number to format
  33056. * @param decimals defines the number of decimals to use
  33057. * @returns the formatted string
  33058. */
  33059. static Format(value: number, decimals?: number): string;
  33060. /**
  33061. * Tries to copy an object by duplicating every property
  33062. * @param source defines the source object
  33063. * @param destination defines the target object
  33064. * @param doNotCopyList defines a list of properties to avoid
  33065. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33066. */
  33067. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33068. /**
  33069. * Gets a boolean indicating if the given object has no own property
  33070. * @param obj defines the object to test
  33071. * @returns true if object has no own property
  33072. */
  33073. static IsEmpty(obj: any): boolean;
  33074. /**
  33075. * Function used to register events at window level
  33076. * @param windowElement defines the Window object to use
  33077. * @param events defines the events to register
  33078. */
  33079. static RegisterTopRootEvents(windowElement: Window, events: {
  33080. name: string;
  33081. handler: Nullable<(e: FocusEvent) => any>;
  33082. }[]): void;
  33083. /**
  33084. * Function used to unregister events from window level
  33085. * @param windowElement defines the Window object to use
  33086. * @param events defines the events to unregister
  33087. */
  33088. static UnregisterTopRootEvents(windowElement: Window, events: {
  33089. name: string;
  33090. handler: Nullable<(e: FocusEvent) => any>;
  33091. }[]): void;
  33092. /**
  33093. * @ignore
  33094. */
  33095. static _ScreenshotCanvas: HTMLCanvasElement;
  33096. /**
  33097. * Dumps the current bound framebuffer
  33098. * @param width defines the rendering width
  33099. * @param height defines the rendering height
  33100. * @param engine defines the hosting engine
  33101. * @param successCallback defines the callback triggered once the data are available
  33102. * @param mimeType defines the mime type of the result
  33103. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33104. */
  33105. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33106. /**
  33107. * Converts the canvas data to blob.
  33108. * This acts as a polyfill for browsers not supporting the to blob function.
  33109. * @param canvas Defines the canvas to extract the data from
  33110. * @param successCallback Defines the callback triggered once the data are available
  33111. * @param mimeType Defines the mime type of the result
  33112. */
  33113. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33114. /**
  33115. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33116. * @param successCallback defines the callback triggered once the data are available
  33117. * @param mimeType defines the mime type of the result
  33118. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33119. */
  33120. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33121. /**
  33122. * Downloads a blob in the browser
  33123. * @param blob defines the blob to download
  33124. * @param fileName defines the name of the downloaded file
  33125. */
  33126. static Download(blob: Blob, fileName: string): void;
  33127. /**
  33128. * Captures a screenshot of the current rendering
  33129. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33130. * @param engine defines the rendering engine
  33131. * @param camera defines the source camera
  33132. * @param size This parameter can be set to a single number or to an object with the
  33133. * following (optional) properties: precision, width, height. If a single number is passed,
  33134. * it will be used for both width and height. If an object is passed, the screenshot size
  33135. * will be derived from the parameters. The precision property is a multiplier allowing
  33136. * rendering at a higher or lower resolution
  33137. * @param successCallback defines the callback receives a single parameter which contains the
  33138. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33139. * src parameter of an <img> to display it
  33140. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33141. * Check your browser for supported MIME types
  33142. */
  33143. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33144. /**
  33145. * Captures a screenshot of the current rendering
  33146. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33147. * @param engine defines the rendering engine
  33148. * @param camera defines the source camera
  33149. * @param size This parameter can be set to a single number or to an object with the
  33150. * following (optional) properties: precision, width, height. If a single number is passed,
  33151. * it will be used for both width and height. If an object is passed, the screenshot size
  33152. * will be derived from the parameters. The precision property is a multiplier allowing
  33153. * rendering at a higher or lower resolution
  33154. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33155. * Check your browser for supported MIME types
  33156. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33157. * to the src parameter of an <img> to display it
  33158. */
  33159. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33160. /**
  33161. * Generates an image screenshot from the specified camera.
  33162. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33163. * @param engine The engine to use for rendering
  33164. * @param camera The camera to use for rendering
  33165. * @param size This parameter can be set to a single number or to an object with the
  33166. * following (optional) properties: precision, width, height. If a single number is passed,
  33167. * it will be used for both width and height. If an object is passed, the screenshot size
  33168. * will be derived from the parameters. The precision property is a multiplier allowing
  33169. * rendering at a higher or lower resolution
  33170. * @param successCallback The callback receives a single parameter which contains the
  33171. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33172. * src parameter of an <img> to display it
  33173. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33174. * Check your browser for supported MIME types
  33175. * @param samples Texture samples (default: 1)
  33176. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33177. * @param fileName A name for for the downloaded file.
  33178. */
  33179. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33180. /**
  33181. * Generates an image screenshot from the specified camera.
  33182. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33183. * @param engine The engine to use for rendering
  33184. * @param camera The camera to use for rendering
  33185. * @param size This parameter can be set to a single number or to an object with the
  33186. * following (optional) properties: precision, width, height. If a single number is passed,
  33187. * it will be used for both width and height. If an object is passed, the screenshot size
  33188. * will be derived from the parameters. The precision property is a multiplier allowing
  33189. * rendering at a higher or lower resolution
  33190. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33191. * Check your browser for supported MIME types
  33192. * @param samples Texture samples (default: 1)
  33193. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33194. * @param fileName A name for for the downloaded file.
  33195. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33196. * to the src parameter of an <img> to display it
  33197. */
  33198. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33199. /**
  33200. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33201. * Be aware Math.random() could cause collisions, but:
  33202. * "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"
  33203. * @returns a pseudo random id
  33204. */
  33205. static RandomId(): string;
  33206. /**
  33207. * Test if the given uri is a base64 string
  33208. * @param uri The uri to test
  33209. * @return True if the uri is a base64 string or false otherwise
  33210. */
  33211. static IsBase64(uri: string): boolean;
  33212. /**
  33213. * Decode the given base64 uri.
  33214. * @param uri The uri to decode
  33215. * @return The decoded base64 data.
  33216. */
  33217. static DecodeBase64(uri: string): ArrayBuffer;
  33218. /**
  33219. * Gets the absolute url.
  33220. * @param url the input url
  33221. * @return the absolute url
  33222. */
  33223. static GetAbsoluteUrl(url: string): string;
  33224. /**
  33225. * No log
  33226. */
  33227. static readonly NoneLogLevel: number;
  33228. /**
  33229. * Only message logs
  33230. */
  33231. static readonly MessageLogLevel: number;
  33232. /**
  33233. * Only warning logs
  33234. */
  33235. static readonly WarningLogLevel: number;
  33236. /**
  33237. * Only error logs
  33238. */
  33239. static readonly ErrorLogLevel: number;
  33240. /**
  33241. * All logs
  33242. */
  33243. static readonly AllLogLevel: number;
  33244. /**
  33245. * Gets a value indicating the number of loading errors
  33246. * @ignorenaming
  33247. */
  33248. static readonly errorsCount: number;
  33249. /**
  33250. * Callback called when a new log is added
  33251. */
  33252. static OnNewCacheEntry: (entry: string) => void;
  33253. /**
  33254. * Log a message to the console
  33255. * @param message defines the message to log
  33256. */
  33257. static Log(message: string): void;
  33258. /**
  33259. * Write a warning message to the console
  33260. * @param message defines the message to log
  33261. */
  33262. static Warn(message: string): void;
  33263. /**
  33264. * Write an error message to the console
  33265. * @param message defines the message to log
  33266. */
  33267. static Error(message: string): void;
  33268. /**
  33269. * Gets current log cache (list of logs)
  33270. */
  33271. static readonly LogCache: string;
  33272. /**
  33273. * Clears the log cache
  33274. */
  33275. static ClearLogCache(): void;
  33276. /**
  33277. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33278. */
  33279. static LogLevels: number;
  33280. /**
  33281. * Checks if the window object exists
  33282. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33283. */
  33284. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33285. /**
  33286. * No performance log
  33287. */
  33288. static readonly PerformanceNoneLogLevel: number;
  33289. /**
  33290. * Use user marks to log performance
  33291. */
  33292. static readonly PerformanceUserMarkLogLevel: number;
  33293. /**
  33294. * Log performance to the console
  33295. */
  33296. static readonly PerformanceConsoleLogLevel: number;
  33297. private static _performance;
  33298. /**
  33299. * Sets the current performance log level
  33300. */
  33301. static PerformanceLogLevel: number;
  33302. private static _StartPerformanceCounterDisabled;
  33303. private static _EndPerformanceCounterDisabled;
  33304. private static _StartUserMark;
  33305. private static _EndUserMark;
  33306. private static _StartPerformanceConsole;
  33307. private static _EndPerformanceConsole;
  33308. /**
  33309. * Starts a performance counter
  33310. */
  33311. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33312. /**
  33313. * Ends a specific performance coutner
  33314. */
  33315. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33316. /**
  33317. * Gets either window.performance.now() if supported or Date.now() else
  33318. */
  33319. static readonly Now: number;
  33320. /**
  33321. * This method will return the name of the class used to create the instance of the given object.
  33322. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33323. * @param object the object to get the class name from
  33324. * @param isType defines if the object is actually a type
  33325. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33326. */
  33327. static GetClassName(object: any, isType?: boolean): string;
  33328. /**
  33329. * Gets the first element of an array satisfying a given predicate
  33330. * @param array defines the array to browse
  33331. * @param predicate defines the predicate to use
  33332. * @returns null if not found or the element
  33333. */
  33334. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33335. /**
  33336. * This method will return the name of the full name of the class, including its owning module (if any).
  33337. * 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).
  33338. * @param object the object to get the class name from
  33339. * @param isType defines if the object is actually a type
  33340. * @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.
  33341. * @ignorenaming
  33342. */
  33343. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33344. /**
  33345. * Returns a promise that resolves after the given amount of time.
  33346. * @param delay Number of milliseconds to delay
  33347. * @returns Promise that resolves after the given amount of time
  33348. */
  33349. static DelayAsync(delay: number): Promise<void>;
  33350. }
  33351. /**
  33352. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33353. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33354. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33355. * @param name The name of the class, case should be preserved
  33356. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33357. */
  33358. export function className(name: string, module?: string): (target: Object) => void;
  33359. /**
  33360. * An implementation of a loop for asynchronous functions.
  33361. */
  33362. export class AsyncLoop {
  33363. /**
  33364. * Defines the number of iterations for the loop
  33365. */
  33366. iterations: number;
  33367. /**
  33368. * Defines the current index of the loop.
  33369. */
  33370. index: number;
  33371. private _done;
  33372. private _fn;
  33373. private _successCallback;
  33374. /**
  33375. * Constructor.
  33376. * @param iterations the number of iterations.
  33377. * @param func the function to run each iteration
  33378. * @param successCallback the callback that will be called upon succesful execution
  33379. * @param offset starting offset.
  33380. */
  33381. constructor(
  33382. /**
  33383. * Defines the number of iterations for the loop
  33384. */
  33385. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33386. /**
  33387. * Execute the next iteration. Must be called after the last iteration was finished.
  33388. */
  33389. executeNext(): void;
  33390. /**
  33391. * Break the loop and run the success callback.
  33392. */
  33393. breakLoop(): void;
  33394. /**
  33395. * Create and run an async loop.
  33396. * @param iterations the number of iterations.
  33397. * @param fn the function to run each iteration
  33398. * @param successCallback the callback that will be called upon succesful execution
  33399. * @param offset starting offset.
  33400. * @returns the created async loop object
  33401. */
  33402. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33403. /**
  33404. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33405. * @param iterations total number of iterations
  33406. * @param syncedIterations number of synchronous iterations in each async iteration.
  33407. * @param fn the function to call each iteration.
  33408. * @param callback a success call back that will be called when iterating stops.
  33409. * @param breakFunction a break condition (optional)
  33410. * @param timeout timeout settings for the setTimeout function. default - 0.
  33411. * @returns the created async loop object
  33412. */
  33413. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33414. }
  33415. }
  33416. declare module "babylonjs/Misc/stringDictionary" {
  33417. import { Nullable } from "babylonjs/types";
  33418. /**
  33419. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33420. * The underlying implementation relies on an associative array to ensure the best performances.
  33421. * The value can be anything including 'null' but except 'undefined'
  33422. */
  33423. export class StringDictionary<T> {
  33424. /**
  33425. * This will clear this dictionary and copy the content from the 'source' one.
  33426. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33427. * @param source the dictionary to take the content from and copy to this dictionary
  33428. */
  33429. copyFrom(source: StringDictionary<T>): void;
  33430. /**
  33431. * Get a value based from its key
  33432. * @param key the given key to get the matching value from
  33433. * @return the value if found, otherwise undefined is returned
  33434. */
  33435. get(key: string): T | undefined;
  33436. /**
  33437. * Get a value from its key or add it if it doesn't exist.
  33438. * This method will ensure you that a given key/data will be present in the dictionary.
  33439. * @param key the given key to get the matching value from
  33440. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33441. * The factory will only be invoked if there's no data for the given key.
  33442. * @return the value corresponding to the key.
  33443. */
  33444. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33445. /**
  33446. * Get a value from its key if present in the dictionary otherwise add it
  33447. * @param key the key to get the value from
  33448. * @param val if there's no such key/value pair in the dictionary add it with this value
  33449. * @return the value corresponding to the key
  33450. */
  33451. getOrAdd(key: string, val: T): T;
  33452. /**
  33453. * Check if there's a given key in the dictionary
  33454. * @param key the key to check for
  33455. * @return true if the key is present, false otherwise
  33456. */
  33457. contains(key: string): boolean;
  33458. /**
  33459. * Add a new key and its corresponding value
  33460. * @param key the key to add
  33461. * @param value the value corresponding to the key
  33462. * @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
  33463. */
  33464. add(key: string, value: T): boolean;
  33465. /**
  33466. * Update a specific value associated to a key
  33467. * @param key defines the key to use
  33468. * @param value defines the value to store
  33469. * @returns true if the value was updated (or false if the key was not found)
  33470. */
  33471. set(key: string, value: T): boolean;
  33472. /**
  33473. * Get the element of the given key and remove it from the dictionary
  33474. * @param key defines the key to search
  33475. * @returns the value associated with the key or null if not found
  33476. */
  33477. getAndRemove(key: string): Nullable<T>;
  33478. /**
  33479. * Remove a key/value from the dictionary.
  33480. * @param key the key to remove
  33481. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33482. */
  33483. remove(key: string): boolean;
  33484. /**
  33485. * Clear the whole content of the dictionary
  33486. */
  33487. clear(): void;
  33488. /**
  33489. * Gets the current count
  33490. */
  33491. readonly count: number;
  33492. /**
  33493. * Execute a callback on each key/val of the dictionary.
  33494. * Note that you can remove any element in this dictionary in the callback implementation
  33495. * @param callback the callback to execute on a given key/value pair
  33496. */
  33497. forEach(callback: (key: string, val: T) => void): void;
  33498. /**
  33499. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33500. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33501. * Note that you can remove any element in this dictionary in the callback implementation
  33502. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33503. * @returns the first item
  33504. */
  33505. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33506. private _count;
  33507. private _data;
  33508. }
  33509. }
  33510. declare module "babylonjs/Collisions/collisionCoordinator" {
  33511. import { Nullable } from "babylonjs/types";
  33512. import { Scene } from "babylonjs/scene";
  33513. import { Vector3 } from "babylonjs/Maths/math.vector";
  33514. import { Collider } from "babylonjs/Collisions/collider";
  33515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33516. /** @hidden */
  33517. export interface ICollisionCoordinator {
  33518. createCollider(): Collider;
  33519. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33520. init(scene: Scene): void;
  33521. }
  33522. /** @hidden */
  33523. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33524. private _scene;
  33525. private _scaledPosition;
  33526. private _scaledVelocity;
  33527. private _finalPosition;
  33528. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33529. createCollider(): Collider;
  33530. init(scene: Scene): void;
  33531. private _collideWithWorld;
  33532. }
  33533. }
  33534. declare module "babylonjs/Inputs/scene.inputManager" {
  33535. import { Nullable } from "babylonjs/types";
  33536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33537. import { Vector2 } from "babylonjs/Maths/math.vector";
  33538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33539. import { Scene } from "babylonjs/scene";
  33540. /**
  33541. * Class used to manage all inputs for the scene.
  33542. */
  33543. export class InputManager {
  33544. /** The distance in pixel that you have to move to prevent some events */
  33545. static DragMovementThreshold: number;
  33546. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33547. static LongPressDelay: number;
  33548. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33549. static DoubleClickDelay: number;
  33550. /** If you need to check double click without raising a single click at first click, enable this flag */
  33551. static ExclusiveDoubleClickMode: boolean;
  33552. private _wheelEventName;
  33553. private _onPointerMove;
  33554. private _onPointerDown;
  33555. private _onPointerUp;
  33556. private _initClickEvent;
  33557. private _initActionManager;
  33558. private _delayedSimpleClick;
  33559. private _delayedSimpleClickTimeout;
  33560. private _previousDelayedSimpleClickTimeout;
  33561. private _meshPickProceed;
  33562. private _previousButtonPressed;
  33563. private _currentPickResult;
  33564. private _previousPickResult;
  33565. private _totalPointersPressed;
  33566. private _doubleClickOccured;
  33567. private _pointerOverMesh;
  33568. private _pickedDownMesh;
  33569. private _pickedUpMesh;
  33570. private _pointerX;
  33571. private _pointerY;
  33572. private _unTranslatedPointerX;
  33573. private _unTranslatedPointerY;
  33574. private _startingPointerPosition;
  33575. private _previousStartingPointerPosition;
  33576. private _startingPointerTime;
  33577. private _previousStartingPointerTime;
  33578. private _pointerCaptures;
  33579. private _onKeyDown;
  33580. private _onKeyUp;
  33581. private _onCanvasFocusObserver;
  33582. private _onCanvasBlurObserver;
  33583. private _scene;
  33584. /**
  33585. * Creates a new InputManager
  33586. * @param scene defines the hosting scene
  33587. */
  33588. constructor(scene: Scene);
  33589. /**
  33590. * Gets the mesh that is currently under the pointer
  33591. */
  33592. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33593. /**
  33594. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33595. */
  33596. readonly unTranslatedPointer: Vector2;
  33597. /**
  33598. * Gets or sets the current on-screen X position of the pointer
  33599. */
  33600. pointerX: number;
  33601. /**
  33602. * Gets or sets the current on-screen Y position of the pointer
  33603. */
  33604. pointerY: number;
  33605. private _updatePointerPosition;
  33606. private _processPointerMove;
  33607. private _setRayOnPointerInfo;
  33608. private _checkPrePointerObservable;
  33609. /**
  33610. * Use this method to simulate a pointer move on a mesh
  33611. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33612. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33613. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33614. */
  33615. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33616. /**
  33617. * Use this method to simulate a pointer down on a mesh
  33618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33621. */
  33622. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33623. private _processPointerDown;
  33624. /** @hidden */
  33625. _isPointerSwiping(): boolean;
  33626. /**
  33627. * Use this method to simulate a pointer up on a mesh
  33628. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33629. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33630. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33631. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33632. */
  33633. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33634. private _processPointerUp;
  33635. /**
  33636. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33637. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33638. * @returns true if the pointer was captured
  33639. */
  33640. isPointerCaptured(pointerId?: number): boolean;
  33641. /**
  33642. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33643. * @param attachUp defines if you want to attach events to pointerup
  33644. * @param attachDown defines if you want to attach events to pointerdown
  33645. * @param attachMove defines if you want to attach events to pointermove
  33646. */
  33647. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33648. /**
  33649. * Detaches all event handlers
  33650. */
  33651. detachControl(): void;
  33652. /**
  33653. * Force the value of meshUnderPointer
  33654. * @param mesh defines the mesh to use
  33655. */
  33656. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33657. /**
  33658. * Gets the mesh under the pointer
  33659. * @returns a Mesh or null if no mesh is under the pointer
  33660. */
  33661. getPointerOverMesh(): Nullable<AbstractMesh>;
  33662. }
  33663. }
  33664. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33665. /**
  33666. * Helper class used to generate session unique ID
  33667. */
  33668. export class UniqueIdGenerator {
  33669. private static _UniqueIdCounter;
  33670. /**
  33671. * Gets an unique (relatively to the current scene) Id
  33672. */
  33673. static readonly UniqueId: number;
  33674. }
  33675. }
  33676. declare module "babylonjs/Animations/animationGroup" {
  33677. import { Animatable } from "babylonjs/Animations/animatable";
  33678. import { Animation } from "babylonjs/Animations/animation";
  33679. import { Scene, IDisposable } from "babylonjs/scene";
  33680. import { Observable } from "babylonjs/Misc/observable";
  33681. import { Nullable } from "babylonjs/types";
  33682. import "babylonjs/Animations/animatable";
  33683. /**
  33684. * This class defines the direct association between an animation and a target
  33685. */
  33686. export class TargetedAnimation {
  33687. /**
  33688. * Animation to perform
  33689. */
  33690. animation: Animation;
  33691. /**
  33692. * Target to animate
  33693. */
  33694. target: any;
  33695. /**
  33696. * Serialize the object
  33697. * @returns the JSON object representing the current entity
  33698. */
  33699. serialize(): any;
  33700. }
  33701. /**
  33702. * Use this class to create coordinated animations on multiple targets
  33703. */
  33704. export class AnimationGroup implements IDisposable {
  33705. /** The name of the animation group */
  33706. name: string;
  33707. private _scene;
  33708. private _targetedAnimations;
  33709. private _animatables;
  33710. private _from;
  33711. private _to;
  33712. private _isStarted;
  33713. private _isPaused;
  33714. private _speedRatio;
  33715. private _loopAnimation;
  33716. /**
  33717. * Gets or sets the unique id of the node
  33718. */
  33719. uniqueId: number;
  33720. /**
  33721. * This observable will notify when one animation have ended
  33722. */
  33723. onAnimationEndObservable: Observable<TargetedAnimation>;
  33724. /**
  33725. * Observer raised when one animation loops
  33726. */
  33727. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33728. /**
  33729. * This observable will notify when all animations have ended.
  33730. */
  33731. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33732. /**
  33733. * This observable will notify when all animations have paused.
  33734. */
  33735. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33736. /**
  33737. * This observable will notify when all animations are playing.
  33738. */
  33739. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33740. /**
  33741. * Gets the first frame
  33742. */
  33743. readonly from: number;
  33744. /**
  33745. * Gets the last frame
  33746. */
  33747. readonly to: number;
  33748. /**
  33749. * Define if the animations are started
  33750. */
  33751. readonly isStarted: boolean;
  33752. /**
  33753. * Gets a value indicating that the current group is playing
  33754. */
  33755. readonly isPlaying: boolean;
  33756. /**
  33757. * Gets or sets the speed ratio to use for all animations
  33758. */
  33759. /**
  33760. * Gets or sets the speed ratio to use for all animations
  33761. */
  33762. speedRatio: number;
  33763. /**
  33764. * Gets or sets if all animations should loop or not
  33765. */
  33766. loopAnimation: boolean;
  33767. /**
  33768. * Gets the targeted animations for this animation group
  33769. */
  33770. readonly targetedAnimations: Array<TargetedAnimation>;
  33771. /**
  33772. * returning the list of animatables controlled by this animation group.
  33773. */
  33774. readonly animatables: Array<Animatable>;
  33775. /**
  33776. * Instantiates a new Animation Group.
  33777. * This helps managing several animations at once.
  33778. * @see http://doc.babylonjs.com/how_to/group
  33779. * @param name Defines the name of the group
  33780. * @param scene Defines the scene the group belongs to
  33781. */
  33782. constructor(
  33783. /** The name of the animation group */
  33784. name: string, scene?: Nullable<Scene>);
  33785. /**
  33786. * Add an animation (with its target) in the group
  33787. * @param animation defines the animation we want to add
  33788. * @param target defines the target of the animation
  33789. * @returns the TargetedAnimation object
  33790. */
  33791. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33792. /**
  33793. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33794. * It can add constant keys at begin or end
  33795. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33796. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33797. * @returns the animation group
  33798. */
  33799. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33800. /**
  33801. * Start all animations on given targets
  33802. * @param loop defines if animations must loop
  33803. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33804. * @param from defines the from key (optional)
  33805. * @param to defines the to key (optional)
  33806. * @returns the current animation group
  33807. */
  33808. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33809. /**
  33810. * Pause all animations
  33811. * @returns the animation group
  33812. */
  33813. pause(): AnimationGroup;
  33814. /**
  33815. * Play all animations to initial state
  33816. * This function will start() the animations if they were not started or will restart() them if they were paused
  33817. * @param loop defines if animations must loop
  33818. * @returns the animation group
  33819. */
  33820. play(loop?: boolean): AnimationGroup;
  33821. /**
  33822. * Reset all animations to initial state
  33823. * @returns the animation group
  33824. */
  33825. reset(): AnimationGroup;
  33826. /**
  33827. * Restart animations from key 0
  33828. * @returns the animation group
  33829. */
  33830. restart(): AnimationGroup;
  33831. /**
  33832. * Stop all animations
  33833. * @returns the animation group
  33834. */
  33835. stop(): AnimationGroup;
  33836. /**
  33837. * Set animation weight for all animatables
  33838. * @param weight defines the weight to use
  33839. * @return the animationGroup
  33840. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33841. */
  33842. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33843. /**
  33844. * Synchronize and normalize all animatables with a source animatable
  33845. * @param root defines the root animatable to synchronize with
  33846. * @return the animationGroup
  33847. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33848. */
  33849. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33850. /**
  33851. * Goes to a specific frame in this animation group
  33852. * @param frame the frame number to go to
  33853. * @return the animationGroup
  33854. */
  33855. goToFrame(frame: number): AnimationGroup;
  33856. /**
  33857. * Dispose all associated resources
  33858. */
  33859. dispose(): void;
  33860. private _checkAnimationGroupEnded;
  33861. /**
  33862. * Clone the current animation group and returns a copy
  33863. * @param newName defines the name of the new group
  33864. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33865. * @returns the new aniamtion group
  33866. */
  33867. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33868. /**
  33869. * Serializes the animationGroup to an object
  33870. * @returns Serialized object
  33871. */
  33872. serialize(): any;
  33873. /**
  33874. * Returns a new AnimationGroup object parsed from the source provided.
  33875. * @param parsedAnimationGroup defines the source
  33876. * @param scene defines the scene that will receive the animationGroup
  33877. * @returns a new AnimationGroup
  33878. */
  33879. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33880. /**
  33881. * Returns the string "AnimationGroup"
  33882. * @returns "AnimationGroup"
  33883. */
  33884. getClassName(): string;
  33885. /**
  33886. * Creates a detailled string about the object
  33887. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33888. * @returns a string representing the object
  33889. */
  33890. toString(fullDetails?: boolean): string;
  33891. }
  33892. }
  33893. declare module "babylonjs/scene" {
  33894. import { Nullable } from "babylonjs/types";
  33895. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33896. import { Observable } from "babylonjs/Misc/observable";
  33897. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33898. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33899. import { Geometry } from "babylonjs/Meshes/geometry";
  33900. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33901. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33902. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33903. import { Mesh } from "babylonjs/Meshes/mesh";
  33904. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33905. import { Bone } from "babylonjs/Bones/bone";
  33906. import { Skeleton } from "babylonjs/Bones/skeleton";
  33907. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33908. import { Camera } from "babylonjs/Cameras/camera";
  33909. import { AbstractScene } from "babylonjs/abstractScene";
  33910. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33911. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33912. import { Material } from "babylonjs/Materials/material";
  33913. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33914. import { Effect } from "babylonjs/Materials/effect";
  33915. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33916. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33917. import { Light } from "babylonjs/Lights/light";
  33918. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33919. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33920. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33921. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33922. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33923. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33924. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33925. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33926. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33927. import { Engine } from "babylonjs/Engines/engine";
  33928. import { Node } from "babylonjs/node";
  33929. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33930. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33931. import { WebRequest } from "babylonjs/Misc/webRequest";
  33932. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33933. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33934. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33935. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33936. import { Plane } from "babylonjs/Maths/math.plane";
  33937. import { Ray } from "babylonjs/Culling/ray";
  33938. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33939. import { Animation } from "babylonjs/Animations/animation";
  33940. import { Animatable } from "babylonjs/Animations/animatable";
  33941. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33942. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33943. import { Collider } from "babylonjs/Collisions/collider";
  33944. /**
  33945. * Define an interface for all classes that will hold resources
  33946. */
  33947. export interface IDisposable {
  33948. /**
  33949. * Releases all held resources
  33950. */
  33951. dispose(): void;
  33952. }
  33953. /** Interface defining initialization parameters for Scene class */
  33954. export interface SceneOptions {
  33955. /**
  33956. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33957. * It will improve performance when the number of geometries becomes important.
  33958. */
  33959. useGeometryUniqueIdsMap?: boolean;
  33960. /**
  33961. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33962. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33963. */
  33964. useMaterialMeshMap?: boolean;
  33965. /**
  33966. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33967. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33968. */
  33969. useClonedMeshhMap?: boolean;
  33970. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33971. virtual?: boolean;
  33972. }
  33973. /**
  33974. * Represents a scene to be rendered by the engine.
  33975. * @see http://doc.babylonjs.com/features/scene
  33976. */
  33977. export class Scene extends AbstractScene implements IAnimatable {
  33978. /** The fog is deactivated */
  33979. static readonly FOGMODE_NONE: number;
  33980. /** The fog density is following an exponential function */
  33981. static readonly FOGMODE_EXP: number;
  33982. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33983. static readonly FOGMODE_EXP2: number;
  33984. /** The fog density is following a linear function. */
  33985. static readonly FOGMODE_LINEAR: number;
  33986. /**
  33987. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33988. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33989. */
  33990. static MinDeltaTime: number;
  33991. /**
  33992. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33994. */
  33995. static MaxDeltaTime: number;
  33996. /**
  33997. * Factory used to create the default material.
  33998. * @param name The name of the material to create
  33999. * @param scene The scene to create the material for
  34000. * @returns The default material
  34001. */
  34002. static DefaultMaterialFactory(scene: Scene): Material;
  34003. /**
  34004. * Factory used to create the a collision coordinator.
  34005. * @returns The collision coordinator
  34006. */
  34007. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34008. /** @hidden */
  34009. _inputManager: InputManager;
  34010. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34011. cameraToUseForPointers: Nullable<Camera>;
  34012. /** @hidden */
  34013. readonly _isScene: boolean;
  34014. /**
  34015. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34016. */
  34017. autoClear: boolean;
  34018. /**
  34019. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34020. */
  34021. autoClearDepthAndStencil: boolean;
  34022. /**
  34023. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34024. */
  34025. clearColor: Color4;
  34026. /**
  34027. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34028. */
  34029. ambientColor: Color3;
  34030. /**
  34031. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34032. * It should only be one of the following (if not the default embedded one):
  34033. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34034. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34035. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34036. * The material properties need to be setup according to the type of texture in use.
  34037. */
  34038. environmentBRDFTexture: BaseTexture;
  34039. /** @hidden */
  34040. protected _environmentTexture: Nullable<BaseTexture>;
  34041. /**
  34042. * Texture used in all pbr material as the reflection texture.
  34043. * As in the majority of the scene they are the same (exception for multi room and so on),
  34044. * this is easier to reference from here than from all the materials.
  34045. */
  34046. /**
  34047. * Texture used in all pbr material as the reflection texture.
  34048. * As in the majority of the scene they are the same (exception for multi room and so on),
  34049. * this is easier to set here than in all the materials.
  34050. */
  34051. environmentTexture: Nullable<BaseTexture>;
  34052. /** @hidden */
  34053. protected _environmentIntensity: number;
  34054. /**
  34055. * Intensity of the environment in all pbr material.
  34056. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34057. * As in the majority of the scene they are the same (exception for multi room and so on),
  34058. * this is easier to reference from here than from all the materials.
  34059. */
  34060. /**
  34061. * Intensity of the environment in all pbr material.
  34062. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34063. * As in the majority of the scene they are the same (exception for multi room and so on),
  34064. * this is easier to set here than in all the materials.
  34065. */
  34066. environmentIntensity: number;
  34067. /** @hidden */
  34068. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34069. /**
  34070. * Default image processing configuration used either in the rendering
  34071. * Forward main pass or through the imageProcessingPostProcess if present.
  34072. * As in the majority of the scene they are the same (exception for multi camera),
  34073. * this is easier to reference from here than from all the materials and post process.
  34074. *
  34075. * No setter as we it is a shared configuration, you can set the values instead.
  34076. */
  34077. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34078. private _forceWireframe;
  34079. /**
  34080. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34081. */
  34082. forceWireframe: boolean;
  34083. private _forcePointsCloud;
  34084. /**
  34085. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34086. */
  34087. forcePointsCloud: boolean;
  34088. /**
  34089. * Gets or sets the active clipplane 1
  34090. */
  34091. clipPlane: Nullable<Plane>;
  34092. /**
  34093. * Gets or sets the active clipplane 2
  34094. */
  34095. clipPlane2: Nullable<Plane>;
  34096. /**
  34097. * Gets or sets the active clipplane 3
  34098. */
  34099. clipPlane3: Nullable<Plane>;
  34100. /**
  34101. * Gets or sets the active clipplane 4
  34102. */
  34103. clipPlane4: Nullable<Plane>;
  34104. /**
  34105. * Gets or sets a boolean indicating if animations are enabled
  34106. */
  34107. animationsEnabled: boolean;
  34108. private _animationPropertiesOverride;
  34109. /**
  34110. * Gets or sets the animation properties override
  34111. */
  34112. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34113. /**
  34114. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34115. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34116. */
  34117. useConstantAnimationDeltaTime: boolean;
  34118. /**
  34119. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34120. * Please note that it requires to run a ray cast through the scene on every frame
  34121. */
  34122. constantlyUpdateMeshUnderPointer: boolean;
  34123. /**
  34124. * Defines the HTML cursor to use when hovering over interactive elements
  34125. */
  34126. hoverCursor: string;
  34127. /**
  34128. * Defines the HTML default cursor to use (empty by default)
  34129. */
  34130. defaultCursor: string;
  34131. /**
  34132. * This is used to call preventDefault() on pointer down
  34133. * in order to block unwanted artifacts like system double clicks
  34134. */
  34135. preventDefaultOnPointerDown: boolean;
  34136. /**
  34137. * This is used to call preventDefault() on pointer up
  34138. * in order to block unwanted artifacts like system double clicks
  34139. */
  34140. preventDefaultOnPointerUp: boolean;
  34141. /**
  34142. * Gets or sets user defined metadata
  34143. */
  34144. metadata: any;
  34145. /**
  34146. * For internal use only. Please do not use.
  34147. */
  34148. reservedDataStore: any;
  34149. /**
  34150. * Gets the name of the plugin used to load this scene (null by default)
  34151. */
  34152. loadingPluginName: string;
  34153. /**
  34154. * Use this array to add regular expressions used to disable offline support for specific urls
  34155. */
  34156. disableOfflineSupportExceptionRules: RegExp[];
  34157. /**
  34158. * An event triggered when the scene is disposed.
  34159. */
  34160. onDisposeObservable: Observable<Scene>;
  34161. private _onDisposeObserver;
  34162. /** Sets a function to be executed when this scene is disposed. */
  34163. onDispose: () => void;
  34164. /**
  34165. * An event triggered before rendering the scene (right after animations and physics)
  34166. */
  34167. onBeforeRenderObservable: Observable<Scene>;
  34168. private _onBeforeRenderObserver;
  34169. /** Sets a function to be executed before rendering this scene */
  34170. beforeRender: Nullable<() => void>;
  34171. /**
  34172. * An event triggered after rendering the scene
  34173. */
  34174. onAfterRenderObservable: Observable<Scene>;
  34175. /**
  34176. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34177. */
  34178. onAfterRenderCameraObservable: Observable<Camera>;
  34179. private _onAfterRenderObserver;
  34180. /** Sets a function to be executed after rendering this scene */
  34181. afterRender: Nullable<() => void>;
  34182. /**
  34183. * An event triggered before animating the scene
  34184. */
  34185. onBeforeAnimationsObservable: Observable<Scene>;
  34186. /**
  34187. * An event triggered after animations processing
  34188. */
  34189. onAfterAnimationsObservable: Observable<Scene>;
  34190. /**
  34191. * An event triggered before draw calls are ready to be sent
  34192. */
  34193. onBeforeDrawPhaseObservable: Observable<Scene>;
  34194. /**
  34195. * An event triggered after draw calls have been sent
  34196. */
  34197. onAfterDrawPhaseObservable: Observable<Scene>;
  34198. /**
  34199. * An event triggered when the scene is ready
  34200. */
  34201. onReadyObservable: Observable<Scene>;
  34202. /**
  34203. * An event triggered before rendering a camera
  34204. */
  34205. onBeforeCameraRenderObservable: Observable<Camera>;
  34206. private _onBeforeCameraRenderObserver;
  34207. /** Sets a function to be executed before rendering a camera*/
  34208. beforeCameraRender: () => void;
  34209. /**
  34210. * An event triggered after rendering a camera
  34211. */
  34212. onAfterCameraRenderObservable: Observable<Camera>;
  34213. private _onAfterCameraRenderObserver;
  34214. /** Sets a function to be executed after rendering a camera*/
  34215. afterCameraRender: () => void;
  34216. /**
  34217. * An event triggered when active meshes evaluation is about to start
  34218. */
  34219. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34220. /**
  34221. * An event triggered when active meshes evaluation is done
  34222. */
  34223. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34224. /**
  34225. * An event triggered when particles rendering is about to start
  34226. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34227. */
  34228. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34229. /**
  34230. * An event triggered when particles rendering is done
  34231. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34232. */
  34233. onAfterParticlesRenderingObservable: Observable<Scene>;
  34234. /**
  34235. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34236. */
  34237. onDataLoadedObservable: Observable<Scene>;
  34238. /**
  34239. * An event triggered when a camera is created
  34240. */
  34241. onNewCameraAddedObservable: Observable<Camera>;
  34242. /**
  34243. * An event triggered when a camera is removed
  34244. */
  34245. onCameraRemovedObservable: Observable<Camera>;
  34246. /**
  34247. * An event triggered when a light is created
  34248. */
  34249. onNewLightAddedObservable: Observable<Light>;
  34250. /**
  34251. * An event triggered when a light is removed
  34252. */
  34253. onLightRemovedObservable: Observable<Light>;
  34254. /**
  34255. * An event triggered when a geometry is created
  34256. */
  34257. onNewGeometryAddedObservable: Observable<Geometry>;
  34258. /**
  34259. * An event triggered when a geometry is removed
  34260. */
  34261. onGeometryRemovedObservable: Observable<Geometry>;
  34262. /**
  34263. * An event triggered when a transform node is created
  34264. */
  34265. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34266. /**
  34267. * An event triggered when a transform node is removed
  34268. */
  34269. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34270. /**
  34271. * An event triggered when a mesh is created
  34272. */
  34273. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34274. /**
  34275. * An event triggered when a mesh is removed
  34276. */
  34277. onMeshRemovedObservable: Observable<AbstractMesh>;
  34278. /**
  34279. * An event triggered when a skeleton is created
  34280. */
  34281. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34282. /**
  34283. * An event triggered when a skeleton is removed
  34284. */
  34285. onSkeletonRemovedObservable: Observable<Skeleton>;
  34286. /**
  34287. * An event triggered when a material is created
  34288. */
  34289. onNewMaterialAddedObservable: Observable<Material>;
  34290. /**
  34291. * An event triggered when a material is removed
  34292. */
  34293. onMaterialRemovedObservable: Observable<Material>;
  34294. /**
  34295. * An event triggered when a texture is created
  34296. */
  34297. onNewTextureAddedObservable: Observable<BaseTexture>;
  34298. /**
  34299. * An event triggered when a texture is removed
  34300. */
  34301. onTextureRemovedObservable: Observable<BaseTexture>;
  34302. /**
  34303. * An event triggered when render targets are about to be rendered
  34304. * Can happen multiple times per frame.
  34305. */
  34306. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34307. /**
  34308. * An event triggered when render targets were rendered.
  34309. * Can happen multiple times per frame.
  34310. */
  34311. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34312. /**
  34313. * An event triggered before calculating deterministic simulation step
  34314. */
  34315. onBeforeStepObservable: Observable<Scene>;
  34316. /**
  34317. * An event triggered after calculating deterministic simulation step
  34318. */
  34319. onAfterStepObservable: Observable<Scene>;
  34320. /**
  34321. * An event triggered when the activeCamera property is updated
  34322. */
  34323. onActiveCameraChanged: Observable<Scene>;
  34324. /**
  34325. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34326. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34327. * 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)
  34328. */
  34329. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34330. /**
  34331. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34332. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34333. * 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)
  34334. */
  34335. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34336. /**
  34337. * This Observable will when a mesh has been imported into the scene.
  34338. */
  34339. onMeshImportedObservable: Observable<AbstractMesh>;
  34340. /**
  34341. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34342. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34343. */
  34344. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34345. /** @hidden */
  34346. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34347. /**
  34348. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34349. */
  34350. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34351. /**
  34352. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34353. */
  34354. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34355. /**
  34356. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34357. */
  34358. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34359. /** Callback called when a pointer move is detected */
  34360. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34361. /** Callback called when a pointer down is detected */
  34362. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34363. /** Callback called when a pointer up is detected */
  34364. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34365. /** Callback called when a pointer pick is detected */
  34366. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34367. /**
  34368. * 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).
  34369. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34370. */
  34371. onPrePointerObservable: Observable<PointerInfoPre>;
  34372. /**
  34373. * Observable event triggered each time an input event is received from the rendering canvas
  34374. */
  34375. onPointerObservable: Observable<PointerInfo>;
  34376. /**
  34377. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34378. */
  34379. readonly unTranslatedPointer: Vector2;
  34380. /**
  34381. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34382. */
  34383. static DragMovementThreshold: number;
  34384. /**
  34385. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34386. */
  34387. static LongPressDelay: number;
  34388. /**
  34389. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34390. */
  34391. static DoubleClickDelay: number;
  34392. /** If you need to check double click without raising a single click at first click, enable this flag */
  34393. static ExclusiveDoubleClickMode: boolean;
  34394. /** @hidden */
  34395. _mirroredCameraPosition: Nullable<Vector3>;
  34396. /**
  34397. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34398. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34399. */
  34400. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34401. /**
  34402. * Observable event triggered each time an keyboard event is received from the hosting window
  34403. */
  34404. onKeyboardObservable: Observable<KeyboardInfo>;
  34405. private _useRightHandedSystem;
  34406. /**
  34407. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34408. */
  34409. useRightHandedSystem: boolean;
  34410. private _timeAccumulator;
  34411. private _currentStepId;
  34412. private _currentInternalStep;
  34413. /**
  34414. * Sets the step Id used by deterministic lock step
  34415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34416. * @param newStepId defines the step Id
  34417. */
  34418. setStepId(newStepId: number): void;
  34419. /**
  34420. * Gets the step Id used by deterministic lock step
  34421. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34422. * @returns the step Id
  34423. */
  34424. getStepId(): number;
  34425. /**
  34426. * Gets the internal step used by deterministic lock step
  34427. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34428. * @returns the internal step
  34429. */
  34430. getInternalStep(): number;
  34431. private _fogEnabled;
  34432. /**
  34433. * Gets or sets a boolean indicating if fog is enabled on this scene
  34434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34435. * (Default is true)
  34436. */
  34437. fogEnabled: boolean;
  34438. private _fogMode;
  34439. /**
  34440. * Gets or sets the fog mode to use
  34441. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34442. * | mode | value |
  34443. * | --- | --- |
  34444. * | FOGMODE_NONE | 0 |
  34445. * | FOGMODE_EXP | 1 |
  34446. * | FOGMODE_EXP2 | 2 |
  34447. * | FOGMODE_LINEAR | 3 |
  34448. */
  34449. fogMode: number;
  34450. /**
  34451. * Gets or sets the fog color to use
  34452. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34453. * (Default is Color3(0.2, 0.2, 0.3))
  34454. */
  34455. fogColor: Color3;
  34456. /**
  34457. * Gets or sets the fog density to use
  34458. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34459. * (Default is 0.1)
  34460. */
  34461. fogDensity: number;
  34462. /**
  34463. * Gets or sets the fog start distance to use
  34464. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34465. * (Default is 0)
  34466. */
  34467. fogStart: number;
  34468. /**
  34469. * Gets or sets the fog end distance to use
  34470. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34471. * (Default is 1000)
  34472. */
  34473. fogEnd: number;
  34474. private _shadowsEnabled;
  34475. /**
  34476. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34477. */
  34478. shadowsEnabled: boolean;
  34479. private _lightsEnabled;
  34480. /**
  34481. * Gets or sets a boolean indicating if lights are enabled on this scene
  34482. */
  34483. lightsEnabled: boolean;
  34484. /** All of the active cameras added to this scene. */
  34485. activeCameras: Camera[];
  34486. /** @hidden */
  34487. _activeCamera: Nullable<Camera>;
  34488. /** Gets or sets the current active camera */
  34489. activeCamera: Nullable<Camera>;
  34490. private _defaultMaterial;
  34491. /** The default material used on meshes when no material is affected */
  34492. /** The default material used on meshes when no material is affected */
  34493. defaultMaterial: Material;
  34494. private _texturesEnabled;
  34495. /**
  34496. * Gets or sets a boolean indicating if textures are enabled on this scene
  34497. */
  34498. texturesEnabled: boolean;
  34499. /**
  34500. * Gets or sets a boolean indicating if particles are enabled on this scene
  34501. */
  34502. particlesEnabled: boolean;
  34503. /**
  34504. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34505. */
  34506. spritesEnabled: boolean;
  34507. private _skeletonsEnabled;
  34508. /**
  34509. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34510. */
  34511. skeletonsEnabled: boolean;
  34512. /**
  34513. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34514. */
  34515. lensFlaresEnabled: boolean;
  34516. /**
  34517. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34518. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34519. */
  34520. collisionsEnabled: boolean;
  34521. private _collisionCoordinator;
  34522. /** @hidden */
  34523. readonly collisionCoordinator: ICollisionCoordinator;
  34524. /**
  34525. * Defines the gravity applied to this scene (used only for collisions)
  34526. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34527. */
  34528. gravity: Vector3;
  34529. /**
  34530. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34531. */
  34532. postProcessesEnabled: boolean;
  34533. /**
  34534. * The list of postprocesses added to the scene
  34535. */
  34536. postProcesses: PostProcess[];
  34537. /**
  34538. * Gets the current postprocess manager
  34539. */
  34540. postProcessManager: PostProcessManager;
  34541. /**
  34542. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34543. */
  34544. renderTargetsEnabled: boolean;
  34545. /**
  34546. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34547. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34548. */
  34549. dumpNextRenderTargets: boolean;
  34550. /**
  34551. * The list of user defined render targets added to the scene
  34552. */
  34553. customRenderTargets: RenderTargetTexture[];
  34554. /**
  34555. * Defines if texture loading must be delayed
  34556. * If true, textures will only be loaded when they need to be rendered
  34557. */
  34558. useDelayedTextureLoading: boolean;
  34559. /**
  34560. * Gets the list of meshes imported to the scene through SceneLoader
  34561. */
  34562. importedMeshesFiles: String[];
  34563. /**
  34564. * Gets or sets a boolean indicating if probes are enabled on this scene
  34565. */
  34566. probesEnabled: boolean;
  34567. /**
  34568. * Gets or sets the current offline provider to use to store scene data
  34569. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34570. */
  34571. offlineProvider: IOfflineProvider;
  34572. /**
  34573. * Gets or sets the action manager associated with the scene
  34574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34575. */
  34576. actionManager: AbstractActionManager;
  34577. private _meshesForIntersections;
  34578. /**
  34579. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34580. */
  34581. proceduralTexturesEnabled: boolean;
  34582. private _engine;
  34583. private _totalVertices;
  34584. /** @hidden */
  34585. _activeIndices: PerfCounter;
  34586. /** @hidden */
  34587. _activeParticles: PerfCounter;
  34588. /** @hidden */
  34589. _activeBones: PerfCounter;
  34590. private _animationRatio;
  34591. /** @hidden */
  34592. _animationTimeLast: number;
  34593. /** @hidden */
  34594. _animationTime: number;
  34595. /**
  34596. * Gets or sets a general scale for animation speed
  34597. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34598. */
  34599. animationTimeScale: number;
  34600. /** @hidden */
  34601. _cachedMaterial: Nullable<Material>;
  34602. /** @hidden */
  34603. _cachedEffect: Nullable<Effect>;
  34604. /** @hidden */
  34605. _cachedVisibility: Nullable<number>;
  34606. private _renderId;
  34607. private _frameId;
  34608. private _executeWhenReadyTimeoutId;
  34609. private _intermediateRendering;
  34610. private _viewUpdateFlag;
  34611. private _projectionUpdateFlag;
  34612. /** @hidden */
  34613. _toBeDisposed: Nullable<IDisposable>[];
  34614. private _activeRequests;
  34615. /** @hidden */
  34616. _pendingData: any[];
  34617. private _isDisposed;
  34618. /**
  34619. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34620. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34621. */
  34622. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34623. private _activeMeshes;
  34624. private _processedMaterials;
  34625. private _renderTargets;
  34626. /** @hidden */
  34627. _activeParticleSystems: SmartArray<IParticleSystem>;
  34628. private _activeSkeletons;
  34629. private _softwareSkinnedMeshes;
  34630. private _renderingManager;
  34631. /** @hidden */
  34632. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34633. private _transformMatrix;
  34634. private _sceneUbo;
  34635. /** @hidden */
  34636. _viewMatrix: Matrix;
  34637. private _projectionMatrix;
  34638. /** @hidden */
  34639. _forcedViewPosition: Nullable<Vector3>;
  34640. /** @hidden */
  34641. _frustumPlanes: Plane[];
  34642. /**
  34643. * Gets the list of frustum planes (built from the active camera)
  34644. */
  34645. readonly frustumPlanes: Plane[];
  34646. /**
  34647. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34648. * This is useful if there are more lights that the maximum simulteanous authorized
  34649. */
  34650. requireLightSorting: boolean;
  34651. /** @hidden */
  34652. readonly useMaterialMeshMap: boolean;
  34653. /** @hidden */
  34654. readonly useClonedMeshhMap: boolean;
  34655. private _externalData;
  34656. private _uid;
  34657. /**
  34658. * @hidden
  34659. * Backing store of defined scene components.
  34660. */
  34661. _components: ISceneComponent[];
  34662. /**
  34663. * @hidden
  34664. * Backing store of defined scene components.
  34665. */
  34666. _serializableComponents: ISceneSerializableComponent[];
  34667. /**
  34668. * List of components to register on the next registration step.
  34669. */
  34670. private _transientComponents;
  34671. /**
  34672. * Registers the transient components if needed.
  34673. */
  34674. private _registerTransientComponents;
  34675. /**
  34676. * @hidden
  34677. * Add a component to the scene.
  34678. * Note that the ccomponent could be registered on th next frame if this is called after
  34679. * the register component stage.
  34680. * @param component Defines the component to add to the scene
  34681. */
  34682. _addComponent(component: ISceneComponent): void;
  34683. /**
  34684. * @hidden
  34685. * Gets a component from the scene.
  34686. * @param name defines the name of the component to retrieve
  34687. * @returns the component or null if not present
  34688. */
  34689. _getComponent(name: string): Nullable<ISceneComponent>;
  34690. /**
  34691. * @hidden
  34692. * Defines the actions happening before camera updates.
  34693. */
  34694. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34695. /**
  34696. * @hidden
  34697. * Defines the actions happening before clear the canvas.
  34698. */
  34699. _beforeClearStage: Stage<SimpleStageAction>;
  34700. /**
  34701. * @hidden
  34702. * Defines the actions when collecting render targets for the frame.
  34703. */
  34704. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34705. /**
  34706. * @hidden
  34707. * Defines the actions happening for one camera in the frame.
  34708. */
  34709. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34710. /**
  34711. * @hidden
  34712. * Defines the actions happening during the per mesh ready checks.
  34713. */
  34714. _isReadyForMeshStage: Stage<MeshStageAction>;
  34715. /**
  34716. * @hidden
  34717. * Defines the actions happening before evaluate active mesh checks.
  34718. */
  34719. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34720. /**
  34721. * @hidden
  34722. * Defines the actions happening during the evaluate sub mesh checks.
  34723. */
  34724. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34725. /**
  34726. * @hidden
  34727. * Defines the actions happening during the active mesh stage.
  34728. */
  34729. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34730. /**
  34731. * @hidden
  34732. * Defines the actions happening during the per camera render target step.
  34733. */
  34734. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34735. /**
  34736. * @hidden
  34737. * Defines the actions happening just before the active camera is drawing.
  34738. */
  34739. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34740. /**
  34741. * @hidden
  34742. * Defines the actions happening just before a render target is drawing.
  34743. */
  34744. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34745. /**
  34746. * @hidden
  34747. * Defines the actions happening just before a rendering group is drawing.
  34748. */
  34749. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34750. /**
  34751. * @hidden
  34752. * Defines the actions happening just before a mesh is drawing.
  34753. */
  34754. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34755. /**
  34756. * @hidden
  34757. * Defines the actions happening just after a mesh has been drawn.
  34758. */
  34759. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34760. /**
  34761. * @hidden
  34762. * Defines the actions happening just after a rendering group has been drawn.
  34763. */
  34764. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34765. /**
  34766. * @hidden
  34767. * Defines the actions happening just after the active camera has been drawn.
  34768. */
  34769. _afterCameraDrawStage: Stage<CameraStageAction>;
  34770. /**
  34771. * @hidden
  34772. * Defines the actions happening just after a render target has been drawn.
  34773. */
  34774. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34775. /**
  34776. * @hidden
  34777. * Defines the actions happening just after rendering all cameras and computing intersections.
  34778. */
  34779. _afterRenderStage: Stage<SimpleStageAction>;
  34780. /**
  34781. * @hidden
  34782. * Defines the actions happening when a pointer move event happens.
  34783. */
  34784. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34785. /**
  34786. * @hidden
  34787. * Defines the actions happening when a pointer down event happens.
  34788. */
  34789. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34790. /**
  34791. * @hidden
  34792. * Defines the actions happening when a pointer up event happens.
  34793. */
  34794. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34795. /**
  34796. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34797. */
  34798. private geometriesByUniqueId;
  34799. /**
  34800. * Creates a new Scene
  34801. * @param engine defines the engine to use to render this scene
  34802. * @param options defines the scene options
  34803. */
  34804. constructor(engine: Engine, options?: SceneOptions);
  34805. /**
  34806. * Gets a string idenfifying the name of the class
  34807. * @returns "Scene" string
  34808. */
  34809. getClassName(): string;
  34810. private _defaultMeshCandidates;
  34811. /**
  34812. * @hidden
  34813. */
  34814. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34815. private _defaultSubMeshCandidates;
  34816. /**
  34817. * @hidden
  34818. */
  34819. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34820. /**
  34821. * Sets the default candidate providers for the scene.
  34822. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34823. * and getCollidingSubMeshCandidates to their default function
  34824. */
  34825. setDefaultCandidateProviders(): void;
  34826. /**
  34827. * Gets the mesh that is currently under the pointer
  34828. */
  34829. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34830. /**
  34831. * Gets or sets the current on-screen X position of the pointer
  34832. */
  34833. pointerX: number;
  34834. /**
  34835. * Gets or sets the current on-screen Y position of the pointer
  34836. */
  34837. pointerY: number;
  34838. /**
  34839. * Gets the cached material (ie. the latest rendered one)
  34840. * @returns the cached material
  34841. */
  34842. getCachedMaterial(): Nullable<Material>;
  34843. /**
  34844. * Gets the cached effect (ie. the latest rendered one)
  34845. * @returns the cached effect
  34846. */
  34847. getCachedEffect(): Nullable<Effect>;
  34848. /**
  34849. * Gets the cached visibility state (ie. the latest rendered one)
  34850. * @returns the cached visibility state
  34851. */
  34852. getCachedVisibility(): Nullable<number>;
  34853. /**
  34854. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34855. * @param material defines the current material
  34856. * @param effect defines the current effect
  34857. * @param visibility defines the current visibility state
  34858. * @returns true if one parameter is not cached
  34859. */
  34860. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34861. /**
  34862. * Gets the engine associated with the scene
  34863. * @returns an Engine
  34864. */
  34865. getEngine(): Engine;
  34866. /**
  34867. * Gets the total number of vertices rendered per frame
  34868. * @returns the total number of vertices rendered per frame
  34869. */
  34870. getTotalVertices(): number;
  34871. /**
  34872. * Gets the performance counter for total vertices
  34873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34874. */
  34875. readonly totalVerticesPerfCounter: PerfCounter;
  34876. /**
  34877. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34878. * @returns the total number of active indices rendered per frame
  34879. */
  34880. getActiveIndices(): number;
  34881. /**
  34882. * Gets the performance counter for active indices
  34883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34884. */
  34885. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34886. /**
  34887. * Gets the total number of active particles rendered per frame
  34888. * @returns the total number of active particles rendered per frame
  34889. */
  34890. getActiveParticles(): number;
  34891. /**
  34892. * Gets the performance counter for active particles
  34893. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34894. */
  34895. readonly activeParticlesPerfCounter: PerfCounter;
  34896. /**
  34897. * Gets the total number of active bones rendered per frame
  34898. * @returns the total number of active bones rendered per frame
  34899. */
  34900. getActiveBones(): number;
  34901. /**
  34902. * Gets the performance counter for active bones
  34903. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34904. */
  34905. readonly activeBonesPerfCounter: PerfCounter;
  34906. /**
  34907. * Gets the array of active meshes
  34908. * @returns an array of AbstractMesh
  34909. */
  34910. getActiveMeshes(): SmartArray<AbstractMesh>;
  34911. /**
  34912. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34913. * @returns a number
  34914. */
  34915. getAnimationRatio(): number;
  34916. /**
  34917. * Gets an unique Id for the current render phase
  34918. * @returns a number
  34919. */
  34920. getRenderId(): number;
  34921. /**
  34922. * Gets an unique Id for the current frame
  34923. * @returns a number
  34924. */
  34925. getFrameId(): number;
  34926. /** Call this function if you want to manually increment the render Id*/
  34927. incrementRenderId(): void;
  34928. private _createUbo;
  34929. /**
  34930. * Use this method to simulate a pointer move on a mesh
  34931. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34932. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34933. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34934. * @returns the current scene
  34935. */
  34936. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34937. /**
  34938. * Use this method to simulate a pointer down on a mesh
  34939. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34940. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34941. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34942. * @returns the current scene
  34943. */
  34944. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34945. /**
  34946. * Use this method to simulate a pointer up on a mesh
  34947. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34948. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34949. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34950. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34951. * @returns the current scene
  34952. */
  34953. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34954. /**
  34955. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34956. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34957. * @returns true if the pointer was captured
  34958. */
  34959. isPointerCaptured(pointerId?: number): boolean;
  34960. /**
  34961. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34962. * @param attachUp defines if you want to attach events to pointerup
  34963. * @param attachDown defines if you want to attach events to pointerdown
  34964. * @param attachMove defines if you want to attach events to pointermove
  34965. */
  34966. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34967. /** Detaches all event handlers*/
  34968. detachControl(): void;
  34969. /**
  34970. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34971. * Delay loaded resources are not taking in account
  34972. * @return true if all required resources are ready
  34973. */
  34974. isReady(): boolean;
  34975. /** Resets all cached information relative to material (including effect and visibility) */
  34976. resetCachedMaterial(): void;
  34977. /**
  34978. * Registers a function to be called before every frame render
  34979. * @param func defines the function to register
  34980. */
  34981. registerBeforeRender(func: () => void): void;
  34982. /**
  34983. * Unregisters a function called before every frame render
  34984. * @param func defines the function to unregister
  34985. */
  34986. unregisterBeforeRender(func: () => void): void;
  34987. /**
  34988. * Registers a function to be called after every frame render
  34989. * @param func defines the function to register
  34990. */
  34991. registerAfterRender(func: () => void): void;
  34992. /**
  34993. * Unregisters a function called after every frame render
  34994. * @param func defines the function to unregister
  34995. */
  34996. unregisterAfterRender(func: () => void): void;
  34997. private _executeOnceBeforeRender;
  34998. /**
  34999. * The provided function will run before render once and will be disposed afterwards.
  35000. * A timeout delay can be provided so that the function will be executed in N ms.
  35001. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35002. * @param func The function to be executed.
  35003. * @param timeout optional delay in ms
  35004. */
  35005. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35006. /** @hidden */
  35007. _addPendingData(data: any): void;
  35008. /** @hidden */
  35009. _removePendingData(data: any): void;
  35010. /**
  35011. * Returns the number of items waiting to be loaded
  35012. * @returns the number of items waiting to be loaded
  35013. */
  35014. getWaitingItemsCount(): number;
  35015. /**
  35016. * Returns a boolean indicating if the scene is still loading data
  35017. */
  35018. readonly isLoading: boolean;
  35019. /**
  35020. * Registers a function to be executed when the scene is ready
  35021. * @param {Function} func - the function to be executed
  35022. */
  35023. executeWhenReady(func: () => void): void;
  35024. /**
  35025. * Returns a promise that resolves when the scene is ready
  35026. * @returns A promise that resolves when the scene is ready
  35027. */
  35028. whenReadyAsync(): Promise<void>;
  35029. /** @hidden */
  35030. _checkIsReady(): void;
  35031. /**
  35032. * Gets all animatable attached to the scene
  35033. */
  35034. readonly animatables: Animatable[];
  35035. /**
  35036. * Resets the last animation time frame.
  35037. * Useful to override when animations start running when loading a scene for the first time.
  35038. */
  35039. resetLastAnimationTimeFrame(): void;
  35040. /**
  35041. * Gets the current view matrix
  35042. * @returns a Matrix
  35043. */
  35044. getViewMatrix(): Matrix;
  35045. /**
  35046. * Gets the current projection matrix
  35047. * @returns a Matrix
  35048. */
  35049. getProjectionMatrix(): Matrix;
  35050. /**
  35051. * Gets the current transform matrix
  35052. * @returns a Matrix made of View * Projection
  35053. */
  35054. getTransformMatrix(): Matrix;
  35055. /**
  35056. * Sets the current transform matrix
  35057. * @param viewL defines the View matrix to use
  35058. * @param projectionL defines the Projection matrix to use
  35059. * @param viewR defines the right View matrix to use (if provided)
  35060. * @param projectionR defines the right Projection matrix to use (if provided)
  35061. */
  35062. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35063. /**
  35064. * Gets the uniform buffer used to store scene data
  35065. * @returns a UniformBuffer
  35066. */
  35067. getSceneUniformBuffer(): UniformBuffer;
  35068. /**
  35069. * Gets an unique (relatively to the current scene) Id
  35070. * @returns an unique number for the scene
  35071. */
  35072. getUniqueId(): number;
  35073. /**
  35074. * Add a mesh to the list of scene's meshes
  35075. * @param newMesh defines the mesh to add
  35076. * @param recursive if all child meshes should also be added to the scene
  35077. */
  35078. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35079. /**
  35080. * Remove a mesh for the list of scene's meshes
  35081. * @param toRemove defines the mesh to remove
  35082. * @param recursive if all child meshes should also be removed from the scene
  35083. * @returns the index where the mesh was in the mesh list
  35084. */
  35085. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35086. /**
  35087. * Add a transform node to the list of scene's transform nodes
  35088. * @param newTransformNode defines the transform node to add
  35089. */
  35090. addTransformNode(newTransformNode: TransformNode): void;
  35091. /**
  35092. * Remove a transform node for the list of scene's transform nodes
  35093. * @param toRemove defines the transform node to remove
  35094. * @returns the index where the transform node was in the transform node list
  35095. */
  35096. removeTransformNode(toRemove: TransformNode): number;
  35097. /**
  35098. * Remove a skeleton for the list of scene's skeletons
  35099. * @param toRemove defines the skeleton to remove
  35100. * @returns the index where the skeleton was in the skeleton list
  35101. */
  35102. removeSkeleton(toRemove: Skeleton): number;
  35103. /**
  35104. * Remove a morph target for the list of scene's morph targets
  35105. * @param toRemove defines the morph target to remove
  35106. * @returns the index where the morph target was in the morph target list
  35107. */
  35108. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35109. /**
  35110. * Remove a light for the list of scene's lights
  35111. * @param toRemove defines the light to remove
  35112. * @returns the index where the light was in the light list
  35113. */
  35114. removeLight(toRemove: Light): number;
  35115. /**
  35116. * Remove a camera for the list of scene's cameras
  35117. * @param toRemove defines the camera to remove
  35118. * @returns the index where the camera was in the camera list
  35119. */
  35120. removeCamera(toRemove: Camera): number;
  35121. /**
  35122. * Remove a particle system for the list of scene's particle systems
  35123. * @param toRemove defines the particle system to remove
  35124. * @returns the index where the particle system was in the particle system list
  35125. */
  35126. removeParticleSystem(toRemove: IParticleSystem): number;
  35127. /**
  35128. * Remove a animation for the list of scene's animations
  35129. * @param toRemove defines the animation to remove
  35130. * @returns the index where the animation was in the animation list
  35131. */
  35132. removeAnimation(toRemove: Animation): number;
  35133. /**
  35134. * Will stop the animation of the given target
  35135. * @param target - the target
  35136. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35137. * @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)
  35138. */
  35139. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35140. /**
  35141. * Removes the given animation group from this scene.
  35142. * @param toRemove The animation group to remove
  35143. * @returns The index of the removed animation group
  35144. */
  35145. removeAnimationGroup(toRemove: AnimationGroup): number;
  35146. /**
  35147. * Removes the given multi-material from this scene.
  35148. * @param toRemove The multi-material to remove
  35149. * @returns The index of the removed multi-material
  35150. */
  35151. removeMultiMaterial(toRemove: MultiMaterial): number;
  35152. /**
  35153. * Removes the given material from this scene.
  35154. * @param toRemove The material to remove
  35155. * @returns The index of the removed material
  35156. */
  35157. removeMaterial(toRemove: Material): number;
  35158. /**
  35159. * Removes the given action manager from this scene.
  35160. * @param toRemove The action manager to remove
  35161. * @returns The index of the removed action manager
  35162. */
  35163. removeActionManager(toRemove: AbstractActionManager): number;
  35164. /**
  35165. * Removes the given texture from this scene.
  35166. * @param toRemove The texture to remove
  35167. * @returns The index of the removed texture
  35168. */
  35169. removeTexture(toRemove: BaseTexture): number;
  35170. /**
  35171. * Adds the given light to this scene
  35172. * @param newLight The light to add
  35173. */
  35174. addLight(newLight: Light): void;
  35175. /**
  35176. * Sorts the list list based on light priorities
  35177. */
  35178. sortLightsByPriority(): void;
  35179. /**
  35180. * Adds the given camera to this scene
  35181. * @param newCamera The camera to add
  35182. */
  35183. addCamera(newCamera: Camera): void;
  35184. /**
  35185. * Adds the given skeleton to this scene
  35186. * @param newSkeleton The skeleton to add
  35187. */
  35188. addSkeleton(newSkeleton: Skeleton): void;
  35189. /**
  35190. * Adds the given particle system to this scene
  35191. * @param newParticleSystem The particle system to add
  35192. */
  35193. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35194. /**
  35195. * Adds the given animation to this scene
  35196. * @param newAnimation The animation to add
  35197. */
  35198. addAnimation(newAnimation: Animation): void;
  35199. /**
  35200. * Adds the given animation group to this scene.
  35201. * @param newAnimationGroup The animation group to add
  35202. */
  35203. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35204. /**
  35205. * Adds the given multi-material to this scene
  35206. * @param newMultiMaterial The multi-material to add
  35207. */
  35208. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35209. /**
  35210. * Adds the given material to this scene
  35211. * @param newMaterial The material to add
  35212. */
  35213. addMaterial(newMaterial: Material): void;
  35214. /**
  35215. * Adds the given morph target to this scene
  35216. * @param newMorphTargetManager The morph target to add
  35217. */
  35218. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35219. /**
  35220. * Adds the given geometry to this scene
  35221. * @param newGeometry The geometry to add
  35222. */
  35223. addGeometry(newGeometry: Geometry): void;
  35224. /**
  35225. * Adds the given action manager to this scene
  35226. * @param newActionManager The action manager to add
  35227. */
  35228. addActionManager(newActionManager: AbstractActionManager): void;
  35229. /**
  35230. * Adds the given texture to this scene.
  35231. * @param newTexture The texture to add
  35232. */
  35233. addTexture(newTexture: BaseTexture): void;
  35234. /**
  35235. * Switch active camera
  35236. * @param newCamera defines the new active camera
  35237. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35238. */
  35239. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35240. /**
  35241. * sets the active camera of the scene using its ID
  35242. * @param id defines the camera's ID
  35243. * @return the new active camera or null if none found.
  35244. */
  35245. setActiveCameraByID(id: string): Nullable<Camera>;
  35246. /**
  35247. * sets the active camera of the scene using its name
  35248. * @param name defines the camera's name
  35249. * @returns the new active camera or null if none found.
  35250. */
  35251. setActiveCameraByName(name: string): Nullable<Camera>;
  35252. /**
  35253. * get an animation group using its name
  35254. * @param name defines the material's name
  35255. * @return the animation group or null if none found.
  35256. */
  35257. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35258. /**
  35259. * Get a material using its unique id
  35260. * @param uniqueId defines the material's unique id
  35261. * @return the material or null if none found.
  35262. */
  35263. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35264. /**
  35265. * get a material using its id
  35266. * @param id defines the material's ID
  35267. * @return the material or null if none found.
  35268. */
  35269. getMaterialByID(id: string): Nullable<Material>;
  35270. /**
  35271. * Gets a the last added material using a given id
  35272. * @param id defines the material's ID
  35273. * @return the last material with the given id or null if none found.
  35274. */
  35275. getLastMaterialByID(id: string): Nullable<Material>;
  35276. /**
  35277. * Gets a material using its name
  35278. * @param name defines the material's name
  35279. * @return the material or null if none found.
  35280. */
  35281. getMaterialByName(name: string): Nullable<Material>;
  35282. /**
  35283. * Get a texture using its unique id
  35284. * @param uniqueId defines the texture's unique id
  35285. * @return the texture or null if none found.
  35286. */
  35287. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35288. /**
  35289. * Gets a camera using its id
  35290. * @param id defines the id to look for
  35291. * @returns the camera or null if not found
  35292. */
  35293. getCameraByID(id: string): Nullable<Camera>;
  35294. /**
  35295. * Gets a camera using its unique id
  35296. * @param uniqueId defines the unique id to look for
  35297. * @returns the camera or null if not found
  35298. */
  35299. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35300. /**
  35301. * Gets a camera using its name
  35302. * @param name defines the camera's name
  35303. * @return the camera or null if none found.
  35304. */
  35305. getCameraByName(name: string): Nullable<Camera>;
  35306. /**
  35307. * Gets a bone using its id
  35308. * @param id defines the bone's id
  35309. * @return the bone or null if not found
  35310. */
  35311. getBoneByID(id: string): Nullable<Bone>;
  35312. /**
  35313. * Gets a bone using its id
  35314. * @param name defines the bone's name
  35315. * @return the bone or null if not found
  35316. */
  35317. getBoneByName(name: string): Nullable<Bone>;
  35318. /**
  35319. * Gets a light node using its name
  35320. * @param name defines the the light's name
  35321. * @return the light or null if none found.
  35322. */
  35323. getLightByName(name: string): Nullable<Light>;
  35324. /**
  35325. * Gets a light node using its id
  35326. * @param id defines the light's id
  35327. * @return the light or null if none found.
  35328. */
  35329. getLightByID(id: string): Nullable<Light>;
  35330. /**
  35331. * Gets a light node using its scene-generated unique ID
  35332. * @param uniqueId defines the light's unique id
  35333. * @return the light or null if none found.
  35334. */
  35335. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35336. /**
  35337. * Gets a particle system by id
  35338. * @param id defines the particle system id
  35339. * @return the corresponding system or null if none found
  35340. */
  35341. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35342. /**
  35343. * Gets a geometry using its ID
  35344. * @param id defines the geometry's id
  35345. * @return the geometry or null if none found.
  35346. */
  35347. getGeometryByID(id: string): Nullable<Geometry>;
  35348. private _getGeometryByUniqueID;
  35349. /**
  35350. * Add a new geometry to this scene
  35351. * @param geometry defines the geometry to be added to the scene.
  35352. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35353. * @return a boolean defining if the geometry was added or not
  35354. */
  35355. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35356. /**
  35357. * Removes an existing geometry
  35358. * @param geometry defines the geometry to be removed from the scene
  35359. * @return a boolean defining if the geometry was removed or not
  35360. */
  35361. removeGeometry(geometry: Geometry): boolean;
  35362. /**
  35363. * Gets the list of geometries attached to the scene
  35364. * @returns an array of Geometry
  35365. */
  35366. getGeometries(): Geometry[];
  35367. /**
  35368. * Gets the first added mesh found of a given ID
  35369. * @param id defines the id to search for
  35370. * @return the mesh found or null if not found at all
  35371. */
  35372. getMeshByID(id: string): Nullable<AbstractMesh>;
  35373. /**
  35374. * Gets a list of meshes using their id
  35375. * @param id defines the id to search for
  35376. * @returns a list of meshes
  35377. */
  35378. getMeshesByID(id: string): Array<AbstractMesh>;
  35379. /**
  35380. * Gets the first added transform node found of a given ID
  35381. * @param id defines the id to search for
  35382. * @return the found transform node or null if not found at all.
  35383. */
  35384. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35385. /**
  35386. * Gets a transform node with its auto-generated unique id
  35387. * @param uniqueId efines the unique id to search for
  35388. * @return the found transform node or null if not found at all.
  35389. */
  35390. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35391. /**
  35392. * Gets a list of transform nodes using their id
  35393. * @param id defines the id to search for
  35394. * @returns a list of transform nodes
  35395. */
  35396. getTransformNodesByID(id: string): Array<TransformNode>;
  35397. /**
  35398. * Gets a mesh with its auto-generated unique id
  35399. * @param uniqueId defines the unique id to search for
  35400. * @return the found mesh or null if not found at all.
  35401. */
  35402. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35403. /**
  35404. * Gets a the last added mesh using a given id
  35405. * @param id defines the id to search for
  35406. * @return the found mesh or null if not found at all.
  35407. */
  35408. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35409. /**
  35410. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35411. * @param id defines the id to search for
  35412. * @return the found node or null if not found at all
  35413. */
  35414. getLastEntryByID(id: string): Nullable<Node>;
  35415. /**
  35416. * Gets a node (Mesh, Camera, Light) using a given id
  35417. * @param id defines the id to search for
  35418. * @return the found node or null if not found at all
  35419. */
  35420. getNodeByID(id: string): Nullable<Node>;
  35421. /**
  35422. * Gets a node (Mesh, Camera, Light) using a given name
  35423. * @param name defines the name to search for
  35424. * @return the found node or null if not found at all.
  35425. */
  35426. getNodeByName(name: string): Nullable<Node>;
  35427. /**
  35428. * Gets a mesh using a given name
  35429. * @param name defines the name to search for
  35430. * @return the found mesh or null if not found at all.
  35431. */
  35432. getMeshByName(name: string): Nullable<AbstractMesh>;
  35433. /**
  35434. * Gets a transform node using a given name
  35435. * @param name defines the name to search for
  35436. * @return the found transform node or null if not found at all.
  35437. */
  35438. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35439. /**
  35440. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35441. * @param id defines the id to search for
  35442. * @return the found skeleton or null if not found at all.
  35443. */
  35444. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35445. /**
  35446. * Gets a skeleton using a given auto generated unique id
  35447. * @param uniqueId defines the unique id to search for
  35448. * @return the found skeleton or null if not found at all.
  35449. */
  35450. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35451. /**
  35452. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35453. * @param id defines the id to search for
  35454. * @return the found skeleton or null if not found at all.
  35455. */
  35456. getSkeletonById(id: string): Nullable<Skeleton>;
  35457. /**
  35458. * Gets a skeleton using a given name
  35459. * @param name defines the name to search for
  35460. * @return the found skeleton or null if not found at all.
  35461. */
  35462. getSkeletonByName(name: string): Nullable<Skeleton>;
  35463. /**
  35464. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35465. * @param id defines the id to search for
  35466. * @return the found morph target manager or null if not found at all.
  35467. */
  35468. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35469. /**
  35470. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35471. * @param id defines the id to search for
  35472. * @return the found morph target or null if not found at all.
  35473. */
  35474. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35475. /**
  35476. * Gets a boolean indicating if the given mesh is active
  35477. * @param mesh defines the mesh to look for
  35478. * @returns true if the mesh is in the active list
  35479. */
  35480. isActiveMesh(mesh: AbstractMesh): boolean;
  35481. /**
  35482. * Return a unique id as a string which can serve as an identifier for the scene
  35483. */
  35484. readonly uid: string;
  35485. /**
  35486. * Add an externaly attached data from its key.
  35487. * This method call will fail and return false, if such key already exists.
  35488. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35489. * @param key the unique key that identifies the data
  35490. * @param data the data object to associate to the key for this Engine instance
  35491. * @return true if no such key were already present and the data was added successfully, false otherwise
  35492. */
  35493. addExternalData<T>(key: string, data: T): boolean;
  35494. /**
  35495. * Get an externaly attached data from its key
  35496. * @param key the unique key that identifies the data
  35497. * @return the associated data, if present (can be null), or undefined if not present
  35498. */
  35499. getExternalData<T>(key: string): Nullable<T>;
  35500. /**
  35501. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35502. * @param key the unique key that identifies the data
  35503. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35504. * @return the associated data, can be null if the factory returned null.
  35505. */
  35506. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35507. /**
  35508. * Remove an externaly attached data from the Engine instance
  35509. * @param key the unique key that identifies the data
  35510. * @return true if the data was successfully removed, false if it doesn't exist
  35511. */
  35512. removeExternalData(key: string): boolean;
  35513. private _evaluateSubMesh;
  35514. /**
  35515. * Clear the processed materials smart array preventing retention point in material dispose.
  35516. */
  35517. freeProcessedMaterials(): void;
  35518. private _preventFreeActiveMeshesAndRenderingGroups;
  35519. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35520. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35521. * when disposing several meshes in a row or a hierarchy of meshes.
  35522. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35523. */
  35524. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35525. /**
  35526. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35527. */
  35528. freeActiveMeshes(): void;
  35529. /**
  35530. * Clear the info related to rendering groups preventing retention points during dispose.
  35531. */
  35532. freeRenderingGroups(): void;
  35533. /** @hidden */
  35534. _isInIntermediateRendering(): boolean;
  35535. /**
  35536. * Lambda returning the list of potentially active meshes.
  35537. */
  35538. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35539. /**
  35540. * Lambda returning the list of potentially active sub meshes.
  35541. */
  35542. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35543. /**
  35544. * Lambda returning the list of potentially intersecting sub meshes.
  35545. */
  35546. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35547. /**
  35548. * Lambda returning the list of potentially colliding sub meshes.
  35549. */
  35550. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35551. private _activeMeshesFrozen;
  35552. /**
  35553. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35554. * @returns the current scene
  35555. */
  35556. freezeActiveMeshes(): Scene;
  35557. /**
  35558. * Use this function to restart evaluating active meshes on every frame
  35559. * @returns the current scene
  35560. */
  35561. unfreezeActiveMeshes(): Scene;
  35562. private _evaluateActiveMeshes;
  35563. private _activeMesh;
  35564. /**
  35565. * Update the transform matrix to update from the current active camera
  35566. * @param force defines a boolean used to force the update even if cache is up to date
  35567. */
  35568. updateTransformMatrix(force?: boolean): void;
  35569. private _bindFrameBuffer;
  35570. /** @hidden */
  35571. _allowPostProcessClearColor: boolean;
  35572. /** @hidden */
  35573. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35574. private _processSubCameras;
  35575. private _checkIntersections;
  35576. /** @hidden */
  35577. _advancePhysicsEngineStep(step: number): void;
  35578. /**
  35579. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35580. */
  35581. getDeterministicFrameTime: () => number;
  35582. /** @hidden */
  35583. _animate(): void;
  35584. /** Execute all animations (for a frame) */
  35585. animate(): void;
  35586. /**
  35587. * Render the scene
  35588. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35589. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35590. */
  35591. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35592. /**
  35593. * Freeze all materials
  35594. * A frozen material will not be updatable but should be faster to render
  35595. */
  35596. freezeMaterials(): void;
  35597. /**
  35598. * Unfreeze all materials
  35599. * A frozen material will not be updatable but should be faster to render
  35600. */
  35601. unfreezeMaterials(): void;
  35602. /**
  35603. * Releases all held ressources
  35604. */
  35605. dispose(): void;
  35606. /**
  35607. * Gets if the scene is already disposed
  35608. */
  35609. readonly isDisposed: boolean;
  35610. /**
  35611. * Call this function to reduce memory footprint of the scene.
  35612. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35613. */
  35614. clearCachedVertexData(): void;
  35615. /**
  35616. * This function will remove the local cached buffer data from texture.
  35617. * It will save memory but will prevent the texture from being rebuilt
  35618. */
  35619. cleanCachedTextureBuffer(): void;
  35620. /**
  35621. * Get the world extend vectors with an optional filter
  35622. *
  35623. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35624. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35625. */
  35626. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35627. min: Vector3;
  35628. max: Vector3;
  35629. };
  35630. /**
  35631. * Creates a ray that can be used to pick in the scene
  35632. * @param x defines the x coordinate of the origin (on-screen)
  35633. * @param y defines the y coordinate of the origin (on-screen)
  35634. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35635. * @param camera defines the camera to use for the picking
  35636. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35637. * @returns a Ray
  35638. */
  35639. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35640. /**
  35641. * Creates a ray that can be used to pick in the scene
  35642. * @param x defines the x coordinate of the origin (on-screen)
  35643. * @param y defines the y coordinate of the origin (on-screen)
  35644. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35645. * @param result defines the ray where to store the picking ray
  35646. * @param camera defines the camera to use for the picking
  35647. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35648. * @returns the current scene
  35649. */
  35650. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35651. /**
  35652. * Creates a ray that can be used to pick in the scene
  35653. * @param x defines the x coordinate of the origin (on-screen)
  35654. * @param y defines the y coordinate of the origin (on-screen)
  35655. * @param camera defines the camera to use for the picking
  35656. * @returns a Ray
  35657. */
  35658. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35659. /**
  35660. * Creates a ray that can be used to pick in the scene
  35661. * @param x defines the x coordinate of the origin (on-screen)
  35662. * @param y defines the y coordinate of the origin (on-screen)
  35663. * @param result defines the ray where to store the picking ray
  35664. * @param camera defines the camera to use for the picking
  35665. * @returns the current scene
  35666. */
  35667. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35668. /** Launch a ray to try to pick a mesh in the scene
  35669. * @param x position on screen
  35670. * @param y position on screen
  35671. * @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
  35672. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35673. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35674. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35675. * @returns a PickingInfo
  35676. */
  35677. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35678. /** Use the given ray to pick a mesh in the scene
  35679. * @param ray The ray to use to pick meshes
  35680. * @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
  35681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35682. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35683. * @returns a PickingInfo
  35684. */
  35685. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35686. /**
  35687. * Launch a ray to try to pick a mesh in the scene
  35688. * @param x X position on screen
  35689. * @param y Y position on screen
  35690. * @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
  35691. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35692. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35693. * @returns an array of PickingInfo
  35694. */
  35695. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35696. /**
  35697. * Launch a ray to try to pick a mesh in the scene
  35698. * @param ray Ray to use
  35699. * @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
  35700. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35701. * @returns an array of PickingInfo
  35702. */
  35703. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35704. /**
  35705. * Force the value of meshUnderPointer
  35706. * @param mesh defines the mesh to use
  35707. */
  35708. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35709. /**
  35710. * Gets the mesh under the pointer
  35711. * @returns a Mesh or null if no mesh is under the pointer
  35712. */
  35713. getPointerOverMesh(): Nullable<AbstractMesh>;
  35714. /** @hidden */
  35715. _rebuildGeometries(): void;
  35716. /** @hidden */
  35717. _rebuildTextures(): void;
  35718. private _getByTags;
  35719. /**
  35720. * Get a list of meshes by tags
  35721. * @param tagsQuery defines the tags query to use
  35722. * @param forEach defines a predicate used to filter results
  35723. * @returns an array of Mesh
  35724. */
  35725. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35726. /**
  35727. * Get a list of cameras by tags
  35728. * @param tagsQuery defines the tags query to use
  35729. * @param forEach defines a predicate used to filter results
  35730. * @returns an array of Camera
  35731. */
  35732. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35733. /**
  35734. * Get a list of lights by tags
  35735. * @param tagsQuery defines the tags query to use
  35736. * @param forEach defines a predicate used to filter results
  35737. * @returns an array of Light
  35738. */
  35739. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35740. /**
  35741. * Get a list of materials by tags
  35742. * @param tagsQuery defines the tags query to use
  35743. * @param forEach defines a predicate used to filter results
  35744. * @returns an array of Material
  35745. */
  35746. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35747. /**
  35748. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35749. * This allowed control for front to back rendering or reversly depending of the special needs.
  35750. *
  35751. * @param renderingGroupId The rendering group id corresponding to its index
  35752. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35753. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35754. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35755. */
  35756. 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;
  35757. /**
  35758. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35759. *
  35760. * @param renderingGroupId The rendering group id corresponding to its index
  35761. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35762. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35763. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35764. */
  35765. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35766. /**
  35767. * Gets the current auto clear configuration for one rendering group of the rendering
  35768. * manager.
  35769. * @param index the rendering group index to get the information for
  35770. * @returns The auto clear setup for the requested rendering group
  35771. */
  35772. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35773. private _blockMaterialDirtyMechanism;
  35774. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35775. blockMaterialDirtyMechanism: boolean;
  35776. /**
  35777. * Will flag all materials as dirty to trigger new shader compilation
  35778. * @param flag defines the flag used to specify which material part must be marked as dirty
  35779. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35780. */
  35781. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35782. /** @hidden */
  35783. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35784. /** @hidden */
  35785. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35786. }
  35787. }
  35788. declare module "babylonjs/assetContainer" {
  35789. import { AbstractScene } from "babylonjs/abstractScene";
  35790. import { Scene } from "babylonjs/scene";
  35791. import { Mesh } from "babylonjs/Meshes/mesh";
  35792. /**
  35793. * Set of assets to keep when moving a scene into an asset container.
  35794. */
  35795. export class KeepAssets extends AbstractScene {
  35796. }
  35797. /**
  35798. * Container with a set of assets that can be added or removed from a scene.
  35799. */
  35800. export class AssetContainer extends AbstractScene {
  35801. /**
  35802. * The scene the AssetContainer belongs to.
  35803. */
  35804. scene: Scene;
  35805. /**
  35806. * Instantiates an AssetContainer.
  35807. * @param scene The scene the AssetContainer belongs to.
  35808. */
  35809. constructor(scene: Scene);
  35810. /**
  35811. * Adds all the assets from the container to the scene.
  35812. */
  35813. addAllToScene(): void;
  35814. /**
  35815. * Removes all the assets in the container from the scene
  35816. */
  35817. removeAllFromScene(): void;
  35818. /**
  35819. * Disposes all the assets in the container
  35820. */
  35821. dispose(): void;
  35822. private _moveAssets;
  35823. /**
  35824. * Removes all the assets contained in the scene and adds them to the container.
  35825. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35826. */
  35827. moveAllFromScene(keepAssets?: KeepAssets): void;
  35828. /**
  35829. * 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.
  35830. * @returns the root mesh
  35831. */
  35832. createRootMesh(): Mesh;
  35833. }
  35834. }
  35835. declare module "babylonjs/abstractScene" {
  35836. import { Scene } from "babylonjs/scene";
  35837. import { Nullable } from "babylonjs/types";
  35838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35839. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35840. import { Geometry } from "babylonjs/Meshes/geometry";
  35841. import { Skeleton } from "babylonjs/Bones/skeleton";
  35842. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35843. import { AssetContainer } from "babylonjs/assetContainer";
  35844. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35845. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35847. import { Material } from "babylonjs/Materials/material";
  35848. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35849. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35850. import { Camera } from "babylonjs/Cameras/camera";
  35851. import { Light } from "babylonjs/Lights/light";
  35852. import { Node } from "babylonjs/node";
  35853. import { Animation } from "babylonjs/Animations/animation";
  35854. /**
  35855. * Defines how the parser contract is defined.
  35856. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35857. */
  35858. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35859. /**
  35860. * Defines how the individual parser contract is defined.
  35861. * These parser can parse an individual asset
  35862. */
  35863. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35864. /**
  35865. * Base class of the scene acting as a container for the different elements composing a scene.
  35866. * This class is dynamically extended by the different components of the scene increasing
  35867. * flexibility and reducing coupling
  35868. */
  35869. export abstract class AbstractScene {
  35870. /**
  35871. * Stores the list of available parsers in the application.
  35872. */
  35873. private static _BabylonFileParsers;
  35874. /**
  35875. * Stores the list of available individual parsers in the application.
  35876. */
  35877. private static _IndividualBabylonFileParsers;
  35878. /**
  35879. * Adds a parser in the list of available ones
  35880. * @param name Defines the name of the parser
  35881. * @param parser Defines the parser to add
  35882. */
  35883. static AddParser(name: string, parser: BabylonFileParser): void;
  35884. /**
  35885. * Gets a general parser from the list of avaialble ones
  35886. * @param name Defines the name of the parser
  35887. * @returns the requested parser or null
  35888. */
  35889. static GetParser(name: string): Nullable<BabylonFileParser>;
  35890. /**
  35891. * Adds n individual parser in the list of available ones
  35892. * @param name Defines the name of the parser
  35893. * @param parser Defines the parser to add
  35894. */
  35895. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35896. /**
  35897. * Gets an individual parser from the list of avaialble ones
  35898. * @param name Defines the name of the parser
  35899. * @returns the requested parser or null
  35900. */
  35901. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35902. /**
  35903. * Parser json data and populate both a scene and its associated container object
  35904. * @param jsonData Defines the data to parse
  35905. * @param scene Defines the scene to parse the data for
  35906. * @param container Defines the container attached to the parsing sequence
  35907. * @param rootUrl Defines the root url of the data
  35908. */
  35909. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35910. /**
  35911. * Gets the list of root nodes (ie. nodes with no parent)
  35912. */
  35913. rootNodes: Node[];
  35914. /** All of the cameras added to this scene
  35915. * @see http://doc.babylonjs.com/babylon101/cameras
  35916. */
  35917. cameras: Camera[];
  35918. /**
  35919. * All of the lights added to this scene
  35920. * @see http://doc.babylonjs.com/babylon101/lights
  35921. */
  35922. lights: Light[];
  35923. /**
  35924. * All of the (abstract) meshes added to this scene
  35925. */
  35926. meshes: AbstractMesh[];
  35927. /**
  35928. * The list of skeletons added to the scene
  35929. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35930. */
  35931. skeletons: Skeleton[];
  35932. /**
  35933. * All of the particle systems added to this scene
  35934. * @see http://doc.babylonjs.com/babylon101/particles
  35935. */
  35936. particleSystems: IParticleSystem[];
  35937. /**
  35938. * Gets a list of Animations associated with the scene
  35939. */
  35940. animations: Animation[];
  35941. /**
  35942. * All of the animation groups added to this scene
  35943. * @see http://doc.babylonjs.com/how_to/group
  35944. */
  35945. animationGroups: AnimationGroup[];
  35946. /**
  35947. * All of the multi-materials added to this scene
  35948. * @see http://doc.babylonjs.com/how_to/multi_materials
  35949. */
  35950. multiMaterials: MultiMaterial[];
  35951. /**
  35952. * All of the materials added to this scene
  35953. * In the context of a Scene, it is not supposed to be modified manually.
  35954. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35955. * Note also that the order of the Material wihin the array is not significant and might change.
  35956. * @see http://doc.babylonjs.com/babylon101/materials
  35957. */
  35958. materials: Material[];
  35959. /**
  35960. * The list of morph target managers added to the scene
  35961. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35962. */
  35963. morphTargetManagers: MorphTargetManager[];
  35964. /**
  35965. * The list of geometries used in the scene.
  35966. */
  35967. geometries: Geometry[];
  35968. /**
  35969. * All of the tranform nodes added to this scene
  35970. * In the context of a Scene, it is not supposed to be modified manually.
  35971. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35972. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35973. * @see http://doc.babylonjs.com/how_to/transformnode
  35974. */
  35975. transformNodes: TransformNode[];
  35976. /**
  35977. * ActionManagers available on the scene.
  35978. */
  35979. actionManagers: AbstractActionManager[];
  35980. /**
  35981. * Textures to keep.
  35982. */
  35983. textures: BaseTexture[];
  35984. /**
  35985. * Environment texture for the scene
  35986. */
  35987. environmentTexture: Nullable<BaseTexture>;
  35988. }
  35989. }
  35990. declare module "babylonjs/Audio/sound" {
  35991. import { Observable } from "babylonjs/Misc/observable";
  35992. import { Vector3 } from "babylonjs/Maths/math.vector";
  35993. import { Nullable } from "babylonjs/types";
  35994. import { Scene } from "babylonjs/scene";
  35995. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35996. /**
  35997. * Interface used to define options for Sound class
  35998. */
  35999. export interface ISoundOptions {
  36000. /**
  36001. * Does the sound autoplay once loaded.
  36002. */
  36003. autoplay?: boolean;
  36004. /**
  36005. * Does the sound loop after it finishes playing once.
  36006. */
  36007. loop?: boolean;
  36008. /**
  36009. * Sound's volume
  36010. */
  36011. volume?: number;
  36012. /**
  36013. * Is it a spatial sound?
  36014. */
  36015. spatialSound?: boolean;
  36016. /**
  36017. * Maximum distance to hear that sound
  36018. */
  36019. maxDistance?: number;
  36020. /**
  36021. * Uses user defined attenuation function
  36022. */
  36023. useCustomAttenuation?: boolean;
  36024. /**
  36025. * Define the roll off factor of spatial sounds.
  36026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36027. */
  36028. rolloffFactor?: number;
  36029. /**
  36030. * Define the reference distance the sound should be heard perfectly.
  36031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36032. */
  36033. refDistance?: number;
  36034. /**
  36035. * Define the distance attenuation model the sound will follow.
  36036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36037. */
  36038. distanceModel?: string;
  36039. /**
  36040. * Defines the playback speed (1 by default)
  36041. */
  36042. playbackRate?: number;
  36043. /**
  36044. * Defines if the sound is from a streaming source
  36045. */
  36046. streaming?: boolean;
  36047. /**
  36048. * Defines an optional length (in seconds) inside the sound file
  36049. */
  36050. length?: number;
  36051. /**
  36052. * Defines an optional offset (in seconds) inside the sound file
  36053. */
  36054. offset?: number;
  36055. /**
  36056. * If true, URLs will not be required to state the audio file codec to use.
  36057. */
  36058. skipCodecCheck?: boolean;
  36059. }
  36060. /**
  36061. * Defines a sound that can be played in the application.
  36062. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36064. */
  36065. export class Sound {
  36066. /**
  36067. * The name of the sound in the scene.
  36068. */
  36069. name: string;
  36070. /**
  36071. * Does the sound autoplay once loaded.
  36072. */
  36073. autoplay: boolean;
  36074. /**
  36075. * Does the sound loop after it finishes playing once.
  36076. */
  36077. loop: boolean;
  36078. /**
  36079. * Does the sound use a custom attenuation curve to simulate the falloff
  36080. * happening when the source gets further away from the camera.
  36081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36082. */
  36083. useCustomAttenuation: boolean;
  36084. /**
  36085. * The sound track id this sound belongs to.
  36086. */
  36087. soundTrackId: number;
  36088. /**
  36089. * Is this sound currently played.
  36090. */
  36091. isPlaying: boolean;
  36092. /**
  36093. * Is this sound currently paused.
  36094. */
  36095. isPaused: boolean;
  36096. /**
  36097. * Does this sound enables spatial sound.
  36098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36099. */
  36100. spatialSound: boolean;
  36101. /**
  36102. * Define the reference distance the sound should be heard perfectly.
  36103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36104. */
  36105. refDistance: number;
  36106. /**
  36107. * Define the roll off factor of spatial sounds.
  36108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36109. */
  36110. rolloffFactor: number;
  36111. /**
  36112. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36114. */
  36115. maxDistance: number;
  36116. /**
  36117. * Define the distance attenuation model the sound will follow.
  36118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36119. */
  36120. distanceModel: string;
  36121. /**
  36122. * @hidden
  36123. * Back Compat
  36124. **/
  36125. onended: () => any;
  36126. /**
  36127. * Observable event when the current playing sound finishes.
  36128. */
  36129. onEndedObservable: Observable<Sound>;
  36130. private _panningModel;
  36131. private _playbackRate;
  36132. private _streaming;
  36133. private _startTime;
  36134. private _startOffset;
  36135. private _position;
  36136. /** @hidden */
  36137. _positionInEmitterSpace: boolean;
  36138. private _localDirection;
  36139. private _volume;
  36140. private _isReadyToPlay;
  36141. private _isDirectional;
  36142. private _readyToPlayCallback;
  36143. private _audioBuffer;
  36144. private _soundSource;
  36145. private _streamingSource;
  36146. private _soundPanner;
  36147. private _soundGain;
  36148. private _inputAudioNode;
  36149. private _outputAudioNode;
  36150. private _coneInnerAngle;
  36151. private _coneOuterAngle;
  36152. private _coneOuterGain;
  36153. private _scene;
  36154. private _connectedTransformNode;
  36155. private _customAttenuationFunction;
  36156. private _registerFunc;
  36157. private _isOutputConnected;
  36158. private _htmlAudioElement;
  36159. private _urlType;
  36160. private _length?;
  36161. private _offset?;
  36162. /** @hidden */
  36163. static _SceneComponentInitialization: (scene: Scene) => void;
  36164. /**
  36165. * Create a sound and attach it to a scene
  36166. * @param name Name of your sound
  36167. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36168. * @param scene defines the scene the sound belongs to
  36169. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36170. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36171. */
  36172. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36173. /**
  36174. * Release the sound and its associated resources
  36175. */
  36176. dispose(): void;
  36177. /**
  36178. * Gets if the sounds is ready to be played or not.
  36179. * @returns true if ready, otherwise false
  36180. */
  36181. isReady(): boolean;
  36182. private _soundLoaded;
  36183. /**
  36184. * Sets the data of the sound from an audiobuffer
  36185. * @param audioBuffer The audioBuffer containing the data
  36186. */
  36187. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36188. /**
  36189. * Updates the current sounds options such as maxdistance, loop...
  36190. * @param options A JSON object containing values named as the object properties
  36191. */
  36192. updateOptions(options: ISoundOptions): void;
  36193. private _createSpatialParameters;
  36194. private _updateSpatialParameters;
  36195. /**
  36196. * Switch the panning model to HRTF:
  36197. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36199. */
  36200. switchPanningModelToHRTF(): void;
  36201. /**
  36202. * Switch the panning model to Equal Power:
  36203. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36205. */
  36206. switchPanningModelToEqualPower(): void;
  36207. private _switchPanningModel;
  36208. /**
  36209. * Connect this sound to a sound track audio node like gain...
  36210. * @param soundTrackAudioNode the sound track audio node to connect to
  36211. */
  36212. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36213. /**
  36214. * Transform this sound into a directional source
  36215. * @param coneInnerAngle Size of the inner cone in degree
  36216. * @param coneOuterAngle Size of the outer cone in degree
  36217. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36218. */
  36219. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36220. /**
  36221. * Gets or sets the inner angle for the directional cone.
  36222. */
  36223. /**
  36224. * Gets or sets the inner angle for the directional cone.
  36225. */
  36226. directionalConeInnerAngle: number;
  36227. /**
  36228. * Gets or sets the outer angle for the directional cone.
  36229. */
  36230. /**
  36231. * Gets or sets the outer angle for the directional cone.
  36232. */
  36233. directionalConeOuterAngle: number;
  36234. /**
  36235. * Sets the position of the emitter if spatial sound is enabled
  36236. * @param newPosition Defines the new posisiton
  36237. */
  36238. setPosition(newPosition: Vector3): void;
  36239. /**
  36240. * Sets the local direction of the emitter if spatial sound is enabled
  36241. * @param newLocalDirection Defines the new local direction
  36242. */
  36243. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36244. private _updateDirection;
  36245. /** @hidden */
  36246. updateDistanceFromListener(): void;
  36247. /**
  36248. * Sets a new custom attenuation function for the sound.
  36249. * @param callback Defines the function used for the attenuation
  36250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36251. */
  36252. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36253. /**
  36254. * Play the sound
  36255. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36256. * @param offset (optional) Start the sound at a specific time in seconds
  36257. * @param length (optional) Sound duration (in seconds)
  36258. */
  36259. play(time?: number, offset?: number, length?: number): void;
  36260. private _onended;
  36261. /**
  36262. * Stop the sound
  36263. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36264. */
  36265. stop(time?: number): void;
  36266. /**
  36267. * Put the sound in pause
  36268. */
  36269. pause(): void;
  36270. /**
  36271. * Sets a dedicated volume for this sounds
  36272. * @param newVolume Define the new volume of the sound
  36273. * @param time Define time for gradual change to new volume
  36274. */
  36275. setVolume(newVolume: number, time?: number): void;
  36276. /**
  36277. * Set the sound play back rate
  36278. * @param newPlaybackRate Define the playback rate the sound should be played at
  36279. */
  36280. setPlaybackRate(newPlaybackRate: number): void;
  36281. /**
  36282. * Gets the volume of the sound.
  36283. * @returns the volume of the sound
  36284. */
  36285. getVolume(): number;
  36286. /**
  36287. * Attach the sound to a dedicated mesh
  36288. * @param transformNode The transform node to connect the sound with
  36289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36290. */
  36291. attachToMesh(transformNode: TransformNode): void;
  36292. /**
  36293. * Detach the sound from the previously attached mesh
  36294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36295. */
  36296. detachFromMesh(): void;
  36297. private _onRegisterAfterWorldMatrixUpdate;
  36298. /**
  36299. * Clone the current sound in the scene.
  36300. * @returns the new sound clone
  36301. */
  36302. clone(): Nullable<Sound>;
  36303. /**
  36304. * Gets the current underlying audio buffer containing the data
  36305. * @returns the audio buffer
  36306. */
  36307. getAudioBuffer(): Nullable<AudioBuffer>;
  36308. /**
  36309. * Serializes the Sound in a JSON representation
  36310. * @returns the JSON representation of the sound
  36311. */
  36312. serialize(): any;
  36313. /**
  36314. * Parse a JSON representation of a sound to innstantiate in a given scene
  36315. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36316. * @param scene Define the scene the new parsed sound should be created in
  36317. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36318. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36319. * @returns the newly parsed sound
  36320. */
  36321. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36322. }
  36323. }
  36324. declare module "babylonjs/Actions/directAudioActions" {
  36325. import { Action } from "babylonjs/Actions/action";
  36326. import { Condition } from "babylonjs/Actions/condition";
  36327. import { Sound } from "babylonjs/Audio/sound";
  36328. /**
  36329. * This defines an action helpful to play a defined sound on a triggered action.
  36330. */
  36331. export class PlaySoundAction extends Action {
  36332. private _sound;
  36333. /**
  36334. * Instantiate the action
  36335. * @param triggerOptions defines the trigger options
  36336. * @param sound defines the sound to play
  36337. * @param condition defines the trigger related conditions
  36338. */
  36339. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36340. /** @hidden */
  36341. _prepare(): void;
  36342. /**
  36343. * Execute the action and play the sound.
  36344. */
  36345. execute(): void;
  36346. /**
  36347. * Serializes the actions and its related information.
  36348. * @param parent defines the object to serialize in
  36349. * @returns the serialized object
  36350. */
  36351. serialize(parent: any): any;
  36352. }
  36353. /**
  36354. * This defines an action helpful to stop a defined sound on a triggered action.
  36355. */
  36356. export class StopSoundAction extends Action {
  36357. private _sound;
  36358. /**
  36359. * Instantiate the action
  36360. * @param triggerOptions defines the trigger options
  36361. * @param sound defines the sound to stop
  36362. * @param condition defines the trigger related conditions
  36363. */
  36364. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36365. /** @hidden */
  36366. _prepare(): void;
  36367. /**
  36368. * Execute the action and stop the sound.
  36369. */
  36370. execute(): void;
  36371. /**
  36372. * Serializes the actions and its related information.
  36373. * @param parent defines the object to serialize in
  36374. * @returns the serialized object
  36375. */
  36376. serialize(parent: any): any;
  36377. }
  36378. }
  36379. declare module "babylonjs/Actions/interpolateValueAction" {
  36380. import { Action } from "babylonjs/Actions/action";
  36381. import { Condition } from "babylonjs/Actions/condition";
  36382. import { Observable } from "babylonjs/Misc/observable";
  36383. /**
  36384. * This defines an action responsible to change the value of a property
  36385. * by interpolating between its current value and the newly set one once triggered.
  36386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36387. */
  36388. export class InterpolateValueAction extends Action {
  36389. /**
  36390. * Defines the path of the property where the value should be interpolated
  36391. */
  36392. propertyPath: string;
  36393. /**
  36394. * Defines the target value at the end of the interpolation.
  36395. */
  36396. value: any;
  36397. /**
  36398. * Defines the time it will take for the property to interpolate to the value.
  36399. */
  36400. duration: number;
  36401. /**
  36402. * Defines if the other scene animations should be stopped when the action has been triggered
  36403. */
  36404. stopOtherAnimations?: boolean;
  36405. /**
  36406. * Defines a callback raised once the interpolation animation has been done.
  36407. */
  36408. onInterpolationDone?: () => void;
  36409. /**
  36410. * Observable triggered once the interpolation animation has been done.
  36411. */
  36412. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36413. private _target;
  36414. private _effectiveTarget;
  36415. private _property;
  36416. /**
  36417. * Instantiate the action
  36418. * @param triggerOptions defines the trigger options
  36419. * @param target defines the object containing the value to interpolate
  36420. * @param propertyPath defines the path to the property in the target object
  36421. * @param value defines the target value at the end of the interpolation
  36422. * @param duration deines the time it will take for the property to interpolate to the value.
  36423. * @param condition defines the trigger related conditions
  36424. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36425. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36426. */
  36427. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36428. /** @hidden */
  36429. _prepare(): void;
  36430. /**
  36431. * Execute the action starts the value interpolation.
  36432. */
  36433. execute(): void;
  36434. /**
  36435. * Serializes the actions and its related information.
  36436. * @param parent defines the object to serialize in
  36437. * @returns the serialized object
  36438. */
  36439. serialize(parent: any): any;
  36440. }
  36441. }
  36442. declare module "babylonjs/Actions/index" {
  36443. export * from "babylonjs/Actions/abstractActionManager";
  36444. export * from "babylonjs/Actions/action";
  36445. export * from "babylonjs/Actions/actionEvent";
  36446. export * from "babylonjs/Actions/actionManager";
  36447. export * from "babylonjs/Actions/condition";
  36448. export * from "babylonjs/Actions/directActions";
  36449. export * from "babylonjs/Actions/directAudioActions";
  36450. export * from "babylonjs/Actions/interpolateValueAction";
  36451. }
  36452. declare module "babylonjs/Animations/index" {
  36453. export * from "babylonjs/Animations/animatable";
  36454. export * from "babylonjs/Animations/animation";
  36455. export * from "babylonjs/Animations/animationGroup";
  36456. export * from "babylonjs/Animations/animationPropertiesOverride";
  36457. export * from "babylonjs/Animations/easing";
  36458. export * from "babylonjs/Animations/runtimeAnimation";
  36459. export * from "babylonjs/Animations/animationEvent";
  36460. export * from "babylonjs/Animations/animationGroup";
  36461. export * from "babylonjs/Animations/animationKey";
  36462. export * from "babylonjs/Animations/animationRange";
  36463. export * from "babylonjs/Animations/animatable.interface";
  36464. }
  36465. declare module "babylonjs/Audio/soundTrack" {
  36466. import { Sound } from "babylonjs/Audio/sound";
  36467. import { Analyser } from "babylonjs/Audio/analyser";
  36468. import { Scene } from "babylonjs/scene";
  36469. /**
  36470. * Options allowed during the creation of a sound track.
  36471. */
  36472. export interface ISoundTrackOptions {
  36473. /**
  36474. * The volume the sound track should take during creation
  36475. */
  36476. volume?: number;
  36477. /**
  36478. * Define if the sound track is the main sound track of the scene
  36479. */
  36480. mainTrack?: boolean;
  36481. }
  36482. /**
  36483. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36484. * It will be also used in a future release to apply effects on a specific track.
  36485. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36486. */
  36487. export class SoundTrack {
  36488. /**
  36489. * The unique identifier of the sound track in the scene.
  36490. */
  36491. id: number;
  36492. /**
  36493. * The list of sounds included in the sound track.
  36494. */
  36495. soundCollection: Array<Sound>;
  36496. private _outputAudioNode;
  36497. private _scene;
  36498. private _isMainTrack;
  36499. private _connectedAnalyser;
  36500. private _options;
  36501. private _isInitialized;
  36502. /**
  36503. * Creates a new sound track.
  36504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36505. * @param scene Define the scene the sound track belongs to
  36506. * @param options
  36507. */
  36508. constructor(scene: Scene, options?: ISoundTrackOptions);
  36509. private _initializeSoundTrackAudioGraph;
  36510. /**
  36511. * Release the sound track and its associated resources
  36512. */
  36513. dispose(): void;
  36514. /**
  36515. * Adds a sound to this sound track
  36516. * @param sound define the cound to add
  36517. * @ignoreNaming
  36518. */
  36519. AddSound(sound: Sound): void;
  36520. /**
  36521. * Removes a sound to this sound track
  36522. * @param sound define the cound to remove
  36523. * @ignoreNaming
  36524. */
  36525. RemoveSound(sound: Sound): void;
  36526. /**
  36527. * Set a global volume for the full sound track.
  36528. * @param newVolume Define the new volume of the sound track
  36529. */
  36530. setVolume(newVolume: number): void;
  36531. /**
  36532. * Switch the panning model to HRTF:
  36533. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36535. */
  36536. switchPanningModelToHRTF(): void;
  36537. /**
  36538. * Switch the panning model to Equal Power:
  36539. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36541. */
  36542. switchPanningModelToEqualPower(): void;
  36543. /**
  36544. * Connect the sound track to an audio analyser allowing some amazing
  36545. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36547. * @param analyser The analyser to connect to the engine
  36548. */
  36549. connectToAnalyser(analyser: Analyser): void;
  36550. }
  36551. }
  36552. declare module "babylonjs/Audio/audioSceneComponent" {
  36553. import { Sound } from "babylonjs/Audio/sound";
  36554. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36555. import { Nullable } from "babylonjs/types";
  36556. import { Vector3 } from "babylonjs/Maths/math.vector";
  36557. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36558. import { Scene } from "babylonjs/scene";
  36559. import { AbstractScene } from "babylonjs/abstractScene";
  36560. import "babylonjs/Audio/audioEngine";
  36561. module "babylonjs/abstractScene" {
  36562. interface AbstractScene {
  36563. /**
  36564. * The list of sounds used in the scene.
  36565. */
  36566. sounds: Nullable<Array<Sound>>;
  36567. }
  36568. }
  36569. module "babylonjs/scene" {
  36570. interface Scene {
  36571. /**
  36572. * @hidden
  36573. * Backing field
  36574. */
  36575. _mainSoundTrack: SoundTrack;
  36576. /**
  36577. * The main sound track played by the scene.
  36578. * It cotains your primary collection of sounds.
  36579. */
  36580. mainSoundTrack: SoundTrack;
  36581. /**
  36582. * The list of sound tracks added to the scene
  36583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36584. */
  36585. soundTracks: Nullable<Array<SoundTrack>>;
  36586. /**
  36587. * Gets a sound using a given name
  36588. * @param name defines the name to search for
  36589. * @return the found sound or null if not found at all.
  36590. */
  36591. getSoundByName(name: string): Nullable<Sound>;
  36592. /**
  36593. * Gets or sets if audio support is enabled
  36594. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36595. */
  36596. audioEnabled: boolean;
  36597. /**
  36598. * Gets or sets if audio will be output to headphones
  36599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36600. */
  36601. headphone: boolean;
  36602. /**
  36603. * Gets or sets custom audio listener position provider
  36604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36605. */
  36606. audioListenerPositionProvider: Nullable<() => Vector3>;
  36607. }
  36608. }
  36609. /**
  36610. * Defines the sound scene component responsible to manage any sounds
  36611. * in a given scene.
  36612. */
  36613. export class AudioSceneComponent implements ISceneSerializableComponent {
  36614. /**
  36615. * The component name helpfull to identify the component in the list of scene components.
  36616. */
  36617. readonly name: string;
  36618. /**
  36619. * The scene the component belongs to.
  36620. */
  36621. scene: Scene;
  36622. private _audioEnabled;
  36623. /**
  36624. * Gets whether audio is enabled or not.
  36625. * Please use related enable/disable method to switch state.
  36626. */
  36627. readonly audioEnabled: boolean;
  36628. private _headphone;
  36629. /**
  36630. * Gets whether audio is outputing to headphone or not.
  36631. * Please use the according Switch methods to change output.
  36632. */
  36633. readonly headphone: boolean;
  36634. private _audioListenerPositionProvider;
  36635. /**
  36636. * Gets the current audio listener position provider
  36637. */
  36638. /**
  36639. * Sets a custom listener position for all sounds in the scene
  36640. * By default, this is the position of the first active camera
  36641. */
  36642. audioListenerPositionProvider: Nullable<() => Vector3>;
  36643. /**
  36644. * Creates a new instance of the component for the given scene
  36645. * @param scene Defines the scene to register the component in
  36646. */
  36647. constructor(scene: Scene);
  36648. /**
  36649. * Registers the component in a given scene
  36650. */
  36651. register(): void;
  36652. /**
  36653. * Rebuilds the elements related to this component in case of
  36654. * context lost for instance.
  36655. */
  36656. rebuild(): void;
  36657. /**
  36658. * Serializes the component data to the specified json object
  36659. * @param serializationObject The object to serialize to
  36660. */
  36661. serialize(serializationObject: any): void;
  36662. /**
  36663. * Adds all the elements from the container to the scene
  36664. * @param container the container holding the elements
  36665. */
  36666. addFromContainer(container: AbstractScene): void;
  36667. /**
  36668. * Removes all the elements in the container from the scene
  36669. * @param container contains the elements to remove
  36670. * @param dispose if the removed element should be disposed (default: false)
  36671. */
  36672. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36673. /**
  36674. * Disposes the component and the associated ressources.
  36675. */
  36676. dispose(): void;
  36677. /**
  36678. * Disables audio in the associated scene.
  36679. */
  36680. disableAudio(): void;
  36681. /**
  36682. * Enables audio in the associated scene.
  36683. */
  36684. enableAudio(): void;
  36685. /**
  36686. * Switch audio to headphone output.
  36687. */
  36688. switchAudioModeForHeadphones(): void;
  36689. /**
  36690. * Switch audio to normal speakers.
  36691. */
  36692. switchAudioModeForNormalSpeakers(): void;
  36693. private _afterRender;
  36694. }
  36695. }
  36696. declare module "babylonjs/Audio/weightedsound" {
  36697. import { Sound } from "babylonjs/Audio/sound";
  36698. /**
  36699. * Wraps one or more Sound objects and selects one with random weight for playback.
  36700. */
  36701. export class WeightedSound {
  36702. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36703. loop: boolean;
  36704. private _coneInnerAngle;
  36705. private _coneOuterAngle;
  36706. private _volume;
  36707. /** A Sound is currently playing. */
  36708. isPlaying: boolean;
  36709. /** A Sound is currently paused. */
  36710. isPaused: boolean;
  36711. private _sounds;
  36712. private _weights;
  36713. private _currentIndex?;
  36714. /**
  36715. * Creates a new WeightedSound from the list of sounds given.
  36716. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36717. * @param sounds Array of Sounds that will be selected from.
  36718. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36719. */
  36720. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36721. /**
  36722. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36723. */
  36724. /**
  36725. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36726. */
  36727. directionalConeInnerAngle: number;
  36728. /**
  36729. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36730. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36731. */
  36732. /**
  36733. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36734. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36735. */
  36736. directionalConeOuterAngle: number;
  36737. /**
  36738. * Playback volume.
  36739. */
  36740. /**
  36741. * Playback volume.
  36742. */
  36743. volume: number;
  36744. private _onended;
  36745. /**
  36746. * Suspend playback
  36747. */
  36748. pause(): void;
  36749. /**
  36750. * Stop playback
  36751. */
  36752. stop(): void;
  36753. /**
  36754. * Start playback.
  36755. * @param startOffset Position the clip head at a specific time in seconds.
  36756. */
  36757. play(startOffset?: number): void;
  36758. }
  36759. }
  36760. declare module "babylonjs/Audio/index" {
  36761. export * from "babylonjs/Audio/analyser";
  36762. export * from "babylonjs/Audio/audioEngine";
  36763. export * from "babylonjs/Audio/audioSceneComponent";
  36764. export * from "babylonjs/Audio/sound";
  36765. export * from "babylonjs/Audio/soundTrack";
  36766. export * from "babylonjs/Audio/weightedsound";
  36767. }
  36768. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36769. import { Behavior } from "babylonjs/Behaviors/behavior";
  36770. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36771. import { BackEase } from "babylonjs/Animations/easing";
  36772. /**
  36773. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36774. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36775. */
  36776. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36777. /**
  36778. * Gets the name of the behavior.
  36779. */
  36780. readonly name: string;
  36781. /**
  36782. * The easing function used by animations
  36783. */
  36784. static EasingFunction: BackEase;
  36785. /**
  36786. * The easing mode used by animations
  36787. */
  36788. static EasingMode: number;
  36789. /**
  36790. * The duration of the animation, in milliseconds
  36791. */
  36792. transitionDuration: number;
  36793. /**
  36794. * Length of the distance animated by the transition when lower radius is reached
  36795. */
  36796. lowerRadiusTransitionRange: number;
  36797. /**
  36798. * Length of the distance animated by the transition when upper radius is reached
  36799. */
  36800. upperRadiusTransitionRange: number;
  36801. private _autoTransitionRange;
  36802. /**
  36803. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36804. */
  36805. /**
  36806. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36807. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36808. */
  36809. autoTransitionRange: boolean;
  36810. private _attachedCamera;
  36811. private _onAfterCheckInputsObserver;
  36812. private _onMeshTargetChangedObserver;
  36813. /**
  36814. * Initializes the behavior.
  36815. */
  36816. init(): void;
  36817. /**
  36818. * Attaches the behavior to its arc rotate camera.
  36819. * @param camera Defines the camera to attach the behavior to
  36820. */
  36821. attach(camera: ArcRotateCamera): void;
  36822. /**
  36823. * Detaches the behavior from its current arc rotate camera.
  36824. */
  36825. detach(): void;
  36826. private _radiusIsAnimating;
  36827. private _radiusBounceTransition;
  36828. private _animatables;
  36829. private _cachedWheelPrecision;
  36830. /**
  36831. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36832. * @param radiusLimit The limit to check against.
  36833. * @return Bool to indicate if at limit.
  36834. */
  36835. private _isRadiusAtLimit;
  36836. /**
  36837. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36838. * @param radiusDelta The delta by which to animate to. Can be negative.
  36839. */
  36840. private _applyBoundRadiusAnimation;
  36841. /**
  36842. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36843. */
  36844. protected _clearAnimationLocks(): void;
  36845. /**
  36846. * Stops and removes all animations that have been applied to the camera
  36847. */
  36848. stopAllAnimations(): void;
  36849. }
  36850. }
  36851. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36852. import { Behavior } from "babylonjs/Behaviors/behavior";
  36853. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36854. import { ExponentialEase } from "babylonjs/Animations/easing";
  36855. import { Nullable } from "babylonjs/types";
  36856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36857. import { Vector3 } from "babylonjs/Maths/math.vector";
  36858. /**
  36859. * 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.
  36860. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36861. */
  36862. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36863. /**
  36864. * Gets the name of the behavior.
  36865. */
  36866. readonly name: string;
  36867. private _mode;
  36868. private _radiusScale;
  36869. private _positionScale;
  36870. private _defaultElevation;
  36871. private _elevationReturnTime;
  36872. private _elevationReturnWaitTime;
  36873. private _zoomStopsAnimation;
  36874. private _framingTime;
  36875. /**
  36876. * The easing function used by animations
  36877. */
  36878. static EasingFunction: ExponentialEase;
  36879. /**
  36880. * The easing mode used by animations
  36881. */
  36882. static EasingMode: number;
  36883. /**
  36884. * Sets the current mode used by the behavior
  36885. */
  36886. /**
  36887. * Gets current mode used by the behavior.
  36888. */
  36889. mode: number;
  36890. /**
  36891. * Sets the scale applied to the radius (1 by default)
  36892. */
  36893. /**
  36894. * Gets the scale applied to the radius
  36895. */
  36896. radiusScale: number;
  36897. /**
  36898. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36899. */
  36900. /**
  36901. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36902. */
  36903. positionScale: number;
  36904. /**
  36905. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36906. * behaviour is triggered, in radians.
  36907. */
  36908. /**
  36909. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36910. * behaviour is triggered, in radians.
  36911. */
  36912. defaultElevation: number;
  36913. /**
  36914. * Sets the time (in milliseconds) taken to return to the default beta position.
  36915. * Negative value indicates camera should not return to default.
  36916. */
  36917. /**
  36918. * Gets the time (in milliseconds) taken to return to the default beta position.
  36919. * Negative value indicates camera should not return to default.
  36920. */
  36921. elevationReturnTime: number;
  36922. /**
  36923. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36924. */
  36925. /**
  36926. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36927. */
  36928. elevationReturnWaitTime: number;
  36929. /**
  36930. * Sets the flag that indicates if user zooming should stop animation.
  36931. */
  36932. /**
  36933. * Gets the flag that indicates if user zooming should stop animation.
  36934. */
  36935. zoomStopsAnimation: boolean;
  36936. /**
  36937. * Sets the transition time when framing the mesh, in milliseconds
  36938. */
  36939. /**
  36940. * Gets the transition time when framing the mesh, in milliseconds
  36941. */
  36942. framingTime: number;
  36943. /**
  36944. * Define if the behavior should automatically change the configured
  36945. * camera limits and sensibilities.
  36946. */
  36947. autoCorrectCameraLimitsAndSensibility: boolean;
  36948. private _onPrePointerObservableObserver;
  36949. private _onAfterCheckInputsObserver;
  36950. private _onMeshTargetChangedObserver;
  36951. private _attachedCamera;
  36952. private _isPointerDown;
  36953. private _lastInteractionTime;
  36954. /**
  36955. * Initializes the behavior.
  36956. */
  36957. init(): void;
  36958. /**
  36959. * Attaches the behavior to its arc rotate camera.
  36960. * @param camera Defines the camera to attach the behavior to
  36961. */
  36962. attach(camera: ArcRotateCamera): void;
  36963. /**
  36964. * Detaches the behavior from its current arc rotate camera.
  36965. */
  36966. detach(): void;
  36967. private _animatables;
  36968. private _betaIsAnimating;
  36969. private _betaTransition;
  36970. private _radiusTransition;
  36971. private _vectorTransition;
  36972. /**
  36973. * Targets the given mesh and updates zoom level accordingly.
  36974. * @param mesh The mesh to target.
  36975. * @param radius Optional. If a cached radius position already exists, overrides default.
  36976. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36977. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36978. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36979. */
  36980. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36981. /**
  36982. * Targets the given mesh with its children and updates zoom level accordingly.
  36983. * @param mesh The mesh to target.
  36984. * @param radius Optional. If a cached radius position already exists, overrides default.
  36985. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36986. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36987. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36988. */
  36989. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36990. /**
  36991. * Targets the given meshes with their children and updates zoom level accordingly.
  36992. * @param meshes The mesh to target.
  36993. * @param radius Optional. If a cached radius position already exists, overrides default.
  36994. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36995. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36996. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36997. */
  36998. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36999. /**
  37000. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37001. * @param minimumWorld Determines the smaller position of the bounding box extend
  37002. * @param maximumWorld Determines the bigger position of the bounding box extend
  37003. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37004. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37005. */
  37006. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37007. /**
  37008. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37009. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37010. * frustum width.
  37011. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37012. * to fully enclose the mesh in the viewing frustum.
  37013. */
  37014. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37015. /**
  37016. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37017. * is automatically returned to its default position (expected to be above ground plane).
  37018. */
  37019. private _maintainCameraAboveGround;
  37020. /**
  37021. * Returns the frustum slope based on the canvas ratio and camera FOV
  37022. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37023. */
  37024. private _getFrustumSlope;
  37025. /**
  37026. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37027. */
  37028. private _clearAnimationLocks;
  37029. /**
  37030. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37031. */
  37032. private _applyUserInteraction;
  37033. /**
  37034. * Stops and removes all animations that have been applied to the camera
  37035. */
  37036. stopAllAnimations(): void;
  37037. /**
  37038. * Gets a value indicating if the user is moving the camera
  37039. */
  37040. readonly isUserIsMoving: boolean;
  37041. /**
  37042. * The camera can move all the way towards the mesh.
  37043. */
  37044. static IgnoreBoundsSizeMode: number;
  37045. /**
  37046. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37047. */
  37048. static FitFrustumSidesMode: number;
  37049. }
  37050. }
  37051. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37052. import { Nullable } from "babylonjs/types";
  37053. import { Camera } from "babylonjs/Cameras/camera";
  37054. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37055. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37056. /**
  37057. * Base class for Camera Pointer Inputs.
  37058. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37059. * for example usage.
  37060. */
  37061. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37062. /**
  37063. * Defines the camera the input is attached to.
  37064. */
  37065. abstract camera: Camera;
  37066. /**
  37067. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37068. */
  37069. protected _altKey: boolean;
  37070. protected _ctrlKey: boolean;
  37071. protected _metaKey: boolean;
  37072. protected _shiftKey: boolean;
  37073. /**
  37074. * Which mouse buttons were pressed at time of last mouse event.
  37075. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37076. */
  37077. protected _buttonsPressed: number;
  37078. /**
  37079. * Defines the buttons associated with the input to handle camera move.
  37080. */
  37081. buttons: number[];
  37082. /**
  37083. * Attach the input controls to a specific dom element to get the input from.
  37084. * @param element Defines the element the controls should be listened from
  37085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37086. */
  37087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37088. /**
  37089. * Detach the current controls from the specified dom element.
  37090. * @param element Defines the element to stop listening the inputs from
  37091. */
  37092. detachControl(element: Nullable<HTMLElement>): void;
  37093. /**
  37094. * Gets the class name of the current input.
  37095. * @returns the class name
  37096. */
  37097. getClassName(): string;
  37098. /**
  37099. * Get the friendly name associated with the input class.
  37100. * @returns the input friendly name
  37101. */
  37102. getSimpleName(): string;
  37103. /**
  37104. * Called on pointer POINTERDOUBLETAP event.
  37105. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37106. */
  37107. protected onDoubleTap(type: string): void;
  37108. /**
  37109. * Called on pointer POINTERMOVE event if only a single touch is active.
  37110. * Override this method to provide functionality.
  37111. */
  37112. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37113. /**
  37114. * Called on pointer POINTERMOVE event if multiple touches are active.
  37115. * Override this method to provide functionality.
  37116. */
  37117. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37118. /**
  37119. * Called on JS contextmenu event.
  37120. * Override this method to provide functionality.
  37121. */
  37122. protected onContextMenu(evt: PointerEvent): void;
  37123. /**
  37124. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37125. * press.
  37126. * Override this method to provide functionality.
  37127. */
  37128. protected onButtonDown(evt: PointerEvent): void;
  37129. /**
  37130. * Called each time a new POINTERUP event occurs. Ie, for each button
  37131. * release.
  37132. * Override this method to provide functionality.
  37133. */
  37134. protected onButtonUp(evt: PointerEvent): void;
  37135. /**
  37136. * Called when window becomes inactive.
  37137. * Override this method to provide functionality.
  37138. */
  37139. protected onLostFocus(): void;
  37140. private _pointerInput;
  37141. private _observer;
  37142. private _onLostFocus;
  37143. private pointA;
  37144. private pointB;
  37145. }
  37146. }
  37147. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37148. import { Nullable } from "babylonjs/types";
  37149. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37150. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37151. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37152. /**
  37153. * Manage the pointers inputs to control an arc rotate camera.
  37154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37155. */
  37156. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37157. /**
  37158. * Defines the camera the input is attached to.
  37159. */
  37160. camera: ArcRotateCamera;
  37161. /**
  37162. * Gets the class name of the current input.
  37163. * @returns the class name
  37164. */
  37165. getClassName(): string;
  37166. /**
  37167. * Defines the buttons associated with the input to handle camera move.
  37168. */
  37169. buttons: number[];
  37170. /**
  37171. * Defines the pointer angular sensibility along the X axis or how fast is
  37172. * the camera rotating.
  37173. */
  37174. angularSensibilityX: number;
  37175. /**
  37176. * Defines the pointer angular sensibility along the Y axis or how fast is
  37177. * the camera rotating.
  37178. */
  37179. angularSensibilityY: number;
  37180. /**
  37181. * Defines the pointer pinch precision or how fast is the camera zooming.
  37182. */
  37183. pinchPrecision: number;
  37184. /**
  37185. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37186. * from 0.
  37187. * It defines the percentage of current camera.radius to use as delta when
  37188. * pinch zoom is used.
  37189. */
  37190. pinchDeltaPercentage: number;
  37191. /**
  37192. * Defines the pointer panning sensibility or how fast is the camera moving.
  37193. */
  37194. panningSensibility: number;
  37195. /**
  37196. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37197. */
  37198. multiTouchPanning: boolean;
  37199. /**
  37200. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37201. * zoom (pinch) through multitouch.
  37202. */
  37203. multiTouchPanAndZoom: boolean;
  37204. /**
  37205. * Revers pinch action direction.
  37206. */
  37207. pinchInwards: boolean;
  37208. private _isPanClick;
  37209. private _twoFingerActivityCount;
  37210. private _isPinching;
  37211. /**
  37212. * Called on pointer POINTERMOVE event if only a single touch is active.
  37213. */
  37214. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37215. /**
  37216. * Called on pointer POINTERDOUBLETAP event.
  37217. */
  37218. protected onDoubleTap(type: string): void;
  37219. /**
  37220. * Called on pointer POINTERMOVE event if multiple touches are active.
  37221. */
  37222. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37223. /**
  37224. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37225. * press.
  37226. */
  37227. protected onButtonDown(evt: PointerEvent): void;
  37228. /**
  37229. * Called each time a new POINTERUP event occurs. Ie, for each button
  37230. * release.
  37231. */
  37232. protected onButtonUp(evt: PointerEvent): void;
  37233. /**
  37234. * Called when window becomes inactive.
  37235. */
  37236. protected onLostFocus(): void;
  37237. }
  37238. }
  37239. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37240. import { Nullable } from "babylonjs/types";
  37241. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37242. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37243. /**
  37244. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37245. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37246. */
  37247. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37248. /**
  37249. * Defines the camera the input is attached to.
  37250. */
  37251. camera: ArcRotateCamera;
  37252. /**
  37253. * Defines the list of key codes associated with the up action (increase alpha)
  37254. */
  37255. keysUp: number[];
  37256. /**
  37257. * Defines the list of key codes associated with the down action (decrease alpha)
  37258. */
  37259. keysDown: number[];
  37260. /**
  37261. * Defines the list of key codes associated with the left action (increase beta)
  37262. */
  37263. keysLeft: number[];
  37264. /**
  37265. * Defines the list of key codes associated with the right action (decrease beta)
  37266. */
  37267. keysRight: number[];
  37268. /**
  37269. * Defines the list of key codes associated with the reset action.
  37270. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37271. */
  37272. keysReset: number[];
  37273. /**
  37274. * Defines the panning sensibility of the inputs.
  37275. * (How fast is the camera paning)
  37276. */
  37277. panningSensibility: number;
  37278. /**
  37279. * Defines the zooming sensibility of the inputs.
  37280. * (How fast is the camera zooming)
  37281. */
  37282. zoomingSensibility: number;
  37283. /**
  37284. * Defines wether maintaining the alt key down switch the movement mode from
  37285. * orientation to zoom.
  37286. */
  37287. useAltToZoom: boolean;
  37288. /**
  37289. * Rotation speed of the camera
  37290. */
  37291. angularSpeed: number;
  37292. private _keys;
  37293. private _ctrlPressed;
  37294. private _altPressed;
  37295. private _onCanvasBlurObserver;
  37296. private _onKeyboardObserver;
  37297. private _engine;
  37298. private _scene;
  37299. /**
  37300. * Attach the input controls to a specific dom element to get the input from.
  37301. * @param element Defines the element the controls should be listened from
  37302. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37303. */
  37304. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37305. /**
  37306. * Detach the current controls from the specified dom element.
  37307. * @param element Defines the element to stop listening the inputs from
  37308. */
  37309. detachControl(element: Nullable<HTMLElement>): void;
  37310. /**
  37311. * Update the current camera state depending on the inputs that have been used this frame.
  37312. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37313. */
  37314. checkInputs(): void;
  37315. /**
  37316. * Gets the class name of the current intput.
  37317. * @returns the class name
  37318. */
  37319. getClassName(): string;
  37320. /**
  37321. * Get the friendly name associated with the input class.
  37322. * @returns the input friendly name
  37323. */
  37324. getSimpleName(): string;
  37325. }
  37326. }
  37327. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37328. import { Nullable } from "babylonjs/types";
  37329. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37330. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37331. /**
  37332. * Manage the mouse wheel inputs to control an arc rotate camera.
  37333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37334. */
  37335. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37336. /**
  37337. * Defines the camera the input is attached to.
  37338. */
  37339. camera: ArcRotateCamera;
  37340. /**
  37341. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37342. */
  37343. wheelPrecision: number;
  37344. /**
  37345. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37346. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37347. */
  37348. wheelDeltaPercentage: number;
  37349. private _wheel;
  37350. private _observer;
  37351. private computeDeltaFromMouseWheelLegacyEvent;
  37352. /**
  37353. * Attach the input controls to a specific dom element to get the input from.
  37354. * @param element Defines the element the controls should be listened from
  37355. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37356. */
  37357. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37358. /**
  37359. * Detach the current controls from the specified dom element.
  37360. * @param element Defines the element to stop listening the inputs from
  37361. */
  37362. detachControl(element: Nullable<HTMLElement>): void;
  37363. /**
  37364. * Gets the class name of the current intput.
  37365. * @returns the class name
  37366. */
  37367. getClassName(): string;
  37368. /**
  37369. * Get the friendly name associated with the input class.
  37370. * @returns the input friendly name
  37371. */
  37372. getSimpleName(): string;
  37373. }
  37374. }
  37375. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37376. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37377. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37378. /**
  37379. * Default Inputs manager for the ArcRotateCamera.
  37380. * It groups all the default supported inputs for ease of use.
  37381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37382. */
  37383. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37384. /**
  37385. * Instantiates a new ArcRotateCameraInputsManager.
  37386. * @param camera Defines the camera the inputs belong to
  37387. */
  37388. constructor(camera: ArcRotateCamera);
  37389. /**
  37390. * Add mouse wheel input support to the input manager.
  37391. * @returns the current input manager
  37392. */
  37393. addMouseWheel(): ArcRotateCameraInputsManager;
  37394. /**
  37395. * Add pointers input support to the input manager.
  37396. * @returns the current input manager
  37397. */
  37398. addPointers(): ArcRotateCameraInputsManager;
  37399. /**
  37400. * Add keyboard input support to the input manager.
  37401. * @returns the current input manager
  37402. */
  37403. addKeyboard(): ArcRotateCameraInputsManager;
  37404. }
  37405. }
  37406. declare module "babylonjs/Cameras/arcRotateCamera" {
  37407. import { Observable } from "babylonjs/Misc/observable";
  37408. import { Nullable } from "babylonjs/types";
  37409. import { Scene } from "babylonjs/scene";
  37410. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37412. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37413. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37414. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37415. import { Camera } from "babylonjs/Cameras/camera";
  37416. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37417. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37418. import { Collider } from "babylonjs/Collisions/collider";
  37419. /**
  37420. * This represents an orbital type of camera.
  37421. *
  37422. * 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.
  37423. * 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.
  37424. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37425. */
  37426. export class ArcRotateCamera extends TargetCamera {
  37427. /**
  37428. * Defines the rotation angle of the camera along the longitudinal axis.
  37429. */
  37430. alpha: number;
  37431. /**
  37432. * Defines the rotation angle of the camera along the latitudinal axis.
  37433. */
  37434. beta: number;
  37435. /**
  37436. * Defines the radius of the camera from it s target point.
  37437. */
  37438. radius: number;
  37439. protected _target: Vector3;
  37440. protected _targetHost: Nullable<AbstractMesh>;
  37441. /**
  37442. * Defines the target point of the camera.
  37443. * The camera looks towards it form the radius distance.
  37444. */
  37445. target: Vector3;
  37446. /**
  37447. * Define the current local position of the camera in the scene
  37448. */
  37449. position: Vector3;
  37450. protected _upVector: Vector3;
  37451. protected _upToYMatrix: Matrix;
  37452. protected _YToUpMatrix: Matrix;
  37453. /**
  37454. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37455. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37456. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37457. */
  37458. upVector: Vector3;
  37459. /**
  37460. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37461. */
  37462. setMatUp(): void;
  37463. /**
  37464. * Current inertia value on the longitudinal axis.
  37465. * The bigger this number the longer it will take for the camera to stop.
  37466. */
  37467. inertialAlphaOffset: number;
  37468. /**
  37469. * Current inertia value on the latitudinal axis.
  37470. * The bigger this number the longer it will take for the camera to stop.
  37471. */
  37472. inertialBetaOffset: number;
  37473. /**
  37474. * Current inertia value on the radius axis.
  37475. * The bigger this number the longer it will take for the camera to stop.
  37476. */
  37477. inertialRadiusOffset: number;
  37478. /**
  37479. * Minimum allowed angle on the longitudinal axis.
  37480. * This can help limiting how the Camera is able to move in the scene.
  37481. */
  37482. lowerAlphaLimit: Nullable<number>;
  37483. /**
  37484. * Maximum allowed angle on the longitudinal axis.
  37485. * This can help limiting how the Camera is able to move in the scene.
  37486. */
  37487. upperAlphaLimit: Nullable<number>;
  37488. /**
  37489. * Minimum allowed angle on the latitudinal axis.
  37490. * This can help limiting how the Camera is able to move in the scene.
  37491. */
  37492. lowerBetaLimit: number;
  37493. /**
  37494. * Maximum allowed angle on the latitudinal axis.
  37495. * This can help limiting how the Camera is able to move in the scene.
  37496. */
  37497. upperBetaLimit: number;
  37498. /**
  37499. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37500. * This can help limiting how the Camera is able to move in the scene.
  37501. */
  37502. lowerRadiusLimit: Nullable<number>;
  37503. /**
  37504. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37505. * This can help limiting how the Camera is able to move in the scene.
  37506. */
  37507. upperRadiusLimit: Nullable<number>;
  37508. /**
  37509. * Defines the current inertia value used during panning of the camera along the X axis.
  37510. */
  37511. inertialPanningX: number;
  37512. /**
  37513. * Defines the current inertia value used during panning of the camera along the Y axis.
  37514. */
  37515. inertialPanningY: number;
  37516. /**
  37517. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37518. * Basically if your fingers moves away from more than this distance you will be considered
  37519. * in pinch mode.
  37520. */
  37521. pinchToPanMaxDistance: number;
  37522. /**
  37523. * Defines the maximum distance the camera can pan.
  37524. * This could help keeping the cammera always in your scene.
  37525. */
  37526. panningDistanceLimit: Nullable<number>;
  37527. /**
  37528. * Defines the target of the camera before paning.
  37529. */
  37530. panningOriginTarget: Vector3;
  37531. /**
  37532. * Defines the value of the inertia used during panning.
  37533. * 0 would mean stop inertia and one would mean no decelleration at all.
  37534. */
  37535. panningInertia: number;
  37536. /**
  37537. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37538. */
  37539. angularSensibilityX: number;
  37540. /**
  37541. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37542. */
  37543. angularSensibilityY: number;
  37544. /**
  37545. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37546. */
  37547. pinchPrecision: number;
  37548. /**
  37549. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37550. * It will be used instead of pinchDeltaPrecision if different from 0.
  37551. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37552. */
  37553. pinchDeltaPercentage: number;
  37554. /**
  37555. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37556. */
  37557. panningSensibility: number;
  37558. /**
  37559. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37560. */
  37561. keysUp: number[];
  37562. /**
  37563. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37564. */
  37565. keysDown: number[];
  37566. /**
  37567. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37568. */
  37569. keysLeft: number[];
  37570. /**
  37571. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37572. */
  37573. keysRight: number[];
  37574. /**
  37575. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37576. */
  37577. wheelPrecision: number;
  37578. /**
  37579. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37580. * It will be used instead of pinchDeltaPrecision if different from 0.
  37581. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37582. */
  37583. wheelDeltaPercentage: number;
  37584. /**
  37585. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37586. */
  37587. zoomOnFactor: number;
  37588. /**
  37589. * Defines a screen offset for the camera position.
  37590. */
  37591. targetScreenOffset: Vector2;
  37592. /**
  37593. * Allows the camera to be completely reversed.
  37594. * If false the camera can not arrive upside down.
  37595. */
  37596. allowUpsideDown: boolean;
  37597. /**
  37598. * Define if double tap/click is used to restore the previously saved state of the camera.
  37599. */
  37600. useInputToRestoreState: boolean;
  37601. /** @hidden */
  37602. _viewMatrix: Matrix;
  37603. /** @hidden */
  37604. _useCtrlForPanning: boolean;
  37605. /** @hidden */
  37606. _panningMouseButton: number;
  37607. /**
  37608. * Defines the input associated to the camera.
  37609. */
  37610. inputs: ArcRotateCameraInputsManager;
  37611. /** @hidden */
  37612. _reset: () => void;
  37613. /**
  37614. * Defines the allowed panning axis.
  37615. */
  37616. panningAxis: Vector3;
  37617. protected _localDirection: Vector3;
  37618. protected _transformedDirection: Vector3;
  37619. private _bouncingBehavior;
  37620. /**
  37621. * Gets the bouncing behavior of the camera if it has been enabled.
  37622. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37623. */
  37624. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37625. /**
  37626. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37627. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37628. */
  37629. useBouncingBehavior: boolean;
  37630. private _framingBehavior;
  37631. /**
  37632. * Gets the framing behavior of the camera if it has been enabled.
  37633. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37634. */
  37635. readonly framingBehavior: Nullable<FramingBehavior>;
  37636. /**
  37637. * Defines if the framing behavior of the camera is enabled on the camera.
  37638. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37639. */
  37640. useFramingBehavior: boolean;
  37641. private _autoRotationBehavior;
  37642. /**
  37643. * Gets the auto rotation behavior of the camera if it has been enabled.
  37644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37645. */
  37646. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37647. /**
  37648. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37650. */
  37651. useAutoRotationBehavior: boolean;
  37652. /**
  37653. * Observable triggered when the mesh target has been changed on the camera.
  37654. */
  37655. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37656. /**
  37657. * Event raised when the camera is colliding with a mesh.
  37658. */
  37659. onCollide: (collidedMesh: AbstractMesh) => void;
  37660. /**
  37661. * Defines whether the camera should check collision with the objects oh the scene.
  37662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37663. */
  37664. checkCollisions: boolean;
  37665. /**
  37666. * Defines the collision radius of the camera.
  37667. * This simulates a sphere around the camera.
  37668. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37669. */
  37670. collisionRadius: Vector3;
  37671. protected _collider: Collider;
  37672. protected _previousPosition: Vector3;
  37673. protected _collisionVelocity: Vector3;
  37674. protected _newPosition: Vector3;
  37675. protected _previousAlpha: number;
  37676. protected _previousBeta: number;
  37677. protected _previousRadius: number;
  37678. protected _collisionTriggered: boolean;
  37679. protected _targetBoundingCenter: Nullable<Vector3>;
  37680. private _computationVector;
  37681. /**
  37682. * Instantiates a new ArcRotateCamera in a given scene
  37683. * @param name Defines the name of the camera
  37684. * @param alpha Defines the camera rotation along the logitudinal axis
  37685. * @param beta Defines the camera rotation along the latitudinal axis
  37686. * @param radius Defines the camera distance from its target
  37687. * @param target Defines the camera target
  37688. * @param scene Defines the scene the camera belongs to
  37689. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37690. */
  37691. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37692. /** @hidden */
  37693. _initCache(): void;
  37694. /** @hidden */
  37695. _updateCache(ignoreParentClass?: boolean): void;
  37696. protected _getTargetPosition(): Vector3;
  37697. private _storedAlpha;
  37698. private _storedBeta;
  37699. private _storedRadius;
  37700. private _storedTarget;
  37701. private _storedTargetScreenOffset;
  37702. /**
  37703. * Stores the current state of the camera (alpha, beta, radius and target)
  37704. * @returns the camera itself
  37705. */
  37706. storeState(): Camera;
  37707. /**
  37708. * @hidden
  37709. * Restored camera state. You must call storeState() first
  37710. */
  37711. _restoreStateValues(): boolean;
  37712. /** @hidden */
  37713. _isSynchronizedViewMatrix(): boolean;
  37714. /**
  37715. * Attached controls to the current camera.
  37716. * @param element Defines the element the controls should be listened from
  37717. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37718. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37719. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37720. */
  37721. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37722. /**
  37723. * Detach the current controls from the camera.
  37724. * The camera will stop reacting to inputs.
  37725. * @param element Defines the element to stop listening the inputs from
  37726. */
  37727. detachControl(element: HTMLElement): void;
  37728. /** @hidden */
  37729. _checkInputs(): void;
  37730. protected _checkLimits(): void;
  37731. /**
  37732. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37733. */
  37734. rebuildAnglesAndRadius(): void;
  37735. /**
  37736. * Use a position to define the current camera related information like aplha, beta and radius
  37737. * @param position Defines the position to set the camera at
  37738. */
  37739. setPosition(position: Vector3): void;
  37740. /**
  37741. * Defines the target the camera should look at.
  37742. * This will automatically adapt alpha beta and radius to fit within the new target.
  37743. * @param target Defines the new target as a Vector or a mesh
  37744. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37745. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37746. */
  37747. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37748. /** @hidden */
  37749. _getViewMatrix(): Matrix;
  37750. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37751. /**
  37752. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37753. * @param meshes Defines the mesh to zoom on
  37754. * @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)
  37755. */
  37756. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37757. /**
  37758. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37759. * The target will be changed but the radius
  37760. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37761. * @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)
  37762. */
  37763. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37764. min: Vector3;
  37765. max: Vector3;
  37766. distance: number;
  37767. }, doNotUpdateMaxZ?: boolean): void;
  37768. /**
  37769. * @override
  37770. * Override Camera.createRigCamera
  37771. */
  37772. createRigCamera(name: string, cameraIndex: number): Camera;
  37773. /**
  37774. * @hidden
  37775. * @override
  37776. * Override Camera._updateRigCameras
  37777. */
  37778. _updateRigCameras(): void;
  37779. /**
  37780. * Destroy the camera and release the current resources hold by it.
  37781. */
  37782. dispose(): void;
  37783. /**
  37784. * Gets the current object class name.
  37785. * @return the class name
  37786. */
  37787. getClassName(): string;
  37788. }
  37789. }
  37790. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37791. import { Behavior } from "babylonjs/Behaviors/behavior";
  37792. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37793. /**
  37794. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37795. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37796. */
  37797. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37798. /**
  37799. * Gets the name of the behavior.
  37800. */
  37801. readonly name: string;
  37802. private _zoomStopsAnimation;
  37803. private _idleRotationSpeed;
  37804. private _idleRotationWaitTime;
  37805. private _idleRotationSpinupTime;
  37806. /**
  37807. * Sets the flag that indicates if user zooming should stop animation.
  37808. */
  37809. /**
  37810. * Gets the flag that indicates if user zooming should stop animation.
  37811. */
  37812. zoomStopsAnimation: boolean;
  37813. /**
  37814. * Sets the default speed at which the camera rotates around the model.
  37815. */
  37816. /**
  37817. * Gets the default speed at which the camera rotates around the model.
  37818. */
  37819. idleRotationSpeed: number;
  37820. /**
  37821. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37822. */
  37823. /**
  37824. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37825. */
  37826. idleRotationWaitTime: number;
  37827. /**
  37828. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37829. */
  37830. /**
  37831. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37832. */
  37833. idleRotationSpinupTime: number;
  37834. /**
  37835. * Gets a value indicating if the camera is currently rotating because of this behavior
  37836. */
  37837. readonly rotationInProgress: boolean;
  37838. private _onPrePointerObservableObserver;
  37839. private _onAfterCheckInputsObserver;
  37840. private _attachedCamera;
  37841. private _isPointerDown;
  37842. private _lastFrameTime;
  37843. private _lastInteractionTime;
  37844. private _cameraRotationSpeed;
  37845. /**
  37846. * Initializes the behavior.
  37847. */
  37848. init(): void;
  37849. /**
  37850. * Attaches the behavior to its arc rotate camera.
  37851. * @param camera Defines the camera to attach the behavior to
  37852. */
  37853. attach(camera: ArcRotateCamera): void;
  37854. /**
  37855. * Detaches the behavior from its current arc rotate camera.
  37856. */
  37857. detach(): void;
  37858. /**
  37859. * Returns true if user is scrolling.
  37860. * @return true if user is scrolling.
  37861. */
  37862. private _userIsZooming;
  37863. private _lastFrameRadius;
  37864. private _shouldAnimationStopForInteraction;
  37865. /**
  37866. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37867. */
  37868. private _applyUserInteraction;
  37869. private _userIsMoving;
  37870. }
  37871. }
  37872. declare module "babylonjs/Behaviors/Cameras/index" {
  37873. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37874. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37875. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37876. }
  37877. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37878. import { Mesh } from "babylonjs/Meshes/mesh";
  37879. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37880. import { Behavior } from "babylonjs/Behaviors/behavior";
  37881. /**
  37882. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37883. */
  37884. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37885. private ui;
  37886. /**
  37887. * The name of the behavior
  37888. */
  37889. name: string;
  37890. /**
  37891. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37892. */
  37893. distanceAwayFromFace: number;
  37894. /**
  37895. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37896. */
  37897. distanceAwayFromBottomOfFace: number;
  37898. private _faceVectors;
  37899. private _target;
  37900. private _scene;
  37901. private _onRenderObserver;
  37902. private _tmpMatrix;
  37903. private _tmpVector;
  37904. /**
  37905. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37906. * @param ui The transform node that should be attched to the mesh
  37907. */
  37908. constructor(ui: TransformNode);
  37909. /**
  37910. * Initializes the behavior
  37911. */
  37912. init(): void;
  37913. private _closestFace;
  37914. private _zeroVector;
  37915. private _lookAtTmpMatrix;
  37916. private _lookAtToRef;
  37917. /**
  37918. * Attaches the AttachToBoxBehavior to the passed in mesh
  37919. * @param target The mesh that the specified node will be attached to
  37920. */
  37921. attach(target: Mesh): void;
  37922. /**
  37923. * Detaches the behavior from the mesh
  37924. */
  37925. detach(): void;
  37926. }
  37927. }
  37928. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37929. import { Behavior } from "babylonjs/Behaviors/behavior";
  37930. import { Mesh } from "babylonjs/Meshes/mesh";
  37931. /**
  37932. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37933. */
  37934. export class FadeInOutBehavior implements Behavior<Mesh> {
  37935. /**
  37936. * Time in milliseconds to delay before fading in (Default: 0)
  37937. */
  37938. delay: number;
  37939. /**
  37940. * Time in milliseconds for the mesh to fade in (Default: 300)
  37941. */
  37942. fadeInTime: number;
  37943. private _millisecondsPerFrame;
  37944. private _hovered;
  37945. private _hoverValue;
  37946. private _ownerNode;
  37947. /**
  37948. * Instatiates the FadeInOutBehavior
  37949. */
  37950. constructor();
  37951. /**
  37952. * The name of the behavior
  37953. */
  37954. readonly name: string;
  37955. /**
  37956. * Initializes the behavior
  37957. */
  37958. init(): void;
  37959. /**
  37960. * Attaches the fade behavior on the passed in mesh
  37961. * @param ownerNode The mesh that will be faded in/out once attached
  37962. */
  37963. attach(ownerNode: Mesh): void;
  37964. /**
  37965. * Detaches the behavior from the mesh
  37966. */
  37967. detach(): void;
  37968. /**
  37969. * Triggers the mesh to begin fading in or out
  37970. * @param value if the object should fade in or out (true to fade in)
  37971. */
  37972. fadeIn(value: boolean): void;
  37973. private _update;
  37974. private _setAllVisibility;
  37975. }
  37976. }
  37977. declare module "babylonjs/Misc/pivotTools" {
  37978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37979. /**
  37980. * Class containing a set of static utilities functions for managing Pivots
  37981. * @hidden
  37982. */
  37983. export class PivotTools {
  37984. private static _PivotCached;
  37985. private static _OldPivotPoint;
  37986. private static _PivotTranslation;
  37987. private static _PivotTmpVector;
  37988. /** @hidden */
  37989. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37990. /** @hidden */
  37991. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37992. }
  37993. }
  37994. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37995. import { Scene } from "babylonjs/scene";
  37996. import { Vector4 } from "babylonjs/Maths/math.vector";
  37997. import { Mesh } from "babylonjs/Meshes/mesh";
  37998. import { Nullable } from "babylonjs/types";
  37999. import { Plane } from "babylonjs/Maths/math.plane";
  38000. /**
  38001. * Class containing static functions to help procedurally build meshes
  38002. */
  38003. export class PlaneBuilder {
  38004. /**
  38005. * Creates a plane mesh
  38006. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38007. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38008. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38012. * @param name defines the name of the mesh
  38013. * @param options defines the options used to create the mesh
  38014. * @param scene defines the hosting scene
  38015. * @returns the plane mesh
  38016. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38017. */
  38018. static CreatePlane(name: string, options: {
  38019. size?: number;
  38020. width?: number;
  38021. height?: number;
  38022. sideOrientation?: number;
  38023. frontUVs?: Vector4;
  38024. backUVs?: Vector4;
  38025. updatable?: boolean;
  38026. sourcePlane?: Plane;
  38027. }, scene?: Nullable<Scene>): Mesh;
  38028. }
  38029. }
  38030. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38031. import { Behavior } from "babylonjs/Behaviors/behavior";
  38032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38033. import { Observable } from "babylonjs/Misc/observable";
  38034. import { Vector3 } from "babylonjs/Maths/math.vector";
  38035. import { Ray } from "babylonjs/Culling/ray";
  38036. import "babylonjs/Meshes/Builders/planeBuilder";
  38037. /**
  38038. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38039. */
  38040. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38041. private static _AnyMouseID;
  38042. /**
  38043. * Abstract mesh the behavior is set on
  38044. */
  38045. attachedNode: AbstractMesh;
  38046. private _dragPlane;
  38047. private _scene;
  38048. private _pointerObserver;
  38049. private _beforeRenderObserver;
  38050. private static _planeScene;
  38051. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38052. /**
  38053. * 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)
  38054. */
  38055. maxDragAngle: number;
  38056. /**
  38057. * @hidden
  38058. */
  38059. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38060. /**
  38061. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38062. */
  38063. currentDraggingPointerID: number;
  38064. /**
  38065. * The last position where the pointer hit the drag plane in world space
  38066. */
  38067. lastDragPosition: Vector3;
  38068. /**
  38069. * If the behavior is currently in a dragging state
  38070. */
  38071. dragging: boolean;
  38072. /**
  38073. * 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)
  38074. */
  38075. dragDeltaRatio: number;
  38076. /**
  38077. * If the drag plane orientation should be updated during the dragging (Default: true)
  38078. */
  38079. updateDragPlane: boolean;
  38080. private _debugMode;
  38081. private _moving;
  38082. /**
  38083. * Fires each time the attached mesh is dragged with the pointer
  38084. * * delta between last drag position and current drag position in world space
  38085. * * dragDistance along the drag axis
  38086. * * dragPlaneNormal normal of the current drag plane used during the drag
  38087. * * dragPlanePoint in world space where the drag intersects the drag plane
  38088. */
  38089. onDragObservable: Observable<{
  38090. delta: Vector3;
  38091. dragPlanePoint: Vector3;
  38092. dragPlaneNormal: Vector3;
  38093. dragDistance: number;
  38094. pointerId: number;
  38095. }>;
  38096. /**
  38097. * Fires each time a drag begins (eg. mouse down on mesh)
  38098. */
  38099. onDragStartObservable: Observable<{
  38100. dragPlanePoint: Vector3;
  38101. pointerId: number;
  38102. }>;
  38103. /**
  38104. * Fires each time a drag ends (eg. mouse release after drag)
  38105. */
  38106. onDragEndObservable: Observable<{
  38107. dragPlanePoint: Vector3;
  38108. pointerId: number;
  38109. }>;
  38110. /**
  38111. * If the attached mesh should be moved when dragged
  38112. */
  38113. moveAttached: boolean;
  38114. /**
  38115. * If the drag behavior will react to drag events (Default: true)
  38116. */
  38117. enabled: boolean;
  38118. /**
  38119. * If pointer events should start and release the drag (Default: true)
  38120. */
  38121. startAndReleaseDragOnPointerEvents: boolean;
  38122. /**
  38123. * If camera controls should be detached during the drag
  38124. */
  38125. detachCameraControls: boolean;
  38126. /**
  38127. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38128. */
  38129. useObjectOrienationForDragging: boolean;
  38130. private _options;
  38131. /**
  38132. * Creates a pointer drag behavior that can be attached to a mesh
  38133. * @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)
  38134. */
  38135. constructor(options?: {
  38136. dragAxis?: Vector3;
  38137. dragPlaneNormal?: Vector3;
  38138. });
  38139. /**
  38140. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38141. */
  38142. validateDrag: (targetPosition: Vector3) => boolean;
  38143. /**
  38144. * The name of the behavior
  38145. */
  38146. readonly name: string;
  38147. /**
  38148. * Initializes the behavior
  38149. */
  38150. init(): void;
  38151. private _tmpVector;
  38152. private _alternatePickedPoint;
  38153. private _worldDragAxis;
  38154. private _targetPosition;
  38155. private _attachedElement;
  38156. /**
  38157. * Attaches the drag behavior the passed in mesh
  38158. * @param ownerNode The mesh that will be dragged around once attached
  38159. * @param predicate Predicate to use for pick filtering
  38160. */
  38161. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38162. /**
  38163. * Force relase the drag action by code.
  38164. */
  38165. releaseDrag(): void;
  38166. private _startDragRay;
  38167. private _lastPointerRay;
  38168. /**
  38169. * Simulates the start of a pointer drag event on the behavior
  38170. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38171. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38172. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38173. */
  38174. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38175. private _startDrag;
  38176. private _dragDelta;
  38177. private _moveDrag;
  38178. private _pickWithRayOnDragPlane;
  38179. private _pointA;
  38180. private _pointB;
  38181. private _pointC;
  38182. private _lineA;
  38183. private _lineB;
  38184. private _localAxis;
  38185. private _lookAt;
  38186. private _updateDragPlanePosition;
  38187. /**
  38188. * Detaches the behavior from the mesh
  38189. */
  38190. detach(): void;
  38191. }
  38192. }
  38193. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38194. import { Mesh } from "babylonjs/Meshes/mesh";
  38195. import { Behavior } from "babylonjs/Behaviors/behavior";
  38196. /**
  38197. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38198. */
  38199. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38200. private _dragBehaviorA;
  38201. private _dragBehaviorB;
  38202. private _startDistance;
  38203. private _initialScale;
  38204. private _targetScale;
  38205. private _ownerNode;
  38206. private _sceneRenderObserver;
  38207. /**
  38208. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38209. */
  38210. constructor();
  38211. /**
  38212. * The name of the behavior
  38213. */
  38214. readonly name: string;
  38215. /**
  38216. * Initializes the behavior
  38217. */
  38218. init(): void;
  38219. private _getCurrentDistance;
  38220. /**
  38221. * Attaches the scale behavior the passed in mesh
  38222. * @param ownerNode The mesh that will be scaled around once attached
  38223. */
  38224. attach(ownerNode: Mesh): void;
  38225. /**
  38226. * Detaches the behavior from the mesh
  38227. */
  38228. detach(): void;
  38229. }
  38230. }
  38231. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38232. import { Behavior } from "babylonjs/Behaviors/behavior";
  38233. import { Mesh } from "babylonjs/Meshes/mesh";
  38234. import { Observable } from "babylonjs/Misc/observable";
  38235. /**
  38236. * 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
  38237. */
  38238. export class SixDofDragBehavior implements Behavior<Mesh> {
  38239. private static _virtualScene;
  38240. private _ownerNode;
  38241. private _sceneRenderObserver;
  38242. private _scene;
  38243. private _targetPosition;
  38244. private _virtualOriginMesh;
  38245. private _virtualDragMesh;
  38246. private _pointerObserver;
  38247. private _moving;
  38248. private _startingOrientation;
  38249. /**
  38250. * 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)
  38251. */
  38252. private zDragFactor;
  38253. /**
  38254. * If the object should rotate to face the drag origin
  38255. */
  38256. rotateDraggedObject: boolean;
  38257. /**
  38258. * If the behavior is currently in a dragging state
  38259. */
  38260. dragging: boolean;
  38261. /**
  38262. * 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)
  38263. */
  38264. dragDeltaRatio: number;
  38265. /**
  38266. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38267. */
  38268. currentDraggingPointerID: number;
  38269. /**
  38270. * If camera controls should be detached during the drag
  38271. */
  38272. detachCameraControls: boolean;
  38273. /**
  38274. * Fires each time a drag starts
  38275. */
  38276. onDragStartObservable: Observable<{}>;
  38277. /**
  38278. * Fires each time a drag ends (eg. mouse release after drag)
  38279. */
  38280. onDragEndObservable: Observable<{}>;
  38281. /**
  38282. * 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
  38283. */
  38284. constructor();
  38285. /**
  38286. * The name of the behavior
  38287. */
  38288. readonly name: string;
  38289. /**
  38290. * Initializes the behavior
  38291. */
  38292. init(): void;
  38293. /**
  38294. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38295. */
  38296. private readonly _pointerCamera;
  38297. /**
  38298. * Attaches the scale behavior the passed in mesh
  38299. * @param ownerNode The mesh that will be scaled around once attached
  38300. */
  38301. attach(ownerNode: Mesh): void;
  38302. /**
  38303. * Detaches the behavior from the mesh
  38304. */
  38305. detach(): void;
  38306. }
  38307. }
  38308. declare module "babylonjs/Behaviors/Meshes/index" {
  38309. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38310. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38311. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38312. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38313. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38314. }
  38315. declare module "babylonjs/Behaviors/index" {
  38316. export * from "babylonjs/Behaviors/behavior";
  38317. export * from "babylonjs/Behaviors/Cameras/index";
  38318. export * from "babylonjs/Behaviors/Meshes/index";
  38319. }
  38320. declare module "babylonjs/Bones/boneIKController" {
  38321. import { Bone } from "babylonjs/Bones/bone";
  38322. import { Vector3 } from "babylonjs/Maths/math.vector";
  38323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38324. import { Nullable } from "babylonjs/types";
  38325. /**
  38326. * Class used to apply inverse kinematics to bones
  38327. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38328. */
  38329. export class BoneIKController {
  38330. private static _tmpVecs;
  38331. private static _tmpQuat;
  38332. private static _tmpMats;
  38333. /**
  38334. * Gets or sets the target mesh
  38335. */
  38336. targetMesh: AbstractMesh;
  38337. /** Gets or sets the mesh used as pole */
  38338. poleTargetMesh: AbstractMesh;
  38339. /**
  38340. * Gets or sets the bone used as pole
  38341. */
  38342. poleTargetBone: Nullable<Bone>;
  38343. /**
  38344. * Gets or sets the target position
  38345. */
  38346. targetPosition: Vector3;
  38347. /**
  38348. * Gets or sets the pole target position
  38349. */
  38350. poleTargetPosition: Vector3;
  38351. /**
  38352. * Gets or sets the pole target local offset
  38353. */
  38354. poleTargetLocalOffset: Vector3;
  38355. /**
  38356. * Gets or sets the pole angle
  38357. */
  38358. poleAngle: number;
  38359. /**
  38360. * Gets or sets the mesh associated with the controller
  38361. */
  38362. mesh: AbstractMesh;
  38363. /**
  38364. * 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)
  38365. */
  38366. slerpAmount: number;
  38367. private _bone1Quat;
  38368. private _bone1Mat;
  38369. private _bone2Ang;
  38370. private _bone1;
  38371. private _bone2;
  38372. private _bone1Length;
  38373. private _bone2Length;
  38374. private _maxAngle;
  38375. private _maxReach;
  38376. private _rightHandedSystem;
  38377. private _bendAxis;
  38378. private _slerping;
  38379. private _adjustRoll;
  38380. /**
  38381. * Gets or sets maximum allowed angle
  38382. */
  38383. maxAngle: number;
  38384. /**
  38385. * Creates a new BoneIKController
  38386. * @param mesh defines the mesh to control
  38387. * @param bone defines the bone to control
  38388. * @param options defines options to set up the controller
  38389. */
  38390. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38391. targetMesh?: AbstractMesh;
  38392. poleTargetMesh?: AbstractMesh;
  38393. poleTargetBone?: Bone;
  38394. poleTargetLocalOffset?: Vector3;
  38395. poleAngle?: number;
  38396. bendAxis?: Vector3;
  38397. maxAngle?: number;
  38398. slerpAmount?: number;
  38399. });
  38400. private _setMaxAngle;
  38401. /**
  38402. * Force the controller to update the bones
  38403. */
  38404. update(): void;
  38405. }
  38406. }
  38407. declare module "babylonjs/Bones/boneLookController" {
  38408. import { Vector3 } from "babylonjs/Maths/math.vector";
  38409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38410. import { Bone } from "babylonjs/Bones/bone";
  38411. import { Space } from "babylonjs/Maths/math.axis";
  38412. /**
  38413. * Class used to make a bone look toward a point in space
  38414. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38415. */
  38416. export class BoneLookController {
  38417. private static _tmpVecs;
  38418. private static _tmpQuat;
  38419. private static _tmpMats;
  38420. /**
  38421. * The target Vector3 that the bone will look at
  38422. */
  38423. target: Vector3;
  38424. /**
  38425. * The mesh that the bone is attached to
  38426. */
  38427. mesh: AbstractMesh;
  38428. /**
  38429. * The bone that will be looking to the target
  38430. */
  38431. bone: Bone;
  38432. /**
  38433. * The up axis of the coordinate system that is used when the bone is rotated
  38434. */
  38435. upAxis: Vector3;
  38436. /**
  38437. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38438. */
  38439. upAxisSpace: Space;
  38440. /**
  38441. * Used to make an adjustment to the yaw of the bone
  38442. */
  38443. adjustYaw: number;
  38444. /**
  38445. * Used to make an adjustment to the pitch of the bone
  38446. */
  38447. adjustPitch: number;
  38448. /**
  38449. * Used to make an adjustment to the roll of the bone
  38450. */
  38451. adjustRoll: number;
  38452. /**
  38453. * 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)
  38454. */
  38455. slerpAmount: number;
  38456. private _minYaw;
  38457. private _maxYaw;
  38458. private _minPitch;
  38459. private _maxPitch;
  38460. private _minYawSin;
  38461. private _minYawCos;
  38462. private _maxYawSin;
  38463. private _maxYawCos;
  38464. private _midYawConstraint;
  38465. private _minPitchTan;
  38466. private _maxPitchTan;
  38467. private _boneQuat;
  38468. private _slerping;
  38469. private _transformYawPitch;
  38470. private _transformYawPitchInv;
  38471. private _firstFrameSkipped;
  38472. private _yawRange;
  38473. private _fowardAxis;
  38474. /**
  38475. * Gets or sets the minimum yaw angle that the bone can look to
  38476. */
  38477. minYaw: number;
  38478. /**
  38479. * Gets or sets the maximum yaw angle that the bone can look to
  38480. */
  38481. maxYaw: number;
  38482. /**
  38483. * Gets or sets the minimum pitch angle that the bone can look to
  38484. */
  38485. minPitch: number;
  38486. /**
  38487. * Gets or sets the maximum pitch angle that the bone can look to
  38488. */
  38489. maxPitch: number;
  38490. /**
  38491. * Create a BoneLookController
  38492. * @param mesh the mesh that the bone belongs to
  38493. * @param bone the bone that will be looking to the target
  38494. * @param target the target Vector3 to look at
  38495. * @param options optional settings:
  38496. * * maxYaw: the maximum angle the bone will yaw to
  38497. * * minYaw: the minimum angle the bone will yaw to
  38498. * * maxPitch: the maximum angle the bone will pitch to
  38499. * * minPitch: the minimum angle the bone will yaw to
  38500. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38501. * * upAxis: the up axis of the coordinate system
  38502. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38503. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38504. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38505. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38506. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38507. * * adjustRoll: used to make an adjustment to the roll of the bone
  38508. **/
  38509. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38510. maxYaw?: number;
  38511. minYaw?: number;
  38512. maxPitch?: number;
  38513. minPitch?: number;
  38514. slerpAmount?: number;
  38515. upAxis?: Vector3;
  38516. upAxisSpace?: Space;
  38517. yawAxis?: Vector3;
  38518. pitchAxis?: Vector3;
  38519. adjustYaw?: number;
  38520. adjustPitch?: number;
  38521. adjustRoll?: number;
  38522. });
  38523. /**
  38524. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38525. */
  38526. update(): void;
  38527. private _getAngleDiff;
  38528. private _getAngleBetween;
  38529. private _isAngleBetween;
  38530. }
  38531. }
  38532. declare module "babylonjs/Bones/index" {
  38533. export * from "babylonjs/Bones/bone";
  38534. export * from "babylonjs/Bones/boneIKController";
  38535. export * from "babylonjs/Bones/boneLookController";
  38536. export * from "babylonjs/Bones/skeleton";
  38537. }
  38538. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38539. import { Nullable } from "babylonjs/types";
  38540. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38541. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38542. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38543. /**
  38544. * Manage the gamepad inputs to control an arc rotate camera.
  38545. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38546. */
  38547. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38548. /**
  38549. * Defines the camera the input is attached to.
  38550. */
  38551. camera: ArcRotateCamera;
  38552. /**
  38553. * Defines the gamepad the input is gathering event from.
  38554. */
  38555. gamepad: Nullable<Gamepad>;
  38556. /**
  38557. * Defines the gamepad rotation sensiblity.
  38558. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38559. */
  38560. gamepadRotationSensibility: number;
  38561. /**
  38562. * Defines the gamepad move sensiblity.
  38563. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38564. */
  38565. gamepadMoveSensibility: number;
  38566. private _onGamepadConnectedObserver;
  38567. private _onGamepadDisconnectedObserver;
  38568. /**
  38569. * Attach the input controls to a specific dom element to get the input from.
  38570. * @param element Defines the element the controls should be listened from
  38571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38572. */
  38573. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38574. /**
  38575. * Detach the current controls from the specified dom element.
  38576. * @param element Defines the element to stop listening the inputs from
  38577. */
  38578. detachControl(element: Nullable<HTMLElement>): void;
  38579. /**
  38580. * Update the current camera state depending on the inputs that have been used this frame.
  38581. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38582. */
  38583. checkInputs(): void;
  38584. /**
  38585. * Gets the class name of the current intput.
  38586. * @returns the class name
  38587. */
  38588. getClassName(): string;
  38589. /**
  38590. * Get the friendly name associated with the input class.
  38591. * @returns the input friendly name
  38592. */
  38593. getSimpleName(): string;
  38594. }
  38595. }
  38596. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38597. import { Nullable } from "babylonjs/types";
  38598. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38600. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38601. interface ArcRotateCameraInputsManager {
  38602. /**
  38603. * Add orientation input support to the input manager.
  38604. * @returns the current input manager
  38605. */
  38606. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38607. }
  38608. }
  38609. /**
  38610. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38612. */
  38613. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38614. /**
  38615. * Defines the camera the input is attached to.
  38616. */
  38617. camera: ArcRotateCamera;
  38618. /**
  38619. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38620. */
  38621. alphaCorrection: number;
  38622. /**
  38623. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38624. */
  38625. gammaCorrection: number;
  38626. private _alpha;
  38627. private _gamma;
  38628. private _dirty;
  38629. private _deviceOrientationHandler;
  38630. /**
  38631. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38632. */
  38633. constructor();
  38634. /**
  38635. * Attach the input controls to a specific dom element to get the input from.
  38636. * @param element Defines the element the controls should be listened from
  38637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38638. */
  38639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38640. /** @hidden */
  38641. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38642. /**
  38643. * Update the current camera state depending on the inputs that have been used this frame.
  38644. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38645. */
  38646. checkInputs(): void;
  38647. /**
  38648. * Detach the current controls from the specified dom element.
  38649. * @param element Defines the element to stop listening the inputs from
  38650. */
  38651. detachControl(element: Nullable<HTMLElement>): void;
  38652. /**
  38653. * Gets the class name of the current intput.
  38654. * @returns the class name
  38655. */
  38656. getClassName(): string;
  38657. /**
  38658. * Get the friendly name associated with the input class.
  38659. * @returns the input friendly name
  38660. */
  38661. getSimpleName(): string;
  38662. }
  38663. }
  38664. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38665. import { Nullable } from "babylonjs/types";
  38666. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38667. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38668. /**
  38669. * Listen to mouse events to control the camera.
  38670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38671. */
  38672. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38673. /**
  38674. * Defines the camera the input is attached to.
  38675. */
  38676. camera: FlyCamera;
  38677. /**
  38678. * Defines if touch is enabled. (Default is true.)
  38679. */
  38680. touchEnabled: boolean;
  38681. /**
  38682. * Defines the buttons associated with the input to handle camera rotation.
  38683. */
  38684. buttons: number[];
  38685. /**
  38686. * Assign buttons for Yaw control.
  38687. */
  38688. buttonsYaw: number[];
  38689. /**
  38690. * Assign buttons for Pitch control.
  38691. */
  38692. buttonsPitch: number[];
  38693. /**
  38694. * Assign buttons for Roll control.
  38695. */
  38696. buttonsRoll: number[];
  38697. /**
  38698. * Detect if any button is being pressed while mouse is moved.
  38699. * -1 = Mouse locked.
  38700. * 0 = Left button.
  38701. * 1 = Middle Button.
  38702. * 2 = Right Button.
  38703. */
  38704. activeButton: number;
  38705. /**
  38706. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38707. * Higher values reduce its sensitivity.
  38708. */
  38709. angularSensibility: number;
  38710. private _mousemoveCallback;
  38711. private _observer;
  38712. private _rollObserver;
  38713. private previousPosition;
  38714. private noPreventDefault;
  38715. private element;
  38716. /**
  38717. * Listen to mouse events to control the camera.
  38718. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38720. */
  38721. constructor(touchEnabled?: boolean);
  38722. /**
  38723. * Attach the mouse control to the HTML DOM element.
  38724. * @param element Defines the element that listens to the input events.
  38725. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38726. */
  38727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38728. /**
  38729. * Detach the current controls from the specified dom element.
  38730. * @param element Defines the element to stop listening the inputs from
  38731. */
  38732. detachControl(element: Nullable<HTMLElement>): void;
  38733. /**
  38734. * Gets the class name of the current input.
  38735. * @returns the class name.
  38736. */
  38737. getClassName(): string;
  38738. /**
  38739. * Get the friendly name associated with the input class.
  38740. * @returns the input's friendly name.
  38741. */
  38742. getSimpleName(): string;
  38743. private _pointerInput;
  38744. private _onMouseMove;
  38745. /**
  38746. * Rotate camera by mouse offset.
  38747. */
  38748. private rotateCamera;
  38749. }
  38750. }
  38751. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38752. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38753. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38754. /**
  38755. * Default Inputs manager for the FlyCamera.
  38756. * It groups all the default supported inputs for ease of use.
  38757. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38758. */
  38759. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38760. /**
  38761. * Instantiates a new FlyCameraInputsManager.
  38762. * @param camera Defines the camera the inputs belong to.
  38763. */
  38764. constructor(camera: FlyCamera);
  38765. /**
  38766. * Add keyboard input support to the input manager.
  38767. * @returns the new FlyCameraKeyboardMoveInput().
  38768. */
  38769. addKeyboard(): FlyCameraInputsManager;
  38770. /**
  38771. * Add mouse input support to the input manager.
  38772. * @param touchEnabled Enable touch screen support.
  38773. * @returns the new FlyCameraMouseInput().
  38774. */
  38775. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38776. }
  38777. }
  38778. declare module "babylonjs/Cameras/flyCamera" {
  38779. import { Scene } from "babylonjs/scene";
  38780. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38782. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38783. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38784. /**
  38785. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38786. * such as in a 3D Space Shooter or a Flight Simulator.
  38787. */
  38788. export class FlyCamera extends TargetCamera {
  38789. /**
  38790. * Define the collision ellipsoid of the camera.
  38791. * This is helpful for simulating a camera body, like a player's body.
  38792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38793. */
  38794. ellipsoid: Vector3;
  38795. /**
  38796. * Define an offset for the position of the ellipsoid around the camera.
  38797. * This can be helpful if the camera is attached away from the player's body center,
  38798. * such as at its head.
  38799. */
  38800. ellipsoidOffset: Vector3;
  38801. /**
  38802. * Enable or disable collisions of the camera with the rest of the scene objects.
  38803. */
  38804. checkCollisions: boolean;
  38805. /**
  38806. * Enable or disable gravity on the camera.
  38807. */
  38808. applyGravity: boolean;
  38809. /**
  38810. * Define the current direction the camera is moving to.
  38811. */
  38812. cameraDirection: Vector3;
  38813. /**
  38814. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38815. * This overrides and empties cameraRotation.
  38816. */
  38817. rotationQuaternion: Quaternion;
  38818. /**
  38819. * Track Roll to maintain the wanted Rolling when looking around.
  38820. */
  38821. _trackRoll: number;
  38822. /**
  38823. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38824. */
  38825. rollCorrect: number;
  38826. /**
  38827. * Mimic a banked turn, Rolling the camera when Yawing.
  38828. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38829. */
  38830. bankedTurn: boolean;
  38831. /**
  38832. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38833. */
  38834. bankedTurnLimit: number;
  38835. /**
  38836. * Value of 0 disables the banked Roll.
  38837. * Value of 1 is equal to the Yaw angle in radians.
  38838. */
  38839. bankedTurnMultiplier: number;
  38840. /**
  38841. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38842. */
  38843. inputs: FlyCameraInputsManager;
  38844. /**
  38845. * Gets the input sensibility for mouse input.
  38846. * Higher values reduce sensitivity.
  38847. */
  38848. /**
  38849. * Sets the input sensibility for a mouse input.
  38850. * Higher values reduce sensitivity.
  38851. */
  38852. angularSensibility: number;
  38853. /**
  38854. * Get the keys for camera movement forward.
  38855. */
  38856. /**
  38857. * Set the keys for camera movement forward.
  38858. */
  38859. keysForward: number[];
  38860. /**
  38861. * Get the keys for camera movement backward.
  38862. */
  38863. keysBackward: number[];
  38864. /**
  38865. * Get the keys for camera movement up.
  38866. */
  38867. /**
  38868. * Set the keys for camera movement up.
  38869. */
  38870. keysUp: number[];
  38871. /**
  38872. * Get the keys for camera movement down.
  38873. */
  38874. /**
  38875. * Set the keys for camera movement down.
  38876. */
  38877. keysDown: number[];
  38878. /**
  38879. * Get the keys for camera movement left.
  38880. */
  38881. /**
  38882. * Set the keys for camera movement left.
  38883. */
  38884. keysLeft: number[];
  38885. /**
  38886. * Set the keys for camera movement right.
  38887. */
  38888. /**
  38889. * Set the keys for camera movement right.
  38890. */
  38891. keysRight: number[];
  38892. /**
  38893. * Event raised when the camera collides with a mesh in the scene.
  38894. */
  38895. onCollide: (collidedMesh: AbstractMesh) => void;
  38896. private _collider;
  38897. private _needMoveForGravity;
  38898. private _oldPosition;
  38899. private _diffPosition;
  38900. private _newPosition;
  38901. /** @hidden */
  38902. _localDirection: Vector3;
  38903. /** @hidden */
  38904. _transformedDirection: Vector3;
  38905. /**
  38906. * Instantiates a FlyCamera.
  38907. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38908. * such as in a 3D Space Shooter or a Flight Simulator.
  38909. * @param name Define the name of the camera in the scene.
  38910. * @param position Define the starting position of the camera in the scene.
  38911. * @param scene Define the scene the camera belongs to.
  38912. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38913. */
  38914. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38915. /**
  38916. * Attach a control to the HTML DOM element.
  38917. * @param element Defines the element that listens to the input events.
  38918. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38919. */
  38920. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38921. /**
  38922. * Detach a control from the HTML DOM element.
  38923. * The camera will stop reacting to that input.
  38924. * @param element Defines the element that listens to the input events.
  38925. */
  38926. detachControl(element: HTMLElement): void;
  38927. private _collisionMask;
  38928. /**
  38929. * Get the mask that the camera ignores in collision events.
  38930. */
  38931. /**
  38932. * Set the mask that the camera ignores in collision events.
  38933. */
  38934. collisionMask: number;
  38935. /** @hidden */
  38936. _collideWithWorld(displacement: Vector3): void;
  38937. /** @hidden */
  38938. private _onCollisionPositionChange;
  38939. /** @hidden */
  38940. _checkInputs(): void;
  38941. /** @hidden */
  38942. _decideIfNeedsToMove(): boolean;
  38943. /** @hidden */
  38944. _updatePosition(): void;
  38945. /**
  38946. * Restore the Roll to its target value at the rate specified.
  38947. * @param rate - Higher means slower restoring.
  38948. * @hidden
  38949. */
  38950. restoreRoll(rate: number): void;
  38951. /**
  38952. * Destroy the camera and release the current resources held by it.
  38953. */
  38954. dispose(): void;
  38955. /**
  38956. * Get the current object class name.
  38957. * @returns the class name.
  38958. */
  38959. getClassName(): string;
  38960. }
  38961. }
  38962. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38963. import { Nullable } from "babylonjs/types";
  38964. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38965. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38966. /**
  38967. * Listen to keyboard events to control the camera.
  38968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38969. */
  38970. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38971. /**
  38972. * Defines the camera the input is attached to.
  38973. */
  38974. camera: FlyCamera;
  38975. /**
  38976. * The list of keyboard keys used to control the forward move of the camera.
  38977. */
  38978. keysForward: number[];
  38979. /**
  38980. * The list of keyboard keys used to control the backward move of the camera.
  38981. */
  38982. keysBackward: number[];
  38983. /**
  38984. * The list of keyboard keys used to control the forward move of the camera.
  38985. */
  38986. keysUp: number[];
  38987. /**
  38988. * The list of keyboard keys used to control the backward move of the camera.
  38989. */
  38990. keysDown: number[];
  38991. /**
  38992. * The list of keyboard keys used to control the right strafe move of the camera.
  38993. */
  38994. keysRight: number[];
  38995. /**
  38996. * The list of keyboard keys used to control the left strafe move of the camera.
  38997. */
  38998. keysLeft: number[];
  38999. private _keys;
  39000. private _onCanvasBlurObserver;
  39001. private _onKeyboardObserver;
  39002. private _engine;
  39003. private _scene;
  39004. /**
  39005. * Attach the input controls to a specific dom element to get the input from.
  39006. * @param element Defines the element the controls should be listened from
  39007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39008. */
  39009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39010. /**
  39011. * Detach the current controls from the specified dom element.
  39012. * @param element Defines the element to stop listening the inputs from
  39013. */
  39014. detachControl(element: Nullable<HTMLElement>): void;
  39015. /**
  39016. * Gets the class name of the current intput.
  39017. * @returns the class name
  39018. */
  39019. getClassName(): string;
  39020. /** @hidden */
  39021. _onLostFocus(e: FocusEvent): void;
  39022. /**
  39023. * Get the friendly name associated with the input class.
  39024. * @returns the input friendly name
  39025. */
  39026. getSimpleName(): string;
  39027. /**
  39028. * Update the current camera state depending on the inputs that have been used this frame.
  39029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39030. */
  39031. checkInputs(): void;
  39032. }
  39033. }
  39034. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39035. import { Nullable } from "babylonjs/types";
  39036. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39037. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39038. /**
  39039. * Manage the mouse wheel inputs to control a follow camera.
  39040. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39041. */
  39042. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39043. /**
  39044. * Defines the camera the input is attached to.
  39045. */
  39046. camera: FollowCamera;
  39047. /**
  39048. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39049. */
  39050. axisControlRadius: boolean;
  39051. /**
  39052. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39053. */
  39054. axisControlHeight: boolean;
  39055. /**
  39056. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39057. */
  39058. axisControlRotation: boolean;
  39059. /**
  39060. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39061. * relation to mouseWheel events.
  39062. */
  39063. wheelPrecision: number;
  39064. /**
  39065. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39066. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39067. */
  39068. wheelDeltaPercentage: number;
  39069. private _wheel;
  39070. private _observer;
  39071. /**
  39072. * Attach the input controls to a specific dom element to get the input from.
  39073. * @param element Defines the element the controls should be listened from
  39074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39075. */
  39076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39077. /**
  39078. * Detach the current controls from the specified dom element.
  39079. * @param element Defines the element to stop listening the inputs from
  39080. */
  39081. detachControl(element: Nullable<HTMLElement>): void;
  39082. /**
  39083. * Gets the class name of the current intput.
  39084. * @returns the class name
  39085. */
  39086. getClassName(): string;
  39087. /**
  39088. * Get the friendly name associated with the input class.
  39089. * @returns the input friendly name
  39090. */
  39091. getSimpleName(): string;
  39092. }
  39093. }
  39094. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39095. import { Nullable } from "babylonjs/types";
  39096. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39097. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39098. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39099. /**
  39100. * Manage the pointers inputs to control an follow camera.
  39101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39102. */
  39103. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39104. /**
  39105. * Defines the camera the input is attached to.
  39106. */
  39107. camera: FollowCamera;
  39108. /**
  39109. * Gets the class name of the current input.
  39110. * @returns the class name
  39111. */
  39112. getClassName(): string;
  39113. /**
  39114. * Defines the pointer angular sensibility along the X axis or how fast is
  39115. * the camera rotating.
  39116. * A negative number will reverse the axis direction.
  39117. */
  39118. angularSensibilityX: number;
  39119. /**
  39120. * Defines the pointer angular sensibility along the Y axis or how fast is
  39121. * the camera rotating.
  39122. * A negative number will reverse the axis direction.
  39123. */
  39124. angularSensibilityY: number;
  39125. /**
  39126. * Defines the pointer pinch precision or how fast is the camera zooming.
  39127. * A negative number will reverse the axis direction.
  39128. */
  39129. pinchPrecision: number;
  39130. /**
  39131. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39132. * from 0.
  39133. * It defines the percentage of current camera.radius to use as delta when
  39134. * pinch zoom is used.
  39135. */
  39136. pinchDeltaPercentage: number;
  39137. /**
  39138. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39139. */
  39140. axisXControlRadius: boolean;
  39141. /**
  39142. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39143. */
  39144. axisXControlHeight: boolean;
  39145. /**
  39146. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39147. */
  39148. axisXControlRotation: boolean;
  39149. /**
  39150. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39151. */
  39152. axisYControlRadius: boolean;
  39153. /**
  39154. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39155. */
  39156. axisYControlHeight: boolean;
  39157. /**
  39158. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39159. */
  39160. axisYControlRotation: boolean;
  39161. /**
  39162. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39163. */
  39164. axisPinchControlRadius: boolean;
  39165. /**
  39166. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39167. */
  39168. axisPinchControlHeight: boolean;
  39169. /**
  39170. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39171. */
  39172. axisPinchControlRotation: boolean;
  39173. /**
  39174. * Log error messages if basic misconfiguration has occurred.
  39175. */
  39176. warningEnable: boolean;
  39177. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39178. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39179. private _warningCounter;
  39180. private _warning;
  39181. }
  39182. }
  39183. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39184. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39185. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39186. /**
  39187. * Default Inputs manager for the FollowCamera.
  39188. * It groups all the default supported inputs for ease of use.
  39189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39190. */
  39191. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39192. /**
  39193. * Instantiates a new FollowCameraInputsManager.
  39194. * @param camera Defines the camera the inputs belong to
  39195. */
  39196. constructor(camera: FollowCamera);
  39197. /**
  39198. * Add keyboard input support to the input manager.
  39199. * @returns the current input manager
  39200. */
  39201. addKeyboard(): FollowCameraInputsManager;
  39202. /**
  39203. * Add mouse wheel input support to the input manager.
  39204. * @returns the current input manager
  39205. */
  39206. addMouseWheel(): FollowCameraInputsManager;
  39207. /**
  39208. * Add pointers input support to the input manager.
  39209. * @returns the current input manager
  39210. */
  39211. addPointers(): FollowCameraInputsManager;
  39212. /**
  39213. * Add orientation input support to the input manager.
  39214. * @returns the current input manager
  39215. */
  39216. addVRDeviceOrientation(): FollowCameraInputsManager;
  39217. }
  39218. }
  39219. declare module "babylonjs/Cameras/followCamera" {
  39220. import { Nullable } from "babylonjs/types";
  39221. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39222. import { Scene } from "babylonjs/scene";
  39223. import { Vector3 } from "babylonjs/Maths/math.vector";
  39224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39225. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39226. /**
  39227. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39228. * an arc rotate version arcFollowCamera are available.
  39229. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39230. */
  39231. export class FollowCamera extends TargetCamera {
  39232. /**
  39233. * Distance the follow camera should follow an object at
  39234. */
  39235. radius: number;
  39236. /**
  39237. * Minimum allowed distance of the camera to the axis of rotation
  39238. * (The camera can not get closer).
  39239. * This can help limiting how the Camera is able to move in the scene.
  39240. */
  39241. lowerRadiusLimit: Nullable<number>;
  39242. /**
  39243. * Maximum allowed distance of the camera to the axis of rotation
  39244. * (The camera can not get further).
  39245. * This can help limiting how the Camera is able to move in the scene.
  39246. */
  39247. upperRadiusLimit: Nullable<number>;
  39248. /**
  39249. * Define a rotation offset between the camera and the object it follows
  39250. */
  39251. rotationOffset: number;
  39252. /**
  39253. * Minimum allowed angle to camera position relative to target object.
  39254. * This can help limiting how the Camera is able to move in the scene.
  39255. */
  39256. lowerRotationOffsetLimit: Nullable<number>;
  39257. /**
  39258. * Maximum allowed angle to camera position relative to target object.
  39259. * This can help limiting how the Camera is able to move in the scene.
  39260. */
  39261. upperRotationOffsetLimit: Nullable<number>;
  39262. /**
  39263. * Define a height offset between the camera and the object it follows.
  39264. * It can help following an object from the top (like a car chaing a plane)
  39265. */
  39266. heightOffset: number;
  39267. /**
  39268. * Minimum allowed height of camera position relative to target object.
  39269. * This can help limiting how the Camera is able to move in the scene.
  39270. */
  39271. lowerHeightOffsetLimit: Nullable<number>;
  39272. /**
  39273. * Maximum allowed height of camera position relative to target object.
  39274. * This can help limiting how the Camera is able to move in the scene.
  39275. */
  39276. upperHeightOffsetLimit: Nullable<number>;
  39277. /**
  39278. * Define how fast the camera can accelerate to follow it s target.
  39279. */
  39280. cameraAcceleration: number;
  39281. /**
  39282. * Define the speed limit of the camera following an object.
  39283. */
  39284. maxCameraSpeed: number;
  39285. /**
  39286. * Define the target of the camera.
  39287. */
  39288. lockedTarget: Nullable<AbstractMesh>;
  39289. /**
  39290. * Defines the input associated with the camera.
  39291. */
  39292. inputs: FollowCameraInputsManager;
  39293. /**
  39294. * Instantiates the follow camera.
  39295. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39296. * @param name Define the name of the camera in the scene
  39297. * @param position Define the position of the camera
  39298. * @param scene Define the scene the camera belong to
  39299. * @param lockedTarget Define the target of the camera
  39300. */
  39301. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39302. private _follow;
  39303. /**
  39304. * Attached controls to the current camera.
  39305. * @param element Defines the element the controls should be listened from
  39306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39307. */
  39308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39309. /**
  39310. * Detach the current controls from the camera.
  39311. * The camera will stop reacting to inputs.
  39312. * @param element Defines the element to stop listening the inputs from
  39313. */
  39314. detachControl(element: HTMLElement): void;
  39315. /** @hidden */
  39316. _checkInputs(): void;
  39317. private _checkLimits;
  39318. /**
  39319. * Gets the camera class name.
  39320. * @returns the class name
  39321. */
  39322. getClassName(): string;
  39323. }
  39324. /**
  39325. * Arc Rotate version of the follow camera.
  39326. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39327. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39328. */
  39329. export class ArcFollowCamera extends TargetCamera {
  39330. /** The longitudinal angle of the camera */
  39331. alpha: number;
  39332. /** The latitudinal angle of the camera */
  39333. beta: number;
  39334. /** The radius of the camera from its target */
  39335. radius: number;
  39336. /** Define the camera target (the messh it should follow) */
  39337. target: Nullable<AbstractMesh>;
  39338. private _cartesianCoordinates;
  39339. /**
  39340. * Instantiates a new ArcFollowCamera
  39341. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39342. * @param name Define the name of the camera
  39343. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39344. * @param beta Define the rotation angle of the camera around the elevation axis
  39345. * @param radius Define the radius of the camera from its target point
  39346. * @param target Define the target of the camera
  39347. * @param scene Define the scene the camera belongs to
  39348. */
  39349. constructor(name: string,
  39350. /** The longitudinal angle of the camera */
  39351. alpha: number,
  39352. /** The latitudinal angle of the camera */
  39353. beta: number,
  39354. /** The radius of the camera from its target */
  39355. radius: number,
  39356. /** Define the camera target (the messh it should follow) */
  39357. target: Nullable<AbstractMesh>, scene: Scene);
  39358. private _follow;
  39359. /** @hidden */
  39360. _checkInputs(): void;
  39361. /**
  39362. * Returns the class name of the object.
  39363. * It is mostly used internally for serialization purposes.
  39364. */
  39365. getClassName(): string;
  39366. }
  39367. }
  39368. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39370. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39371. import { Nullable } from "babylonjs/types";
  39372. /**
  39373. * Manage the keyboard inputs to control the movement of a follow camera.
  39374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39375. */
  39376. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39377. /**
  39378. * Defines the camera the input is attached to.
  39379. */
  39380. camera: FollowCamera;
  39381. /**
  39382. * Defines the list of key codes associated with the up action (increase heightOffset)
  39383. */
  39384. keysHeightOffsetIncr: number[];
  39385. /**
  39386. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39387. */
  39388. keysHeightOffsetDecr: number[];
  39389. /**
  39390. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39391. */
  39392. keysHeightOffsetModifierAlt: boolean;
  39393. /**
  39394. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39395. */
  39396. keysHeightOffsetModifierCtrl: boolean;
  39397. /**
  39398. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39399. */
  39400. keysHeightOffsetModifierShift: boolean;
  39401. /**
  39402. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39403. */
  39404. keysRotationOffsetIncr: number[];
  39405. /**
  39406. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39407. */
  39408. keysRotationOffsetDecr: number[];
  39409. /**
  39410. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39411. */
  39412. keysRotationOffsetModifierAlt: boolean;
  39413. /**
  39414. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39415. */
  39416. keysRotationOffsetModifierCtrl: boolean;
  39417. /**
  39418. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39419. */
  39420. keysRotationOffsetModifierShift: boolean;
  39421. /**
  39422. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39423. */
  39424. keysRadiusIncr: number[];
  39425. /**
  39426. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39427. */
  39428. keysRadiusDecr: number[];
  39429. /**
  39430. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39431. */
  39432. keysRadiusModifierAlt: boolean;
  39433. /**
  39434. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39435. */
  39436. keysRadiusModifierCtrl: boolean;
  39437. /**
  39438. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39439. */
  39440. keysRadiusModifierShift: boolean;
  39441. /**
  39442. * Defines the rate of change of heightOffset.
  39443. */
  39444. heightSensibility: number;
  39445. /**
  39446. * Defines the rate of change of rotationOffset.
  39447. */
  39448. rotationSensibility: number;
  39449. /**
  39450. * Defines the rate of change of radius.
  39451. */
  39452. radiusSensibility: number;
  39453. private _keys;
  39454. private _ctrlPressed;
  39455. private _altPressed;
  39456. private _shiftPressed;
  39457. private _onCanvasBlurObserver;
  39458. private _onKeyboardObserver;
  39459. private _engine;
  39460. private _scene;
  39461. /**
  39462. * Attach the input controls to a specific dom element to get the input from.
  39463. * @param element Defines the element the controls should be listened from
  39464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39465. */
  39466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39467. /**
  39468. * Detach the current controls from the specified dom element.
  39469. * @param element Defines the element to stop listening the inputs from
  39470. */
  39471. detachControl(element: Nullable<HTMLElement>): void;
  39472. /**
  39473. * Update the current camera state depending on the inputs that have been used this frame.
  39474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39475. */
  39476. checkInputs(): void;
  39477. /**
  39478. * Gets the class name of the current input.
  39479. * @returns the class name
  39480. */
  39481. getClassName(): string;
  39482. /**
  39483. * Get the friendly name associated with the input class.
  39484. * @returns the input friendly name
  39485. */
  39486. getSimpleName(): string;
  39487. /**
  39488. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39489. * allow modification of the heightOffset value.
  39490. */
  39491. private _modifierHeightOffset;
  39492. /**
  39493. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39494. * allow modification of the rotationOffset value.
  39495. */
  39496. private _modifierRotationOffset;
  39497. /**
  39498. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39499. * allow modification of the radius value.
  39500. */
  39501. private _modifierRadius;
  39502. }
  39503. }
  39504. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39505. import { Nullable } from "babylonjs/types";
  39506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39507. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39508. import { Observable } from "babylonjs/Misc/observable";
  39509. module "babylonjs/Cameras/freeCameraInputsManager" {
  39510. interface FreeCameraInputsManager {
  39511. /**
  39512. * @hidden
  39513. */
  39514. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39515. /**
  39516. * Add orientation input support to the input manager.
  39517. * @returns the current input manager
  39518. */
  39519. addDeviceOrientation(): FreeCameraInputsManager;
  39520. }
  39521. }
  39522. /**
  39523. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39524. * Screen rotation is taken into account.
  39525. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39526. */
  39527. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39528. private _camera;
  39529. private _screenOrientationAngle;
  39530. private _constantTranform;
  39531. private _screenQuaternion;
  39532. private _alpha;
  39533. private _beta;
  39534. private _gamma;
  39535. /**
  39536. * Can be used to detect if a device orientation sensor is availible on a device
  39537. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39538. * @returns a promise that will resolve on orientation change
  39539. */
  39540. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39541. /**
  39542. * @hidden
  39543. */
  39544. _onDeviceOrientationChangedObservable: Observable<void>;
  39545. /**
  39546. * Instantiates a new input
  39547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39548. */
  39549. constructor();
  39550. /**
  39551. * Define the camera controlled by the input.
  39552. */
  39553. camera: FreeCamera;
  39554. /**
  39555. * Attach the input controls to a specific dom element to get the input from.
  39556. * @param element Defines the element the controls should be listened from
  39557. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39558. */
  39559. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39560. private _orientationChanged;
  39561. private _deviceOrientation;
  39562. /**
  39563. * Detach the current controls from the specified dom element.
  39564. * @param element Defines the element to stop listening the inputs from
  39565. */
  39566. detachControl(element: Nullable<HTMLElement>): void;
  39567. /**
  39568. * Update the current camera state depending on the inputs that have been used this frame.
  39569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39570. */
  39571. checkInputs(): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39585. import { Nullable } from "babylonjs/types";
  39586. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39587. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39588. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39589. /**
  39590. * Manage the gamepad inputs to control a free camera.
  39591. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39592. */
  39593. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39594. /**
  39595. * Define the camera the input is attached to.
  39596. */
  39597. camera: FreeCamera;
  39598. /**
  39599. * Define the Gamepad controlling the input
  39600. */
  39601. gamepad: Nullable<Gamepad>;
  39602. /**
  39603. * Defines the gamepad rotation sensiblity.
  39604. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39605. */
  39606. gamepadAngularSensibility: number;
  39607. /**
  39608. * Defines the gamepad move sensiblity.
  39609. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39610. */
  39611. gamepadMoveSensibility: number;
  39612. private _onGamepadConnectedObserver;
  39613. private _onGamepadDisconnectedObserver;
  39614. private _cameraTransform;
  39615. private _deltaTransform;
  39616. private _vector3;
  39617. private _vector2;
  39618. /**
  39619. * Attach the input controls to a specific dom element to get the input from.
  39620. * @param element Defines the element the controls should be listened from
  39621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39622. */
  39623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39624. /**
  39625. * Detach the current controls from the specified dom element.
  39626. * @param element Defines the element to stop listening the inputs from
  39627. */
  39628. detachControl(element: Nullable<HTMLElement>): void;
  39629. /**
  39630. * Update the current camera state depending on the inputs that have been used this frame.
  39631. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39632. */
  39633. checkInputs(): void;
  39634. /**
  39635. * Gets the class name of the current intput.
  39636. * @returns the class name
  39637. */
  39638. getClassName(): string;
  39639. /**
  39640. * Get the friendly name associated with the input class.
  39641. * @returns the input friendly name
  39642. */
  39643. getSimpleName(): string;
  39644. }
  39645. }
  39646. declare module "babylonjs/Misc/virtualJoystick" {
  39647. import { Nullable } from "babylonjs/types";
  39648. import { Vector3 } from "babylonjs/Maths/math.vector";
  39649. /**
  39650. * Defines the potential axis of a Joystick
  39651. */
  39652. export enum JoystickAxis {
  39653. /** X axis */
  39654. X = 0,
  39655. /** Y axis */
  39656. Y = 1,
  39657. /** Z axis */
  39658. Z = 2
  39659. }
  39660. /**
  39661. * Class used to define virtual joystick (used in touch mode)
  39662. */
  39663. export class VirtualJoystick {
  39664. /**
  39665. * Gets or sets a boolean indicating that left and right values must be inverted
  39666. */
  39667. reverseLeftRight: boolean;
  39668. /**
  39669. * Gets or sets a boolean indicating that up and down values must be inverted
  39670. */
  39671. reverseUpDown: boolean;
  39672. /**
  39673. * Gets the offset value for the position (ie. the change of the position value)
  39674. */
  39675. deltaPosition: Vector3;
  39676. /**
  39677. * Gets a boolean indicating if the virtual joystick was pressed
  39678. */
  39679. pressed: boolean;
  39680. /**
  39681. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39682. */
  39683. static Canvas: Nullable<HTMLCanvasElement>;
  39684. private static _globalJoystickIndex;
  39685. private static vjCanvasContext;
  39686. private static vjCanvasWidth;
  39687. private static vjCanvasHeight;
  39688. private static halfWidth;
  39689. private _action;
  39690. private _axisTargetedByLeftAndRight;
  39691. private _axisTargetedByUpAndDown;
  39692. private _joystickSensibility;
  39693. private _inversedSensibility;
  39694. private _joystickPointerID;
  39695. private _joystickColor;
  39696. private _joystickPointerPos;
  39697. private _joystickPreviousPointerPos;
  39698. private _joystickPointerStartPos;
  39699. private _deltaJoystickVector;
  39700. private _leftJoystick;
  39701. private _touches;
  39702. private _onPointerDownHandlerRef;
  39703. private _onPointerMoveHandlerRef;
  39704. private _onPointerUpHandlerRef;
  39705. private _onResize;
  39706. /**
  39707. * Creates a new virtual joystick
  39708. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39709. */
  39710. constructor(leftJoystick?: boolean);
  39711. /**
  39712. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39713. * @param newJoystickSensibility defines the new sensibility
  39714. */
  39715. setJoystickSensibility(newJoystickSensibility: number): void;
  39716. private _onPointerDown;
  39717. private _onPointerMove;
  39718. private _onPointerUp;
  39719. /**
  39720. * Change the color of the virtual joystick
  39721. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39722. */
  39723. setJoystickColor(newColor: string): void;
  39724. /**
  39725. * Defines a callback to call when the joystick is touched
  39726. * @param action defines the callback
  39727. */
  39728. setActionOnTouch(action: () => any): void;
  39729. /**
  39730. * Defines which axis you'd like to control for left & right
  39731. * @param axis defines the axis to use
  39732. */
  39733. setAxisForLeftRight(axis: JoystickAxis): void;
  39734. /**
  39735. * Defines which axis you'd like to control for up & down
  39736. * @param axis defines the axis to use
  39737. */
  39738. setAxisForUpDown(axis: JoystickAxis): void;
  39739. private _drawVirtualJoystick;
  39740. /**
  39741. * Release internal HTML canvas
  39742. */
  39743. releaseCanvas(): void;
  39744. }
  39745. }
  39746. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39747. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39748. import { Nullable } from "babylonjs/types";
  39749. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39750. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39751. module "babylonjs/Cameras/freeCameraInputsManager" {
  39752. interface FreeCameraInputsManager {
  39753. /**
  39754. * Add virtual joystick input support to the input manager.
  39755. * @returns the current input manager
  39756. */
  39757. addVirtualJoystick(): FreeCameraInputsManager;
  39758. }
  39759. }
  39760. /**
  39761. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39763. */
  39764. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39765. /**
  39766. * Defines the camera the input is attached to.
  39767. */
  39768. camera: FreeCamera;
  39769. private _leftjoystick;
  39770. private _rightjoystick;
  39771. /**
  39772. * Gets the left stick of the virtual joystick.
  39773. * @returns The virtual Joystick
  39774. */
  39775. getLeftJoystick(): VirtualJoystick;
  39776. /**
  39777. * Gets the right stick of the virtual joystick.
  39778. * @returns The virtual Joystick
  39779. */
  39780. getRightJoystick(): VirtualJoystick;
  39781. /**
  39782. * Update the current camera state depending on the inputs that have been used this frame.
  39783. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39784. */
  39785. checkInputs(): void;
  39786. /**
  39787. * Attach the input controls to a specific dom element to get the input from.
  39788. * @param element Defines the element the controls should be listened from
  39789. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39790. */
  39791. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39792. /**
  39793. * Detach the current controls from the specified dom element.
  39794. * @param element Defines the element to stop listening the inputs from
  39795. */
  39796. detachControl(element: Nullable<HTMLElement>): void;
  39797. /**
  39798. * Gets the class name of the current intput.
  39799. * @returns the class name
  39800. */
  39801. getClassName(): string;
  39802. /**
  39803. * Get the friendly name associated with the input class.
  39804. * @returns the input friendly name
  39805. */
  39806. getSimpleName(): string;
  39807. }
  39808. }
  39809. declare module "babylonjs/Cameras/Inputs/index" {
  39810. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39811. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39812. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39813. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39814. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39815. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39816. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39817. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39818. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39819. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39820. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39821. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39822. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39823. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39824. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39825. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39826. }
  39827. declare module "babylonjs/Cameras/touchCamera" {
  39828. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39829. import { Scene } from "babylonjs/scene";
  39830. import { Vector3 } from "babylonjs/Maths/math.vector";
  39831. /**
  39832. * This represents a FPS type of camera controlled by touch.
  39833. * This is like a universal camera minus the Gamepad controls.
  39834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39835. */
  39836. export class TouchCamera extends FreeCamera {
  39837. /**
  39838. * Defines the touch sensibility for rotation.
  39839. * The higher the faster.
  39840. */
  39841. touchAngularSensibility: number;
  39842. /**
  39843. * Defines the touch sensibility for move.
  39844. * The higher the faster.
  39845. */
  39846. touchMoveSensibility: number;
  39847. /**
  39848. * Instantiates a new touch camera.
  39849. * This represents a FPS type of camera controlled by touch.
  39850. * This is like a universal camera minus the Gamepad controls.
  39851. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39852. * @param name Define the name of the camera in the scene
  39853. * @param position Define the start position of the camera in the scene
  39854. * @param scene Define the scene the camera belongs to
  39855. */
  39856. constructor(name: string, position: Vector3, scene: Scene);
  39857. /**
  39858. * Gets the current object class name.
  39859. * @return the class name
  39860. */
  39861. getClassName(): string;
  39862. /** @hidden */
  39863. _setupInputs(): void;
  39864. }
  39865. }
  39866. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39867. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39868. import { Scene } from "babylonjs/scene";
  39869. import { Vector3 } from "babylonjs/Maths/math.vector";
  39870. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39871. import { Axis } from "babylonjs/Maths/math.axis";
  39872. /**
  39873. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39874. * being tilted forward or back and left or right.
  39875. */
  39876. export class DeviceOrientationCamera extends FreeCamera {
  39877. private _initialQuaternion;
  39878. private _quaternionCache;
  39879. private _tmpDragQuaternion;
  39880. private _disablePointerInputWhenUsingDeviceOrientation;
  39881. /**
  39882. * Creates a new device orientation camera
  39883. * @param name The name of the camera
  39884. * @param position The start position camera
  39885. * @param scene The scene the camera belongs to
  39886. */
  39887. constructor(name: string, position: Vector3, scene: Scene);
  39888. /**
  39889. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39890. */
  39891. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39892. private _dragFactor;
  39893. /**
  39894. * Enabled turning on the y axis when the orientation sensor is active
  39895. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39896. */
  39897. enableHorizontalDragging(dragFactor?: number): void;
  39898. /**
  39899. * Gets the current instance class name ("DeviceOrientationCamera").
  39900. * This helps avoiding instanceof at run time.
  39901. * @returns the class name
  39902. */
  39903. getClassName(): string;
  39904. /**
  39905. * @hidden
  39906. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39907. */
  39908. _checkInputs(): void;
  39909. /**
  39910. * Reset the camera to its default orientation on the specified axis only.
  39911. * @param axis The axis to reset
  39912. */
  39913. resetToCurrentRotation(axis?: Axis): void;
  39914. }
  39915. }
  39916. declare module "babylonjs/Gamepads/xboxGamepad" {
  39917. import { Observable } from "babylonjs/Misc/observable";
  39918. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39919. /**
  39920. * Defines supported buttons for XBox360 compatible gamepads
  39921. */
  39922. export enum Xbox360Button {
  39923. /** A */
  39924. A = 0,
  39925. /** B */
  39926. B = 1,
  39927. /** X */
  39928. X = 2,
  39929. /** Y */
  39930. Y = 3,
  39931. /** Start */
  39932. Start = 4,
  39933. /** Back */
  39934. Back = 5,
  39935. /** Left button */
  39936. LB = 6,
  39937. /** Right button */
  39938. RB = 7,
  39939. /** Left stick */
  39940. LeftStick = 8,
  39941. /** Right stick */
  39942. RightStick = 9
  39943. }
  39944. /** Defines values for XBox360 DPad */
  39945. export enum Xbox360Dpad {
  39946. /** Up */
  39947. Up = 0,
  39948. /** Down */
  39949. Down = 1,
  39950. /** Left */
  39951. Left = 2,
  39952. /** Right */
  39953. Right = 3
  39954. }
  39955. /**
  39956. * Defines a XBox360 gamepad
  39957. */
  39958. export class Xbox360Pad extends Gamepad {
  39959. private _leftTrigger;
  39960. private _rightTrigger;
  39961. private _onlefttriggerchanged;
  39962. private _onrighttriggerchanged;
  39963. private _onbuttondown;
  39964. private _onbuttonup;
  39965. private _ondpaddown;
  39966. private _ondpadup;
  39967. /** Observable raised when a button is pressed */
  39968. onButtonDownObservable: Observable<Xbox360Button>;
  39969. /** Observable raised when a button is released */
  39970. onButtonUpObservable: Observable<Xbox360Button>;
  39971. /** Observable raised when a pad is pressed */
  39972. onPadDownObservable: Observable<Xbox360Dpad>;
  39973. /** Observable raised when a pad is released */
  39974. onPadUpObservable: Observable<Xbox360Dpad>;
  39975. private _buttonA;
  39976. private _buttonB;
  39977. private _buttonX;
  39978. private _buttonY;
  39979. private _buttonBack;
  39980. private _buttonStart;
  39981. private _buttonLB;
  39982. private _buttonRB;
  39983. private _buttonLeftStick;
  39984. private _buttonRightStick;
  39985. private _dPadUp;
  39986. private _dPadDown;
  39987. private _dPadLeft;
  39988. private _dPadRight;
  39989. private _isXboxOnePad;
  39990. /**
  39991. * Creates a new XBox360 gamepad object
  39992. * @param id defines the id of this gamepad
  39993. * @param index defines its index
  39994. * @param gamepad defines the internal HTML gamepad object
  39995. * @param xboxOne defines if it is a XBox One gamepad
  39996. */
  39997. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39998. /**
  39999. * Defines the callback to call when left trigger is pressed
  40000. * @param callback defines the callback to use
  40001. */
  40002. onlefttriggerchanged(callback: (value: number) => void): void;
  40003. /**
  40004. * Defines the callback to call when right trigger is pressed
  40005. * @param callback defines the callback to use
  40006. */
  40007. onrighttriggerchanged(callback: (value: number) => void): void;
  40008. /**
  40009. * Gets the left trigger value
  40010. */
  40011. /**
  40012. * Sets the left trigger value
  40013. */
  40014. leftTrigger: number;
  40015. /**
  40016. * Gets the right trigger value
  40017. */
  40018. /**
  40019. * Sets the right trigger value
  40020. */
  40021. rightTrigger: number;
  40022. /**
  40023. * Defines the callback to call when a button is pressed
  40024. * @param callback defines the callback to use
  40025. */
  40026. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40027. /**
  40028. * Defines the callback to call when a button is released
  40029. * @param callback defines the callback to use
  40030. */
  40031. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40032. /**
  40033. * Defines the callback to call when a pad is pressed
  40034. * @param callback defines the callback to use
  40035. */
  40036. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40037. /**
  40038. * Defines the callback to call when a pad is released
  40039. * @param callback defines the callback to use
  40040. */
  40041. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40042. private _setButtonValue;
  40043. private _setDPadValue;
  40044. /**
  40045. * Gets the value of the `A` button
  40046. */
  40047. /**
  40048. * Sets the value of the `A` button
  40049. */
  40050. buttonA: number;
  40051. /**
  40052. * Gets the value of the `B` button
  40053. */
  40054. /**
  40055. * Sets the value of the `B` button
  40056. */
  40057. buttonB: number;
  40058. /**
  40059. * Gets the value of the `X` button
  40060. */
  40061. /**
  40062. * Sets the value of the `X` button
  40063. */
  40064. buttonX: number;
  40065. /**
  40066. * Gets the value of the `Y` button
  40067. */
  40068. /**
  40069. * Sets the value of the `Y` button
  40070. */
  40071. buttonY: number;
  40072. /**
  40073. * Gets the value of the `Start` button
  40074. */
  40075. /**
  40076. * Sets the value of the `Start` button
  40077. */
  40078. buttonStart: number;
  40079. /**
  40080. * Gets the value of the `Back` button
  40081. */
  40082. /**
  40083. * Sets the value of the `Back` button
  40084. */
  40085. buttonBack: number;
  40086. /**
  40087. * Gets the value of the `Left` button
  40088. */
  40089. /**
  40090. * Sets the value of the `Left` button
  40091. */
  40092. buttonLB: number;
  40093. /**
  40094. * Gets the value of the `Right` button
  40095. */
  40096. /**
  40097. * Sets the value of the `Right` button
  40098. */
  40099. buttonRB: number;
  40100. /**
  40101. * Gets the value of the Left joystick
  40102. */
  40103. /**
  40104. * Sets the value of the Left joystick
  40105. */
  40106. buttonLeftStick: number;
  40107. /**
  40108. * Gets the value of the Right joystick
  40109. */
  40110. /**
  40111. * Sets the value of the Right joystick
  40112. */
  40113. buttonRightStick: number;
  40114. /**
  40115. * Gets the value of D-pad up
  40116. */
  40117. /**
  40118. * Sets the value of D-pad up
  40119. */
  40120. dPadUp: number;
  40121. /**
  40122. * Gets the value of D-pad down
  40123. */
  40124. /**
  40125. * Sets the value of D-pad down
  40126. */
  40127. dPadDown: number;
  40128. /**
  40129. * Gets the value of D-pad left
  40130. */
  40131. /**
  40132. * Sets the value of D-pad left
  40133. */
  40134. dPadLeft: number;
  40135. /**
  40136. * Gets the value of D-pad right
  40137. */
  40138. /**
  40139. * Sets the value of D-pad right
  40140. */
  40141. dPadRight: number;
  40142. /**
  40143. * Force the gamepad to synchronize with device values
  40144. */
  40145. update(): void;
  40146. /**
  40147. * Disposes the gamepad
  40148. */
  40149. dispose(): void;
  40150. }
  40151. }
  40152. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40153. import { Observable } from "babylonjs/Misc/observable";
  40154. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40155. /**
  40156. * Defines supported buttons for DualShock compatible gamepads
  40157. */
  40158. export enum DualShockButton {
  40159. /** Cross */
  40160. Cross = 0,
  40161. /** Circle */
  40162. Circle = 1,
  40163. /** Square */
  40164. Square = 2,
  40165. /** Triangle */
  40166. Triangle = 3,
  40167. /** Options */
  40168. Options = 4,
  40169. /** Share */
  40170. Share = 5,
  40171. /** L1 */
  40172. L1 = 6,
  40173. /** R1 */
  40174. R1 = 7,
  40175. /** Left stick */
  40176. LeftStick = 8,
  40177. /** Right stick */
  40178. RightStick = 9
  40179. }
  40180. /** Defines values for DualShock DPad */
  40181. export enum DualShockDpad {
  40182. /** Up */
  40183. Up = 0,
  40184. /** Down */
  40185. Down = 1,
  40186. /** Left */
  40187. Left = 2,
  40188. /** Right */
  40189. Right = 3
  40190. }
  40191. /**
  40192. * Defines a DualShock gamepad
  40193. */
  40194. export class DualShockPad extends Gamepad {
  40195. private _leftTrigger;
  40196. private _rightTrigger;
  40197. private _onlefttriggerchanged;
  40198. private _onrighttriggerchanged;
  40199. private _onbuttondown;
  40200. private _onbuttonup;
  40201. private _ondpaddown;
  40202. private _ondpadup;
  40203. /** Observable raised when a button is pressed */
  40204. onButtonDownObservable: Observable<DualShockButton>;
  40205. /** Observable raised when a button is released */
  40206. onButtonUpObservable: Observable<DualShockButton>;
  40207. /** Observable raised when a pad is pressed */
  40208. onPadDownObservable: Observable<DualShockDpad>;
  40209. /** Observable raised when a pad is released */
  40210. onPadUpObservable: Observable<DualShockDpad>;
  40211. private _buttonCross;
  40212. private _buttonCircle;
  40213. private _buttonSquare;
  40214. private _buttonTriangle;
  40215. private _buttonShare;
  40216. private _buttonOptions;
  40217. private _buttonL1;
  40218. private _buttonR1;
  40219. private _buttonLeftStick;
  40220. private _buttonRightStick;
  40221. private _dPadUp;
  40222. private _dPadDown;
  40223. private _dPadLeft;
  40224. private _dPadRight;
  40225. /**
  40226. * Creates a new DualShock gamepad object
  40227. * @param id defines the id of this gamepad
  40228. * @param index defines its index
  40229. * @param gamepad defines the internal HTML gamepad object
  40230. */
  40231. constructor(id: string, index: number, gamepad: any);
  40232. /**
  40233. * Defines the callback to call when left trigger is pressed
  40234. * @param callback defines the callback to use
  40235. */
  40236. onlefttriggerchanged(callback: (value: number) => void): void;
  40237. /**
  40238. * Defines the callback to call when right trigger is pressed
  40239. * @param callback defines the callback to use
  40240. */
  40241. onrighttriggerchanged(callback: (value: number) => void): void;
  40242. /**
  40243. * Gets the left trigger value
  40244. */
  40245. /**
  40246. * Sets the left trigger value
  40247. */
  40248. leftTrigger: number;
  40249. /**
  40250. * Gets the right trigger value
  40251. */
  40252. /**
  40253. * Sets the right trigger value
  40254. */
  40255. rightTrigger: number;
  40256. /**
  40257. * Defines the callback to call when a button is pressed
  40258. * @param callback defines the callback to use
  40259. */
  40260. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40261. /**
  40262. * Defines the callback to call when a button is released
  40263. * @param callback defines the callback to use
  40264. */
  40265. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40266. /**
  40267. * Defines the callback to call when a pad is pressed
  40268. * @param callback defines the callback to use
  40269. */
  40270. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40271. /**
  40272. * Defines the callback to call when a pad is released
  40273. * @param callback defines the callback to use
  40274. */
  40275. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40276. private _setButtonValue;
  40277. private _setDPadValue;
  40278. /**
  40279. * Gets the value of the `Cross` button
  40280. */
  40281. /**
  40282. * Sets the value of the `Cross` button
  40283. */
  40284. buttonCross: number;
  40285. /**
  40286. * Gets the value of the `Circle` button
  40287. */
  40288. /**
  40289. * Sets the value of the `Circle` button
  40290. */
  40291. buttonCircle: number;
  40292. /**
  40293. * Gets the value of the `Square` button
  40294. */
  40295. /**
  40296. * Sets the value of the `Square` button
  40297. */
  40298. buttonSquare: number;
  40299. /**
  40300. * Gets the value of the `Triangle` button
  40301. */
  40302. /**
  40303. * Sets the value of the `Triangle` button
  40304. */
  40305. buttonTriangle: number;
  40306. /**
  40307. * Gets the value of the `Options` button
  40308. */
  40309. /**
  40310. * Sets the value of the `Options` button
  40311. */
  40312. buttonOptions: number;
  40313. /**
  40314. * Gets the value of the `Share` button
  40315. */
  40316. /**
  40317. * Sets the value of the `Share` button
  40318. */
  40319. buttonShare: number;
  40320. /**
  40321. * Gets the value of the `L1` button
  40322. */
  40323. /**
  40324. * Sets the value of the `L1` button
  40325. */
  40326. buttonL1: number;
  40327. /**
  40328. * Gets the value of the `R1` button
  40329. */
  40330. /**
  40331. * Sets the value of the `R1` button
  40332. */
  40333. buttonR1: number;
  40334. /**
  40335. * Gets the value of the Left joystick
  40336. */
  40337. /**
  40338. * Sets the value of the Left joystick
  40339. */
  40340. buttonLeftStick: number;
  40341. /**
  40342. * Gets the value of the Right joystick
  40343. */
  40344. /**
  40345. * Sets the value of the Right joystick
  40346. */
  40347. buttonRightStick: number;
  40348. /**
  40349. * Gets the value of D-pad up
  40350. */
  40351. /**
  40352. * Sets the value of D-pad up
  40353. */
  40354. dPadUp: number;
  40355. /**
  40356. * Gets the value of D-pad down
  40357. */
  40358. /**
  40359. * Sets the value of D-pad down
  40360. */
  40361. dPadDown: number;
  40362. /**
  40363. * Gets the value of D-pad left
  40364. */
  40365. /**
  40366. * Sets the value of D-pad left
  40367. */
  40368. dPadLeft: number;
  40369. /**
  40370. * Gets the value of D-pad right
  40371. */
  40372. /**
  40373. * Sets the value of D-pad right
  40374. */
  40375. dPadRight: number;
  40376. /**
  40377. * Force the gamepad to synchronize with device values
  40378. */
  40379. update(): void;
  40380. /**
  40381. * Disposes the gamepad
  40382. */
  40383. dispose(): void;
  40384. }
  40385. }
  40386. declare module "babylonjs/Gamepads/gamepadManager" {
  40387. import { Observable } from "babylonjs/Misc/observable";
  40388. import { Nullable } from "babylonjs/types";
  40389. import { Scene } from "babylonjs/scene";
  40390. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40391. /**
  40392. * Manager for handling gamepads
  40393. */
  40394. export class GamepadManager {
  40395. private _scene?;
  40396. private _babylonGamepads;
  40397. private _oneGamepadConnected;
  40398. /** @hidden */
  40399. _isMonitoring: boolean;
  40400. private _gamepadEventSupported;
  40401. private _gamepadSupport;
  40402. /**
  40403. * observable to be triggered when the gamepad controller has been connected
  40404. */
  40405. onGamepadConnectedObservable: Observable<Gamepad>;
  40406. /**
  40407. * observable to be triggered when the gamepad controller has been disconnected
  40408. */
  40409. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40410. private _onGamepadConnectedEvent;
  40411. private _onGamepadDisconnectedEvent;
  40412. /**
  40413. * Initializes the gamepad manager
  40414. * @param _scene BabylonJS scene
  40415. */
  40416. constructor(_scene?: Scene | undefined);
  40417. /**
  40418. * The gamepads in the game pad manager
  40419. */
  40420. readonly gamepads: Gamepad[];
  40421. /**
  40422. * Get the gamepad controllers based on type
  40423. * @param type The type of gamepad controller
  40424. * @returns Nullable gamepad
  40425. */
  40426. getGamepadByType(type?: number): Nullable<Gamepad>;
  40427. /**
  40428. * Disposes the gamepad manager
  40429. */
  40430. dispose(): void;
  40431. private _addNewGamepad;
  40432. private _startMonitoringGamepads;
  40433. private _stopMonitoringGamepads;
  40434. /** @hidden */
  40435. _checkGamepadsStatus(): void;
  40436. private _updateGamepadObjects;
  40437. }
  40438. }
  40439. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40440. import { Nullable } from "babylonjs/types";
  40441. import { Scene } from "babylonjs/scene";
  40442. import { ISceneComponent } from "babylonjs/sceneComponent";
  40443. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40444. module "babylonjs/scene" {
  40445. interface Scene {
  40446. /** @hidden */
  40447. _gamepadManager: Nullable<GamepadManager>;
  40448. /**
  40449. * Gets the gamepad manager associated with the scene
  40450. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40451. */
  40452. gamepadManager: GamepadManager;
  40453. }
  40454. }
  40455. module "babylonjs/Cameras/freeCameraInputsManager" {
  40456. /**
  40457. * Interface representing a free camera inputs manager
  40458. */
  40459. interface FreeCameraInputsManager {
  40460. /**
  40461. * Adds gamepad input support to the FreeCameraInputsManager.
  40462. * @returns the FreeCameraInputsManager
  40463. */
  40464. addGamepad(): FreeCameraInputsManager;
  40465. }
  40466. }
  40467. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40468. /**
  40469. * Interface representing an arc rotate camera inputs manager
  40470. */
  40471. interface ArcRotateCameraInputsManager {
  40472. /**
  40473. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40474. * @returns the camera inputs manager
  40475. */
  40476. addGamepad(): ArcRotateCameraInputsManager;
  40477. }
  40478. }
  40479. /**
  40480. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40481. */
  40482. export class GamepadSystemSceneComponent implements ISceneComponent {
  40483. /**
  40484. * The component name helpfull to identify the component in the list of scene components.
  40485. */
  40486. readonly name: string;
  40487. /**
  40488. * The scene the component belongs to.
  40489. */
  40490. scene: Scene;
  40491. /**
  40492. * Creates a new instance of the component for the given scene
  40493. * @param scene Defines the scene to register the component in
  40494. */
  40495. constructor(scene: Scene);
  40496. /**
  40497. * Registers the component in a given scene
  40498. */
  40499. register(): void;
  40500. /**
  40501. * Rebuilds the elements related to this component in case of
  40502. * context lost for instance.
  40503. */
  40504. rebuild(): void;
  40505. /**
  40506. * Disposes the component and the associated ressources
  40507. */
  40508. dispose(): void;
  40509. private _beforeCameraUpdate;
  40510. }
  40511. }
  40512. declare module "babylonjs/Cameras/universalCamera" {
  40513. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40514. import { Scene } from "babylonjs/scene";
  40515. import { Vector3 } from "babylonjs/Maths/math.vector";
  40516. import "babylonjs/Gamepads/gamepadSceneComponent";
  40517. /**
  40518. * 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,
  40519. * which still works and will still be found in many Playgrounds.
  40520. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40521. */
  40522. export class UniversalCamera extends TouchCamera {
  40523. /**
  40524. * Defines the gamepad rotation sensiblity.
  40525. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40526. */
  40527. gamepadAngularSensibility: number;
  40528. /**
  40529. * Defines the gamepad move sensiblity.
  40530. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40531. */
  40532. gamepadMoveSensibility: number;
  40533. /**
  40534. * 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,
  40535. * which still works and will still be found in many Playgrounds.
  40536. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40537. * @param name Define the name of the camera in the scene
  40538. * @param position Define the start position of the camera in the scene
  40539. * @param scene Define the scene the camera belongs to
  40540. */
  40541. constructor(name: string, position: Vector3, scene: Scene);
  40542. /**
  40543. * Gets the current object class name.
  40544. * @return the class name
  40545. */
  40546. getClassName(): string;
  40547. }
  40548. }
  40549. declare module "babylonjs/Cameras/gamepadCamera" {
  40550. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40551. import { Scene } from "babylonjs/scene";
  40552. import { Vector3 } from "babylonjs/Maths/math.vector";
  40553. /**
  40554. * This represents a FPS type of camera. This is only here for back compat purpose.
  40555. * Please use the UniversalCamera instead as both are identical.
  40556. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40557. */
  40558. export class GamepadCamera extends UniversalCamera {
  40559. /**
  40560. * Instantiates a new Gamepad Camera
  40561. * This represents a FPS type of camera. This is only here for back compat purpose.
  40562. * Please use the UniversalCamera instead as both are identical.
  40563. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40564. * @param name Define the name of the camera in the scene
  40565. * @param position Define the start position of the camera in the scene
  40566. * @param scene Define the scene the camera belongs to
  40567. */
  40568. constructor(name: string, position: Vector3, scene: Scene);
  40569. /**
  40570. * Gets the current object class name.
  40571. * @return the class name
  40572. */
  40573. getClassName(): string;
  40574. }
  40575. }
  40576. declare module "babylonjs/Shaders/pass.fragment" {
  40577. /** @hidden */
  40578. export var passPixelShader: {
  40579. name: string;
  40580. shader: string;
  40581. };
  40582. }
  40583. declare module "babylonjs/Shaders/passCube.fragment" {
  40584. /** @hidden */
  40585. export var passCubePixelShader: {
  40586. name: string;
  40587. shader: string;
  40588. };
  40589. }
  40590. declare module "babylonjs/PostProcesses/passPostProcess" {
  40591. import { Nullable } from "babylonjs/types";
  40592. import { Camera } from "babylonjs/Cameras/camera";
  40593. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40594. import { Engine } from "babylonjs/Engines/engine";
  40595. import "babylonjs/Shaders/pass.fragment";
  40596. import "babylonjs/Shaders/passCube.fragment";
  40597. /**
  40598. * PassPostProcess which produces an output the same as it's input
  40599. */
  40600. export class PassPostProcess extends PostProcess {
  40601. /**
  40602. * Creates the PassPostProcess
  40603. * @param name The name of the effect.
  40604. * @param options The required width/height ratio to downsize to before computing the render pass.
  40605. * @param camera The camera to apply the render pass to.
  40606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40607. * @param engine The engine which the post process will be applied. (default: current engine)
  40608. * @param reusable If the post process can be reused on the same frame. (default: false)
  40609. * @param textureType The type of texture to be used when performing the post processing.
  40610. * @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)
  40611. */
  40612. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40613. }
  40614. /**
  40615. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40616. */
  40617. export class PassCubePostProcess extends PostProcess {
  40618. private _face;
  40619. /**
  40620. * Gets or sets the cube face to display.
  40621. * * 0 is +X
  40622. * * 1 is -X
  40623. * * 2 is +Y
  40624. * * 3 is -Y
  40625. * * 4 is +Z
  40626. * * 5 is -Z
  40627. */
  40628. face: number;
  40629. /**
  40630. * Creates the PassCubePostProcess
  40631. * @param name The name of the effect.
  40632. * @param options The required width/height ratio to downsize to before computing the render pass.
  40633. * @param camera The camera to apply the render pass to.
  40634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40635. * @param engine The engine which the post process will be applied. (default: current engine)
  40636. * @param reusable If the post process can be reused on the same frame. (default: false)
  40637. * @param textureType The type of texture to be used when performing the post processing.
  40638. * @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)
  40639. */
  40640. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40641. }
  40642. }
  40643. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40644. /** @hidden */
  40645. export var anaglyphPixelShader: {
  40646. name: string;
  40647. shader: string;
  40648. };
  40649. }
  40650. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40651. import { Engine } from "babylonjs/Engines/engine";
  40652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40653. import { Camera } from "babylonjs/Cameras/camera";
  40654. import "babylonjs/Shaders/anaglyph.fragment";
  40655. /**
  40656. * Postprocess used to generate anaglyphic rendering
  40657. */
  40658. export class AnaglyphPostProcess extends PostProcess {
  40659. private _passedProcess;
  40660. /**
  40661. * Creates a new AnaglyphPostProcess
  40662. * @param name defines postprocess name
  40663. * @param options defines creation options or target ratio scale
  40664. * @param rigCameras defines cameras using this postprocess
  40665. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40666. * @param engine defines hosting engine
  40667. * @param reusable defines if the postprocess will be reused multiple times per frame
  40668. */
  40669. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40670. }
  40671. }
  40672. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40673. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40675. import { Scene } from "babylonjs/scene";
  40676. import { Vector3 } from "babylonjs/Maths/math.vector";
  40677. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40678. /**
  40679. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40680. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40681. */
  40682. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40683. /**
  40684. * Creates a new AnaglyphArcRotateCamera
  40685. * @param name defines camera name
  40686. * @param alpha defines alpha angle (in radians)
  40687. * @param beta defines beta angle (in radians)
  40688. * @param radius defines radius
  40689. * @param target defines camera target
  40690. * @param interaxialDistance defines distance between each color axis
  40691. * @param scene defines the hosting scene
  40692. */
  40693. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40694. /**
  40695. * Gets camera class name
  40696. * @returns AnaglyphArcRotateCamera
  40697. */
  40698. getClassName(): string;
  40699. }
  40700. }
  40701. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40702. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40703. import { Scene } from "babylonjs/scene";
  40704. import { Vector3 } from "babylonjs/Maths/math.vector";
  40705. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40706. /**
  40707. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40708. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40709. */
  40710. export class AnaglyphFreeCamera extends FreeCamera {
  40711. /**
  40712. * Creates a new AnaglyphFreeCamera
  40713. * @param name defines camera name
  40714. * @param position defines initial position
  40715. * @param interaxialDistance defines distance between each color axis
  40716. * @param scene defines the hosting scene
  40717. */
  40718. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40719. /**
  40720. * Gets camera class name
  40721. * @returns AnaglyphFreeCamera
  40722. */
  40723. getClassName(): string;
  40724. }
  40725. }
  40726. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40727. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40728. import { Scene } from "babylonjs/scene";
  40729. import { Vector3 } from "babylonjs/Maths/math.vector";
  40730. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40731. /**
  40732. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40733. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40734. */
  40735. export class AnaglyphGamepadCamera extends GamepadCamera {
  40736. /**
  40737. * Creates a new AnaglyphGamepadCamera
  40738. * @param name defines camera name
  40739. * @param position defines initial position
  40740. * @param interaxialDistance defines distance between each color axis
  40741. * @param scene defines the hosting scene
  40742. */
  40743. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40744. /**
  40745. * Gets camera class name
  40746. * @returns AnaglyphGamepadCamera
  40747. */
  40748. getClassName(): string;
  40749. }
  40750. }
  40751. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40752. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40753. import { Scene } from "babylonjs/scene";
  40754. import { Vector3 } from "babylonjs/Maths/math.vector";
  40755. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40756. /**
  40757. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40758. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40759. */
  40760. export class AnaglyphUniversalCamera extends UniversalCamera {
  40761. /**
  40762. * Creates a new AnaglyphUniversalCamera
  40763. * @param name defines camera name
  40764. * @param position defines initial position
  40765. * @param interaxialDistance defines distance between each color axis
  40766. * @param scene defines the hosting scene
  40767. */
  40768. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40769. /**
  40770. * Gets camera class name
  40771. * @returns AnaglyphUniversalCamera
  40772. */
  40773. getClassName(): string;
  40774. }
  40775. }
  40776. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40777. /** @hidden */
  40778. export var stereoscopicInterlacePixelShader: {
  40779. name: string;
  40780. shader: string;
  40781. };
  40782. }
  40783. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40784. import { Camera } from "babylonjs/Cameras/camera";
  40785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40786. import { Engine } from "babylonjs/Engines/engine";
  40787. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40788. /**
  40789. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40790. */
  40791. export class StereoscopicInterlacePostProcess extends PostProcess {
  40792. private _stepSize;
  40793. private _passedProcess;
  40794. /**
  40795. * Initializes a StereoscopicInterlacePostProcess
  40796. * @param name The name of the effect.
  40797. * @param rigCameras The rig cameras to be appled to the post process
  40798. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40799. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40800. * @param engine The engine which the post process will be applied. (default: current engine)
  40801. * @param reusable If the post process can be reused on the same frame. (default: false)
  40802. */
  40803. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40804. }
  40805. }
  40806. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40807. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40808. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40809. import { Scene } from "babylonjs/scene";
  40810. import { Vector3 } from "babylonjs/Maths/math.vector";
  40811. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40812. /**
  40813. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40814. * @see http://doc.babylonjs.com/features/cameras
  40815. */
  40816. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40817. /**
  40818. * Creates a new StereoscopicArcRotateCamera
  40819. * @param name defines camera name
  40820. * @param alpha defines alpha angle (in radians)
  40821. * @param beta defines beta angle (in radians)
  40822. * @param radius defines radius
  40823. * @param target defines camera target
  40824. * @param interaxialDistance defines distance between each color axis
  40825. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40826. * @param scene defines the hosting scene
  40827. */
  40828. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40829. /**
  40830. * Gets camera class name
  40831. * @returns StereoscopicArcRotateCamera
  40832. */
  40833. getClassName(): string;
  40834. }
  40835. }
  40836. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40837. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40838. import { Scene } from "babylonjs/scene";
  40839. import { Vector3 } from "babylonjs/Maths/math.vector";
  40840. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40841. /**
  40842. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40843. * @see http://doc.babylonjs.com/features/cameras
  40844. */
  40845. export class StereoscopicFreeCamera extends FreeCamera {
  40846. /**
  40847. * Creates a new StereoscopicFreeCamera
  40848. * @param name defines camera name
  40849. * @param position defines initial position
  40850. * @param interaxialDistance defines distance between each color axis
  40851. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40852. * @param scene defines the hosting scene
  40853. */
  40854. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40855. /**
  40856. * Gets camera class name
  40857. * @returns StereoscopicFreeCamera
  40858. */
  40859. getClassName(): string;
  40860. }
  40861. }
  40862. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40863. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40864. import { Scene } from "babylonjs/scene";
  40865. import { Vector3 } from "babylonjs/Maths/math.vector";
  40866. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40867. /**
  40868. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40869. * @see http://doc.babylonjs.com/features/cameras
  40870. */
  40871. export class StereoscopicGamepadCamera extends GamepadCamera {
  40872. /**
  40873. * Creates a new StereoscopicGamepadCamera
  40874. * @param name defines camera name
  40875. * @param position defines initial position
  40876. * @param interaxialDistance defines distance between each color axis
  40877. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40878. * @param scene defines the hosting scene
  40879. */
  40880. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40881. /**
  40882. * Gets camera class name
  40883. * @returns StereoscopicGamepadCamera
  40884. */
  40885. getClassName(): string;
  40886. }
  40887. }
  40888. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40889. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40890. import { Scene } from "babylonjs/scene";
  40891. import { Vector3 } from "babylonjs/Maths/math.vector";
  40892. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40893. /**
  40894. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40895. * @see http://doc.babylonjs.com/features/cameras
  40896. */
  40897. export class StereoscopicUniversalCamera extends UniversalCamera {
  40898. /**
  40899. * Creates a new StereoscopicUniversalCamera
  40900. * @param name defines camera name
  40901. * @param position defines initial position
  40902. * @param interaxialDistance defines distance between each color axis
  40903. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40904. * @param scene defines the hosting scene
  40905. */
  40906. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40907. /**
  40908. * Gets camera class name
  40909. * @returns StereoscopicUniversalCamera
  40910. */
  40911. getClassName(): string;
  40912. }
  40913. }
  40914. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40915. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40916. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40917. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40918. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40919. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40920. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40921. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40922. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40923. }
  40924. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40925. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40926. import { Scene } from "babylonjs/scene";
  40927. import { Vector3 } from "babylonjs/Maths/math.vector";
  40928. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40929. /**
  40930. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40931. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40932. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40933. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40934. */
  40935. export class VirtualJoysticksCamera extends FreeCamera {
  40936. /**
  40937. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40938. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40939. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40940. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40941. * @param name Define the name of the camera in the scene
  40942. * @param position Define the start position of the camera in the scene
  40943. * @param scene Define the scene the camera belongs to
  40944. */
  40945. constructor(name: string, position: Vector3, scene: Scene);
  40946. /**
  40947. * Gets the current object class name.
  40948. * @return the class name
  40949. */
  40950. getClassName(): string;
  40951. }
  40952. }
  40953. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40954. import { Matrix } from "babylonjs/Maths/math.vector";
  40955. /**
  40956. * This represents all the required metrics to create a VR camera.
  40957. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40958. */
  40959. export class VRCameraMetrics {
  40960. /**
  40961. * Define the horizontal resolution off the screen.
  40962. */
  40963. hResolution: number;
  40964. /**
  40965. * Define the vertical resolution off the screen.
  40966. */
  40967. vResolution: number;
  40968. /**
  40969. * Define the horizontal screen size.
  40970. */
  40971. hScreenSize: number;
  40972. /**
  40973. * Define the vertical screen size.
  40974. */
  40975. vScreenSize: number;
  40976. /**
  40977. * Define the vertical screen center position.
  40978. */
  40979. vScreenCenter: number;
  40980. /**
  40981. * Define the distance of the eyes to the screen.
  40982. */
  40983. eyeToScreenDistance: number;
  40984. /**
  40985. * Define the distance between both lenses
  40986. */
  40987. lensSeparationDistance: number;
  40988. /**
  40989. * Define the distance between both viewer's eyes.
  40990. */
  40991. interpupillaryDistance: number;
  40992. /**
  40993. * Define the distortion factor of the VR postprocess.
  40994. * Please, touch with care.
  40995. */
  40996. distortionK: number[];
  40997. /**
  40998. * Define the chromatic aberration correction factors for the VR post process.
  40999. */
  41000. chromaAbCorrection: number[];
  41001. /**
  41002. * Define the scale factor of the post process.
  41003. * The smaller the better but the slower.
  41004. */
  41005. postProcessScaleFactor: number;
  41006. /**
  41007. * Define an offset for the lens center.
  41008. */
  41009. lensCenterOffset: number;
  41010. /**
  41011. * Define if the current vr camera should compensate the distortion of the lense or not.
  41012. */
  41013. compensateDistortion: boolean;
  41014. /**
  41015. * Defines if multiview should be enabled when rendering (Default: false)
  41016. */
  41017. multiviewEnabled: boolean;
  41018. /**
  41019. * Gets the rendering aspect ratio based on the provided resolutions.
  41020. */
  41021. readonly aspectRatio: number;
  41022. /**
  41023. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41024. */
  41025. readonly aspectRatioFov: number;
  41026. /**
  41027. * @hidden
  41028. */
  41029. readonly leftHMatrix: Matrix;
  41030. /**
  41031. * @hidden
  41032. */
  41033. readonly rightHMatrix: Matrix;
  41034. /**
  41035. * @hidden
  41036. */
  41037. readonly leftPreViewMatrix: Matrix;
  41038. /**
  41039. * @hidden
  41040. */
  41041. readonly rightPreViewMatrix: Matrix;
  41042. /**
  41043. * Get the default VRMetrics based on the most generic setup.
  41044. * @returns the default vr metrics
  41045. */
  41046. static GetDefault(): VRCameraMetrics;
  41047. }
  41048. }
  41049. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41050. /** @hidden */
  41051. export var vrDistortionCorrectionPixelShader: {
  41052. name: string;
  41053. shader: string;
  41054. };
  41055. }
  41056. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41057. import { Camera } from "babylonjs/Cameras/camera";
  41058. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41060. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41061. /**
  41062. * VRDistortionCorrectionPostProcess used for mobile VR
  41063. */
  41064. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41065. private _isRightEye;
  41066. private _distortionFactors;
  41067. private _postProcessScaleFactor;
  41068. private _lensCenterOffset;
  41069. private _scaleIn;
  41070. private _scaleFactor;
  41071. private _lensCenter;
  41072. /**
  41073. * Initializes the VRDistortionCorrectionPostProcess
  41074. * @param name The name of the effect.
  41075. * @param camera The camera to apply the render pass to.
  41076. * @param isRightEye If this is for the right eye distortion
  41077. * @param vrMetrics All the required metrics for the VR camera
  41078. */
  41079. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41080. }
  41081. }
  41082. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41083. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41084. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41085. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41086. import { Scene } from "babylonjs/scene";
  41087. import { Vector3 } from "babylonjs/Maths/math.vector";
  41088. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41089. import "babylonjs/Cameras/RigModes/vrRigMode";
  41090. /**
  41091. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41092. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41093. */
  41094. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41095. /**
  41096. * Creates a new VRDeviceOrientationArcRotateCamera
  41097. * @param name defines camera name
  41098. * @param alpha defines the camera rotation along the logitudinal axis
  41099. * @param beta defines the camera rotation along the latitudinal axis
  41100. * @param radius defines the camera distance from its target
  41101. * @param target defines the camera target
  41102. * @param scene defines the scene the camera belongs to
  41103. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41104. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41105. */
  41106. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41107. /**
  41108. * Gets camera class name
  41109. * @returns VRDeviceOrientationArcRotateCamera
  41110. */
  41111. getClassName(): string;
  41112. }
  41113. }
  41114. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41115. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41116. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41117. import { Scene } from "babylonjs/scene";
  41118. import { Vector3 } from "babylonjs/Maths/math.vector";
  41119. import "babylonjs/Cameras/RigModes/vrRigMode";
  41120. /**
  41121. * Camera used to simulate VR rendering (based on FreeCamera)
  41122. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41123. */
  41124. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41125. /**
  41126. * Creates a new VRDeviceOrientationFreeCamera
  41127. * @param name defines camera name
  41128. * @param position defines the start position of the camera
  41129. * @param scene defines the scene the camera belongs to
  41130. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41131. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41132. */
  41133. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41134. /**
  41135. * Gets camera class name
  41136. * @returns VRDeviceOrientationFreeCamera
  41137. */
  41138. getClassName(): string;
  41139. }
  41140. }
  41141. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41142. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41143. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41144. import { Scene } from "babylonjs/scene";
  41145. import { Vector3 } from "babylonjs/Maths/math.vector";
  41146. import "babylonjs/Gamepads/gamepadSceneComponent";
  41147. /**
  41148. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41149. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41150. */
  41151. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41152. /**
  41153. * Creates a new VRDeviceOrientationGamepadCamera
  41154. * @param name defines camera name
  41155. * @param position defines the start position of the camera
  41156. * @param scene defines the scene the camera belongs to
  41157. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41158. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41159. */
  41160. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41161. /**
  41162. * Gets camera class name
  41163. * @returns VRDeviceOrientationGamepadCamera
  41164. */
  41165. getClassName(): string;
  41166. }
  41167. }
  41168. declare module "babylonjs/Materials/pushMaterial" {
  41169. import { Nullable } from "babylonjs/types";
  41170. import { Scene } from "babylonjs/scene";
  41171. import { Matrix } from "babylonjs/Maths/math.vector";
  41172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41173. import { Mesh } from "babylonjs/Meshes/mesh";
  41174. import { Material } from "babylonjs/Materials/material";
  41175. import { Effect } from "babylonjs/Materials/effect";
  41176. /**
  41177. * Base class of materials working in push mode in babylon JS
  41178. * @hidden
  41179. */
  41180. export class PushMaterial extends Material {
  41181. protected _activeEffect: Effect;
  41182. protected _normalMatrix: Matrix;
  41183. /**
  41184. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41185. * This means that the material can keep using a previous shader while a new one is being compiled.
  41186. * This is mostly used when shader parallel compilation is supported (true by default)
  41187. */
  41188. allowShaderHotSwapping: boolean;
  41189. constructor(name: string, scene: Scene);
  41190. getEffect(): Effect;
  41191. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41192. /**
  41193. * Binds the given world matrix to the active effect
  41194. *
  41195. * @param world the matrix to bind
  41196. */
  41197. bindOnlyWorldMatrix(world: Matrix): void;
  41198. /**
  41199. * Binds the given normal matrix to the active effect
  41200. *
  41201. * @param normalMatrix the matrix to bind
  41202. */
  41203. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41204. bind(world: Matrix, mesh?: Mesh): void;
  41205. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41206. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41207. }
  41208. }
  41209. declare module "babylonjs/Materials/materialFlags" {
  41210. /**
  41211. * This groups all the flags used to control the materials channel.
  41212. */
  41213. export class MaterialFlags {
  41214. private static _DiffuseTextureEnabled;
  41215. /**
  41216. * Are diffuse textures enabled in the application.
  41217. */
  41218. static DiffuseTextureEnabled: boolean;
  41219. private static _AmbientTextureEnabled;
  41220. /**
  41221. * Are ambient textures enabled in the application.
  41222. */
  41223. static AmbientTextureEnabled: boolean;
  41224. private static _OpacityTextureEnabled;
  41225. /**
  41226. * Are opacity textures enabled in the application.
  41227. */
  41228. static OpacityTextureEnabled: boolean;
  41229. private static _ReflectionTextureEnabled;
  41230. /**
  41231. * Are reflection textures enabled in the application.
  41232. */
  41233. static ReflectionTextureEnabled: boolean;
  41234. private static _EmissiveTextureEnabled;
  41235. /**
  41236. * Are emissive textures enabled in the application.
  41237. */
  41238. static EmissiveTextureEnabled: boolean;
  41239. private static _SpecularTextureEnabled;
  41240. /**
  41241. * Are specular textures enabled in the application.
  41242. */
  41243. static SpecularTextureEnabled: boolean;
  41244. private static _BumpTextureEnabled;
  41245. /**
  41246. * Are bump textures enabled in the application.
  41247. */
  41248. static BumpTextureEnabled: boolean;
  41249. private static _LightmapTextureEnabled;
  41250. /**
  41251. * Are lightmap textures enabled in the application.
  41252. */
  41253. static LightmapTextureEnabled: boolean;
  41254. private static _RefractionTextureEnabled;
  41255. /**
  41256. * Are refraction textures enabled in the application.
  41257. */
  41258. static RefractionTextureEnabled: boolean;
  41259. private static _ColorGradingTextureEnabled;
  41260. /**
  41261. * Are color grading textures enabled in the application.
  41262. */
  41263. static ColorGradingTextureEnabled: boolean;
  41264. private static _FresnelEnabled;
  41265. /**
  41266. * Are fresnels enabled in the application.
  41267. */
  41268. static FresnelEnabled: boolean;
  41269. private static _ClearCoatTextureEnabled;
  41270. /**
  41271. * Are clear coat textures enabled in the application.
  41272. */
  41273. static ClearCoatTextureEnabled: boolean;
  41274. private static _ClearCoatBumpTextureEnabled;
  41275. /**
  41276. * Are clear coat bump textures enabled in the application.
  41277. */
  41278. static ClearCoatBumpTextureEnabled: boolean;
  41279. private static _ClearCoatTintTextureEnabled;
  41280. /**
  41281. * Are clear coat tint textures enabled in the application.
  41282. */
  41283. static ClearCoatTintTextureEnabled: boolean;
  41284. private static _SheenTextureEnabled;
  41285. /**
  41286. * Are sheen textures enabled in the application.
  41287. */
  41288. static SheenTextureEnabled: boolean;
  41289. private static _AnisotropicTextureEnabled;
  41290. /**
  41291. * Are anisotropic textures enabled in the application.
  41292. */
  41293. static AnisotropicTextureEnabled: boolean;
  41294. private static _ThicknessTextureEnabled;
  41295. /**
  41296. * Are thickness textures enabled in the application.
  41297. */
  41298. static ThicknessTextureEnabled: boolean;
  41299. }
  41300. }
  41301. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41302. /** @hidden */
  41303. export var defaultFragmentDeclaration: {
  41304. name: string;
  41305. shader: string;
  41306. };
  41307. }
  41308. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41309. /** @hidden */
  41310. export var defaultUboDeclaration: {
  41311. name: string;
  41312. shader: string;
  41313. };
  41314. }
  41315. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41316. /** @hidden */
  41317. export var lightFragmentDeclaration: {
  41318. name: string;
  41319. shader: string;
  41320. };
  41321. }
  41322. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41323. /** @hidden */
  41324. export var lightUboDeclaration: {
  41325. name: string;
  41326. shader: string;
  41327. };
  41328. }
  41329. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41330. /** @hidden */
  41331. export var lightsFragmentFunctions: {
  41332. name: string;
  41333. shader: string;
  41334. };
  41335. }
  41336. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41337. /** @hidden */
  41338. export var shadowsFragmentFunctions: {
  41339. name: string;
  41340. shader: string;
  41341. };
  41342. }
  41343. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41344. /** @hidden */
  41345. export var fresnelFunction: {
  41346. name: string;
  41347. shader: string;
  41348. };
  41349. }
  41350. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41351. /** @hidden */
  41352. export var reflectionFunction: {
  41353. name: string;
  41354. shader: string;
  41355. };
  41356. }
  41357. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41358. /** @hidden */
  41359. export var bumpFragmentFunctions: {
  41360. name: string;
  41361. shader: string;
  41362. };
  41363. }
  41364. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41365. /** @hidden */
  41366. export var logDepthDeclaration: {
  41367. name: string;
  41368. shader: string;
  41369. };
  41370. }
  41371. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41372. /** @hidden */
  41373. export var bumpFragment: {
  41374. name: string;
  41375. shader: string;
  41376. };
  41377. }
  41378. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41379. /** @hidden */
  41380. export var depthPrePass: {
  41381. name: string;
  41382. shader: string;
  41383. };
  41384. }
  41385. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41386. /** @hidden */
  41387. export var lightFragment: {
  41388. name: string;
  41389. shader: string;
  41390. };
  41391. }
  41392. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41393. /** @hidden */
  41394. export var logDepthFragment: {
  41395. name: string;
  41396. shader: string;
  41397. };
  41398. }
  41399. declare module "babylonjs/Shaders/default.fragment" {
  41400. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41401. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41402. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41403. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41404. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41405. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41406. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41407. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41408. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41409. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41410. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41411. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41412. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41413. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41414. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41415. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41416. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41417. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41418. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41419. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41420. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41421. /** @hidden */
  41422. export var defaultPixelShader: {
  41423. name: string;
  41424. shader: string;
  41425. };
  41426. }
  41427. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41428. /** @hidden */
  41429. export var defaultVertexDeclaration: {
  41430. name: string;
  41431. shader: string;
  41432. };
  41433. }
  41434. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41435. /** @hidden */
  41436. export var bumpVertexDeclaration: {
  41437. name: string;
  41438. shader: string;
  41439. };
  41440. }
  41441. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41442. /** @hidden */
  41443. export var bumpVertex: {
  41444. name: string;
  41445. shader: string;
  41446. };
  41447. }
  41448. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41449. /** @hidden */
  41450. export var fogVertex: {
  41451. name: string;
  41452. shader: string;
  41453. };
  41454. }
  41455. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41456. /** @hidden */
  41457. export var shadowsVertex: {
  41458. name: string;
  41459. shader: string;
  41460. };
  41461. }
  41462. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41463. /** @hidden */
  41464. export var pointCloudVertex: {
  41465. name: string;
  41466. shader: string;
  41467. };
  41468. }
  41469. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41470. /** @hidden */
  41471. export var logDepthVertex: {
  41472. name: string;
  41473. shader: string;
  41474. };
  41475. }
  41476. declare module "babylonjs/Shaders/default.vertex" {
  41477. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41478. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41479. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41480. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41481. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41482. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41483. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41484. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41485. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41486. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41487. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41488. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41489. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41491. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41492. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41493. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41494. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41495. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41496. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41497. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41498. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41499. /** @hidden */
  41500. export var defaultVertexShader: {
  41501. name: string;
  41502. shader: string;
  41503. };
  41504. }
  41505. declare module "babylonjs/Materials/standardMaterial" {
  41506. import { SmartArray } from "babylonjs/Misc/smartArray";
  41507. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41508. import { Nullable } from "babylonjs/types";
  41509. import { Scene } from "babylonjs/scene";
  41510. import { Matrix } from "babylonjs/Maths/math.vector";
  41511. import { Color3 } from "babylonjs/Maths/math.color";
  41512. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41514. import { Mesh } from "babylonjs/Meshes/mesh";
  41515. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41516. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41517. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41518. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41519. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41520. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41522. import "babylonjs/Shaders/default.fragment";
  41523. import "babylonjs/Shaders/default.vertex";
  41524. /** @hidden */
  41525. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41526. MAINUV1: boolean;
  41527. MAINUV2: boolean;
  41528. DIFFUSE: boolean;
  41529. DIFFUSEDIRECTUV: number;
  41530. AMBIENT: boolean;
  41531. AMBIENTDIRECTUV: number;
  41532. OPACITY: boolean;
  41533. OPACITYDIRECTUV: number;
  41534. OPACITYRGB: boolean;
  41535. REFLECTION: boolean;
  41536. EMISSIVE: boolean;
  41537. EMISSIVEDIRECTUV: number;
  41538. SPECULAR: boolean;
  41539. SPECULARDIRECTUV: number;
  41540. BUMP: boolean;
  41541. BUMPDIRECTUV: number;
  41542. PARALLAX: boolean;
  41543. PARALLAXOCCLUSION: boolean;
  41544. SPECULAROVERALPHA: boolean;
  41545. CLIPPLANE: boolean;
  41546. CLIPPLANE2: boolean;
  41547. CLIPPLANE3: boolean;
  41548. CLIPPLANE4: boolean;
  41549. ALPHATEST: boolean;
  41550. DEPTHPREPASS: boolean;
  41551. ALPHAFROMDIFFUSE: boolean;
  41552. POINTSIZE: boolean;
  41553. FOG: boolean;
  41554. SPECULARTERM: boolean;
  41555. DIFFUSEFRESNEL: boolean;
  41556. OPACITYFRESNEL: boolean;
  41557. REFLECTIONFRESNEL: boolean;
  41558. REFRACTIONFRESNEL: boolean;
  41559. EMISSIVEFRESNEL: boolean;
  41560. FRESNEL: boolean;
  41561. NORMAL: boolean;
  41562. UV1: boolean;
  41563. UV2: boolean;
  41564. VERTEXCOLOR: boolean;
  41565. VERTEXALPHA: boolean;
  41566. NUM_BONE_INFLUENCERS: number;
  41567. BonesPerMesh: number;
  41568. BONETEXTURE: boolean;
  41569. INSTANCES: boolean;
  41570. GLOSSINESS: boolean;
  41571. ROUGHNESS: boolean;
  41572. EMISSIVEASILLUMINATION: boolean;
  41573. LINKEMISSIVEWITHDIFFUSE: boolean;
  41574. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41575. LIGHTMAP: boolean;
  41576. LIGHTMAPDIRECTUV: number;
  41577. OBJECTSPACE_NORMALMAP: boolean;
  41578. USELIGHTMAPASSHADOWMAP: boolean;
  41579. REFLECTIONMAP_3D: boolean;
  41580. REFLECTIONMAP_SPHERICAL: boolean;
  41581. REFLECTIONMAP_PLANAR: boolean;
  41582. REFLECTIONMAP_CUBIC: boolean;
  41583. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41584. REFLECTIONMAP_PROJECTION: boolean;
  41585. REFLECTIONMAP_SKYBOX: boolean;
  41586. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41587. REFLECTIONMAP_EXPLICIT: boolean;
  41588. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41589. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41590. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41591. INVERTCUBICMAP: boolean;
  41592. LOGARITHMICDEPTH: boolean;
  41593. REFRACTION: boolean;
  41594. REFRACTIONMAP_3D: boolean;
  41595. REFLECTIONOVERALPHA: boolean;
  41596. TWOSIDEDLIGHTING: boolean;
  41597. SHADOWFLOAT: boolean;
  41598. MORPHTARGETS: boolean;
  41599. MORPHTARGETS_NORMAL: boolean;
  41600. MORPHTARGETS_TANGENT: boolean;
  41601. MORPHTARGETS_UV: boolean;
  41602. NUM_MORPH_INFLUENCERS: number;
  41603. NONUNIFORMSCALING: boolean;
  41604. PREMULTIPLYALPHA: boolean;
  41605. IMAGEPROCESSING: boolean;
  41606. VIGNETTE: boolean;
  41607. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41608. VIGNETTEBLENDMODEOPAQUE: boolean;
  41609. TONEMAPPING: boolean;
  41610. TONEMAPPING_ACES: boolean;
  41611. CONTRAST: boolean;
  41612. COLORCURVES: boolean;
  41613. COLORGRADING: boolean;
  41614. COLORGRADING3D: boolean;
  41615. SAMPLER3DGREENDEPTH: boolean;
  41616. SAMPLER3DBGRMAP: boolean;
  41617. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41618. MULTIVIEW: boolean;
  41619. /**
  41620. * If the reflection texture on this material is in linear color space
  41621. * @hidden
  41622. */
  41623. IS_REFLECTION_LINEAR: boolean;
  41624. /**
  41625. * If the refraction texture on this material is in linear color space
  41626. * @hidden
  41627. */
  41628. IS_REFRACTION_LINEAR: boolean;
  41629. EXPOSURE: boolean;
  41630. constructor();
  41631. setReflectionMode(modeToEnable: string): void;
  41632. }
  41633. /**
  41634. * This is the default material used in Babylon. It is the best trade off between quality
  41635. * and performances.
  41636. * @see http://doc.babylonjs.com/babylon101/materials
  41637. */
  41638. export class StandardMaterial extends PushMaterial {
  41639. private _diffuseTexture;
  41640. /**
  41641. * The basic texture of the material as viewed under a light.
  41642. */
  41643. diffuseTexture: Nullable<BaseTexture>;
  41644. private _ambientTexture;
  41645. /**
  41646. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41647. */
  41648. ambientTexture: Nullable<BaseTexture>;
  41649. private _opacityTexture;
  41650. /**
  41651. * Define the transparency of the material from a texture.
  41652. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41653. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41654. */
  41655. opacityTexture: Nullable<BaseTexture>;
  41656. private _reflectionTexture;
  41657. /**
  41658. * Define the texture used to display the reflection.
  41659. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41660. */
  41661. reflectionTexture: Nullable<BaseTexture>;
  41662. private _emissiveTexture;
  41663. /**
  41664. * Define texture of the material as if self lit.
  41665. * This will be mixed in the final result even in the absence of light.
  41666. */
  41667. emissiveTexture: Nullable<BaseTexture>;
  41668. private _specularTexture;
  41669. /**
  41670. * Define how the color and intensity of the highlight given by the light in the material.
  41671. */
  41672. specularTexture: Nullable<BaseTexture>;
  41673. private _bumpTexture;
  41674. /**
  41675. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41676. * 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.
  41677. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41678. */
  41679. bumpTexture: Nullable<BaseTexture>;
  41680. private _lightmapTexture;
  41681. /**
  41682. * Complex lighting can be computationally expensive to compute at runtime.
  41683. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41684. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41685. */
  41686. lightmapTexture: Nullable<BaseTexture>;
  41687. private _refractionTexture;
  41688. /**
  41689. * Define the texture used to display the refraction.
  41690. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41691. */
  41692. refractionTexture: Nullable<BaseTexture>;
  41693. /**
  41694. * The color of the material lit by the environmental background lighting.
  41695. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41696. */
  41697. ambientColor: Color3;
  41698. /**
  41699. * The basic color of the material as viewed under a light.
  41700. */
  41701. diffuseColor: Color3;
  41702. /**
  41703. * Define how the color and intensity of the highlight given by the light in the material.
  41704. */
  41705. specularColor: Color3;
  41706. /**
  41707. * Define the color of the material as if self lit.
  41708. * This will be mixed in the final result even in the absence of light.
  41709. */
  41710. emissiveColor: Color3;
  41711. /**
  41712. * Defines how sharp are the highlights in the material.
  41713. * The bigger the value the sharper giving a more glossy feeling to the result.
  41714. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41715. */
  41716. specularPower: number;
  41717. private _useAlphaFromDiffuseTexture;
  41718. /**
  41719. * Does the transparency come from the diffuse texture alpha channel.
  41720. */
  41721. useAlphaFromDiffuseTexture: boolean;
  41722. private _useEmissiveAsIllumination;
  41723. /**
  41724. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41725. */
  41726. useEmissiveAsIllumination: boolean;
  41727. private _linkEmissiveWithDiffuse;
  41728. /**
  41729. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41730. * the emissive level when the final color is close to one.
  41731. */
  41732. linkEmissiveWithDiffuse: boolean;
  41733. private _useSpecularOverAlpha;
  41734. /**
  41735. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41736. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41737. */
  41738. useSpecularOverAlpha: boolean;
  41739. private _useReflectionOverAlpha;
  41740. /**
  41741. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41742. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41743. */
  41744. useReflectionOverAlpha: boolean;
  41745. private _disableLighting;
  41746. /**
  41747. * Does lights from the scene impacts this material.
  41748. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41749. */
  41750. disableLighting: boolean;
  41751. private _useObjectSpaceNormalMap;
  41752. /**
  41753. * Allows using an object space normal map (instead of tangent space).
  41754. */
  41755. useObjectSpaceNormalMap: boolean;
  41756. private _useParallax;
  41757. /**
  41758. * Is parallax enabled or not.
  41759. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41760. */
  41761. useParallax: boolean;
  41762. private _useParallaxOcclusion;
  41763. /**
  41764. * Is parallax occlusion enabled or not.
  41765. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41766. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41767. */
  41768. useParallaxOcclusion: boolean;
  41769. /**
  41770. * 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.
  41771. */
  41772. parallaxScaleBias: number;
  41773. private _roughness;
  41774. /**
  41775. * Helps to define how blurry the reflections should appears in the material.
  41776. */
  41777. roughness: number;
  41778. /**
  41779. * In case of refraction, define the value of the index of refraction.
  41780. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41781. */
  41782. indexOfRefraction: number;
  41783. /**
  41784. * Invert the refraction texture alongside the y axis.
  41785. * It can be useful with procedural textures or probe for instance.
  41786. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41787. */
  41788. invertRefractionY: boolean;
  41789. /**
  41790. * Defines the alpha limits in alpha test mode.
  41791. */
  41792. alphaCutOff: number;
  41793. private _useLightmapAsShadowmap;
  41794. /**
  41795. * In case of light mapping, define whether the map contains light or shadow informations.
  41796. */
  41797. useLightmapAsShadowmap: boolean;
  41798. private _diffuseFresnelParameters;
  41799. /**
  41800. * Define the diffuse fresnel parameters of the material.
  41801. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41802. */
  41803. diffuseFresnelParameters: FresnelParameters;
  41804. private _opacityFresnelParameters;
  41805. /**
  41806. * Define the opacity fresnel parameters of the material.
  41807. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41808. */
  41809. opacityFresnelParameters: FresnelParameters;
  41810. private _reflectionFresnelParameters;
  41811. /**
  41812. * Define the reflection fresnel parameters of the material.
  41813. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41814. */
  41815. reflectionFresnelParameters: FresnelParameters;
  41816. private _refractionFresnelParameters;
  41817. /**
  41818. * Define the refraction fresnel parameters of the material.
  41819. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41820. */
  41821. refractionFresnelParameters: FresnelParameters;
  41822. private _emissiveFresnelParameters;
  41823. /**
  41824. * Define the emissive fresnel parameters of the material.
  41825. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41826. */
  41827. emissiveFresnelParameters: FresnelParameters;
  41828. private _useReflectionFresnelFromSpecular;
  41829. /**
  41830. * If true automatically deducts the fresnels values from the material specularity.
  41831. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41832. */
  41833. useReflectionFresnelFromSpecular: boolean;
  41834. private _useGlossinessFromSpecularMapAlpha;
  41835. /**
  41836. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41837. */
  41838. useGlossinessFromSpecularMapAlpha: boolean;
  41839. private _maxSimultaneousLights;
  41840. /**
  41841. * Defines the maximum number of lights that can be used in the material
  41842. */
  41843. maxSimultaneousLights: number;
  41844. private _invertNormalMapX;
  41845. /**
  41846. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41847. */
  41848. invertNormalMapX: boolean;
  41849. private _invertNormalMapY;
  41850. /**
  41851. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41852. */
  41853. invertNormalMapY: boolean;
  41854. private _twoSidedLighting;
  41855. /**
  41856. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41857. */
  41858. twoSidedLighting: boolean;
  41859. /**
  41860. * Default configuration related to image processing available in the standard Material.
  41861. */
  41862. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41863. /**
  41864. * Gets the image processing configuration used either in this material.
  41865. */
  41866. /**
  41867. * Sets the Default image processing configuration used either in the this material.
  41868. *
  41869. * If sets to null, the scene one is in use.
  41870. */
  41871. imageProcessingConfiguration: ImageProcessingConfiguration;
  41872. /**
  41873. * Keep track of the image processing observer to allow dispose and replace.
  41874. */
  41875. private _imageProcessingObserver;
  41876. /**
  41877. * Attaches a new image processing configuration to the Standard Material.
  41878. * @param configuration
  41879. */
  41880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41881. /**
  41882. * Gets wether the color curves effect is enabled.
  41883. */
  41884. /**
  41885. * Sets wether the color curves effect is enabled.
  41886. */
  41887. cameraColorCurvesEnabled: boolean;
  41888. /**
  41889. * Gets wether the color grading effect is enabled.
  41890. */
  41891. /**
  41892. * Gets wether the color grading effect is enabled.
  41893. */
  41894. cameraColorGradingEnabled: boolean;
  41895. /**
  41896. * Gets wether tonemapping is enabled or not.
  41897. */
  41898. /**
  41899. * Sets wether tonemapping is enabled or not
  41900. */
  41901. cameraToneMappingEnabled: boolean;
  41902. /**
  41903. * The camera exposure used on this material.
  41904. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41905. * This corresponds to a photographic exposure.
  41906. */
  41907. /**
  41908. * The camera exposure used on this material.
  41909. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41910. * This corresponds to a photographic exposure.
  41911. */
  41912. cameraExposure: number;
  41913. /**
  41914. * Gets The camera contrast used on this material.
  41915. */
  41916. /**
  41917. * Sets The camera contrast used on this material.
  41918. */
  41919. cameraContrast: number;
  41920. /**
  41921. * Gets the Color Grading 2D Lookup Texture.
  41922. */
  41923. /**
  41924. * Sets the Color Grading 2D Lookup Texture.
  41925. */
  41926. cameraColorGradingTexture: Nullable<BaseTexture>;
  41927. /**
  41928. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41929. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41930. * 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;
  41931. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41932. */
  41933. /**
  41934. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41935. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41936. * 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;
  41937. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41938. */
  41939. cameraColorCurves: Nullable<ColorCurves>;
  41940. /**
  41941. * Custom callback helping to override the default shader used in the material.
  41942. */
  41943. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41944. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41945. protected _worldViewProjectionMatrix: Matrix;
  41946. protected _globalAmbientColor: Color3;
  41947. protected _useLogarithmicDepth: boolean;
  41948. protected _rebuildInParallel: boolean;
  41949. /**
  41950. * Instantiates a new standard material.
  41951. * This is the default material used in Babylon. It is the best trade off between quality
  41952. * and performances.
  41953. * @see http://doc.babylonjs.com/babylon101/materials
  41954. * @param name Define the name of the material in the scene
  41955. * @param scene Define the scene the material belong to
  41956. */
  41957. constructor(name: string, scene: Scene);
  41958. /**
  41959. * Gets a boolean indicating that current material needs to register RTT
  41960. */
  41961. readonly hasRenderTargetTextures: boolean;
  41962. /**
  41963. * Gets the current class name of the material e.g. "StandardMaterial"
  41964. * Mainly use in serialization.
  41965. * @returns the class name
  41966. */
  41967. getClassName(): string;
  41968. /**
  41969. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41970. * You can try switching to logarithmic depth.
  41971. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41972. */
  41973. useLogarithmicDepth: boolean;
  41974. /**
  41975. * Specifies if the material will require alpha blending
  41976. * @returns a boolean specifying if alpha blending is needed
  41977. */
  41978. needAlphaBlending(): boolean;
  41979. /**
  41980. * Specifies if this material should be rendered in alpha test mode
  41981. * @returns a boolean specifying if an alpha test is needed.
  41982. */
  41983. needAlphaTesting(): boolean;
  41984. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41985. /**
  41986. * Get the texture used for alpha test purpose.
  41987. * @returns the diffuse texture in case of the standard material.
  41988. */
  41989. getAlphaTestTexture(): Nullable<BaseTexture>;
  41990. /**
  41991. * Get if the submesh is ready to be used and all its information available.
  41992. * Child classes can use it to update shaders
  41993. * @param mesh defines the mesh to check
  41994. * @param subMesh defines which submesh to check
  41995. * @param useInstances specifies that instances should be used
  41996. * @returns a boolean indicating that the submesh is ready or not
  41997. */
  41998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41999. /**
  42000. * Builds the material UBO layouts.
  42001. * Used internally during the effect preparation.
  42002. */
  42003. buildUniformLayout(): void;
  42004. /**
  42005. * Unbinds the material from the mesh
  42006. */
  42007. unbind(): void;
  42008. /**
  42009. * Binds the submesh to this material by preparing the effect and shader to draw
  42010. * @param world defines the world transformation matrix
  42011. * @param mesh defines the mesh containing the submesh
  42012. * @param subMesh defines the submesh to bind the material to
  42013. */
  42014. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42015. /**
  42016. * Get the list of animatables in the material.
  42017. * @returns the list of animatables object used in the material
  42018. */
  42019. getAnimatables(): IAnimatable[];
  42020. /**
  42021. * Gets the active textures from the material
  42022. * @returns an array of textures
  42023. */
  42024. getActiveTextures(): BaseTexture[];
  42025. /**
  42026. * Specifies if the material uses a texture
  42027. * @param texture defines the texture to check against the material
  42028. * @returns a boolean specifying if the material uses the texture
  42029. */
  42030. hasTexture(texture: BaseTexture): boolean;
  42031. /**
  42032. * Disposes the material
  42033. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42034. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42035. */
  42036. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42037. /**
  42038. * Makes a duplicate of the material, and gives it a new name
  42039. * @param name defines the new name for the duplicated material
  42040. * @returns the cloned material
  42041. */
  42042. clone(name: string): StandardMaterial;
  42043. /**
  42044. * Serializes this material in a JSON representation
  42045. * @returns the serialized material object
  42046. */
  42047. serialize(): any;
  42048. /**
  42049. * Creates a standard material from parsed material data
  42050. * @param source defines the JSON representation of the material
  42051. * @param scene defines the hosting scene
  42052. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42053. * @returns a new standard material
  42054. */
  42055. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42056. /**
  42057. * Are diffuse textures enabled in the application.
  42058. */
  42059. static DiffuseTextureEnabled: boolean;
  42060. /**
  42061. * Are ambient textures enabled in the application.
  42062. */
  42063. static AmbientTextureEnabled: boolean;
  42064. /**
  42065. * Are opacity textures enabled in the application.
  42066. */
  42067. static OpacityTextureEnabled: boolean;
  42068. /**
  42069. * Are reflection textures enabled in the application.
  42070. */
  42071. static ReflectionTextureEnabled: boolean;
  42072. /**
  42073. * Are emissive textures enabled in the application.
  42074. */
  42075. static EmissiveTextureEnabled: boolean;
  42076. /**
  42077. * Are specular textures enabled in the application.
  42078. */
  42079. static SpecularTextureEnabled: boolean;
  42080. /**
  42081. * Are bump textures enabled in the application.
  42082. */
  42083. static BumpTextureEnabled: boolean;
  42084. /**
  42085. * Are lightmap textures enabled in the application.
  42086. */
  42087. static LightmapTextureEnabled: boolean;
  42088. /**
  42089. * Are refraction textures enabled in the application.
  42090. */
  42091. static RefractionTextureEnabled: boolean;
  42092. /**
  42093. * Are color grading textures enabled in the application.
  42094. */
  42095. static ColorGradingTextureEnabled: boolean;
  42096. /**
  42097. * Are fresnels enabled in the application.
  42098. */
  42099. static FresnelEnabled: boolean;
  42100. }
  42101. }
  42102. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42103. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42105. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42106. /** @hidden */
  42107. export var imageProcessingPixelShader: {
  42108. name: string;
  42109. shader: string;
  42110. };
  42111. }
  42112. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42113. import { Nullable } from "babylonjs/types";
  42114. import { Color4 } from "babylonjs/Maths/math.color";
  42115. import { Camera } from "babylonjs/Cameras/camera";
  42116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42117. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42118. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42120. import { Engine } from "babylonjs/Engines/engine";
  42121. import "babylonjs/Shaders/imageProcessing.fragment";
  42122. import "babylonjs/Shaders/postprocess.vertex";
  42123. /**
  42124. * ImageProcessingPostProcess
  42125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42126. */
  42127. export class ImageProcessingPostProcess extends PostProcess {
  42128. /**
  42129. * Default configuration related to image processing available in the PBR Material.
  42130. */
  42131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42132. /**
  42133. * Gets the image processing configuration used either in this material.
  42134. */
  42135. /**
  42136. * Sets the Default image processing configuration used either in the this material.
  42137. *
  42138. * If sets to null, the scene one is in use.
  42139. */
  42140. imageProcessingConfiguration: ImageProcessingConfiguration;
  42141. /**
  42142. * Keep track of the image processing observer to allow dispose and replace.
  42143. */
  42144. private _imageProcessingObserver;
  42145. /**
  42146. * Attaches a new image processing configuration to the PBR Material.
  42147. * @param configuration
  42148. */
  42149. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42150. /**
  42151. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42152. */
  42153. /**
  42154. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42155. */
  42156. colorCurves: Nullable<ColorCurves>;
  42157. /**
  42158. * Gets wether the color curves effect is enabled.
  42159. */
  42160. /**
  42161. * Sets wether the color curves effect is enabled.
  42162. */
  42163. colorCurvesEnabled: boolean;
  42164. /**
  42165. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42166. */
  42167. /**
  42168. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42169. */
  42170. colorGradingTexture: Nullable<BaseTexture>;
  42171. /**
  42172. * Gets wether the color grading effect is enabled.
  42173. */
  42174. /**
  42175. * Gets wether the color grading effect is enabled.
  42176. */
  42177. colorGradingEnabled: boolean;
  42178. /**
  42179. * Gets exposure used in the effect.
  42180. */
  42181. /**
  42182. * Sets exposure used in the effect.
  42183. */
  42184. exposure: number;
  42185. /**
  42186. * Gets wether tonemapping is enabled or not.
  42187. */
  42188. /**
  42189. * Sets wether tonemapping is enabled or not
  42190. */
  42191. toneMappingEnabled: boolean;
  42192. /**
  42193. * Gets the type of tone mapping effect.
  42194. */
  42195. /**
  42196. * Sets the type of tone mapping effect.
  42197. */
  42198. toneMappingType: number;
  42199. /**
  42200. * Gets contrast used in the effect.
  42201. */
  42202. /**
  42203. * Sets contrast used in the effect.
  42204. */
  42205. contrast: number;
  42206. /**
  42207. * Gets Vignette stretch size.
  42208. */
  42209. /**
  42210. * Sets Vignette stretch size.
  42211. */
  42212. vignetteStretch: number;
  42213. /**
  42214. * Gets Vignette centre X Offset.
  42215. */
  42216. /**
  42217. * Sets Vignette centre X Offset.
  42218. */
  42219. vignetteCentreX: number;
  42220. /**
  42221. * Gets Vignette centre Y Offset.
  42222. */
  42223. /**
  42224. * Sets Vignette centre Y Offset.
  42225. */
  42226. vignetteCentreY: number;
  42227. /**
  42228. * Gets Vignette weight or intensity of the vignette effect.
  42229. */
  42230. /**
  42231. * Sets Vignette weight or intensity of the vignette effect.
  42232. */
  42233. vignetteWeight: number;
  42234. /**
  42235. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42236. * if vignetteEnabled is set to true.
  42237. */
  42238. /**
  42239. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42240. * if vignetteEnabled is set to true.
  42241. */
  42242. vignetteColor: Color4;
  42243. /**
  42244. * Gets Camera field of view used by the Vignette effect.
  42245. */
  42246. /**
  42247. * Sets Camera field of view used by the Vignette effect.
  42248. */
  42249. vignetteCameraFov: number;
  42250. /**
  42251. * Gets the vignette blend mode allowing different kind of effect.
  42252. */
  42253. /**
  42254. * Sets the vignette blend mode allowing different kind of effect.
  42255. */
  42256. vignetteBlendMode: number;
  42257. /**
  42258. * Gets wether the vignette effect is enabled.
  42259. */
  42260. /**
  42261. * Sets wether the vignette effect is enabled.
  42262. */
  42263. vignetteEnabled: boolean;
  42264. private _fromLinearSpace;
  42265. /**
  42266. * Gets wether the input of the processing is in Gamma or Linear Space.
  42267. */
  42268. /**
  42269. * Sets wether the input of the processing is in Gamma or Linear Space.
  42270. */
  42271. fromLinearSpace: boolean;
  42272. /**
  42273. * Defines cache preventing GC.
  42274. */
  42275. private _defines;
  42276. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42277. /**
  42278. * "ImageProcessingPostProcess"
  42279. * @returns "ImageProcessingPostProcess"
  42280. */
  42281. getClassName(): string;
  42282. protected _updateParameters(): void;
  42283. dispose(camera?: Camera): void;
  42284. }
  42285. }
  42286. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42287. import { Scene } from "babylonjs/scene";
  42288. import { Color3 } from "babylonjs/Maths/math.color";
  42289. import { Mesh } from "babylonjs/Meshes/mesh";
  42290. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42291. import { Nullable } from "babylonjs/types";
  42292. /**
  42293. * Class containing static functions to help procedurally build meshes
  42294. */
  42295. export class GroundBuilder {
  42296. /**
  42297. * Creates a ground mesh
  42298. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42299. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42301. * @param name defines the name of the mesh
  42302. * @param options defines the options used to create the mesh
  42303. * @param scene defines the hosting scene
  42304. * @returns the ground mesh
  42305. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42306. */
  42307. static CreateGround(name: string, options: {
  42308. width?: number;
  42309. height?: number;
  42310. subdivisions?: number;
  42311. subdivisionsX?: number;
  42312. subdivisionsY?: number;
  42313. updatable?: boolean;
  42314. }, scene: any): Mesh;
  42315. /**
  42316. * Creates a tiled ground mesh
  42317. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42318. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42319. * * 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
  42320. * * 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
  42321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42322. * @param name defines the name of the mesh
  42323. * @param options defines the options used to create the mesh
  42324. * @param scene defines the hosting scene
  42325. * @returns the tiled ground mesh
  42326. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42327. */
  42328. static CreateTiledGround(name: string, options: {
  42329. xmin: number;
  42330. zmin: number;
  42331. xmax: number;
  42332. zmax: number;
  42333. subdivisions?: {
  42334. w: number;
  42335. h: number;
  42336. };
  42337. precision?: {
  42338. w: number;
  42339. h: number;
  42340. };
  42341. updatable?: boolean;
  42342. }, scene?: Nullable<Scene>): Mesh;
  42343. /**
  42344. * Creates a ground mesh from a height map
  42345. * * The parameter `url` sets the URL of the height map image resource.
  42346. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42347. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42348. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42349. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42350. * * 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.
  42351. * * 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).
  42352. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42354. * @param name defines the name of the mesh
  42355. * @param url defines the url to the height map
  42356. * @param options defines the options used to create the mesh
  42357. * @param scene defines the hosting scene
  42358. * @returns the ground mesh
  42359. * @see https://doc.babylonjs.com/babylon101/height_map
  42360. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42361. */
  42362. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42363. width?: number;
  42364. height?: number;
  42365. subdivisions?: number;
  42366. minHeight?: number;
  42367. maxHeight?: number;
  42368. colorFilter?: Color3;
  42369. alphaFilter?: number;
  42370. updatable?: boolean;
  42371. onReady?: (mesh: GroundMesh) => void;
  42372. }, scene?: Nullable<Scene>): GroundMesh;
  42373. }
  42374. }
  42375. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42376. import { Vector4 } from "babylonjs/Maths/math.vector";
  42377. import { Mesh } from "babylonjs/Meshes/mesh";
  42378. /**
  42379. * Class containing static functions to help procedurally build meshes
  42380. */
  42381. export class TorusBuilder {
  42382. /**
  42383. * Creates a torus mesh
  42384. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42385. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42386. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42390. * @param name defines the name of the mesh
  42391. * @param options defines the options used to create the mesh
  42392. * @param scene defines the hosting scene
  42393. * @returns the torus mesh
  42394. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42395. */
  42396. static CreateTorus(name: string, options: {
  42397. diameter?: number;
  42398. thickness?: number;
  42399. tessellation?: number;
  42400. updatable?: boolean;
  42401. sideOrientation?: number;
  42402. frontUVs?: Vector4;
  42403. backUVs?: Vector4;
  42404. }, scene: any): Mesh;
  42405. }
  42406. }
  42407. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42408. import { Vector4 } from "babylonjs/Maths/math.vector";
  42409. import { Color4 } from "babylonjs/Maths/math.color";
  42410. import { Mesh } from "babylonjs/Meshes/mesh";
  42411. /**
  42412. * Class containing static functions to help procedurally build meshes
  42413. */
  42414. export class CylinderBuilder {
  42415. /**
  42416. * Creates a cylinder or a cone mesh
  42417. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42418. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42419. * * 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.
  42420. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42421. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42422. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42423. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42424. * * 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).
  42425. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42426. * * 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).
  42427. * * 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
  42428. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42429. * * 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
  42430. * * 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.
  42431. * * If `enclose` is false, a ring surface is one element.
  42432. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42433. * * 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
  42434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42435. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42437. * @param name defines the name of the mesh
  42438. * @param options defines the options used to create the mesh
  42439. * @param scene defines the hosting scene
  42440. * @returns the cylinder mesh
  42441. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42442. */
  42443. static CreateCylinder(name: string, options: {
  42444. height?: number;
  42445. diameterTop?: number;
  42446. diameterBottom?: number;
  42447. diameter?: number;
  42448. tessellation?: number;
  42449. subdivisions?: number;
  42450. arc?: number;
  42451. faceColors?: Color4[];
  42452. faceUV?: Vector4[];
  42453. updatable?: boolean;
  42454. hasRings?: boolean;
  42455. enclose?: boolean;
  42456. cap?: number;
  42457. sideOrientation?: number;
  42458. frontUVs?: Vector4;
  42459. backUVs?: Vector4;
  42460. }, scene: any): Mesh;
  42461. }
  42462. }
  42463. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42464. import { Observable } from "babylonjs/Misc/observable";
  42465. import { Nullable } from "babylonjs/types";
  42466. import { Camera } from "babylonjs/Cameras/camera";
  42467. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42468. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42469. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42470. import { Scene } from "babylonjs/scene";
  42471. import { Vector3 } from "babylonjs/Maths/math.vector";
  42472. import { Color3 } from "babylonjs/Maths/math.color";
  42473. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42475. import { Mesh } from "babylonjs/Meshes/mesh";
  42476. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42477. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42478. import "babylonjs/Meshes/Builders/groundBuilder";
  42479. import "babylonjs/Meshes/Builders/torusBuilder";
  42480. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42481. import "babylonjs/Gamepads/gamepadSceneComponent";
  42482. import "babylonjs/Animations/animatable";
  42483. /**
  42484. * Options to modify the vr teleportation behavior.
  42485. */
  42486. export interface VRTeleportationOptions {
  42487. /**
  42488. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42489. */
  42490. floorMeshName?: string;
  42491. /**
  42492. * A list of meshes to be used as the teleportation floor. (default: empty)
  42493. */
  42494. floorMeshes?: Mesh[];
  42495. }
  42496. /**
  42497. * Options to modify the vr experience helper's behavior.
  42498. */
  42499. export interface VRExperienceHelperOptions extends WebVROptions {
  42500. /**
  42501. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42502. */
  42503. createDeviceOrientationCamera?: boolean;
  42504. /**
  42505. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42506. */
  42507. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42508. /**
  42509. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42510. */
  42511. laserToggle?: boolean;
  42512. /**
  42513. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42514. */
  42515. floorMeshes?: Mesh[];
  42516. /**
  42517. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42518. */
  42519. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42520. }
  42521. /**
  42522. * Event containing information after VR has been entered
  42523. */
  42524. export class OnAfterEnteringVRObservableEvent {
  42525. /**
  42526. * If entering vr was successful
  42527. */
  42528. success: boolean;
  42529. }
  42530. /**
  42531. * Helps to quickly add VR support to an existing scene.
  42532. * See http://doc.babylonjs.com/how_to/webvr_helper
  42533. */
  42534. export class VRExperienceHelper {
  42535. /** Options to modify the vr experience helper's behavior. */
  42536. webVROptions: VRExperienceHelperOptions;
  42537. private _scene;
  42538. private _position;
  42539. private _btnVR;
  42540. private _btnVRDisplayed;
  42541. private _webVRsupported;
  42542. private _webVRready;
  42543. private _webVRrequesting;
  42544. private _webVRpresenting;
  42545. private _hasEnteredVR;
  42546. private _fullscreenVRpresenting;
  42547. private _canvas;
  42548. private _webVRCamera;
  42549. private _vrDeviceOrientationCamera;
  42550. private _deviceOrientationCamera;
  42551. private _existingCamera;
  42552. private _onKeyDown;
  42553. private _onVrDisplayPresentChange;
  42554. private _onVRDisplayChanged;
  42555. private _onVRRequestPresentStart;
  42556. private _onVRRequestPresentComplete;
  42557. /**
  42558. * 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)
  42559. */
  42560. enableGazeEvenWhenNoPointerLock: boolean;
  42561. /**
  42562. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42563. */
  42564. exitVROnDoubleTap: boolean;
  42565. /**
  42566. * Observable raised right before entering VR.
  42567. */
  42568. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42569. /**
  42570. * Observable raised when entering VR has completed.
  42571. */
  42572. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42573. /**
  42574. * Observable raised when exiting VR.
  42575. */
  42576. onExitingVRObservable: Observable<VRExperienceHelper>;
  42577. /**
  42578. * Observable raised when controller mesh is loaded.
  42579. */
  42580. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42581. /** Return this.onEnteringVRObservable
  42582. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42583. */
  42584. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42585. /** Return this.onExitingVRObservable
  42586. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42587. */
  42588. readonly onExitingVR: Observable<VRExperienceHelper>;
  42589. /** Return this.onControllerMeshLoadedObservable
  42590. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42591. */
  42592. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42593. private _rayLength;
  42594. private _useCustomVRButton;
  42595. private _teleportationRequested;
  42596. private _teleportActive;
  42597. private _floorMeshName;
  42598. private _floorMeshesCollection;
  42599. private _rotationAllowed;
  42600. private _teleportBackwardsVector;
  42601. private _teleportationTarget;
  42602. private _isDefaultTeleportationTarget;
  42603. private _postProcessMove;
  42604. private _teleportationFillColor;
  42605. private _teleportationBorderColor;
  42606. private _rotationAngle;
  42607. private _haloCenter;
  42608. private _cameraGazer;
  42609. private _padSensibilityUp;
  42610. private _padSensibilityDown;
  42611. private _leftController;
  42612. private _rightController;
  42613. /**
  42614. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42615. */
  42616. onNewMeshSelected: Observable<AbstractMesh>;
  42617. /**
  42618. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42619. * This observable will provide the mesh and the controller used to select the mesh
  42620. */
  42621. onMeshSelectedWithController: Observable<{
  42622. mesh: AbstractMesh;
  42623. controller: WebVRController;
  42624. }>;
  42625. /**
  42626. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42627. */
  42628. onNewMeshPicked: Observable<PickingInfo>;
  42629. private _circleEase;
  42630. /**
  42631. * Observable raised before camera teleportation
  42632. */
  42633. onBeforeCameraTeleport: Observable<Vector3>;
  42634. /**
  42635. * Observable raised after camera teleportation
  42636. */
  42637. onAfterCameraTeleport: Observable<Vector3>;
  42638. /**
  42639. * Observable raised when current selected mesh gets unselected
  42640. */
  42641. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42642. private _raySelectionPredicate;
  42643. /**
  42644. * To be optionaly changed by user to define custom ray selection
  42645. */
  42646. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42647. /**
  42648. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42649. */
  42650. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42651. /**
  42652. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42653. */
  42654. teleportationEnabled: boolean;
  42655. private _defaultHeight;
  42656. private _teleportationInitialized;
  42657. private _interactionsEnabled;
  42658. private _interactionsRequested;
  42659. private _displayGaze;
  42660. private _displayLaserPointer;
  42661. /**
  42662. * The mesh used to display where the user is going to teleport.
  42663. */
  42664. /**
  42665. * Sets the mesh to be used to display where the user is going to teleport.
  42666. */
  42667. teleportationTarget: Mesh;
  42668. /**
  42669. * 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
  42670. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42671. * See http://doc.babylonjs.com/resources/baking_transformations
  42672. */
  42673. gazeTrackerMesh: Mesh;
  42674. /**
  42675. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42676. */
  42677. updateGazeTrackerScale: boolean;
  42678. /**
  42679. * If the gaze trackers color should be updated when selecting meshes
  42680. */
  42681. updateGazeTrackerColor: boolean;
  42682. /**
  42683. * If the controller laser color should be updated when selecting meshes
  42684. */
  42685. updateControllerLaserColor: boolean;
  42686. /**
  42687. * The gaze tracking mesh corresponding to the left controller
  42688. */
  42689. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42690. /**
  42691. * The gaze tracking mesh corresponding to the right controller
  42692. */
  42693. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42694. /**
  42695. * If the ray of the gaze should be displayed.
  42696. */
  42697. /**
  42698. * Sets if the ray of the gaze should be displayed.
  42699. */
  42700. displayGaze: boolean;
  42701. /**
  42702. * If the ray of the LaserPointer should be displayed.
  42703. */
  42704. /**
  42705. * Sets if the ray of the LaserPointer should be displayed.
  42706. */
  42707. displayLaserPointer: boolean;
  42708. /**
  42709. * The deviceOrientationCamera used as the camera when not in VR.
  42710. */
  42711. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42712. /**
  42713. * Based on the current WebVR support, returns the current VR camera used.
  42714. */
  42715. readonly currentVRCamera: Nullable<Camera>;
  42716. /**
  42717. * The webVRCamera which is used when in VR.
  42718. */
  42719. readonly webVRCamera: WebVRFreeCamera;
  42720. /**
  42721. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42722. */
  42723. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42724. /**
  42725. * The html button that is used to trigger entering into VR.
  42726. */
  42727. readonly vrButton: Nullable<HTMLButtonElement>;
  42728. private readonly _teleportationRequestInitiated;
  42729. /**
  42730. * Defines wether or not Pointer lock should be requested when switching to
  42731. * full screen.
  42732. */
  42733. requestPointerLockOnFullScreen: boolean;
  42734. /**
  42735. * Instantiates a VRExperienceHelper.
  42736. * Helps to quickly add VR support to an existing scene.
  42737. * @param scene The scene the VRExperienceHelper belongs to.
  42738. * @param webVROptions Options to modify the vr experience helper's behavior.
  42739. */
  42740. constructor(scene: Scene,
  42741. /** Options to modify the vr experience helper's behavior. */
  42742. webVROptions?: VRExperienceHelperOptions);
  42743. private _onDefaultMeshLoaded;
  42744. private _onResize;
  42745. private _onFullscreenChange;
  42746. /**
  42747. * Gets a value indicating if we are currently in VR mode.
  42748. */
  42749. readonly isInVRMode: boolean;
  42750. private onVrDisplayPresentChange;
  42751. private onVRDisplayChanged;
  42752. private moveButtonToBottomRight;
  42753. private displayVRButton;
  42754. private updateButtonVisibility;
  42755. private _cachedAngularSensibility;
  42756. /**
  42757. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42758. * Otherwise, will use the fullscreen API.
  42759. */
  42760. enterVR(): void;
  42761. /**
  42762. * Attempt to exit VR, or fullscreen.
  42763. */
  42764. exitVR(): void;
  42765. /**
  42766. * The position of the vr experience helper.
  42767. */
  42768. /**
  42769. * Sets the position of the vr experience helper.
  42770. */
  42771. position: Vector3;
  42772. /**
  42773. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42774. */
  42775. enableInteractions(): void;
  42776. private readonly _noControllerIsActive;
  42777. private beforeRender;
  42778. private _isTeleportationFloor;
  42779. /**
  42780. * Adds a floor mesh to be used for teleportation.
  42781. * @param floorMesh the mesh to be used for teleportation.
  42782. */
  42783. addFloorMesh(floorMesh: Mesh): void;
  42784. /**
  42785. * Removes a floor mesh from being used for teleportation.
  42786. * @param floorMesh the mesh to be removed.
  42787. */
  42788. removeFloorMesh(floorMesh: Mesh): void;
  42789. /**
  42790. * Enables interactions and teleportation using the VR controllers and gaze.
  42791. * @param vrTeleportationOptions options to modify teleportation behavior.
  42792. */
  42793. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42794. private _onNewGamepadConnected;
  42795. private _tryEnableInteractionOnController;
  42796. private _onNewGamepadDisconnected;
  42797. private _enableInteractionOnController;
  42798. private _checkTeleportWithRay;
  42799. private _checkRotate;
  42800. private _checkTeleportBackwards;
  42801. private _enableTeleportationOnController;
  42802. private _createTeleportationCircles;
  42803. private _displayTeleportationTarget;
  42804. private _hideTeleportationTarget;
  42805. private _rotateCamera;
  42806. private _moveTeleportationSelectorTo;
  42807. private _workingVector;
  42808. private _workingQuaternion;
  42809. private _workingMatrix;
  42810. /**
  42811. * Teleports the users feet to the desired location
  42812. * @param location The location where the user's feet should be placed
  42813. */
  42814. teleportCamera(location: Vector3): void;
  42815. private _convertNormalToDirectionOfRay;
  42816. private _castRayAndSelectObject;
  42817. private _notifySelectedMeshUnselected;
  42818. /**
  42819. * Sets the color of the laser ray from the vr controllers.
  42820. * @param color new color for the ray.
  42821. */
  42822. changeLaserColor(color: Color3): void;
  42823. /**
  42824. * Sets the color of the ray from the vr headsets gaze.
  42825. * @param color new color for the ray.
  42826. */
  42827. changeGazeColor(color: Color3): void;
  42828. /**
  42829. * Exits VR and disposes of the vr experience helper
  42830. */
  42831. dispose(): void;
  42832. /**
  42833. * Gets the name of the VRExperienceHelper class
  42834. * @returns "VRExperienceHelper"
  42835. */
  42836. getClassName(): string;
  42837. }
  42838. }
  42839. declare module "babylonjs/Cameras/VR/index" {
  42840. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42841. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42842. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42843. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42844. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42845. export * from "babylonjs/Cameras/VR/webVRCamera";
  42846. }
  42847. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42848. import { Observable } from "babylonjs/Misc/observable";
  42849. import { Nullable } from "babylonjs/types";
  42850. import { IDisposable, Scene } from "babylonjs/scene";
  42851. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42852. /**
  42853. * Manages an XRSession to work with Babylon's engine
  42854. * @see https://doc.babylonjs.com/how_to/webxr
  42855. */
  42856. export class WebXRSessionManager implements IDisposable {
  42857. private scene;
  42858. /**
  42859. * Fires every time a new xrFrame arrives which can be used to update the camera
  42860. */
  42861. onXRFrameObservable: Observable<any>;
  42862. /**
  42863. * Fires when the xr session is ended either by the device or manually done
  42864. */
  42865. onXRSessionEnded: Observable<any>;
  42866. /**
  42867. * Underlying xr session
  42868. */
  42869. session: XRSession;
  42870. /**
  42871. * Type of reference space used when creating the session
  42872. */
  42873. referenceSpace: XRReferenceSpace;
  42874. /** @hidden */
  42875. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42876. /**
  42877. * Current XR frame
  42878. */
  42879. currentFrame: Nullable<XRFrame>;
  42880. private _xrNavigator;
  42881. private baseLayer;
  42882. /**
  42883. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42884. * @param scene The scene which the session should be created for
  42885. */
  42886. constructor(scene: Scene);
  42887. /**
  42888. * Initializes the manager
  42889. * After initialization enterXR can be called to start an XR session
  42890. * @returns Promise which resolves after it is initialized
  42891. */
  42892. initializeAsync(): Promise<void>;
  42893. /**
  42894. * Initializes an xr session
  42895. * @param xrSessionMode mode to initialize
  42896. * @returns a promise which will resolve once the session has been initialized
  42897. */
  42898. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42899. /**
  42900. * Sets the reference space on the xr session
  42901. * @param referenceSpace space to set
  42902. * @returns a promise that will resolve once the reference space has been set
  42903. */
  42904. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42905. /**
  42906. * Updates the render state of the session
  42907. * @param state state to set
  42908. * @returns a promise that resolves once the render state has been updated
  42909. */
  42910. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42911. /**
  42912. * Starts rendering to the xr layer
  42913. * @returns a promise that will resolve once rendering has started
  42914. */
  42915. startRenderingToXRAsync(): Promise<void>;
  42916. /**
  42917. * Stops the xrSession and restores the renderloop
  42918. * @returns Promise which resolves after it exits XR
  42919. */
  42920. exitXRAsync(): Promise<unknown>;
  42921. /**
  42922. * Checks if a session would be supported for the creation options specified
  42923. * @param sessionMode session mode to check if supported eg. immersive-vr
  42924. * @returns true if supported
  42925. */
  42926. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42927. /**
  42928. * @hidden
  42929. * Converts the render layer of xrSession to a render target
  42930. * @param session session to create render target for
  42931. * @param scene scene the new render target should be created for
  42932. */
  42933. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42934. /**
  42935. * Disposes of the session manager
  42936. */
  42937. dispose(): void;
  42938. }
  42939. }
  42940. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42941. import { Scene } from "babylonjs/scene";
  42942. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42943. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42944. /**
  42945. * WebXR Camera which holds the views for the xrSession
  42946. * @see https://doc.babylonjs.com/how_to/webxr
  42947. */
  42948. export class WebXRCamera extends FreeCamera {
  42949. private static _TmpMatrix;
  42950. /**
  42951. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42952. * @param name the name of the camera
  42953. * @param scene the scene to add the camera to
  42954. */
  42955. constructor(name: string, scene: Scene);
  42956. private _updateNumberOfRigCameras;
  42957. /** @hidden */
  42958. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42959. /**
  42960. * Updates the cameras position from the current pose information of the XR session
  42961. * @param xrSessionManager the session containing pose information
  42962. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42963. */
  42964. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42965. }
  42966. }
  42967. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42968. import { Nullable } from "babylonjs/types";
  42969. import { IDisposable } from "babylonjs/scene";
  42970. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42971. /**
  42972. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42973. */
  42974. export class WebXRManagedOutputCanvas implements IDisposable {
  42975. private helper;
  42976. private _canvas;
  42977. /**
  42978. * xrpresent context of the canvas which can be used to display/mirror xr content
  42979. */
  42980. canvasContext: WebGLRenderingContext;
  42981. /**
  42982. * xr layer for the canvas
  42983. */
  42984. xrLayer: Nullable<XRWebGLLayer>;
  42985. /**
  42986. * Initializes the xr layer for the session
  42987. * @param xrSession xr session
  42988. * @returns a promise that will resolve once the XR Layer has been created
  42989. */
  42990. initializeXRLayerAsync(xrSession: any): any;
  42991. /**
  42992. * Initializes the canvas to be added/removed upon entering/exiting xr
  42993. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42994. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42995. */
  42996. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42997. /**
  42998. * Disposes of the object
  42999. */
  43000. dispose(): void;
  43001. private _setManagedOutputCanvas;
  43002. private _addCanvas;
  43003. private _removeCanvas;
  43004. }
  43005. }
  43006. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43007. import { Observable } from "babylonjs/Misc/observable";
  43008. import { IDisposable, Scene } from "babylonjs/scene";
  43009. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43010. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43011. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43012. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43013. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43014. /**
  43015. * States of the webXR experience
  43016. */
  43017. export enum WebXRState {
  43018. /**
  43019. * Transitioning to being in XR mode
  43020. */
  43021. ENTERING_XR = 0,
  43022. /**
  43023. * Transitioning to non XR mode
  43024. */
  43025. EXITING_XR = 1,
  43026. /**
  43027. * In XR mode and presenting
  43028. */
  43029. IN_XR = 2,
  43030. /**
  43031. * Not entered XR mode
  43032. */
  43033. NOT_IN_XR = 3
  43034. }
  43035. /**
  43036. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43037. * @see https://doc.babylonjs.com/how_to/webxr
  43038. */
  43039. export class WebXRExperienceHelper implements IDisposable {
  43040. private scene;
  43041. /**
  43042. * 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
  43043. */
  43044. container: AbstractMesh;
  43045. /**
  43046. * Camera used to render xr content
  43047. */
  43048. camera: WebXRCamera;
  43049. /**
  43050. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43051. */
  43052. state: WebXRState;
  43053. private _setState;
  43054. private static _TmpVector;
  43055. /**
  43056. * Fires when the state of the experience helper has changed
  43057. */
  43058. onStateChangedObservable: Observable<WebXRState>;
  43059. /** Session manager used to keep track of xr session */
  43060. sessionManager: WebXRSessionManager;
  43061. private _nonVRCamera;
  43062. private _originalSceneAutoClear;
  43063. private _supported;
  43064. /**
  43065. * Creates the experience helper
  43066. * @param scene the scene to attach the experience helper to
  43067. * @returns a promise for the experience helper
  43068. */
  43069. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43070. /**
  43071. * Creates a WebXRExperienceHelper
  43072. * @param scene The scene the helper should be created in
  43073. */
  43074. private constructor();
  43075. /**
  43076. * Exits XR mode and returns the scene to its original state
  43077. * @returns promise that resolves after xr mode has exited
  43078. */
  43079. exitXRAsync(): Promise<unknown>;
  43080. /**
  43081. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43082. * @param sessionCreationOptions options for the XR session
  43083. * @param referenceSpaceType frame of reference of the XR session
  43084. * @param outputCanvas the output canvas that will be used to enter XR mode
  43085. * @returns promise that resolves after xr mode has entered
  43086. */
  43087. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43088. /**
  43089. * Updates the global position of the camera by moving the camera's container
  43090. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43091. * @param position The desired global position of the camera
  43092. */
  43093. setPositionOfCameraUsingContainer(position: Vector3): void;
  43094. /**
  43095. * Rotates the xr camera by rotating the camera's container around the camera's position
  43096. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43097. * @param rotation the desired quaternion rotation to apply to the camera
  43098. */
  43099. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43100. /**
  43101. * Disposes of the experience helper
  43102. */
  43103. dispose(): void;
  43104. }
  43105. }
  43106. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43107. import { Nullable } from "babylonjs/types";
  43108. import { Observable } from "babylonjs/Misc/observable";
  43109. import { IDisposable, Scene } from "babylonjs/scene";
  43110. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43111. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43112. /**
  43113. * Button which can be used to enter a different mode of XR
  43114. */
  43115. export class WebXREnterExitUIButton {
  43116. /** button element */
  43117. element: HTMLElement;
  43118. /** XR initialization options for the button */
  43119. sessionMode: XRSessionMode;
  43120. /** Reference space type */
  43121. referenceSpaceType: XRReferenceSpaceType;
  43122. /**
  43123. * Creates a WebXREnterExitUIButton
  43124. * @param element button element
  43125. * @param sessionMode XR initialization session mode
  43126. * @param referenceSpaceType the type of reference space to be used
  43127. */
  43128. constructor(
  43129. /** button element */
  43130. element: HTMLElement,
  43131. /** XR initialization options for the button */
  43132. sessionMode: XRSessionMode,
  43133. /** Reference space type */
  43134. referenceSpaceType: XRReferenceSpaceType);
  43135. /**
  43136. * Overwritable function which can be used to update the button's visuals when the state changes
  43137. * @param activeButton the current active button in the UI
  43138. */
  43139. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43140. }
  43141. /**
  43142. * Options to create the webXR UI
  43143. */
  43144. export class WebXREnterExitUIOptions {
  43145. /**
  43146. * Context to enter xr with
  43147. */
  43148. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43149. /**
  43150. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43151. */
  43152. customButtons?: Array<WebXREnterExitUIButton>;
  43153. }
  43154. /**
  43155. * UI to allow the user to enter/exit XR mode
  43156. */
  43157. export class WebXREnterExitUI implements IDisposable {
  43158. private scene;
  43159. private _overlay;
  43160. private _buttons;
  43161. private _activeButton;
  43162. /**
  43163. * Fired every time the active button is changed.
  43164. *
  43165. * When xr is entered via a button that launches xr that button will be the callback parameter
  43166. *
  43167. * When exiting xr the callback parameter will be null)
  43168. */
  43169. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43170. /**
  43171. * Creates UI to allow the user to enter/exit XR mode
  43172. * @param scene the scene to add the ui to
  43173. * @param helper the xr experience helper to enter/exit xr with
  43174. * @param options options to configure the UI
  43175. * @returns the created ui
  43176. */
  43177. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43178. private constructor();
  43179. private _updateButtons;
  43180. /**
  43181. * Disposes of the object
  43182. */
  43183. dispose(): void;
  43184. }
  43185. }
  43186. declare module "babylonjs/Cameras/XR/webXRController" {
  43187. import { Nullable } from "babylonjs/types";
  43188. import { Observable } from "babylonjs/Misc/observable";
  43189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43190. import { Ray } from "babylonjs/Culling/ray";
  43191. import { Scene } from "babylonjs/scene";
  43192. /**
  43193. * Represents an XR input
  43194. */
  43195. export class WebXRController {
  43196. private scene;
  43197. /** The underlying input source for the controller */
  43198. inputSource: XRInputSource;
  43199. private parentContainer;
  43200. /**
  43201. * 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
  43202. */
  43203. grip?: AbstractMesh;
  43204. /**
  43205. * Pointer which can be used to select objects or attach a visible laser to
  43206. */
  43207. pointer: AbstractMesh;
  43208. /**
  43209. * Event that fires when the controller is removed/disposed
  43210. */
  43211. onDisposeObservable: Observable<{}>;
  43212. private _tmpMatrix;
  43213. private _tmpQuaternion;
  43214. private _tmpVector;
  43215. /**
  43216. * Creates the controller
  43217. * @see https://doc.babylonjs.com/how_to/webxr
  43218. * @param scene the scene which the controller should be associated to
  43219. * @param inputSource the underlying input source for the controller
  43220. * @param parentContainer parent that the controller meshes should be children of
  43221. */
  43222. constructor(scene: Scene,
  43223. /** The underlying input source for the controller */
  43224. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43225. /**
  43226. * Updates the controller pose based on the given XRFrame
  43227. * @param xrFrame xr frame to update the pose with
  43228. * @param referenceSpace reference space to use
  43229. */
  43230. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43231. /**
  43232. * Gets a world space ray coming from the controller
  43233. * @param result the resulting ray
  43234. */
  43235. getWorldPointerRayToRef(result: Ray): void;
  43236. /**
  43237. * Disposes of the object
  43238. */
  43239. dispose(): void;
  43240. }
  43241. }
  43242. declare module "babylonjs/Cameras/XR/webXRInput" {
  43243. import { Observable } from "babylonjs/Misc/observable";
  43244. import { IDisposable } from "babylonjs/scene";
  43245. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43246. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43247. /**
  43248. * XR input used to track XR inputs such as controllers/rays
  43249. */
  43250. export class WebXRInput implements IDisposable {
  43251. /**
  43252. * Base experience the input listens to
  43253. */
  43254. baseExperience: WebXRExperienceHelper;
  43255. /**
  43256. * XR controllers being tracked
  43257. */
  43258. controllers: Array<WebXRController>;
  43259. private _frameObserver;
  43260. private _stateObserver;
  43261. /**
  43262. * Event when a controller has been connected/added
  43263. */
  43264. onControllerAddedObservable: Observable<WebXRController>;
  43265. /**
  43266. * Event when a controller has been removed/disconnected
  43267. */
  43268. onControllerRemovedObservable: Observable<WebXRController>;
  43269. /**
  43270. * Initializes the WebXRInput
  43271. * @param baseExperience experience helper which the input should be created for
  43272. */
  43273. constructor(
  43274. /**
  43275. * Base experience the input listens to
  43276. */
  43277. baseExperience: WebXRExperienceHelper);
  43278. private _onInputSourcesChange;
  43279. private _addAndRemoveControllers;
  43280. /**
  43281. * Disposes of the object
  43282. */
  43283. dispose(): void;
  43284. }
  43285. }
  43286. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43288. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43289. /**
  43290. * Enables teleportation
  43291. */
  43292. export class WebXRControllerTeleportation {
  43293. private _teleportationFillColor;
  43294. private _teleportationBorderColor;
  43295. private _tmpRay;
  43296. private _tmpVector;
  43297. /**
  43298. * Creates a WebXRControllerTeleportation
  43299. * @param input input manager to add teleportation to
  43300. * @param floorMeshes floormeshes which can be teleported to
  43301. */
  43302. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43303. }
  43304. }
  43305. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43306. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43307. /**
  43308. * Handles pointer input automatically for the pointer of XR controllers
  43309. */
  43310. export class WebXRControllerPointerSelection {
  43311. private static _idCounter;
  43312. private _tmpRay;
  43313. /**
  43314. * Creates a WebXRControllerPointerSelection
  43315. * @param input input manager to setup pointer selection
  43316. */
  43317. constructor(input: WebXRInput);
  43318. private _convertNormalToDirectionOfRay;
  43319. private _updatePointerDistance;
  43320. }
  43321. }
  43322. declare module "babylonjs/Loading/sceneLoader" {
  43323. import { Observable } from "babylonjs/Misc/observable";
  43324. import { Nullable } from "babylonjs/types";
  43325. import { Scene } from "babylonjs/scene";
  43326. import { Engine } from "babylonjs/Engines/engine";
  43327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43328. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43329. import { AssetContainer } from "babylonjs/assetContainer";
  43330. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43331. import { Skeleton } from "babylonjs/Bones/skeleton";
  43332. /**
  43333. * Class used to represent data loading progression
  43334. */
  43335. export class SceneLoaderProgressEvent {
  43336. /** defines if data length to load can be evaluated */
  43337. readonly lengthComputable: boolean;
  43338. /** defines the loaded data length */
  43339. readonly loaded: number;
  43340. /** defines the data length to load */
  43341. readonly total: number;
  43342. /**
  43343. * Create a new progress event
  43344. * @param lengthComputable defines if data length to load can be evaluated
  43345. * @param loaded defines the loaded data length
  43346. * @param total defines the data length to load
  43347. */
  43348. constructor(
  43349. /** defines if data length to load can be evaluated */
  43350. lengthComputable: boolean,
  43351. /** defines the loaded data length */
  43352. loaded: number,
  43353. /** defines the data length to load */
  43354. total: number);
  43355. /**
  43356. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43357. * @param event defines the source event
  43358. * @returns a new SceneLoaderProgressEvent
  43359. */
  43360. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43361. }
  43362. /**
  43363. * Interface used by SceneLoader plugins to define supported file extensions
  43364. */
  43365. export interface ISceneLoaderPluginExtensions {
  43366. /**
  43367. * Defines the list of supported extensions
  43368. */
  43369. [extension: string]: {
  43370. isBinary: boolean;
  43371. };
  43372. }
  43373. /**
  43374. * Interface used by SceneLoader plugin factory
  43375. */
  43376. export interface ISceneLoaderPluginFactory {
  43377. /**
  43378. * Defines the name of the factory
  43379. */
  43380. name: string;
  43381. /**
  43382. * Function called to create a new plugin
  43383. * @return the new plugin
  43384. */
  43385. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43386. /**
  43387. * Boolean indicating if the plugin can direct load specific data
  43388. */
  43389. canDirectLoad?: (data: string) => boolean;
  43390. }
  43391. /**
  43392. * Interface used to define a SceneLoader plugin
  43393. */
  43394. export interface ISceneLoaderPlugin {
  43395. /**
  43396. * The friendly name of this plugin.
  43397. */
  43398. name: string;
  43399. /**
  43400. * The file extensions supported by this plugin.
  43401. */
  43402. extensions: string | ISceneLoaderPluginExtensions;
  43403. /**
  43404. * Import meshes into a scene.
  43405. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43406. * @param scene The scene to import into
  43407. * @param data The data to import
  43408. * @param rootUrl The root url for scene and resources
  43409. * @param meshes The meshes array to import into
  43410. * @param particleSystems The particle systems array to import into
  43411. * @param skeletons The skeletons array to import into
  43412. * @param onError The callback when import fails
  43413. * @returns True if successful or false otherwise
  43414. */
  43415. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43416. /**
  43417. * Load into a scene.
  43418. * @param scene The scene to load into
  43419. * @param data The data to import
  43420. * @param rootUrl The root url for scene and resources
  43421. * @param onError The callback when import fails
  43422. * @returns true if successful or false otherwise
  43423. */
  43424. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43425. /**
  43426. * The callback that returns true if the data can be directly loaded.
  43427. */
  43428. canDirectLoad?: (data: string) => boolean;
  43429. /**
  43430. * The callback that allows custom handling of the root url based on the response url.
  43431. */
  43432. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43433. /**
  43434. * Load into an asset container.
  43435. * @param scene The scene to load into
  43436. * @param data The data to import
  43437. * @param rootUrl The root url for scene and resources
  43438. * @param onError The callback when import fails
  43439. * @returns The loaded asset container
  43440. */
  43441. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43442. }
  43443. /**
  43444. * Interface used to define an async SceneLoader plugin
  43445. */
  43446. export interface ISceneLoaderPluginAsync {
  43447. /**
  43448. * The friendly name of this plugin.
  43449. */
  43450. name: string;
  43451. /**
  43452. * The file extensions supported by this plugin.
  43453. */
  43454. extensions: string | ISceneLoaderPluginExtensions;
  43455. /**
  43456. * Import meshes into a scene.
  43457. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43458. * @param scene The scene to import into
  43459. * @param data The data to import
  43460. * @param rootUrl The root url for scene and resources
  43461. * @param onProgress The callback when the load progresses
  43462. * @param fileName Defines the name of the file to load
  43463. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43464. */
  43465. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43466. meshes: AbstractMesh[];
  43467. particleSystems: IParticleSystem[];
  43468. skeletons: Skeleton[];
  43469. animationGroups: AnimationGroup[];
  43470. }>;
  43471. /**
  43472. * Load into a scene.
  43473. * @param scene The scene to load into
  43474. * @param data The data to import
  43475. * @param rootUrl The root url for scene and resources
  43476. * @param onProgress The callback when the load progresses
  43477. * @param fileName Defines the name of the file to load
  43478. * @returns Nothing
  43479. */
  43480. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43481. /**
  43482. * The callback that returns true if the data can be directly loaded.
  43483. */
  43484. canDirectLoad?: (data: string) => boolean;
  43485. /**
  43486. * The callback that allows custom handling of the root url based on the response url.
  43487. */
  43488. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43489. /**
  43490. * Load into an asset container.
  43491. * @param scene The scene to load into
  43492. * @param data The data to import
  43493. * @param rootUrl The root url for scene and resources
  43494. * @param onProgress The callback when the load progresses
  43495. * @param fileName Defines the name of the file to load
  43496. * @returns The loaded asset container
  43497. */
  43498. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43499. }
  43500. /**
  43501. * Class used to load scene from various file formats using registered plugins
  43502. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43503. */
  43504. export class SceneLoader {
  43505. /**
  43506. * No logging while loading
  43507. */
  43508. static readonly NO_LOGGING: number;
  43509. /**
  43510. * Minimal logging while loading
  43511. */
  43512. static readonly MINIMAL_LOGGING: number;
  43513. /**
  43514. * Summary logging while loading
  43515. */
  43516. static readonly SUMMARY_LOGGING: number;
  43517. /**
  43518. * Detailled logging while loading
  43519. */
  43520. static readonly DETAILED_LOGGING: number;
  43521. /**
  43522. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43523. */
  43524. static ForceFullSceneLoadingForIncremental: boolean;
  43525. /**
  43526. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43527. */
  43528. static ShowLoadingScreen: boolean;
  43529. /**
  43530. * Defines the current logging level (while loading the scene)
  43531. * @ignorenaming
  43532. */
  43533. static loggingLevel: number;
  43534. /**
  43535. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43536. */
  43537. static CleanBoneMatrixWeights: boolean;
  43538. /**
  43539. * Event raised when a plugin is used to load a scene
  43540. */
  43541. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43542. private static _registeredPlugins;
  43543. private static _getDefaultPlugin;
  43544. private static _getPluginForExtension;
  43545. private static _getPluginForDirectLoad;
  43546. private static _getPluginForFilename;
  43547. private static _getDirectLoad;
  43548. private static _loadData;
  43549. private static _getFileInfo;
  43550. /**
  43551. * Gets a plugin that can load the given extension
  43552. * @param extension defines the extension to load
  43553. * @returns a plugin or null if none works
  43554. */
  43555. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43556. /**
  43557. * Gets a boolean indicating that the given extension can be loaded
  43558. * @param extension defines the extension to load
  43559. * @returns true if the extension is supported
  43560. */
  43561. static IsPluginForExtensionAvailable(extension: string): boolean;
  43562. /**
  43563. * Adds a new plugin to the list of registered plugins
  43564. * @param plugin defines the plugin to add
  43565. */
  43566. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43567. /**
  43568. * Import meshes into a scene
  43569. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43570. * @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)
  43571. * @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)
  43572. * @param scene the instance of BABYLON.Scene to append to
  43573. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43574. * @param onProgress a callback with a progress event for each file being loaded
  43575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43576. * @param pluginExtension the extension used to determine the plugin
  43577. * @returns The loaded plugin
  43578. */
  43579. 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>;
  43580. /**
  43581. * Import meshes into a scene
  43582. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43583. * @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)
  43584. * @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)
  43585. * @param scene the instance of BABYLON.Scene to append to
  43586. * @param onProgress a callback with a progress event for each file being loaded
  43587. * @param pluginExtension the extension used to determine the plugin
  43588. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43589. */
  43590. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43591. meshes: AbstractMesh[];
  43592. particleSystems: IParticleSystem[];
  43593. skeletons: Skeleton[];
  43594. animationGroups: AnimationGroup[];
  43595. }>;
  43596. /**
  43597. * Load a scene
  43598. * @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)
  43599. * @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)
  43600. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43601. * @param onSuccess a callback with the scene when import succeeds
  43602. * @param onProgress a callback with a progress event for each file being loaded
  43603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43604. * @param pluginExtension the extension used to determine the plugin
  43605. * @returns The loaded plugin
  43606. */
  43607. 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>;
  43608. /**
  43609. * Load a scene
  43610. * @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)
  43611. * @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)
  43612. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43613. * @param onProgress a callback with a progress event for each file being loaded
  43614. * @param pluginExtension the extension used to determine the plugin
  43615. * @returns The loaded scene
  43616. */
  43617. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43618. /**
  43619. * Append a scene
  43620. * @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)
  43621. * @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)
  43622. * @param scene is the instance of BABYLON.Scene to append to
  43623. * @param onSuccess a callback with the scene when import succeeds
  43624. * @param onProgress a callback with a progress event for each file being loaded
  43625. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43626. * @param pluginExtension the extension used to determine the plugin
  43627. * @returns The loaded plugin
  43628. */
  43629. 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>;
  43630. /**
  43631. * Append a scene
  43632. * @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)
  43633. * @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)
  43634. * @param scene is the instance of BABYLON.Scene to append to
  43635. * @param onProgress a callback with a progress event for each file being loaded
  43636. * @param pluginExtension the extension used to determine the plugin
  43637. * @returns The given scene
  43638. */
  43639. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43640. /**
  43641. * Load a scene into an asset container
  43642. * @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)
  43643. * @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)
  43644. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43645. * @param onSuccess a callback with the scene when import succeeds
  43646. * @param onProgress a callback with a progress event for each file being loaded
  43647. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43648. * @param pluginExtension the extension used to determine the plugin
  43649. * @returns The loaded plugin
  43650. */
  43651. 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>;
  43652. /**
  43653. * Load a scene into an asset container
  43654. * @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)
  43655. * @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)
  43656. * @param scene is the instance of Scene to append to
  43657. * @param onProgress a callback with a progress event for each file being loaded
  43658. * @param pluginExtension the extension used to determine the plugin
  43659. * @returns The loaded asset container
  43660. */
  43661. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43662. }
  43663. }
  43664. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43665. import { Scene } from "babylonjs/scene";
  43666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43667. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43668. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43669. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43670. /**
  43671. * Generic Controller
  43672. */
  43673. export class GenericController extends WebVRController {
  43674. /**
  43675. * Base Url for the controller model.
  43676. */
  43677. static readonly MODEL_BASE_URL: string;
  43678. /**
  43679. * File name for the controller model.
  43680. */
  43681. static readonly MODEL_FILENAME: string;
  43682. /**
  43683. * Creates a new GenericController from a gamepad
  43684. * @param vrGamepad the gamepad that the controller should be created from
  43685. */
  43686. constructor(vrGamepad: any);
  43687. /**
  43688. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43689. * @param scene scene in which to add meshes
  43690. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43691. */
  43692. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43693. /**
  43694. * Called once for each button that changed state since the last frame
  43695. * @param buttonIdx Which button index changed
  43696. * @param state New state of the button
  43697. * @param changes Which properties on the state changed since last frame
  43698. */
  43699. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43700. }
  43701. }
  43702. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43703. import { Observable } from "babylonjs/Misc/observable";
  43704. import { Scene } from "babylonjs/scene";
  43705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43706. import { Ray } from "babylonjs/Culling/ray";
  43707. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43708. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43709. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43710. /**
  43711. * Defines the WindowsMotionController object that the state of the windows motion controller
  43712. */
  43713. export class WindowsMotionController extends WebVRController {
  43714. /**
  43715. * The base url used to load the left and right controller models
  43716. */
  43717. static MODEL_BASE_URL: string;
  43718. /**
  43719. * The name of the left controller model file
  43720. */
  43721. static MODEL_LEFT_FILENAME: string;
  43722. /**
  43723. * The name of the right controller model file
  43724. */
  43725. static MODEL_RIGHT_FILENAME: string;
  43726. /**
  43727. * The controller name prefix for this controller type
  43728. */
  43729. static readonly GAMEPAD_ID_PREFIX: string;
  43730. /**
  43731. * The controller id pattern for this controller type
  43732. */
  43733. private static readonly GAMEPAD_ID_PATTERN;
  43734. private _loadedMeshInfo;
  43735. private readonly _mapping;
  43736. /**
  43737. * Fired when the trackpad on this controller is clicked
  43738. */
  43739. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43740. /**
  43741. * Fired when the trackpad on this controller is modified
  43742. */
  43743. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43744. /**
  43745. * The current x and y values of this controller's trackpad
  43746. */
  43747. trackpad: StickValues;
  43748. /**
  43749. * Creates a new WindowsMotionController from a gamepad
  43750. * @param vrGamepad the gamepad that the controller should be created from
  43751. */
  43752. constructor(vrGamepad: any);
  43753. /**
  43754. * Fired when the trigger on this controller is modified
  43755. */
  43756. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43757. /**
  43758. * Fired when the menu button on this controller is modified
  43759. */
  43760. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43761. /**
  43762. * Fired when the grip button on this controller is modified
  43763. */
  43764. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43765. /**
  43766. * Fired when the thumbstick button on this controller is modified
  43767. */
  43768. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43769. /**
  43770. * Fired when the touchpad button on this controller is modified
  43771. */
  43772. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43773. /**
  43774. * Fired when the touchpad values on this controller are modified
  43775. */
  43776. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43777. private _updateTrackpad;
  43778. /**
  43779. * Called once per frame by the engine.
  43780. */
  43781. update(): void;
  43782. /**
  43783. * Called once for each button that changed state since the last frame
  43784. * @param buttonIdx Which button index changed
  43785. * @param state New state of the button
  43786. * @param changes Which properties on the state changed since last frame
  43787. */
  43788. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43789. /**
  43790. * Moves the buttons on the controller mesh based on their current state
  43791. * @param buttonName the name of the button to move
  43792. * @param buttonValue the value of the button which determines the buttons new position
  43793. */
  43794. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43795. /**
  43796. * Moves the axis on the controller mesh based on its current state
  43797. * @param axis the index of the axis
  43798. * @param axisValue the value of the axis which determines the meshes new position
  43799. * @hidden
  43800. */
  43801. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43802. /**
  43803. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43804. * @param scene scene in which to add meshes
  43805. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43806. */
  43807. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43808. /**
  43809. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43810. * can be transformed by button presses and axes values, based on this._mapping.
  43811. *
  43812. * @param scene scene in which the meshes exist
  43813. * @param meshes list of meshes that make up the controller model to process
  43814. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43815. */
  43816. private processModel;
  43817. private createMeshInfo;
  43818. /**
  43819. * Gets the ray of the controller in the direction the controller is pointing
  43820. * @param length the length the resulting ray should be
  43821. * @returns a ray in the direction the controller is pointing
  43822. */
  43823. getForwardRay(length?: number): Ray;
  43824. /**
  43825. * Disposes of the controller
  43826. */
  43827. dispose(): void;
  43828. }
  43829. }
  43830. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43831. import { Observable } from "babylonjs/Misc/observable";
  43832. import { Scene } from "babylonjs/scene";
  43833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43834. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43835. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43836. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43837. /**
  43838. * Oculus Touch Controller
  43839. */
  43840. export class OculusTouchController extends WebVRController {
  43841. /**
  43842. * Base Url for the controller model.
  43843. */
  43844. static MODEL_BASE_URL: string;
  43845. /**
  43846. * File name for the left controller model.
  43847. */
  43848. static MODEL_LEFT_FILENAME: string;
  43849. /**
  43850. * File name for the right controller model.
  43851. */
  43852. static MODEL_RIGHT_FILENAME: string;
  43853. /**
  43854. * Base Url for the Quest controller model.
  43855. */
  43856. static QUEST_MODEL_BASE_URL: string;
  43857. /**
  43858. * @hidden
  43859. * If the controllers are running on a device that needs the updated Quest controller models
  43860. */
  43861. static _IsQuest: boolean;
  43862. /**
  43863. * Fired when the secondary trigger on this controller is modified
  43864. */
  43865. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43866. /**
  43867. * Fired when the thumb rest on this controller is modified
  43868. */
  43869. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43870. /**
  43871. * Creates a new OculusTouchController from a gamepad
  43872. * @param vrGamepad the gamepad that the controller should be created from
  43873. */
  43874. constructor(vrGamepad: any);
  43875. /**
  43876. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43877. * @param scene scene in which to add meshes
  43878. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43879. */
  43880. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43881. /**
  43882. * Fired when the A button on this controller is modified
  43883. */
  43884. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43885. /**
  43886. * Fired when the B button on this controller is modified
  43887. */
  43888. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43889. /**
  43890. * Fired when the X button on this controller is modified
  43891. */
  43892. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43893. /**
  43894. * Fired when the Y button on this controller is modified
  43895. */
  43896. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43897. /**
  43898. * Called once for each button that changed state since the last frame
  43899. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43900. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43901. * 2) secondary trigger (same)
  43902. * 3) A (right) X (left), touch, pressed = value
  43903. * 4) B / Y
  43904. * 5) thumb rest
  43905. * @param buttonIdx Which button index changed
  43906. * @param state New state of the button
  43907. * @param changes Which properties on the state changed since last frame
  43908. */
  43909. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43910. }
  43911. }
  43912. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43913. import { Scene } from "babylonjs/scene";
  43914. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43915. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43916. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43917. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43918. import { Observable } from "babylonjs/Misc/observable";
  43919. /**
  43920. * Vive Controller
  43921. */
  43922. export class ViveController extends WebVRController {
  43923. /**
  43924. * Base Url for the controller model.
  43925. */
  43926. static MODEL_BASE_URL: string;
  43927. /**
  43928. * File name for the controller model.
  43929. */
  43930. static MODEL_FILENAME: string;
  43931. /**
  43932. * Creates a new ViveController from a gamepad
  43933. * @param vrGamepad the gamepad that the controller should be created from
  43934. */
  43935. constructor(vrGamepad: any);
  43936. /**
  43937. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43938. * @param scene scene in which to add meshes
  43939. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43940. */
  43941. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43942. /**
  43943. * Fired when the left button on this controller is modified
  43944. */
  43945. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43946. /**
  43947. * Fired when the right button on this controller is modified
  43948. */
  43949. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43950. /**
  43951. * Fired when the menu button on this controller is modified
  43952. */
  43953. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43954. /**
  43955. * Called once for each button that changed state since the last frame
  43956. * Vive mapping:
  43957. * 0: touchpad
  43958. * 1: trigger
  43959. * 2: left AND right buttons
  43960. * 3: menu button
  43961. * @param buttonIdx Which button index changed
  43962. * @param state New state of the button
  43963. * @param changes Which properties on the state changed since last frame
  43964. */
  43965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43966. }
  43967. }
  43968. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43969. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43970. /**
  43971. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43972. */
  43973. export class WebXRControllerModelLoader {
  43974. /**
  43975. * Creates the WebXRControllerModelLoader
  43976. * @param input xr input that creates the controllers
  43977. */
  43978. constructor(input: WebXRInput);
  43979. }
  43980. }
  43981. declare module "babylonjs/Cameras/XR/index" {
  43982. export * from "babylonjs/Cameras/XR/webXRCamera";
  43983. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43984. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43985. export * from "babylonjs/Cameras/XR/webXRInput";
  43986. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43987. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43988. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43989. export * from "babylonjs/Cameras/XR/webXRController";
  43990. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43991. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43992. }
  43993. declare module "babylonjs/Cameras/RigModes/index" {
  43994. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43995. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43996. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43997. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43998. }
  43999. declare module "babylonjs/Cameras/index" {
  44000. export * from "babylonjs/Cameras/Inputs/index";
  44001. export * from "babylonjs/Cameras/cameraInputsManager";
  44002. export * from "babylonjs/Cameras/camera";
  44003. export * from "babylonjs/Cameras/targetCamera";
  44004. export * from "babylonjs/Cameras/freeCamera";
  44005. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44006. export * from "babylonjs/Cameras/touchCamera";
  44007. export * from "babylonjs/Cameras/arcRotateCamera";
  44008. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44009. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44010. export * from "babylonjs/Cameras/flyCamera";
  44011. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44012. export * from "babylonjs/Cameras/followCamera";
  44013. export * from "babylonjs/Cameras/followCameraInputsManager";
  44014. export * from "babylonjs/Cameras/gamepadCamera";
  44015. export * from "babylonjs/Cameras/Stereoscopic/index";
  44016. export * from "babylonjs/Cameras/universalCamera";
  44017. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44018. export * from "babylonjs/Cameras/VR/index";
  44019. export * from "babylonjs/Cameras/XR/index";
  44020. export * from "babylonjs/Cameras/RigModes/index";
  44021. }
  44022. declare module "babylonjs/Collisions/index" {
  44023. export * from "babylonjs/Collisions/collider";
  44024. export * from "babylonjs/Collisions/collisionCoordinator";
  44025. export * from "babylonjs/Collisions/pickingInfo";
  44026. export * from "babylonjs/Collisions/intersectionInfo";
  44027. export * from "babylonjs/Collisions/meshCollisionData";
  44028. }
  44029. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44030. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44031. import { Vector3 } from "babylonjs/Maths/math.vector";
  44032. import { Ray } from "babylonjs/Culling/ray";
  44033. import { Plane } from "babylonjs/Maths/math.plane";
  44034. /**
  44035. * Contains an array of blocks representing the octree
  44036. */
  44037. export interface IOctreeContainer<T> {
  44038. /**
  44039. * Blocks within the octree
  44040. */
  44041. blocks: Array<OctreeBlock<T>>;
  44042. }
  44043. /**
  44044. * Class used to store a cell in an octree
  44045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44046. */
  44047. export class OctreeBlock<T> {
  44048. /**
  44049. * Gets the content of the current block
  44050. */
  44051. entries: T[];
  44052. /**
  44053. * Gets the list of block children
  44054. */
  44055. blocks: Array<OctreeBlock<T>>;
  44056. private _depth;
  44057. private _maxDepth;
  44058. private _capacity;
  44059. private _minPoint;
  44060. private _maxPoint;
  44061. private _boundingVectors;
  44062. private _creationFunc;
  44063. /**
  44064. * Creates a new block
  44065. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44066. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44067. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44068. * @param depth defines the current depth of this block in the octree
  44069. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44070. * @param creationFunc defines a callback to call when an element is added to the block
  44071. */
  44072. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44073. /**
  44074. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44075. */
  44076. readonly capacity: number;
  44077. /**
  44078. * Gets the minimum vector (in world space) of the block's bounding box
  44079. */
  44080. readonly minPoint: Vector3;
  44081. /**
  44082. * Gets the maximum vector (in world space) of the block's bounding box
  44083. */
  44084. readonly maxPoint: Vector3;
  44085. /**
  44086. * Add a new element to this block
  44087. * @param entry defines the element to add
  44088. */
  44089. addEntry(entry: T): void;
  44090. /**
  44091. * Remove an element from this block
  44092. * @param entry defines the element to remove
  44093. */
  44094. removeEntry(entry: T): void;
  44095. /**
  44096. * Add an array of elements to this block
  44097. * @param entries defines the array of elements to add
  44098. */
  44099. addEntries(entries: T[]): void;
  44100. /**
  44101. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44102. * @param frustumPlanes defines the frustum planes to test
  44103. * @param selection defines the array to store current content if selection is positive
  44104. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44105. */
  44106. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44107. /**
  44108. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44109. * @param sphereCenter defines the bounding sphere center
  44110. * @param sphereRadius defines the bounding sphere radius
  44111. * @param selection defines the array to store current content if selection is positive
  44112. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44113. */
  44114. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44115. /**
  44116. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44117. * @param ray defines the ray to test with
  44118. * @param selection defines the array to store current content if selection is positive
  44119. */
  44120. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44121. /**
  44122. * Subdivide the content into child blocks (this block will then be empty)
  44123. */
  44124. createInnerBlocks(): void;
  44125. /**
  44126. * @hidden
  44127. */
  44128. 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;
  44129. }
  44130. }
  44131. declare module "babylonjs/Culling/Octrees/octree" {
  44132. import { SmartArray } from "babylonjs/Misc/smartArray";
  44133. import { Vector3 } from "babylonjs/Maths/math.vector";
  44134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44136. import { Ray } from "babylonjs/Culling/ray";
  44137. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44138. import { Plane } from "babylonjs/Maths/math.plane";
  44139. /**
  44140. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44141. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44142. */
  44143. export class Octree<T> {
  44144. /** 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.) */
  44145. maxDepth: number;
  44146. /**
  44147. * Blocks within the octree containing objects
  44148. */
  44149. blocks: Array<OctreeBlock<T>>;
  44150. /**
  44151. * Content stored in the octree
  44152. */
  44153. dynamicContent: T[];
  44154. private _maxBlockCapacity;
  44155. private _selectionContent;
  44156. private _creationFunc;
  44157. /**
  44158. * Creates a octree
  44159. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44160. * @param creationFunc function to be used to instatiate the octree
  44161. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44162. * @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.)
  44163. */
  44164. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44165. /** 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.) */
  44166. maxDepth?: number);
  44167. /**
  44168. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44169. * @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);
  44170. * @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);
  44171. * @param entries meshes to be added to the octree blocks
  44172. */
  44173. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44174. /**
  44175. * Adds a mesh to the octree
  44176. * @param entry Mesh to add to the octree
  44177. */
  44178. addMesh(entry: T): void;
  44179. /**
  44180. * Remove an element from the octree
  44181. * @param entry defines the element to remove
  44182. */
  44183. removeMesh(entry: T): void;
  44184. /**
  44185. * Selects an array of meshes within the frustum
  44186. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44187. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44188. * @returns array of meshes within the frustum
  44189. */
  44190. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44191. /**
  44192. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44193. * @param sphereCenter defines the bounding sphere center
  44194. * @param sphereRadius defines the bounding sphere radius
  44195. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44196. * @returns an array of objects that intersect the sphere
  44197. */
  44198. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44199. /**
  44200. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44201. * @param ray defines the ray to test with
  44202. * @returns array of intersected objects
  44203. */
  44204. intersectsRay(ray: Ray): SmartArray<T>;
  44205. /**
  44206. * Adds a mesh into the octree block if it intersects the block
  44207. */
  44208. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44209. /**
  44210. * Adds a submesh into the octree block if it intersects the block
  44211. */
  44212. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44213. }
  44214. }
  44215. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44216. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44217. import { Scene } from "babylonjs/scene";
  44218. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44220. import { Ray } from "babylonjs/Culling/ray";
  44221. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44222. import { Collider } from "babylonjs/Collisions/collider";
  44223. module "babylonjs/scene" {
  44224. interface Scene {
  44225. /**
  44226. * @hidden
  44227. * Backing Filed
  44228. */
  44229. _selectionOctree: Octree<AbstractMesh>;
  44230. /**
  44231. * Gets the octree used to boost mesh selection (picking)
  44232. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44233. */
  44234. selectionOctree: Octree<AbstractMesh>;
  44235. /**
  44236. * Creates or updates the octree used to boost selection (picking)
  44237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44238. * @param maxCapacity defines the maximum capacity per leaf
  44239. * @param maxDepth defines the maximum depth of the octree
  44240. * @returns an octree of AbstractMesh
  44241. */
  44242. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44243. }
  44244. }
  44245. module "babylonjs/Meshes/abstractMesh" {
  44246. interface AbstractMesh {
  44247. /**
  44248. * @hidden
  44249. * Backing Field
  44250. */
  44251. _submeshesOctree: Octree<SubMesh>;
  44252. /**
  44253. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44254. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44255. * @param maxCapacity defines the maximum size of each block (64 by default)
  44256. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44257. * @returns the new octree
  44258. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44260. */
  44261. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44262. }
  44263. }
  44264. /**
  44265. * Defines the octree scene component responsible to manage any octrees
  44266. * in a given scene.
  44267. */
  44268. export class OctreeSceneComponent {
  44269. /**
  44270. * The component name help to identify the component in the list of scene components.
  44271. */
  44272. readonly name: string;
  44273. /**
  44274. * The scene the component belongs to.
  44275. */
  44276. scene: Scene;
  44277. /**
  44278. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44279. */
  44280. readonly checksIsEnabled: boolean;
  44281. /**
  44282. * Creates a new instance of the component for the given scene
  44283. * @param scene Defines the scene to register the component in
  44284. */
  44285. constructor(scene: Scene);
  44286. /**
  44287. * Registers the component in a given scene
  44288. */
  44289. register(): void;
  44290. /**
  44291. * Return the list of active meshes
  44292. * @returns the list of active meshes
  44293. */
  44294. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44295. /**
  44296. * Return the list of active sub meshes
  44297. * @param mesh The mesh to get the candidates sub meshes from
  44298. * @returns the list of active sub meshes
  44299. */
  44300. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44301. private _tempRay;
  44302. /**
  44303. * Return the list of sub meshes intersecting with a given local ray
  44304. * @param mesh defines the mesh to find the submesh for
  44305. * @param localRay defines the ray in local space
  44306. * @returns the list of intersecting sub meshes
  44307. */
  44308. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44309. /**
  44310. * Return the list of sub meshes colliding with a collider
  44311. * @param mesh defines the mesh to find the submesh for
  44312. * @param collider defines the collider to evaluate the collision against
  44313. * @returns the list of colliding sub meshes
  44314. */
  44315. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44316. /**
  44317. * Rebuilds the elements related to this component in case of
  44318. * context lost for instance.
  44319. */
  44320. rebuild(): void;
  44321. /**
  44322. * Disposes the component and the associated ressources.
  44323. */
  44324. dispose(): void;
  44325. }
  44326. }
  44327. declare module "babylonjs/Culling/Octrees/index" {
  44328. export * from "babylonjs/Culling/Octrees/octree";
  44329. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44330. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44331. }
  44332. declare module "babylonjs/Culling/index" {
  44333. export * from "babylonjs/Culling/boundingBox";
  44334. export * from "babylonjs/Culling/boundingInfo";
  44335. export * from "babylonjs/Culling/boundingSphere";
  44336. export * from "babylonjs/Culling/Octrees/index";
  44337. export * from "babylonjs/Culling/ray";
  44338. }
  44339. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44340. import { IDisposable, Scene } from "babylonjs/scene";
  44341. import { Nullable } from "babylonjs/types";
  44342. import { Observable } from "babylonjs/Misc/observable";
  44343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44344. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44345. import { Camera } from "babylonjs/Cameras/camera";
  44346. /**
  44347. * Renders a layer on top of an existing scene
  44348. */
  44349. export class UtilityLayerRenderer implements IDisposable {
  44350. /** the original scene that will be rendered on top of */
  44351. originalScene: Scene;
  44352. private _pointerCaptures;
  44353. private _lastPointerEvents;
  44354. private static _DefaultUtilityLayer;
  44355. private static _DefaultKeepDepthUtilityLayer;
  44356. private _sharedGizmoLight;
  44357. private _renderCamera;
  44358. /**
  44359. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44360. * @returns the camera that is used when rendering the utility layer
  44361. */
  44362. getRenderCamera(): Nullable<Camera>;
  44363. /**
  44364. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44365. * @param cam the camera that should be used when rendering the utility layer
  44366. */
  44367. setRenderCamera(cam: Nullable<Camera>): void;
  44368. /**
  44369. * @hidden
  44370. * Light which used by gizmos to get light shading
  44371. */
  44372. _getSharedGizmoLight(): HemisphericLight;
  44373. /**
  44374. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44375. */
  44376. pickUtilitySceneFirst: boolean;
  44377. /**
  44378. * 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)
  44379. */
  44380. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44381. /**
  44382. * 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)
  44383. */
  44384. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44385. /**
  44386. * The scene that is rendered on top of the original scene
  44387. */
  44388. utilityLayerScene: Scene;
  44389. /**
  44390. * If the utility layer should automatically be rendered on top of existing scene
  44391. */
  44392. shouldRender: boolean;
  44393. /**
  44394. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44395. */
  44396. onlyCheckPointerDownEvents: boolean;
  44397. /**
  44398. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44399. */
  44400. processAllEvents: boolean;
  44401. /**
  44402. * Observable raised when the pointer move from the utility layer scene to the main scene
  44403. */
  44404. onPointerOutObservable: Observable<number>;
  44405. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44406. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44407. private _afterRenderObserver;
  44408. private _sceneDisposeObserver;
  44409. private _originalPointerObserver;
  44410. /**
  44411. * Instantiates a UtilityLayerRenderer
  44412. * @param originalScene the original scene that will be rendered on top of
  44413. * @param handleEvents boolean indicating if the utility layer should handle events
  44414. */
  44415. constructor(
  44416. /** the original scene that will be rendered on top of */
  44417. originalScene: Scene, handleEvents?: boolean);
  44418. private _notifyObservers;
  44419. /**
  44420. * Renders the utility layers scene on top of the original scene
  44421. */
  44422. render(): void;
  44423. /**
  44424. * Disposes of the renderer
  44425. */
  44426. dispose(): void;
  44427. private _updateCamera;
  44428. }
  44429. }
  44430. declare module "babylonjs/Gizmos/gizmo" {
  44431. import { Nullable } from "babylonjs/types";
  44432. import { IDisposable } from "babylonjs/scene";
  44433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44434. import { Mesh } from "babylonjs/Meshes/mesh";
  44435. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44436. /**
  44437. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44438. */
  44439. export class Gizmo implements IDisposable {
  44440. /** The utility layer the gizmo will be added to */
  44441. gizmoLayer: UtilityLayerRenderer;
  44442. /**
  44443. * The root mesh of the gizmo
  44444. */
  44445. _rootMesh: Mesh;
  44446. private _attachedMesh;
  44447. /**
  44448. * Ratio for the scale of the gizmo (Default: 1)
  44449. */
  44450. scaleRatio: number;
  44451. /**
  44452. * If a custom mesh has been set (Default: false)
  44453. */
  44454. protected _customMeshSet: boolean;
  44455. /**
  44456. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44457. * * When set, interactions will be enabled
  44458. */
  44459. attachedMesh: Nullable<AbstractMesh>;
  44460. /**
  44461. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44462. * @param mesh The mesh to replace the default mesh of the gizmo
  44463. */
  44464. setCustomMesh(mesh: Mesh): void;
  44465. /**
  44466. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44467. */
  44468. updateGizmoRotationToMatchAttachedMesh: boolean;
  44469. /**
  44470. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44471. */
  44472. updateGizmoPositionToMatchAttachedMesh: boolean;
  44473. /**
  44474. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44475. */
  44476. updateScale: boolean;
  44477. protected _interactionsEnabled: boolean;
  44478. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44479. private _beforeRenderObserver;
  44480. private _tempVector;
  44481. /**
  44482. * Creates a gizmo
  44483. * @param gizmoLayer The utility layer the gizmo will be added to
  44484. */
  44485. constructor(
  44486. /** The utility layer the gizmo will be added to */
  44487. gizmoLayer?: UtilityLayerRenderer);
  44488. /**
  44489. * Updates the gizmo to match the attached mesh's position/rotation
  44490. */
  44491. protected _update(): void;
  44492. /**
  44493. * Disposes of the gizmo
  44494. */
  44495. dispose(): void;
  44496. }
  44497. }
  44498. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44499. import { Observable } from "babylonjs/Misc/observable";
  44500. import { Nullable } from "babylonjs/types";
  44501. import { Vector3 } from "babylonjs/Maths/math.vector";
  44502. import { Color3 } from "babylonjs/Maths/math.color";
  44503. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44505. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44506. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44507. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44508. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44509. import { Scene } from "babylonjs/scene";
  44510. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44511. /**
  44512. * Single plane drag gizmo
  44513. */
  44514. export class PlaneDragGizmo extends Gizmo {
  44515. /**
  44516. * Drag behavior responsible for the gizmos dragging interactions
  44517. */
  44518. dragBehavior: PointerDragBehavior;
  44519. private _pointerObserver;
  44520. /**
  44521. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44522. */
  44523. snapDistance: number;
  44524. /**
  44525. * Event that fires each time the gizmo snaps to a new location.
  44526. * * snapDistance is the the change in distance
  44527. */
  44528. onSnapObservable: Observable<{
  44529. snapDistance: number;
  44530. }>;
  44531. private _plane;
  44532. private _coloredMaterial;
  44533. private _hoverMaterial;
  44534. private _isEnabled;
  44535. private _parent;
  44536. /** @hidden */
  44537. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44538. /** @hidden */
  44539. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44540. /**
  44541. * Creates a PlaneDragGizmo
  44542. * @param gizmoLayer The utility layer the gizmo will be added to
  44543. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44544. * @param color The color of the gizmo
  44545. */
  44546. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44547. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44548. /**
  44549. * If the gizmo is enabled
  44550. */
  44551. isEnabled: boolean;
  44552. /**
  44553. * Disposes of the gizmo
  44554. */
  44555. dispose(): void;
  44556. }
  44557. }
  44558. declare module "babylonjs/Gizmos/positionGizmo" {
  44559. import { Observable } from "babylonjs/Misc/observable";
  44560. import { Nullable } from "babylonjs/types";
  44561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44562. import { Mesh } from "babylonjs/Meshes/mesh";
  44563. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44564. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44565. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44566. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44567. /**
  44568. * Gizmo that enables dragging a mesh along 3 axis
  44569. */
  44570. export class PositionGizmo extends Gizmo {
  44571. /**
  44572. * Internal gizmo used for interactions on the x axis
  44573. */
  44574. xGizmo: AxisDragGizmo;
  44575. /**
  44576. * Internal gizmo used for interactions on the y axis
  44577. */
  44578. yGizmo: AxisDragGizmo;
  44579. /**
  44580. * Internal gizmo used for interactions on the z axis
  44581. */
  44582. zGizmo: AxisDragGizmo;
  44583. /**
  44584. * Internal gizmo used for interactions on the yz plane
  44585. */
  44586. xPlaneGizmo: PlaneDragGizmo;
  44587. /**
  44588. * Internal gizmo used for interactions on the xz plane
  44589. */
  44590. yPlaneGizmo: PlaneDragGizmo;
  44591. /**
  44592. * Internal gizmo used for interactions on the xy plane
  44593. */
  44594. zPlaneGizmo: PlaneDragGizmo;
  44595. /**
  44596. * private variables
  44597. */
  44598. private _meshAttached;
  44599. private _updateGizmoRotationToMatchAttachedMesh;
  44600. private _snapDistance;
  44601. private _scaleRatio;
  44602. /** Fires an event when any of it's sub gizmos are dragged */
  44603. onDragStartObservable: Observable<unknown>;
  44604. /** Fires an event when any of it's sub gizmos are released from dragging */
  44605. onDragEndObservable: Observable<unknown>;
  44606. /**
  44607. * If set to true, planar drag is enabled
  44608. */
  44609. private _planarGizmoEnabled;
  44610. attachedMesh: Nullable<AbstractMesh>;
  44611. /**
  44612. * Creates a PositionGizmo
  44613. * @param gizmoLayer The utility layer the gizmo will be added to
  44614. */
  44615. constructor(gizmoLayer?: UtilityLayerRenderer);
  44616. /**
  44617. * If the planar drag gizmo is enabled
  44618. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44619. */
  44620. planarGizmoEnabled: boolean;
  44621. updateGizmoRotationToMatchAttachedMesh: boolean;
  44622. /**
  44623. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44624. */
  44625. snapDistance: number;
  44626. /**
  44627. * Ratio for the scale of the gizmo (Default: 1)
  44628. */
  44629. scaleRatio: number;
  44630. /**
  44631. * Disposes of the gizmo
  44632. */
  44633. dispose(): void;
  44634. /**
  44635. * CustomMeshes are not supported by this gizmo
  44636. * @param mesh The mesh to replace the default mesh of the gizmo
  44637. */
  44638. setCustomMesh(mesh: Mesh): void;
  44639. }
  44640. }
  44641. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44642. import { Observable } from "babylonjs/Misc/observable";
  44643. import { Nullable } from "babylonjs/types";
  44644. import { Vector3 } from "babylonjs/Maths/math.vector";
  44645. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44646. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44647. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44648. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44649. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44650. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44651. import { Scene } from "babylonjs/scene";
  44652. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44653. import { Color3 } from "babylonjs/Maths/math.color";
  44654. /**
  44655. * Single axis drag gizmo
  44656. */
  44657. export class AxisDragGizmo extends Gizmo {
  44658. /**
  44659. * Drag behavior responsible for the gizmos dragging interactions
  44660. */
  44661. dragBehavior: PointerDragBehavior;
  44662. private _pointerObserver;
  44663. /**
  44664. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44665. */
  44666. snapDistance: number;
  44667. /**
  44668. * Event that fires each time the gizmo snaps to a new location.
  44669. * * snapDistance is the the change in distance
  44670. */
  44671. onSnapObservable: Observable<{
  44672. snapDistance: number;
  44673. }>;
  44674. private _isEnabled;
  44675. private _parent;
  44676. private _arrow;
  44677. private _coloredMaterial;
  44678. private _hoverMaterial;
  44679. /** @hidden */
  44680. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44681. /** @hidden */
  44682. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44683. /**
  44684. * Creates an AxisDragGizmo
  44685. * @param gizmoLayer The utility layer the gizmo will be added to
  44686. * @param dragAxis The axis which the gizmo will be able to drag on
  44687. * @param color The color of the gizmo
  44688. */
  44689. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44690. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44691. /**
  44692. * If the gizmo is enabled
  44693. */
  44694. isEnabled: boolean;
  44695. /**
  44696. * Disposes of the gizmo
  44697. */
  44698. dispose(): void;
  44699. }
  44700. }
  44701. declare module "babylonjs/Debug/axesViewer" {
  44702. import { Vector3 } from "babylonjs/Maths/math.vector";
  44703. import { Nullable } from "babylonjs/types";
  44704. import { Scene } from "babylonjs/scene";
  44705. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44706. /**
  44707. * The Axes viewer will show 3 axes in a specific point in space
  44708. */
  44709. export class AxesViewer {
  44710. private _xAxis;
  44711. private _yAxis;
  44712. private _zAxis;
  44713. private _scaleLinesFactor;
  44714. private _instanced;
  44715. /**
  44716. * Gets the hosting scene
  44717. */
  44718. scene: Scene;
  44719. /**
  44720. * Gets or sets a number used to scale line length
  44721. */
  44722. scaleLines: number;
  44723. /** Gets the node hierarchy used to render x-axis */
  44724. readonly xAxis: TransformNode;
  44725. /** Gets the node hierarchy used to render y-axis */
  44726. readonly yAxis: TransformNode;
  44727. /** Gets the node hierarchy used to render z-axis */
  44728. readonly zAxis: TransformNode;
  44729. /**
  44730. * Creates a new AxesViewer
  44731. * @param scene defines the hosting scene
  44732. * @param scaleLines defines a number used to scale line length (1 by default)
  44733. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44734. * @param xAxis defines the node hierarchy used to render the x-axis
  44735. * @param yAxis defines the node hierarchy used to render the y-axis
  44736. * @param zAxis defines the node hierarchy used to render the z-axis
  44737. */
  44738. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44739. /**
  44740. * Force the viewer to update
  44741. * @param position defines the position of the viewer
  44742. * @param xaxis defines the x axis of the viewer
  44743. * @param yaxis defines the y axis of the viewer
  44744. * @param zaxis defines the z axis of the viewer
  44745. */
  44746. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44747. /**
  44748. * Creates an instance of this axes viewer.
  44749. * @returns a new axes viewer with instanced meshes
  44750. */
  44751. createInstance(): AxesViewer;
  44752. /** Releases resources */
  44753. dispose(): void;
  44754. private static _SetRenderingGroupId;
  44755. }
  44756. }
  44757. declare module "babylonjs/Debug/boneAxesViewer" {
  44758. import { Nullable } from "babylonjs/types";
  44759. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44760. import { Vector3 } from "babylonjs/Maths/math.vector";
  44761. import { Mesh } from "babylonjs/Meshes/mesh";
  44762. import { Bone } from "babylonjs/Bones/bone";
  44763. import { Scene } from "babylonjs/scene";
  44764. /**
  44765. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44766. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44767. */
  44768. export class BoneAxesViewer extends AxesViewer {
  44769. /**
  44770. * Gets or sets the target mesh where to display the axes viewer
  44771. */
  44772. mesh: Nullable<Mesh>;
  44773. /**
  44774. * Gets or sets the target bone where to display the axes viewer
  44775. */
  44776. bone: Nullable<Bone>;
  44777. /** Gets current position */
  44778. pos: Vector3;
  44779. /** Gets direction of X axis */
  44780. xaxis: Vector3;
  44781. /** Gets direction of Y axis */
  44782. yaxis: Vector3;
  44783. /** Gets direction of Z axis */
  44784. zaxis: Vector3;
  44785. /**
  44786. * Creates a new BoneAxesViewer
  44787. * @param scene defines the hosting scene
  44788. * @param bone defines the target bone
  44789. * @param mesh defines the target mesh
  44790. * @param scaleLines defines a scaling factor for line length (1 by default)
  44791. */
  44792. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44793. /**
  44794. * Force the viewer to update
  44795. */
  44796. update(): void;
  44797. /** Releases resources */
  44798. dispose(): void;
  44799. }
  44800. }
  44801. declare module "babylonjs/Debug/debugLayer" {
  44802. import { Scene } from "babylonjs/scene";
  44803. /**
  44804. * Interface used to define scene explorer extensibility option
  44805. */
  44806. export interface IExplorerExtensibilityOption {
  44807. /**
  44808. * Define the option label
  44809. */
  44810. label: string;
  44811. /**
  44812. * Defines the action to execute on click
  44813. */
  44814. action: (entity: any) => void;
  44815. }
  44816. /**
  44817. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44818. */
  44819. export interface IExplorerExtensibilityGroup {
  44820. /**
  44821. * Defines a predicate to test if a given type mut be extended
  44822. */
  44823. predicate: (entity: any) => boolean;
  44824. /**
  44825. * Gets the list of options added to a type
  44826. */
  44827. entries: IExplorerExtensibilityOption[];
  44828. }
  44829. /**
  44830. * Interface used to define the options to use to create the Inspector
  44831. */
  44832. export interface IInspectorOptions {
  44833. /**
  44834. * Display in overlay mode (default: false)
  44835. */
  44836. overlay?: boolean;
  44837. /**
  44838. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44839. */
  44840. globalRoot?: HTMLElement;
  44841. /**
  44842. * Display the Scene explorer
  44843. */
  44844. showExplorer?: boolean;
  44845. /**
  44846. * Display the property inspector
  44847. */
  44848. showInspector?: boolean;
  44849. /**
  44850. * Display in embed mode (both panes on the right)
  44851. */
  44852. embedMode?: boolean;
  44853. /**
  44854. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44855. */
  44856. handleResize?: boolean;
  44857. /**
  44858. * Allow the panes to popup (default: true)
  44859. */
  44860. enablePopup?: boolean;
  44861. /**
  44862. * Allow the panes to be closed by users (default: true)
  44863. */
  44864. enableClose?: boolean;
  44865. /**
  44866. * Optional list of extensibility entries
  44867. */
  44868. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44869. /**
  44870. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44871. */
  44872. inspectorURL?: string;
  44873. }
  44874. module "babylonjs/scene" {
  44875. interface Scene {
  44876. /**
  44877. * @hidden
  44878. * Backing field
  44879. */
  44880. _debugLayer: DebugLayer;
  44881. /**
  44882. * Gets the debug layer (aka Inspector) associated with the scene
  44883. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44884. */
  44885. debugLayer: DebugLayer;
  44886. }
  44887. }
  44888. /**
  44889. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44890. * what is happening in your scene
  44891. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44892. */
  44893. export class DebugLayer {
  44894. /**
  44895. * Define the url to get the inspector script from.
  44896. * By default it uses the babylonjs CDN.
  44897. * @ignoreNaming
  44898. */
  44899. static InspectorURL: string;
  44900. private _scene;
  44901. private BJSINSPECTOR;
  44902. private _onPropertyChangedObservable?;
  44903. /**
  44904. * Observable triggered when a property is changed through the inspector.
  44905. */
  44906. readonly onPropertyChangedObservable: any;
  44907. /**
  44908. * Instantiates a new debug layer.
  44909. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44910. * what is happening in your scene
  44911. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44912. * @param scene Defines the scene to inspect
  44913. */
  44914. constructor(scene: Scene);
  44915. /** Creates the inspector window. */
  44916. private _createInspector;
  44917. /**
  44918. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44919. * @param entity defines the entity to select
  44920. * @param lineContainerTitle defines the specific block to highlight
  44921. */
  44922. select(entity: any, lineContainerTitle?: string): void;
  44923. /** Get the inspector from bundle or global */
  44924. private _getGlobalInspector;
  44925. /**
  44926. * Get if the inspector is visible or not.
  44927. * @returns true if visible otherwise, false
  44928. */
  44929. isVisible(): boolean;
  44930. /**
  44931. * Hide the inspector and close its window.
  44932. */
  44933. hide(): void;
  44934. /**
  44935. * Launch the debugLayer.
  44936. * @param config Define the configuration of the inspector
  44937. * @return a promise fulfilled when the debug layer is visible
  44938. */
  44939. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44940. }
  44941. }
  44942. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44943. import { Nullable } from "babylonjs/types";
  44944. import { Scene } from "babylonjs/scene";
  44945. import { Vector4 } from "babylonjs/Maths/math.vector";
  44946. import { Color4 } from "babylonjs/Maths/math.color";
  44947. import { Mesh } from "babylonjs/Meshes/mesh";
  44948. /**
  44949. * Class containing static functions to help procedurally build meshes
  44950. */
  44951. export class BoxBuilder {
  44952. /**
  44953. * Creates a box mesh
  44954. * * The parameter `size` sets the size (float) of each box side (default 1)
  44955. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44956. * * 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)
  44957. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44961. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44962. * @param name defines the name of the mesh
  44963. * @param options defines the options used to create the mesh
  44964. * @param scene defines the hosting scene
  44965. * @returns the box mesh
  44966. */
  44967. static CreateBox(name: string, options: {
  44968. size?: number;
  44969. width?: number;
  44970. height?: number;
  44971. depth?: number;
  44972. faceUV?: Vector4[];
  44973. faceColors?: Color4[];
  44974. sideOrientation?: number;
  44975. frontUVs?: Vector4;
  44976. backUVs?: Vector4;
  44977. wrap?: boolean;
  44978. topBaseAt?: number;
  44979. bottomBaseAt?: number;
  44980. updatable?: boolean;
  44981. }, scene?: Nullable<Scene>): Mesh;
  44982. }
  44983. }
  44984. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44985. import { Vector4 } from "babylonjs/Maths/math.vector";
  44986. import { Mesh } from "babylonjs/Meshes/mesh";
  44987. import { Scene } from "babylonjs/scene";
  44988. import { Nullable } from "babylonjs/types";
  44989. /**
  44990. * Class containing static functions to help procedurally build meshes
  44991. */
  44992. export class SphereBuilder {
  44993. /**
  44994. * Creates a sphere mesh
  44995. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44996. * * 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`)
  44997. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44998. * * 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
  44999. * * 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)
  45000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45003. * @param name defines the name of the mesh
  45004. * @param options defines the options used to create the mesh
  45005. * @param scene defines the hosting scene
  45006. * @returns the sphere mesh
  45007. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45008. */
  45009. static CreateSphere(name: string, options: {
  45010. segments?: number;
  45011. diameter?: number;
  45012. diameterX?: number;
  45013. diameterY?: number;
  45014. diameterZ?: number;
  45015. arc?: number;
  45016. slice?: number;
  45017. sideOrientation?: number;
  45018. frontUVs?: Vector4;
  45019. backUVs?: Vector4;
  45020. updatable?: boolean;
  45021. }, scene?: Nullable<Scene>): Mesh;
  45022. }
  45023. }
  45024. declare module "babylonjs/Debug/physicsViewer" {
  45025. import { Nullable } from "babylonjs/types";
  45026. import { Scene } from "babylonjs/scene";
  45027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45028. import { Mesh } from "babylonjs/Meshes/mesh";
  45029. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45030. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45031. /**
  45032. * Used to show the physics impostor around the specific mesh
  45033. */
  45034. export class PhysicsViewer {
  45035. /** @hidden */
  45036. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45037. /** @hidden */
  45038. protected _meshes: Array<Nullable<AbstractMesh>>;
  45039. /** @hidden */
  45040. protected _scene: Nullable<Scene>;
  45041. /** @hidden */
  45042. protected _numMeshes: number;
  45043. /** @hidden */
  45044. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45045. private _renderFunction;
  45046. private _utilityLayer;
  45047. private _debugBoxMesh;
  45048. private _debugSphereMesh;
  45049. private _debugCylinderMesh;
  45050. private _debugMaterial;
  45051. private _debugMeshMeshes;
  45052. /**
  45053. * Creates a new PhysicsViewer
  45054. * @param scene defines the hosting scene
  45055. */
  45056. constructor(scene: Scene);
  45057. /** @hidden */
  45058. protected _updateDebugMeshes(): void;
  45059. /**
  45060. * Renders a specified physic impostor
  45061. * @param impostor defines the impostor to render
  45062. * @param targetMesh defines the mesh represented by the impostor
  45063. * @returns the new debug mesh used to render the impostor
  45064. */
  45065. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45066. /**
  45067. * Hides a specified physic impostor
  45068. * @param impostor defines the impostor to hide
  45069. */
  45070. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45071. private _getDebugMaterial;
  45072. private _getDebugBoxMesh;
  45073. private _getDebugSphereMesh;
  45074. private _getDebugCylinderMesh;
  45075. private _getDebugMeshMesh;
  45076. private _getDebugMesh;
  45077. /** Releases all resources */
  45078. dispose(): void;
  45079. }
  45080. }
  45081. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45082. import { Vector3 } from "babylonjs/Maths/math.vector";
  45083. import { Color4 } from "babylonjs/Maths/math.color";
  45084. import { Nullable } from "babylonjs/types";
  45085. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45086. import { Scene } from "babylonjs/scene";
  45087. /**
  45088. * Class containing static functions to help procedurally build meshes
  45089. */
  45090. export class LinesBuilder {
  45091. /**
  45092. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45093. * * 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
  45094. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45095. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45096. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45097. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45098. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45099. * * 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
  45100. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45103. * @param name defines the name of the new line system
  45104. * @param options defines the options used to create the line system
  45105. * @param scene defines the hosting scene
  45106. * @returns a new line system mesh
  45107. */
  45108. static CreateLineSystem(name: string, options: {
  45109. lines: Vector3[][];
  45110. updatable?: boolean;
  45111. instance?: Nullable<LinesMesh>;
  45112. colors?: Nullable<Color4[][]>;
  45113. useVertexAlpha?: boolean;
  45114. }, scene: Nullable<Scene>): LinesMesh;
  45115. /**
  45116. * Creates a line mesh
  45117. * 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
  45118. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45119. * * The parameter `points` is an array successive Vector3
  45120. * * 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
  45121. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45122. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45123. * * When updating an instance, remember that only point positions can change, not the number of points
  45124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45125. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45126. * @param name defines the name of the new line system
  45127. * @param options defines the options used to create the line system
  45128. * @param scene defines the hosting scene
  45129. * @returns a new line mesh
  45130. */
  45131. static CreateLines(name: string, options: {
  45132. points: Vector3[];
  45133. updatable?: boolean;
  45134. instance?: Nullable<LinesMesh>;
  45135. colors?: Color4[];
  45136. useVertexAlpha?: boolean;
  45137. }, scene?: Nullable<Scene>): LinesMesh;
  45138. /**
  45139. * Creates a dashed line mesh
  45140. * * 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
  45141. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45142. * * The parameter `points` is an array successive Vector3
  45143. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45144. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45145. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45146. * * 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
  45147. * * When updating an instance, remember that only point positions can change, not the number of points
  45148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45149. * @param name defines the name of the mesh
  45150. * @param options defines the options used to create the mesh
  45151. * @param scene defines the hosting scene
  45152. * @returns the dashed line mesh
  45153. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45154. */
  45155. static CreateDashedLines(name: string, options: {
  45156. points: Vector3[];
  45157. dashSize?: number;
  45158. gapSize?: number;
  45159. dashNb?: number;
  45160. updatable?: boolean;
  45161. instance?: LinesMesh;
  45162. }, scene?: Nullable<Scene>): LinesMesh;
  45163. }
  45164. }
  45165. declare module "babylonjs/Debug/rayHelper" {
  45166. import { Nullable } from "babylonjs/types";
  45167. import { Ray } from "babylonjs/Culling/ray";
  45168. import { Vector3 } from "babylonjs/Maths/math.vector";
  45169. import { Color3 } from "babylonjs/Maths/math.color";
  45170. import { Scene } from "babylonjs/scene";
  45171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45172. import "babylonjs/Meshes/Builders/linesBuilder";
  45173. /**
  45174. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45175. * in order to better appreciate the issue one might have.
  45176. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45177. */
  45178. export class RayHelper {
  45179. /**
  45180. * Defines the ray we are currently tryin to visualize.
  45181. */
  45182. ray: Nullable<Ray>;
  45183. private _renderPoints;
  45184. private _renderLine;
  45185. private _renderFunction;
  45186. private _scene;
  45187. private _updateToMeshFunction;
  45188. private _attachedToMesh;
  45189. private _meshSpaceDirection;
  45190. private _meshSpaceOrigin;
  45191. /**
  45192. * Helper function to create a colored helper in a scene in one line.
  45193. * @param ray Defines the ray we are currently tryin to visualize
  45194. * @param scene Defines the scene the ray is used in
  45195. * @param color Defines the color we want to see the ray in
  45196. * @returns The newly created ray helper.
  45197. */
  45198. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45199. /**
  45200. * Instantiate a new ray helper.
  45201. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45202. * in order to better appreciate the issue one might have.
  45203. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45204. * @param ray Defines the ray we are currently tryin to visualize
  45205. */
  45206. constructor(ray: Ray);
  45207. /**
  45208. * Shows the ray we are willing to debug.
  45209. * @param scene Defines the scene the ray needs to be rendered in
  45210. * @param color Defines the color the ray needs to be rendered in
  45211. */
  45212. show(scene: Scene, color?: Color3): void;
  45213. /**
  45214. * Hides the ray we are debugging.
  45215. */
  45216. hide(): void;
  45217. private _render;
  45218. /**
  45219. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45220. * @param mesh Defines the mesh we want the helper attached to
  45221. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45222. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45223. * @param length Defines the length of the ray
  45224. */
  45225. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45226. /**
  45227. * Detach the ray helper from the mesh it has previously been attached to.
  45228. */
  45229. detachFromMesh(): void;
  45230. private _updateToMesh;
  45231. /**
  45232. * Dispose the helper and release its associated resources.
  45233. */
  45234. dispose(): void;
  45235. }
  45236. }
  45237. declare module "babylonjs/Debug/skeletonViewer" {
  45238. import { Color3 } from "babylonjs/Maths/math.color";
  45239. import { Scene } from "babylonjs/scene";
  45240. import { Nullable } from "babylonjs/types";
  45241. import { Skeleton } from "babylonjs/Bones/skeleton";
  45242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45243. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45244. /**
  45245. * Class used to render a debug view of a given skeleton
  45246. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45247. */
  45248. export class SkeletonViewer {
  45249. /** defines the skeleton to render */
  45250. skeleton: Skeleton;
  45251. /** defines the mesh attached to the skeleton */
  45252. mesh: AbstractMesh;
  45253. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45254. autoUpdateBonesMatrices: boolean;
  45255. /** defines the rendering group id to use with the viewer */
  45256. renderingGroupId: number;
  45257. /** Gets or sets the color used to render the skeleton */
  45258. color: Color3;
  45259. private _scene;
  45260. private _debugLines;
  45261. private _debugMesh;
  45262. private _isEnabled;
  45263. private _renderFunction;
  45264. private _utilityLayer;
  45265. /**
  45266. * Returns the mesh used to render the bones
  45267. */
  45268. readonly debugMesh: Nullable<LinesMesh>;
  45269. /**
  45270. * Creates a new SkeletonViewer
  45271. * @param skeleton defines the skeleton to render
  45272. * @param mesh defines the mesh attached to the skeleton
  45273. * @param scene defines the hosting scene
  45274. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45275. * @param renderingGroupId defines the rendering group id to use with the viewer
  45276. */
  45277. constructor(
  45278. /** defines the skeleton to render */
  45279. skeleton: Skeleton,
  45280. /** defines the mesh attached to the skeleton */
  45281. mesh: AbstractMesh, scene: Scene,
  45282. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45283. autoUpdateBonesMatrices?: boolean,
  45284. /** defines the rendering group id to use with the viewer */
  45285. renderingGroupId?: number);
  45286. /** Gets or sets a boolean indicating if the viewer is enabled */
  45287. isEnabled: boolean;
  45288. private _getBonePosition;
  45289. private _getLinesForBonesWithLength;
  45290. private _getLinesForBonesNoLength;
  45291. /** Update the viewer to sync with current skeleton state */
  45292. update(): void;
  45293. /** Release associated resources */
  45294. dispose(): void;
  45295. }
  45296. }
  45297. declare module "babylonjs/Debug/index" {
  45298. export * from "babylonjs/Debug/axesViewer";
  45299. export * from "babylonjs/Debug/boneAxesViewer";
  45300. export * from "babylonjs/Debug/debugLayer";
  45301. export * from "babylonjs/Debug/physicsViewer";
  45302. export * from "babylonjs/Debug/rayHelper";
  45303. export * from "babylonjs/Debug/skeletonViewer";
  45304. }
  45305. declare module "babylonjs/Engines/nullEngine" {
  45306. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45307. import { Scene } from "babylonjs/scene";
  45308. import { Engine } from "babylonjs/Engines/engine";
  45309. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45310. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45312. import { Effect } from "babylonjs/Materials/effect";
  45313. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45315. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45316. /**
  45317. * Options to create the null engine
  45318. */
  45319. export class NullEngineOptions {
  45320. /**
  45321. * Render width (Default: 512)
  45322. */
  45323. renderWidth: number;
  45324. /**
  45325. * Render height (Default: 256)
  45326. */
  45327. renderHeight: number;
  45328. /**
  45329. * Texture size (Default: 512)
  45330. */
  45331. textureSize: number;
  45332. /**
  45333. * If delta time between frames should be constant
  45334. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45335. */
  45336. deterministicLockstep: boolean;
  45337. /**
  45338. * Maximum about of steps between frames (Default: 4)
  45339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45340. */
  45341. lockstepMaxSteps: number;
  45342. }
  45343. /**
  45344. * The null engine class provides support for headless version of babylon.js.
  45345. * This can be used in server side scenario or for testing purposes
  45346. */
  45347. export class NullEngine extends Engine {
  45348. private _options;
  45349. /**
  45350. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45351. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45352. * @returns true if engine is in deterministic lock step mode
  45353. */
  45354. isDeterministicLockStep(): boolean;
  45355. /**
  45356. * Gets the max steps when engine is running in deterministic lock step
  45357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45358. * @returns the max steps
  45359. */
  45360. getLockstepMaxSteps(): number;
  45361. /**
  45362. * Gets the current hardware scaling level.
  45363. * By default the hardware scaling level is computed from the window device ratio.
  45364. * 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.
  45365. * @returns a number indicating the current hardware scaling level
  45366. */
  45367. getHardwareScalingLevel(): number;
  45368. constructor(options?: NullEngineOptions);
  45369. /**
  45370. * Creates a vertex buffer
  45371. * @param vertices the data for the vertex buffer
  45372. * @returns the new WebGL static buffer
  45373. */
  45374. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45375. /**
  45376. * Creates a new index buffer
  45377. * @param indices defines the content of the index buffer
  45378. * @param updatable defines if the index buffer must be updatable
  45379. * @returns a new webGL buffer
  45380. */
  45381. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45382. /**
  45383. * Clear the current render buffer or the current render target (if any is set up)
  45384. * @param color defines the color to use
  45385. * @param backBuffer defines if the back buffer must be cleared
  45386. * @param depth defines if the depth buffer must be cleared
  45387. * @param stencil defines if the stencil buffer must be cleared
  45388. */
  45389. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45390. /**
  45391. * Gets the current render width
  45392. * @param useScreen defines if screen size must be used (or the current render target if any)
  45393. * @returns a number defining the current render width
  45394. */
  45395. getRenderWidth(useScreen?: boolean): number;
  45396. /**
  45397. * Gets the current render height
  45398. * @param useScreen defines if screen size must be used (or the current render target if any)
  45399. * @returns a number defining the current render height
  45400. */
  45401. getRenderHeight(useScreen?: boolean): number;
  45402. /**
  45403. * Set the WebGL's viewport
  45404. * @param viewport defines the viewport element to be used
  45405. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45406. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45407. */
  45408. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45409. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45410. /**
  45411. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45412. * @param pipelineContext defines the pipeline context to use
  45413. * @param uniformsNames defines the list of uniform names
  45414. * @returns an array of webGL uniform locations
  45415. */
  45416. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45417. /**
  45418. * Gets the lsit of active attributes for a given webGL program
  45419. * @param pipelineContext defines the pipeline context to use
  45420. * @param attributesNames defines the list of attribute names to get
  45421. * @returns an array of indices indicating the offset of each attribute
  45422. */
  45423. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45424. /**
  45425. * Binds an effect to the webGL context
  45426. * @param effect defines the effect to bind
  45427. */
  45428. bindSamplers(effect: Effect): void;
  45429. /**
  45430. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45431. * @param effect defines the effect to activate
  45432. */
  45433. enableEffect(effect: Effect): void;
  45434. /**
  45435. * Set various states to the webGL context
  45436. * @param culling defines backface culling state
  45437. * @param zOffset defines the value to apply to zOffset (0 by default)
  45438. * @param force defines if states must be applied even if cache is up to date
  45439. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45440. */
  45441. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45442. /**
  45443. * Set the value of an uniform to an array of int32
  45444. * @param uniform defines the webGL uniform location where to store the value
  45445. * @param array defines the array of int32 to store
  45446. */
  45447. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45448. /**
  45449. * Set the value of an uniform to an array of int32 (stored as vec2)
  45450. * @param uniform defines the webGL uniform location where to store the value
  45451. * @param array defines the array of int32 to store
  45452. */
  45453. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45454. /**
  45455. * Set the value of an uniform to an array of int32 (stored as vec3)
  45456. * @param uniform defines the webGL uniform location where to store the value
  45457. * @param array defines the array of int32 to store
  45458. */
  45459. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45460. /**
  45461. * Set the value of an uniform to an array of int32 (stored as vec4)
  45462. * @param uniform defines the webGL uniform location where to store the value
  45463. * @param array defines the array of int32 to store
  45464. */
  45465. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45466. /**
  45467. * Set the value of an uniform to an array of float32
  45468. * @param uniform defines the webGL uniform location where to store the value
  45469. * @param array defines the array of float32 to store
  45470. */
  45471. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45472. /**
  45473. * Set the value of an uniform to an array of float32 (stored as vec2)
  45474. * @param uniform defines the webGL uniform location where to store the value
  45475. * @param array defines the array of float32 to store
  45476. */
  45477. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45478. /**
  45479. * Set the value of an uniform to an array of float32 (stored as vec3)
  45480. * @param uniform defines the webGL uniform location where to store the value
  45481. * @param array defines the array of float32 to store
  45482. */
  45483. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45484. /**
  45485. * Set the value of an uniform to an array of float32 (stored as vec4)
  45486. * @param uniform defines the webGL uniform location where to store the value
  45487. * @param array defines the array of float32 to store
  45488. */
  45489. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45490. /**
  45491. * Set the value of an uniform to an array of number
  45492. * @param uniform defines the webGL uniform location where to store the value
  45493. * @param array defines the array of number to store
  45494. */
  45495. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45496. /**
  45497. * Set the value of an uniform to an array of number (stored as vec2)
  45498. * @param uniform defines the webGL uniform location where to store the value
  45499. * @param array defines the array of number to store
  45500. */
  45501. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45502. /**
  45503. * Set the value of an uniform to an array of number (stored as vec3)
  45504. * @param uniform defines the webGL uniform location where to store the value
  45505. * @param array defines the array of number to store
  45506. */
  45507. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45508. /**
  45509. * Set the value of an uniform to an array of number (stored as vec4)
  45510. * @param uniform defines the webGL uniform location where to store the value
  45511. * @param array defines the array of number to store
  45512. */
  45513. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45514. /**
  45515. * Set the value of an uniform to an array of float32 (stored as matrices)
  45516. * @param uniform defines the webGL uniform location where to store the value
  45517. * @param matrices defines the array of float32 to store
  45518. */
  45519. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45520. /**
  45521. * Set the value of an uniform to a matrix (3x3)
  45522. * @param uniform defines the webGL uniform location where to store the value
  45523. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45524. */
  45525. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45526. /**
  45527. * Set the value of an uniform to a matrix (2x2)
  45528. * @param uniform defines the webGL uniform location where to store the value
  45529. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45530. */
  45531. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45532. /**
  45533. * Set the value of an uniform to a number (float)
  45534. * @param uniform defines the webGL uniform location where to store the value
  45535. * @param value defines the float number to store
  45536. */
  45537. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45538. /**
  45539. * Set the value of an uniform to a vec2
  45540. * @param uniform defines the webGL uniform location where to store the value
  45541. * @param x defines the 1st component of the value
  45542. * @param y defines the 2nd component of the value
  45543. */
  45544. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45545. /**
  45546. * Set the value of an uniform to a vec3
  45547. * @param uniform defines the webGL uniform location where to store the value
  45548. * @param x defines the 1st component of the value
  45549. * @param y defines the 2nd component of the value
  45550. * @param z defines the 3rd component of the value
  45551. */
  45552. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45553. /**
  45554. * Set the value of an uniform to a boolean
  45555. * @param uniform defines the webGL uniform location where to store the value
  45556. * @param bool defines the boolean to store
  45557. */
  45558. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45559. /**
  45560. * Set the value of an uniform to a vec4
  45561. * @param uniform defines the webGL uniform location where to store the value
  45562. * @param x defines the 1st component of the value
  45563. * @param y defines the 2nd component of the value
  45564. * @param z defines the 3rd component of the value
  45565. * @param w defines the 4th component of the value
  45566. */
  45567. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45568. /**
  45569. * Sets the current alpha mode
  45570. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45571. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45573. */
  45574. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45575. /**
  45576. * Bind webGl buffers directly to the webGL context
  45577. * @param vertexBuffers defines the vertex buffer to bind
  45578. * @param indexBuffer defines the index buffer to bind
  45579. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45580. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45581. * @param effect defines the effect associated with the vertex buffer
  45582. */
  45583. bindBuffers(vertexBuffers: {
  45584. [key: string]: VertexBuffer;
  45585. }, indexBuffer: DataBuffer, effect: Effect): void;
  45586. /**
  45587. * Force the entire cache to be cleared
  45588. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45589. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45590. */
  45591. wipeCaches(bruteForce?: boolean): void;
  45592. /**
  45593. * Send a draw order
  45594. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45595. * @param indexStart defines the starting index
  45596. * @param indexCount defines the number of index to draw
  45597. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45598. */
  45599. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45600. /**
  45601. * Draw a list of indexed primitives
  45602. * @param fillMode defines the primitive to use
  45603. * @param indexStart defines the starting index
  45604. * @param indexCount defines the number of index to draw
  45605. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45606. */
  45607. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45608. /**
  45609. * Draw a list of unindexed primitives
  45610. * @param fillMode defines the primitive to use
  45611. * @param verticesStart defines the index of first vertex to draw
  45612. * @param verticesCount defines the count of vertices to draw
  45613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45614. */
  45615. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45616. /** @hidden */
  45617. _createTexture(): WebGLTexture;
  45618. /** @hidden */
  45619. _releaseTexture(texture: InternalTexture): void;
  45620. /**
  45621. * Usually called from Texture.ts.
  45622. * Passed information to create a WebGLTexture
  45623. * @param urlArg defines a value which contains one of the following:
  45624. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45625. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45626. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45627. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45628. * @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)
  45629. * @param scene needed for loading to the correct scene
  45630. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45631. * @param onLoad optional callback to be called upon successful completion
  45632. * @param onError optional callback to be called upon failure
  45633. * @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
  45634. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45635. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45636. * @param forcedExtension defines the extension to use to pick the right loader
  45637. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45638. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45639. */
  45640. 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;
  45641. /**
  45642. * Creates a new render target texture
  45643. * @param size defines the size of the texture
  45644. * @param options defines the options used to create the texture
  45645. * @returns a new render target texture stored in an InternalTexture
  45646. */
  45647. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45648. /**
  45649. * Update the sampling mode of a given texture
  45650. * @param samplingMode defines the required sampling mode
  45651. * @param texture defines the texture to update
  45652. */
  45653. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45654. /**
  45655. * Binds the frame buffer to the specified texture.
  45656. * @param texture The texture to render to or null for the default canvas
  45657. * @param faceIndex The face of the texture to render to in case of cube texture
  45658. * @param requiredWidth The width of the target to render to
  45659. * @param requiredHeight The height of the target to render to
  45660. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45661. * @param depthStencilTexture The depth stencil texture to use to render
  45662. * @param lodLevel defines le lod level to bind to the frame buffer
  45663. */
  45664. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45665. /**
  45666. * Unbind the current render target texture from the webGL context
  45667. * @param texture defines the render target texture to unbind
  45668. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45669. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45670. */
  45671. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45672. /**
  45673. * Creates a dynamic vertex buffer
  45674. * @param vertices the data for the dynamic vertex buffer
  45675. * @returns the new WebGL dynamic buffer
  45676. */
  45677. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45678. /**
  45679. * Update the content of a dynamic texture
  45680. * @param texture defines the texture to update
  45681. * @param canvas defines the canvas containing the source
  45682. * @param invertY defines if data must be stored with Y axis inverted
  45683. * @param premulAlpha defines if alpha is stored as premultiplied
  45684. * @param format defines the format of the data
  45685. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45686. */
  45687. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45688. /**
  45689. * Gets a boolean indicating if all created effects are ready
  45690. * @returns true if all effects are ready
  45691. */
  45692. areAllEffectsReady(): boolean;
  45693. /**
  45694. * @hidden
  45695. * Get the current error code of the webGL context
  45696. * @returns the error code
  45697. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45698. */
  45699. getError(): number;
  45700. /** @hidden */
  45701. _getUnpackAlignement(): number;
  45702. /** @hidden */
  45703. _unpackFlipY(value: boolean): void;
  45704. /**
  45705. * Update a dynamic index buffer
  45706. * @param indexBuffer defines the target index buffer
  45707. * @param indices defines the data to update
  45708. * @param offset defines the offset in the target index buffer where update should start
  45709. */
  45710. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45711. /**
  45712. * Updates a dynamic vertex buffer.
  45713. * @param vertexBuffer the vertex buffer to update
  45714. * @param vertices the data used to update the vertex buffer
  45715. * @param byteOffset the byte offset of the data (optional)
  45716. * @param byteLength the byte length of the data (optional)
  45717. */
  45718. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45719. /** @hidden */
  45720. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45721. /** @hidden */
  45722. _bindTexture(channel: number, texture: InternalTexture): void;
  45723. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45724. /**
  45725. * 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
  45726. */
  45727. releaseEffects(): void;
  45728. displayLoadingUI(): void;
  45729. hideLoadingUI(): void;
  45730. /** @hidden */
  45731. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45732. /** @hidden */
  45733. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45734. /** @hidden */
  45735. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45736. /** @hidden */
  45737. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45738. }
  45739. }
  45740. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45741. import { Nullable, int } from "babylonjs/types";
  45742. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45743. /** @hidden */
  45744. export class _OcclusionDataStorage {
  45745. /** @hidden */
  45746. occlusionInternalRetryCounter: number;
  45747. /** @hidden */
  45748. isOcclusionQueryInProgress: boolean;
  45749. /** @hidden */
  45750. isOccluded: boolean;
  45751. /** @hidden */
  45752. occlusionRetryCount: number;
  45753. /** @hidden */
  45754. occlusionType: number;
  45755. /** @hidden */
  45756. occlusionQueryAlgorithmType: number;
  45757. }
  45758. module "babylonjs/Engines/engine" {
  45759. interface Engine {
  45760. /**
  45761. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45762. * @return the new query
  45763. */
  45764. createQuery(): WebGLQuery;
  45765. /**
  45766. * Delete and release a webGL query
  45767. * @param query defines the query to delete
  45768. * @return the current engine
  45769. */
  45770. deleteQuery(query: WebGLQuery): Engine;
  45771. /**
  45772. * Check if a given query has resolved and got its value
  45773. * @param query defines the query to check
  45774. * @returns true if the query got its value
  45775. */
  45776. isQueryResultAvailable(query: WebGLQuery): boolean;
  45777. /**
  45778. * Gets the value of a given query
  45779. * @param query defines the query to check
  45780. * @returns the value of the query
  45781. */
  45782. getQueryResult(query: WebGLQuery): number;
  45783. /**
  45784. * Initiates an occlusion query
  45785. * @param algorithmType defines the algorithm to use
  45786. * @param query defines the query to use
  45787. * @returns the current engine
  45788. * @see http://doc.babylonjs.com/features/occlusionquery
  45789. */
  45790. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45791. /**
  45792. * Ends an occlusion query
  45793. * @see http://doc.babylonjs.com/features/occlusionquery
  45794. * @param algorithmType defines the algorithm to use
  45795. * @returns the current engine
  45796. */
  45797. endOcclusionQuery(algorithmType: number): Engine;
  45798. /**
  45799. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45800. * Please note that only one query can be issued at a time
  45801. * @returns a time token used to track the time span
  45802. */
  45803. startTimeQuery(): Nullable<_TimeToken>;
  45804. /**
  45805. * Ends a time query
  45806. * @param token defines the token used to measure the time span
  45807. * @returns the time spent (in ns)
  45808. */
  45809. endTimeQuery(token: _TimeToken): int;
  45810. /** @hidden */
  45811. _currentNonTimestampToken: Nullable<_TimeToken>;
  45812. /** @hidden */
  45813. _createTimeQuery(): WebGLQuery;
  45814. /** @hidden */
  45815. _deleteTimeQuery(query: WebGLQuery): void;
  45816. /** @hidden */
  45817. _getGlAlgorithmType(algorithmType: number): number;
  45818. /** @hidden */
  45819. _getTimeQueryResult(query: WebGLQuery): any;
  45820. /** @hidden */
  45821. _getTimeQueryAvailability(query: WebGLQuery): any;
  45822. }
  45823. }
  45824. module "babylonjs/Meshes/abstractMesh" {
  45825. interface AbstractMesh {
  45826. /**
  45827. * Backing filed
  45828. * @hidden
  45829. */
  45830. __occlusionDataStorage: _OcclusionDataStorage;
  45831. /**
  45832. * Access property
  45833. * @hidden
  45834. */
  45835. _occlusionDataStorage: _OcclusionDataStorage;
  45836. /**
  45837. * 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.
  45838. * The default value is -1 which means don't break the query and wait till the result
  45839. * @see http://doc.babylonjs.com/features/occlusionquery
  45840. */
  45841. occlusionRetryCount: number;
  45842. /**
  45843. * 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:
  45844. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45845. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45846. * * 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.
  45847. * @see http://doc.babylonjs.com/features/occlusionquery
  45848. */
  45849. occlusionType: number;
  45850. /**
  45851. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45852. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45853. * * 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.
  45854. * @see http://doc.babylonjs.com/features/occlusionquery
  45855. */
  45856. occlusionQueryAlgorithmType: number;
  45857. /**
  45858. * 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
  45859. * @see http://doc.babylonjs.com/features/occlusionquery
  45860. */
  45861. isOccluded: boolean;
  45862. /**
  45863. * Flag to check the progress status of the query
  45864. * @see http://doc.babylonjs.com/features/occlusionquery
  45865. */
  45866. isOcclusionQueryInProgress: boolean;
  45867. }
  45868. }
  45869. }
  45870. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45871. import { Nullable } from "babylonjs/types";
  45872. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45873. /** @hidden */
  45874. export var _forceTransformFeedbackToBundle: boolean;
  45875. module "babylonjs/Engines/engine" {
  45876. interface Engine {
  45877. /**
  45878. * Creates a webGL transform feedback object
  45879. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45880. * @returns the webGL transform feedback object
  45881. */
  45882. createTransformFeedback(): WebGLTransformFeedback;
  45883. /**
  45884. * Delete a webGL transform feedback object
  45885. * @param value defines the webGL transform feedback object to delete
  45886. */
  45887. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45888. /**
  45889. * Bind a webGL transform feedback object to the webgl context
  45890. * @param value defines the webGL transform feedback object to bind
  45891. */
  45892. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45893. /**
  45894. * Begins a transform feedback operation
  45895. * @param usePoints defines if points or triangles must be used
  45896. */
  45897. beginTransformFeedback(usePoints: boolean): void;
  45898. /**
  45899. * Ends a transform feedback operation
  45900. */
  45901. endTransformFeedback(): void;
  45902. /**
  45903. * Specify the varyings to use with transform feedback
  45904. * @param program defines the associated webGL program
  45905. * @param value defines the list of strings representing the varying names
  45906. */
  45907. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45908. /**
  45909. * Bind a webGL buffer for a transform feedback operation
  45910. * @param value defines the webGL buffer to bind
  45911. */
  45912. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45913. }
  45914. }
  45915. }
  45916. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45917. import { Scene } from "babylonjs/scene";
  45918. import { Engine } from "babylonjs/Engines/engine";
  45919. import { Texture } from "babylonjs/Materials/Textures/texture";
  45920. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45921. import "babylonjs/Engines/Extensions/engine.multiRender";
  45922. /**
  45923. * Creation options of the multi render target texture.
  45924. */
  45925. export interface IMultiRenderTargetOptions {
  45926. /**
  45927. * Define if the texture needs to create mip maps after render.
  45928. */
  45929. generateMipMaps?: boolean;
  45930. /**
  45931. * Define the types of all the draw buffers we want to create
  45932. */
  45933. types?: number[];
  45934. /**
  45935. * Define the sampling modes of all the draw buffers we want to create
  45936. */
  45937. samplingModes?: number[];
  45938. /**
  45939. * Define if a depth buffer is required
  45940. */
  45941. generateDepthBuffer?: boolean;
  45942. /**
  45943. * Define if a stencil buffer is required
  45944. */
  45945. generateStencilBuffer?: boolean;
  45946. /**
  45947. * Define if a depth texture is required instead of a depth buffer
  45948. */
  45949. generateDepthTexture?: boolean;
  45950. /**
  45951. * Define the number of desired draw buffers
  45952. */
  45953. textureCount?: number;
  45954. /**
  45955. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45956. */
  45957. doNotChangeAspectRatio?: boolean;
  45958. /**
  45959. * Define the default type of the buffers we are creating
  45960. */
  45961. defaultType?: number;
  45962. }
  45963. /**
  45964. * A multi render target, like a render target provides the ability to render to a texture.
  45965. * Unlike the render target, it can render to several draw buffers in one draw.
  45966. * This is specially interesting in deferred rendering or for any effects requiring more than
  45967. * just one color from a single pass.
  45968. */
  45969. export class MultiRenderTarget extends RenderTargetTexture {
  45970. private _internalTextures;
  45971. private _textures;
  45972. private _multiRenderTargetOptions;
  45973. /**
  45974. * Get if draw buffers are currently supported by the used hardware and browser.
  45975. */
  45976. readonly isSupported: boolean;
  45977. /**
  45978. * Get the list of textures generated by the multi render target.
  45979. */
  45980. readonly textures: Texture[];
  45981. /**
  45982. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45983. */
  45984. readonly depthTexture: Texture;
  45985. /**
  45986. * Set the wrapping mode on U of all the textures we are rendering to.
  45987. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45988. */
  45989. wrapU: number;
  45990. /**
  45991. * Set the wrapping mode on V of all the textures we are rendering to.
  45992. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45993. */
  45994. wrapV: number;
  45995. /**
  45996. * Instantiate a new multi render target texture.
  45997. * A multi render target, like a render target provides the ability to render to a texture.
  45998. * Unlike the render target, it can render to several draw buffers in one draw.
  45999. * This is specially interesting in deferred rendering or for any effects requiring more than
  46000. * just one color from a single pass.
  46001. * @param name Define the name of the texture
  46002. * @param size Define the size of the buffers to render to
  46003. * @param count Define the number of target we are rendering into
  46004. * @param scene Define the scene the texture belongs to
  46005. * @param options Define the options used to create the multi render target
  46006. */
  46007. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46008. /** @hidden */
  46009. _rebuild(): void;
  46010. private _createInternalTextures;
  46011. private _createTextures;
  46012. /**
  46013. * Define the number of samples used if MSAA is enabled.
  46014. */
  46015. samples: number;
  46016. /**
  46017. * Resize all the textures in the multi render target.
  46018. * Be carrefull as it will recreate all the data in the new texture.
  46019. * @param size Define the new size
  46020. */
  46021. resize(size: any): void;
  46022. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46023. /**
  46024. * Dispose the render targets and their associated resources
  46025. */
  46026. dispose(): void;
  46027. /**
  46028. * Release all the underlying texture used as draw buffers.
  46029. */
  46030. releaseInternalTextures(): void;
  46031. }
  46032. }
  46033. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46034. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46035. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46036. import { Nullable } from "babylonjs/types";
  46037. module "babylonjs/Engines/thinEngine" {
  46038. interface ThinEngine {
  46039. /**
  46040. * Unbind a list of render target textures from the webGL context
  46041. * This is used only when drawBuffer extension or webGL2 are active
  46042. * @param textures defines the render target textures to unbind
  46043. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46044. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46045. */
  46046. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46047. /**
  46048. * Create a multi render target texture
  46049. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46050. * @param size defines the size of the texture
  46051. * @param options defines the creation options
  46052. * @returns the cube texture as an InternalTexture
  46053. */
  46054. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46055. /**
  46056. * Update the sample count for a given multiple render target texture
  46057. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46058. * @param textures defines the textures to update
  46059. * @param samples defines the sample count to set
  46060. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46061. */
  46062. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46063. }
  46064. }
  46065. }
  46066. declare module "babylonjs/Engines/Extensions/index" {
  46067. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46068. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46069. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46070. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46071. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46072. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46073. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46074. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46075. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46076. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46077. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46078. }
  46079. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46080. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46081. /** @hidden */
  46082. export var rgbdEncodePixelShader: {
  46083. name: string;
  46084. shader: string;
  46085. };
  46086. }
  46087. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46088. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46089. /** @hidden */
  46090. export var rgbdDecodePixelShader: {
  46091. name: string;
  46092. shader: string;
  46093. };
  46094. }
  46095. declare module "babylonjs/Misc/environmentTextureTools" {
  46096. import { Nullable } from "babylonjs/types";
  46097. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46098. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46099. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46100. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46101. import "babylonjs/Shaders/rgbdEncode.fragment";
  46102. import "babylonjs/Shaders/rgbdDecode.fragment";
  46103. /**
  46104. * Raw texture data and descriptor sufficient for WebGL texture upload
  46105. */
  46106. export interface EnvironmentTextureInfo {
  46107. /**
  46108. * Version of the environment map
  46109. */
  46110. version: number;
  46111. /**
  46112. * Width of image
  46113. */
  46114. width: number;
  46115. /**
  46116. * Irradiance information stored in the file.
  46117. */
  46118. irradiance: any;
  46119. /**
  46120. * Specular information stored in the file.
  46121. */
  46122. specular: any;
  46123. }
  46124. /**
  46125. * Defines One Image in the file. It requires only the position in the file
  46126. * as well as the length.
  46127. */
  46128. interface BufferImageData {
  46129. /**
  46130. * Length of the image data.
  46131. */
  46132. length: number;
  46133. /**
  46134. * Position of the data from the null terminator delimiting the end of the JSON.
  46135. */
  46136. position: number;
  46137. }
  46138. /**
  46139. * Defines the specular data enclosed in the file.
  46140. * This corresponds to the version 1 of the data.
  46141. */
  46142. export interface EnvironmentTextureSpecularInfoV1 {
  46143. /**
  46144. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46145. */
  46146. specularDataPosition?: number;
  46147. /**
  46148. * This contains all the images data needed to reconstruct the cubemap.
  46149. */
  46150. mipmaps: Array<BufferImageData>;
  46151. /**
  46152. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46153. */
  46154. lodGenerationScale: number;
  46155. }
  46156. /**
  46157. * Sets of helpers addressing the serialization and deserialization of environment texture
  46158. * stored in a BabylonJS env file.
  46159. * Those files are usually stored as .env files.
  46160. */
  46161. export class EnvironmentTextureTools {
  46162. /**
  46163. * Magic number identifying the env file.
  46164. */
  46165. private static _MagicBytes;
  46166. /**
  46167. * Gets the environment info from an env file.
  46168. * @param data The array buffer containing the .env bytes.
  46169. * @returns the environment file info (the json header) if successfully parsed.
  46170. */
  46171. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46172. /**
  46173. * Creates an environment texture from a loaded cube texture.
  46174. * @param texture defines the cube texture to convert in env file
  46175. * @return a promise containing the environment data if succesfull.
  46176. */
  46177. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46178. /**
  46179. * Creates a JSON representation of the spherical data.
  46180. * @param texture defines the texture containing the polynomials
  46181. * @return the JSON representation of the spherical info
  46182. */
  46183. private static _CreateEnvTextureIrradiance;
  46184. /**
  46185. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46186. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46187. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46188. * @return the views described by info providing access to the underlying buffer
  46189. */
  46190. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46191. /**
  46192. * Uploads the texture info contained in the env file to the GPU.
  46193. * @param texture defines the internal texture to upload to
  46194. * @param arrayBuffer defines the buffer cotaining the data to load
  46195. * @param info defines the texture info retrieved through the GetEnvInfo method
  46196. * @returns a promise
  46197. */
  46198. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46199. /**
  46200. * Uploads the levels of image data to the GPU.
  46201. * @param texture defines the internal texture to upload to
  46202. * @param imageData defines the array buffer views of image data [mipmap][face]
  46203. * @returns a promise
  46204. */
  46205. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46206. /**
  46207. * Uploads spherical polynomials information to the texture.
  46208. * @param texture defines the texture we are trying to upload the information to
  46209. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46210. */
  46211. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46212. /** @hidden */
  46213. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46214. }
  46215. }
  46216. declare module "babylonjs/Maths/math.vertexFormat" {
  46217. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46218. /**
  46219. * Contains position and normal vectors for a vertex
  46220. */
  46221. export class PositionNormalVertex {
  46222. /** the position of the vertex (defaut: 0,0,0) */
  46223. position: Vector3;
  46224. /** the normal of the vertex (defaut: 0,1,0) */
  46225. normal: Vector3;
  46226. /**
  46227. * Creates a PositionNormalVertex
  46228. * @param position the position of the vertex (defaut: 0,0,0)
  46229. * @param normal the normal of the vertex (defaut: 0,1,0)
  46230. */
  46231. constructor(
  46232. /** the position of the vertex (defaut: 0,0,0) */
  46233. position?: Vector3,
  46234. /** the normal of the vertex (defaut: 0,1,0) */
  46235. normal?: Vector3);
  46236. /**
  46237. * Clones the PositionNormalVertex
  46238. * @returns the cloned PositionNormalVertex
  46239. */
  46240. clone(): PositionNormalVertex;
  46241. }
  46242. /**
  46243. * Contains position, normal and uv vectors for a vertex
  46244. */
  46245. export class PositionNormalTextureVertex {
  46246. /** the position of the vertex (defaut: 0,0,0) */
  46247. position: Vector3;
  46248. /** the normal of the vertex (defaut: 0,1,0) */
  46249. normal: Vector3;
  46250. /** the uv of the vertex (default: 0,0) */
  46251. uv: Vector2;
  46252. /**
  46253. * Creates a PositionNormalTextureVertex
  46254. * @param position the position of the vertex (defaut: 0,0,0)
  46255. * @param normal the normal of the vertex (defaut: 0,1,0)
  46256. * @param uv the uv of the vertex (default: 0,0)
  46257. */
  46258. constructor(
  46259. /** the position of the vertex (defaut: 0,0,0) */
  46260. position?: Vector3,
  46261. /** the normal of the vertex (defaut: 0,1,0) */
  46262. normal?: Vector3,
  46263. /** the uv of the vertex (default: 0,0) */
  46264. uv?: Vector2);
  46265. /**
  46266. * Clones the PositionNormalTextureVertex
  46267. * @returns the cloned PositionNormalTextureVertex
  46268. */
  46269. clone(): PositionNormalTextureVertex;
  46270. }
  46271. }
  46272. declare module "babylonjs/Maths/math" {
  46273. export * from "babylonjs/Maths/math.axis";
  46274. export * from "babylonjs/Maths/math.color";
  46275. export * from "babylonjs/Maths/math.constants";
  46276. export * from "babylonjs/Maths/math.frustum";
  46277. export * from "babylonjs/Maths/math.path";
  46278. export * from "babylonjs/Maths/math.plane";
  46279. export * from "babylonjs/Maths/math.size";
  46280. export * from "babylonjs/Maths/math.vector";
  46281. export * from "babylonjs/Maths/math.vertexFormat";
  46282. export * from "babylonjs/Maths/math.viewport";
  46283. }
  46284. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46285. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46286. /** @hidden */
  46287. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46288. private _genericAttributeLocation;
  46289. private _varyingLocationCount;
  46290. private _varyingLocationMap;
  46291. private _replacements;
  46292. private _textureCount;
  46293. private _uniforms;
  46294. lineProcessor(line: string): string;
  46295. attributeProcessor(attribute: string): string;
  46296. varyingProcessor(varying: string, isFragment: boolean): string;
  46297. uniformProcessor(uniform: string): string;
  46298. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46299. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46300. }
  46301. }
  46302. declare module "babylonjs/Engines/nativeEngine" {
  46303. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46304. import { Engine } from "babylonjs/Engines/engine";
  46305. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46306. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46308. import { Effect } from "babylonjs/Materials/effect";
  46309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46310. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46311. import { Scene } from "babylonjs/scene";
  46312. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46313. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46314. /**
  46315. * Container for accessors for natively-stored mesh data buffers.
  46316. */
  46317. class NativeDataBuffer extends DataBuffer {
  46318. /**
  46319. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46320. */
  46321. nativeIndexBuffer?: any;
  46322. /**
  46323. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46324. */
  46325. nativeVertexBuffer?: any;
  46326. }
  46327. /** @hidden */
  46328. export class NativeEngine extends Engine {
  46329. private readonly _native;
  46330. getHardwareScalingLevel(): number;
  46331. constructor();
  46332. /**
  46333. * Can be used to override the current requestAnimationFrame requester.
  46334. * @hidden
  46335. */
  46336. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46337. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46338. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46339. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46340. recordVertexArrayObject(vertexBuffers: {
  46341. [key: string]: VertexBuffer;
  46342. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46343. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46344. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46345. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46346. /**
  46347. * Draw a list of indexed primitives
  46348. * @param fillMode defines the primitive to use
  46349. * @param indexStart defines the starting index
  46350. * @param indexCount defines the number of index to draw
  46351. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46352. */
  46353. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46354. /**
  46355. * Draw a list of unindexed primitives
  46356. * @param fillMode defines the primitive to use
  46357. * @param verticesStart defines the index of first vertex to draw
  46358. * @param verticesCount defines the count of vertices to draw
  46359. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46360. */
  46361. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46362. createPipelineContext(): IPipelineContext;
  46363. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46364. /** @hidden */
  46365. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46366. /** @hidden */
  46367. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46368. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46369. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46370. protected _setProgram(program: WebGLProgram): void;
  46371. _releaseEffect(effect: Effect): void;
  46372. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46373. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46374. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46375. bindSamplers(effect: Effect): void;
  46376. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46377. getRenderWidth(useScreen?: boolean): number;
  46378. getRenderHeight(useScreen?: boolean): number;
  46379. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46380. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46381. /**
  46382. * Set the z offset to apply to current rendering
  46383. * @param value defines the offset to apply
  46384. */
  46385. setZOffset(value: number): void;
  46386. /**
  46387. * Gets the current value of the zOffset
  46388. * @returns the current zOffset state
  46389. */
  46390. getZOffset(): number;
  46391. /**
  46392. * Enable or disable depth buffering
  46393. * @param enable defines the state to set
  46394. */
  46395. setDepthBuffer(enable: boolean): void;
  46396. /**
  46397. * Gets a boolean indicating if depth writing is enabled
  46398. * @returns the current depth writing state
  46399. */
  46400. getDepthWrite(): boolean;
  46401. /**
  46402. * Enable or disable depth writing
  46403. * @param enable defines the state to set
  46404. */
  46405. setDepthWrite(enable: boolean): void;
  46406. /**
  46407. * Enable or disable color writing
  46408. * @param enable defines the state to set
  46409. */
  46410. setColorWrite(enable: boolean): void;
  46411. /**
  46412. * Gets a boolean indicating if color writing is enabled
  46413. * @returns the current color writing state
  46414. */
  46415. getColorWrite(): boolean;
  46416. /**
  46417. * Sets alpha constants used by some alpha blending modes
  46418. * @param r defines the red component
  46419. * @param g defines the green component
  46420. * @param b defines the blue component
  46421. * @param a defines the alpha component
  46422. */
  46423. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46424. /**
  46425. * Sets the current alpha mode
  46426. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46427. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46428. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46429. */
  46430. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46431. /**
  46432. * Gets the current alpha mode
  46433. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46434. * @returns the current alpha mode
  46435. */
  46436. getAlphaMode(): number;
  46437. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46438. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46439. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46440. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46441. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46442. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46443. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46444. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46445. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46446. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46447. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46448. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46449. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46450. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46451. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46452. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46453. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46454. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46455. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46456. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46457. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46458. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46459. wipeCaches(bruteForce?: boolean): void;
  46460. _createTexture(): WebGLTexture;
  46461. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46462. /**
  46463. * Usually called from BABYLON.Texture.ts.
  46464. * Passed information to create a WebGLTexture
  46465. * @param urlArg defines a value which contains one of the following:
  46466. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46467. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46468. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46469. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46470. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46471. * @param scene needed for loading to the correct scene
  46472. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46473. * @param onLoad optional callback to be called upon successful completion
  46474. * @param onError optional callback to be called upon failure
  46475. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46476. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46477. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46478. * @param forcedExtension defines the extension to use to pick the right loader
  46479. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46480. */
  46481. 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;
  46482. /**
  46483. * Creates a cube texture
  46484. * @param rootUrl defines the url where the files to load is located
  46485. * @param scene defines the current scene
  46486. * @param files defines the list of files to load (1 per face)
  46487. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46488. * @param onLoad defines an optional callback raised when the texture is loaded
  46489. * @param onError defines an optional callback raised if there is an issue to load the texture
  46490. * @param format defines the format of the data
  46491. * @param forcedExtension defines the extension to use to pick the right loader
  46492. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46493. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46494. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46495. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46496. * @returns the cube texture as an InternalTexture
  46497. */
  46498. 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;
  46499. private _getSamplingFilter;
  46500. private static _GetNativeTextureFormat;
  46501. createRenderTargetTexture(size: number | {
  46502. width: number;
  46503. height: number;
  46504. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46505. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46506. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46507. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46508. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46509. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46510. /**
  46511. * Updates a dynamic vertex buffer.
  46512. * @param vertexBuffer the vertex buffer to update
  46513. * @param data the data used to update the vertex buffer
  46514. * @param byteOffset the byte offset of the data (optional)
  46515. * @param byteLength the byte length of the data (optional)
  46516. */
  46517. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46518. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46519. private _updateAnisotropicLevel;
  46520. private _getAddressMode;
  46521. /** @hidden */
  46522. _bindTexture(channel: number, texture: InternalTexture): void;
  46523. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46524. releaseEffects(): void;
  46525. /** @hidden */
  46526. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46527. /** @hidden */
  46528. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46529. /** @hidden */
  46530. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46531. /** @hidden */
  46532. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46533. }
  46534. }
  46535. declare module "babylonjs/Engines/index" {
  46536. export * from "babylonjs/Engines/constants";
  46537. export * from "babylonjs/Engines/engineCapabilities";
  46538. export * from "babylonjs/Engines/instancingAttributeInfo";
  46539. export * from "babylonjs/Engines/thinEngine";
  46540. export * from "babylonjs/Engines/engine";
  46541. export * from "babylonjs/Engines/engineStore";
  46542. export * from "babylonjs/Engines/nullEngine";
  46543. export * from "babylonjs/Engines/Extensions/index";
  46544. export * from "babylonjs/Engines/IPipelineContext";
  46545. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46546. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46547. export * from "babylonjs/Engines/nativeEngine";
  46548. }
  46549. declare module "babylonjs/Events/clipboardEvents" {
  46550. /**
  46551. * Gather the list of clipboard event types as constants.
  46552. */
  46553. export class ClipboardEventTypes {
  46554. /**
  46555. * The clipboard event is fired when a copy command is active (pressed).
  46556. */
  46557. static readonly COPY: number;
  46558. /**
  46559. * The clipboard event is fired when a cut command is active (pressed).
  46560. */
  46561. static readonly CUT: number;
  46562. /**
  46563. * The clipboard event is fired when a paste command is active (pressed).
  46564. */
  46565. static readonly PASTE: number;
  46566. }
  46567. /**
  46568. * This class is used to store clipboard related info for the onClipboardObservable event.
  46569. */
  46570. export class ClipboardInfo {
  46571. /**
  46572. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46573. */
  46574. type: number;
  46575. /**
  46576. * Defines the related dom event
  46577. */
  46578. event: ClipboardEvent;
  46579. /**
  46580. *Creates an instance of ClipboardInfo.
  46581. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46582. * @param event Defines the related dom event
  46583. */
  46584. constructor(
  46585. /**
  46586. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46587. */
  46588. type: number,
  46589. /**
  46590. * Defines the related dom event
  46591. */
  46592. event: ClipboardEvent);
  46593. /**
  46594. * Get the clipboard event's type from the keycode.
  46595. * @param keyCode Defines the keyCode for the current keyboard event.
  46596. * @return {number}
  46597. */
  46598. static GetTypeFromCharacter(keyCode: number): number;
  46599. }
  46600. }
  46601. declare module "babylonjs/Events/index" {
  46602. export * from "babylonjs/Events/keyboardEvents";
  46603. export * from "babylonjs/Events/pointerEvents";
  46604. export * from "babylonjs/Events/clipboardEvents";
  46605. }
  46606. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46607. import { Scene } from "babylonjs/scene";
  46608. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46609. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46610. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46611. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46612. /**
  46613. * Google Daydream controller
  46614. */
  46615. export class DaydreamController extends WebVRController {
  46616. /**
  46617. * Base Url for the controller model.
  46618. */
  46619. static MODEL_BASE_URL: string;
  46620. /**
  46621. * File name for the controller model.
  46622. */
  46623. static MODEL_FILENAME: string;
  46624. /**
  46625. * Gamepad Id prefix used to identify Daydream Controller.
  46626. */
  46627. static readonly GAMEPAD_ID_PREFIX: string;
  46628. /**
  46629. * Creates a new DaydreamController from a gamepad
  46630. * @param vrGamepad the gamepad that the controller should be created from
  46631. */
  46632. constructor(vrGamepad: any);
  46633. /**
  46634. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46635. * @param scene scene in which to add meshes
  46636. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46637. */
  46638. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46639. /**
  46640. * Called once for each button that changed state since the last frame
  46641. * @param buttonIdx Which button index changed
  46642. * @param state New state of the button
  46643. * @param changes Which properties on the state changed since last frame
  46644. */
  46645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46646. }
  46647. }
  46648. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46649. import { Scene } from "babylonjs/scene";
  46650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46651. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46652. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46653. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46654. /**
  46655. * Gear VR Controller
  46656. */
  46657. export class GearVRController extends WebVRController {
  46658. /**
  46659. * Base Url for the controller model.
  46660. */
  46661. static MODEL_BASE_URL: string;
  46662. /**
  46663. * File name for the controller model.
  46664. */
  46665. static MODEL_FILENAME: string;
  46666. /**
  46667. * Gamepad Id prefix used to identify this controller.
  46668. */
  46669. static readonly GAMEPAD_ID_PREFIX: string;
  46670. private readonly _buttonIndexToObservableNameMap;
  46671. /**
  46672. * Creates a new GearVRController from a gamepad
  46673. * @param vrGamepad the gamepad that the controller should be created from
  46674. */
  46675. constructor(vrGamepad: any);
  46676. /**
  46677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46678. * @param scene scene in which to add meshes
  46679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46680. */
  46681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46682. /**
  46683. * Called once for each button that changed state since the last frame
  46684. * @param buttonIdx Which button index changed
  46685. * @param state New state of the button
  46686. * @param changes Which properties on the state changed since last frame
  46687. */
  46688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46689. }
  46690. }
  46691. declare module "babylonjs/Gamepads/Controllers/index" {
  46692. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46693. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46694. export * from "babylonjs/Gamepads/Controllers/genericController";
  46695. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46696. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46697. export * from "babylonjs/Gamepads/Controllers/viveController";
  46698. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46699. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46700. }
  46701. declare module "babylonjs/Gamepads/index" {
  46702. export * from "babylonjs/Gamepads/Controllers/index";
  46703. export * from "babylonjs/Gamepads/gamepad";
  46704. export * from "babylonjs/Gamepads/gamepadManager";
  46705. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46706. export * from "babylonjs/Gamepads/xboxGamepad";
  46707. export * from "babylonjs/Gamepads/dualShockGamepad";
  46708. }
  46709. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46710. import { Scene } from "babylonjs/scene";
  46711. import { Vector4 } from "babylonjs/Maths/math.vector";
  46712. import { Color4 } from "babylonjs/Maths/math.color";
  46713. import { Mesh } from "babylonjs/Meshes/mesh";
  46714. import { Nullable } from "babylonjs/types";
  46715. /**
  46716. * Class containing static functions to help procedurally build meshes
  46717. */
  46718. export class PolyhedronBuilder {
  46719. /**
  46720. * Creates a polyhedron mesh
  46721. * * 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
  46722. * * The parameter `size` (positive float, default 1) sets the polygon size
  46723. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46724. * * 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`
  46725. * * 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
  46726. * * 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)`)
  46727. * * 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
  46728. * * 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
  46729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46732. * @param name defines the name of the mesh
  46733. * @param options defines the options used to create the mesh
  46734. * @param scene defines the hosting scene
  46735. * @returns the polyhedron mesh
  46736. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46737. */
  46738. static CreatePolyhedron(name: string, options: {
  46739. type?: number;
  46740. size?: number;
  46741. sizeX?: number;
  46742. sizeY?: number;
  46743. sizeZ?: number;
  46744. custom?: any;
  46745. faceUV?: Vector4[];
  46746. faceColors?: Color4[];
  46747. flat?: boolean;
  46748. updatable?: boolean;
  46749. sideOrientation?: number;
  46750. frontUVs?: Vector4;
  46751. backUVs?: Vector4;
  46752. }, scene?: Nullable<Scene>): Mesh;
  46753. }
  46754. }
  46755. declare module "babylonjs/Gizmos/scaleGizmo" {
  46756. import { Observable } from "babylonjs/Misc/observable";
  46757. import { Nullable } from "babylonjs/types";
  46758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46759. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46760. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46761. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46762. /**
  46763. * Gizmo that enables scaling a mesh along 3 axis
  46764. */
  46765. export class ScaleGizmo extends Gizmo {
  46766. /**
  46767. * Internal gizmo used for interactions on the x axis
  46768. */
  46769. xGizmo: AxisScaleGizmo;
  46770. /**
  46771. * Internal gizmo used for interactions on the y axis
  46772. */
  46773. yGizmo: AxisScaleGizmo;
  46774. /**
  46775. * Internal gizmo used for interactions on the z axis
  46776. */
  46777. zGizmo: AxisScaleGizmo;
  46778. /**
  46779. * Internal gizmo used to scale all axis equally
  46780. */
  46781. uniformScaleGizmo: AxisScaleGizmo;
  46782. private _meshAttached;
  46783. private _updateGizmoRotationToMatchAttachedMesh;
  46784. private _snapDistance;
  46785. private _scaleRatio;
  46786. private _uniformScalingMesh;
  46787. private _octahedron;
  46788. /** Fires an event when any of it's sub gizmos are dragged */
  46789. onDragStartObservable: Observable<unknown>;
  46790. /** Fires an event when any of it's sub gizmos are released from dragging */
  46791. onDragEndObservable: Observable<unknown>;
  46792. attachedMesh: Nullable<AbstractMesh>;
  46793. /**
  46794. * Creates a ScaleGizmo
  46795. * @param gizmoLayer The utility layer the gizmo will be added to
  46796. */
  46797. constructor(gizmoLayer?: UtilityLayerRenderer);
  46798. updateGizmoRotationToMatchAttachedMesh: boolean;
  46799. /**
  46800. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46801. */
  46802. snapDistance: number;
  46803. /**
  46804. * Ratio for the scale of the gizmo (Default: 1)
  46805. */
  46806. scaleRatio: number;
  46807. /**
  46808. * Disposes of the gizmo
  46809. */
  46810. dispose(): void;
  46811. }
  46812. }
  46813. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46814. import { Observable } from "babylonjs/Misc/observable";
  46815. import { Nullable } from "babylonjs/types";
  46816. import { Vector3 } from "babylonjs/Maths/math.vector";
  46817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46818. import { Mesh } from "babylonjs/Meshes/mesh";
  46819. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46820. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46821. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46822. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46823. import { Color3 } from "babylonjs/Maths/math.color";
  46824. /**
  46825. * Single axis scale gizmo
  46826. */
  46827. export class AxisScaleGizmo extends Gizmo {
  46828. /**
  46829. * Drag behavior responsible for the gizmos dragging interactions
  46830. */
  46831. dragBehavior: PointerDragBehavior;
  46832. private _pointerObserver;
  46833. /**
  46834. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46835. */
  46836. snapDistance: number;
  46837. /**
  46838. * Event that fires each time the gizmo snaps to a new location.
  46839. * * snapDistance is the the change in distance
  46840. */
  46841. onSnapObservable: Observable<{
  46842. snapDistance: number;
  46843. }>;
  46844. /**
  46845. * If the scaling operation should be done on all axis (default: false)
  46846. */
  46847. uniformScaling: boolean;
  46848. private _isEnabled;
  46849. private _parent;
  46850. private _arrow;
  46851. private _coloredMaterial;
  46852. private _hoverMaterial;
  46853. /**
  46854. * Creates an AxisScaleGizmo
  46855. * @param gizmoLayer The utility layer the gizmo will be added to
  46856. * @param dragAxis The axis which the gizmo will be able to scale on
  46857. * @param color The color of the gizmo
  46858. */
  46859. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46860. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46861. /**
  46862. * If the gizmo is enabled
  46863. */
  46864. isEnabled: boolean;
  46865. /**
  46866. * Disposes of the gizmo
  46867. */
  46868. dispose(): void;
  46869. /**
  46870. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46871. * @param mesh The mesh to replace the default mesh of the gizmo
  46872. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46873. */
  46874. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46875. }
  46876. }
  46877. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46878. import { Observable } from "babylonjs/Misc/observable";
  46879. import { Nullable } from "babylonjs/types";
  46880. import { Vector3 } from "babylonjs/Maths/math.vector";
  46881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46882. import { Mesh } from "babylonjs/Meshes/mesh";
  46883. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46884. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46885. import { Color3 } from "babylonjs/Maths/math.color";
  46886. import "babylonjs/Meshes/Builders/boxBuilder";
  46887. /**
  46888. * Bounding box gizmo
  46889. */
  46890. export class BoundingBoxGizmo extends Gizmo {
  46891. private _lineBoundingBox;
  46892. private _rotateSpheresParent;
  46893. private _scaleBoxesParent;
  46894. private _boundingDimensions;
  46895. private _renderObserver;
  46896. private _pointerObserver;
  46897. private _scaleDragSpeed;
  46898. private _tmpQuaternion;
  46899. private _tmpVector;
  46900. private _tmpRotationMatrix;
  46901. /**
  46902. * 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)
  46903. */
  46904. ignoreChildren: boolean;
  46905. /**
  46906. * 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)
  46907. */
  46908. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46909. /**
  46910. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46911. */
  46912. rotationSphereSize: number;
  46913. /**
  46914. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46915. */
  46916. scaleBoxSize: number;
  46917. /**
  46918. * 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)
  46919. */
  46920. fixedDragMeshScreenSize: boolean;
  46921. /**
  46922. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46923. */
  46924. fixedDragMeshScreenSizeDistanceFactor: number;
  46925. /**
  46926. * Fired when a rotation sphere or scale box is dragged
  46927. */
  46928. onDragStartObservable: Observable<{}>;
  46929. /**
  46930. * Fired when a scale box is dragged
  46931. */
  46932. onScaleBoxDragObservable: Observable<{}>;
  46933. /**
  46934. * Fired when a scale box drag is ended
  46935. */
  46936. onScaleBoxDragEndObservable: Observable<{}>;
  46937. /**
  46938. * Fired when a rotation sphere is dragged
  46939. */
  46940. onRotationSphereDragObservable: Observable<{}>;
  46941. /**
  46942. * Fired when a rotation sphere drag is ended
  46943. */
  46944. onRotationSphereDragEndObservable: Observable<{}>;
  46945. /**
  46946. * 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)
  46947. */
  46948. scalePivot: Nullable<Vector3>;
  46949. /**
  46950. * Mesh used as a pivot to rotate the attached mesh
  46951. */
  46952. private _anchorMesh;
  46953. private _existingMeshScale;
  46954. private _dragMesh;
  46955. private pointerDragBehavior;
  46956. private coloredMaterial;
  46957. private hoverColoredMaterial;
  46958. /**
  46959. * Sets the color of the bounding box gizmo
  46960. * @param color the color to set
  46961. */
  46962. setColor(color: Color3): void;
  46963. /**
  46964. * Creates an BoundingBoxGizmo
  46965. * @param gizmoLayer The utility layer the gizmo will be added to
  46966. * @param color The color of the gizmo
  46967. */
  46968. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46969. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46970. private _selectNode;
  46971. /**
  46972. * Updates the bounding box information for the Gizmo
  46973. */
  46974. updateBoundingBox(): void;
  46975. private _updateRotationSpheres;
  46976. private _updateScaleBoxes;
  46977. /**
  46978. * Enables rotation on the specified axis and disables rotation on the others
  46979. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46980. */
  46981. setEnabledRotationAxis(axis: string): void;
  46982. /**
  46983. * Enables/disables scaling
  46984. * @param enable if scaling should be enabled
  46985. */
  46986. setEnabledScaling(enable: boolean): void;
  46987. private _updateDummy;
  46988. /**
  46989. * Enables a pointer drag behavior on the bounding box of the gizmo
  46990. */
  46991. enableDragBehavior(): void;
  46992. /**
  46993. * Disposes of the gizmo
  46994. */
  46995. dispose(): void;
  46996. /**
  46997. * 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)
  46998. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46999. * @returns the bounding box mesh with the passed in mesh as a child
  47000. */
  47001. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47002. /**
  47003. * CustomMeshes are not supported by this gizmo
  47004. * @param mesh The mesh to replace the default mesh of the gizmo
  47005. */
  47006. setCustomMesh(mesh: Mesh): void;
  47007. }
  47008. }
  47009. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47010. import { Observable } from "babylonjs/Misc/observable";
  47011. import { Nullable } from "babylonjs/types";
  47012. import { Vector3 } from "babylonjs/Maths/math.vector";
  47013. import { Color3 } from "babylonjs/Maths/math.color";
  47014. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47015. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47016. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47017. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47018. import "babylonjs/Meshes/Builders/linesBuilder";
  47019. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47020. /**
  47021. * Single plane rotation gizmo
  47022. */
  47023. export class PlaneRotationGizmo extends Gizmo {
  47024. /**
  47025. * Drag behavior responsible for the gizmos dragging interactions
  47026. */
  47027. dragBehavior: PointerDragBehavior;
  47028. private _pointerObserver;
  47029. /**
  47030. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47031. */
  47032. snapDistance: number;
  47033. /**
  47034. * Event that fires each time the gizmo snaps to a new location.
  47035. * * snapDistance is the the change in distance
  47036. */
  47037. onSnapObservable: Observable<{
  47038. snapDistance: number;
  47039. }>;
  47040. private _isEnabled;
  47041. private _parent;
  47042. /**
  47043. * Creates a PlaneRotationGizmo
  47044. * @param gizmoLayer The utility layer the gizmo will be added to
  47045. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47046. * @param color The color of the gizmo
  47047. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47048. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47049. */
  47050. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47051. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47052. /**
  47053. * If the gizmo is enabled
  47054. */
  47055. isEnabled: boolean;
  47056. /**
  47057. * Disposes of the gizmo
  47058. */
  47059. dispose(): void;
  47060. }
  47061. }
  47062. declare module "babylonjs/Gizmos/rotationGizmo" {
  47063. import { Observable } from "babylonjs/Misc/observable";
  47064. import { Nullable } from "babylonjs/types";
  47065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47066. import { Mesh } from "babylonjs/Meshes/mesh";
  47067. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47068. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47069. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47070. /**
  47071. * Gizmo that enables rotating a mesh along 3 axis
  47072. */
  47073. export class RotationGizmo extends Gizmo {
  47074. /**
  47075. * Internal gizmo used for interactions on the x axis
  47076. */
  47077. xGizmo: PlaneRotationGizmo;
  47078. /**
  47079. * Internal gizmo used for interactions on the y axis
  47080. */
  47081. yGizmo: PlaneRotationGizmo;
  47082. /**
  47083. * Internal gizmo used for interactions on the z axis
  47084. */
  47085. zGizmo: PlaneRotationGizmo;
  47086. /** Fires an event when any of it's sub gizmos are dragged */
  47087. onDragStartObservable: Observable<unknown>;
  47088. /** Fires an event when any of it's sub gizmos are released from dragging */
  47089. onDragEndObservable: Observable<unknown>;
  47090. private _meshAttached;
  47091. attachedMesh: Nullable<AbstractMesh>;
  47092. /**
  47093. * Creates a RotationGizmo
  47094. * @param gizmoLayer The utility layer the gizmo will be added to
  47095. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47096. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47097. */
  47098. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47099. updateGizmoRotationToMatchAttachedMesh: boolean;
  47100. /**
  47101. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47102. */
  47103. snapDistance: number;
  47104. /**
  47105. * Ratio for the scale of the gizmo (Default: 1)
  47106. */
  47107. scaleRatio: number;
  47108. /**
  47109. * Disposes of the gizmo
  47110. */
  47111. dispose(): void;
  47112. /**
  47113. * CustomMeshes are not supported by this gizmo
  47114. * @param mesh The mesh to replace the default mesh of the gizmo
  47115. */
  47116. setCustomMesh(mesh: Mesh): void;
  47117. }
  47118. }
  47119. declare module "babylonjs/Gizmos/gizmoManager" {
  47120. import { Observable } from "babylonjs/Misc/observable";
  47121. import { Nullable } from "babylonjs/types";
  47122. import { Scene, IDisposable } from "babylonjs/scene";
  47123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47124. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47125. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47126. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47127. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47128. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47129. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47130. /**
  47131. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47132. */
  47133. export class GizmoManager implements IDisposable {
  47134. private scene;
  47135. /**
  47136. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47137. */
  47138. gizmos: {
  47139. positionGizmo: Nullable<PositionGizmo>;
  47140. rotationGizmo: Nullable<RotationGizmo>;
  47141. scaleGizmo: Nullable<ScaleGizmo>;
  47142. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47143. };
  47144. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47145. clearGizmoOnEmptyPointerEvent: boolean;
  47146. /** Fires an event when the manager is attached to a mesh */
  47147. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47148. private _gizmosEnabled;
  47149. private _pointerObserver;
  47150. private _attachedMesh;
  47151. private _boundingBoxColor;
  47152. private _defaultUtilityLayer;
  47153. private _defaultKeepDepthUtilityLayer;
  47154. /**
  47155. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47156. */
  47157. boundingBoxDragBehavior: SixDofDragBehavior;
  47158. /**
  47159. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47160. */
  47161. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47162. /**
  47163. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47164. */
  47165. usePointerToAttachGizmos: boolean;
  47166. /**
  47167. * Utility layer that the bounding box gizmo belongs to
  47168. */
  47169. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47170. /**
  47171. * Utility layer that all gizmos besides bounding box belong to
  47172. */
  47173. readonly utilityLayer: UtilityLayerRenderer;
  47174. /**
  47175. * Instatiates a gizmo manager
  47176. * @param scene the scene to overlay the gizmos on top of
  47177. */
  47178. constructor(scene: Scene);
  47179. /**
  47180. * Attaches a set of gizmos to the specified mesh
  47181. * @param mesh The mesh the gizmo's should be attached to
  47182. */
  47183. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47184. /**
  47185. * If the position gizmo is enabled
  47186. */
  47187. positionGizmoEnabled: boolean;
  47188. /**
  47189. * If the rotation gizmo is enabled
  47190. */
  47191. rotationGizmoEnabled: boolean;
  47192. /**
  47193. * If the scale gizmo is enabled
  47194. */
  47195. scaleGizmoEnabled: boolean;
  47196. /**
  47197. * If the boundingBox gizmo is enabled
  47198. */
  47199. boundingBoxGizmoEnabled: boolean;
  47200. /**
  47201. * Disposes of the gizmo manager
  47202. */
  47203. dispose(): void;
  47204. }
  47205. }
  47206. declare module "babylonjs/Lights/directionalLight" {
  47207. import { Camera } from "babylonjs/Cameras/camera";
  47208. import { Scene } from "babylonjs/scene";
  47209. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47211. import { Light } from "babylonjs/Lights/light";
  47212. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47213. import { Effect } from "babylonjs/Materials/effect";
  47214. /**
  47215. * A directional light is defined by a direction (what a surprise!).
  47216. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47217. * 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.
  47218. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47219. */
  47220. export class DirectionalLight extends ShadowLight {
  47221. private _shadowFrustumSize;
  47222. /**
  47223. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47224. */
  47225. /**
  47226. * Specifies a fix frustum size for the shadow generation.
  47227. */
  47228. shadowFrustumSize: number;
  47229. private _shadowOrthoScale;
  47230. /**
  47231. * Gets the shadow projection scale against the optimal computed one.
  47232. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47233. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47234. */
  47235. /**
  47236. * Sets the shadow projection scale against the optimal computed one.
  47237. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47238. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47239. */
  47240. shadowOrthoScale: number;
  47241. /**
  47242. * Automatically compute the projection matrix to best fit (including all the casters)
  47243. * on each frame.
  47244. */
  47245. autoUpdateExtends: boolean;
  47246. private _orthoLeft;
  47247. private _orthoRight;
  47248. private _orthoTop;
  47249. private _orthoBottom;
  47250. /**
  47251. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47252. * The directional light is emitted from everywhere in the given direction.
  47253. * It can cast shadows.
  47254. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47255. * @param name The friendly name of the light
  47256. * @param direction The direction of the light
  47257. * @param scene The scene the light belongs to
  47258. */
  47259. constructor(name: string, direction: Vector3, scene: Scene);
  47260. /**
  47261. * Returns the string "DirectionalLight".
  47262. * @return The class name
  47263. */
  47264. getClassName(): string;
  47265. /**
  47266. * Returns the integer 1.
  47267. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47268. */
  47269. getTypeID(): number;
  47270. /**
  47271. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47272. * Returns the DirectionalLight Shadow projection matrix.
  47273. */
  47274. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47275. /**
  47276. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47277. * Returns the DirectionalLight Shadow projection matrix.
  47278. */
  47279. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47280. /**
  47281. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47282. * Returns the DirectionalLight Shadow projection matrix.
  47283. */
  47284. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47285. protected _buildUniformLayout(): void;
  47286. /**
  47287. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47288. * @param effect The effect to update
  47289. * @param lightIndex The index of the light in the effect to update
  47290. * @returns The directional light
  47291. */
  47292. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47293. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47294. /**
  47295. * Gets the minZ used for shadow according to both the scene and the light.
  47296. *
  47297. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47298. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47299. * @param activeCamera The camera we are returning the min for
  47300. * @returns the depth min z
  47301. */
  47302. getDepthMinZ(activeCamera: Camera): number;
  47303. /**
  47304. * Gets the maxZ used for shadow according to both the scene and the light.
  47305. *
  47306. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47307. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47308. * @param activeCamera The camera we are returning the max for
  47309. * @returns the depth max z
  47310. */
  47311. getDepthMaxZ(activeCamera: Camera): number;
  47312. /**
  47313. * Prepares the list of defines specific to the light type.
  47314. * @param defines the list of defines
  47315. * @param lightIndex defines the index of the light for the effect
  47316. */
  47317. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47318. }
  47319. }
  47320. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47321. import { Mesh } from "babylonjs/Meshes/mesh";
  47322. /**
  47323. * Class containing static functions to help procedurally build meshes
  47324. */
  47325. export class HemisphereBuilder {
  47326. /**
  47327. * Creates a hemisphere mesh
  47328. * @param name defines the name of the mesh
  47329. * @param options defines the options used to create the mesh
  47330. * @param scene defines the hosting scene
  47331. * @returns the hemisphere mesh
  47332. */
  47333. static CreateHemisphere(name: string, options: {
  47334. segments?: number;
  47335. diameter?: number;
  47336. sideOrientation?: number;
  47337. }, scene: any): Mesh;
  47338. }
  47339. }
  47340. declare module "babylonjs/Lights/spotLight" {
  47341. import { Nullable } from "babylonjs/types";
  47342. import { Scene } from "babylonjs/scene";
  47343. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47345. import { Effect } from "babylonjs/Materials/effect";
  47346. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47347. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47348. /**
  47349. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47350. * These values define a cone of light starting from the position, emitting toward the direction.
  47351. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47352. * and the exponent defines the speed of the decay of the light with distance (reach).
  47353. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47354. */
  47355. export class SpotLight extends ShadowLight {
  47356. private _angle;
  47357. private _innerAngle;
  47358. private _cosHalfAngle;
  47359. private _lightAngleScale;
  47360. private _lightAngleOffset;
  47361. /**
  47362. * Gets the cone angle of the spot light in Radians.
  47363. */
  47364. /**
  47365. * Sets the cone angle of the spot light in Radians.
  47366. */
  47367. angle: number;
  47368. /**
  47369. * Only used in gltf falloff mode, this defines the angle where
  47370. * the directional falloff will start before cutting at angle which could be seen
  47371. * as outer angle.
  47372. */
  47373. /**
  47374. * Only used in gltf falloff mode, this defines the angle where
  47375. * the directional falloff will start before cutting at angle which could be seen
  47376. * as outer angle.
  47377. */
  47378. innerAngle: number;
  47379. private _shadowAngleScale;
  47380. /**
  47381. * Allows scaling the angle of the light for shadow generation only.
  47382. */
  47383. /**
  47384. * Allows scaling the angle of the light for shadow generation only.
  47385. */
  47386. shadowAngleScale: number;
  47387. /**
  47388. * The light decay speed with the distance from the emission spot.
  47389. */
  47390. exponent: number;
  47391. private _projectionTextureMatrix;
  47392. /**
  47393. * Allows reading the projecton texture
  47394. */
  47395. readonly projectionTextureMatrix: Matrix;
  47396. protected _projectionTextureLightNear: number;
  47397. /**
  47398. * Gets the near clip of the Spotlight for texture projection.
  47399. */
  47400. /**
  47401. * Sets the near clip of the Spotlight for texture projection.
  47402. */
  47403. projectionTextureLightNear: number;
  47404. protected _projectionTextureLightFar: number;
  47405. /**
  47406. * Gets the far clip of the Spotlight for texture projection.
  47407. */
  47408. /**
  47409. * Sets the far clip of the Spotlight for texture projection.
  47410. */
  47411. projectionTextureLightFar: number;
  47412. protected _projectionTextureUpDirection: Vector3;
  47413. /**
  47414. * Gets the Up vector of the Spotlight for texture projection.
  47415. */
  47416. /**
  47417. * Sets the Up vector of the Spotlight for texture projection.
  47418. */
  47419. projectionTextureUpDirection: Vector3;
  47420. private _projectionTexture;
  47421. /**
  47422. * Gets the projection texture of the light.
  47423. */
  47424. /**
  47425. * Sets the projection texture of the light.
  47426. */
  47427. projectionTexture: Nullable<BaseTexture>;
  47428. private _projectionTextureViewLightDirty;
  47429. private _projectionTextureProjectionLightDirty;
  47430. private _projectionTextureDirty;
  47431. private _projectionTextureViewTargetVector;
  47432. private _projectionTextureViewLightMatrix;
  47433. private _projectionTextureProjectionLightMatrix;
  47434. private _projectionTextureScalingMatrix;
  47435. /**
  47436. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47437. * It can cast shadows.
  47438. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47439. * @param name The light friendly name
  47440. * @param position The position of the spot light in the scene
  47441. * @param direction The direction of the light in the scene
  47442. * @param angle The cone angle of the light in Radians
  47443. * @param exponent The light decay speed with the distance from the emission spot
  47444. * @param scene The scene the lights belongs to
  47445. */
  47446. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47447. /**
  47448. * Returns the string "SpotLight".
  47449. * @returns the class name
  47450. */
  47451. getClassName(): string;
  47452. /**
  47453. * Returns the integer 2.
  47454. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47455. */
  47456. getTypeID(): number;
  47457. /**
  47458. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47459. */
  47460. protected _setDirection(value: Vector3): void;
  47461. /**
  47462. * Overrides the position setter to recompute the projection texture view light Matrix.
  47463. */
  47464. protected _setPosition(value: Vector3): void;
  47465. /**
  47466. * 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.
  47467. * Returns the SpotLight.
  47468. */
  47469. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47470. protected _computeProjectionTextureViewLightMatrix(): void;
  47471. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47472. /**
  47473. * Main function for light texture projection matrix computing.
  47474. */
  47475. protected _computeProjectionTextureMatrix(): void;
  47476. protected _buildUniformLayout(): void;
  47477. private _computeAngleValues;
  47478. /**
  47479. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47480. * @param effect The effect to update
  47481. * @param lightIndex The index of the light in the effect to update
  47482. * @returns The spot light
  47483. */
  47484. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47485. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47486. /**
  47487. * Disposes the light and the associated resources.
  47488. */
  47489. dispose(): void;
  47490. /**
  47491. * Prepares the list of defines specific to the light type.
  47492. * @param defines the list of defines
  47493. * @param lightIndex defines the index of the light for the effect
  47494. */
  47495. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47496. }
  47497. }
  47498. declare module "babylonjs/Gizmos/lightGizmo" {
  47499. import { Nullable } from "babylonjs/types";
  47500. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47501. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47502. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47503. import { Light } from "babylonjs/Lights/light";
  47504. /**
  47505. * Gizmo that enables viewing a light
  47506. */
  47507. export class LightGizmo extends Gizmo {
  47508. private _lightMesh;
  47509. private _material;
  47510. private cachedPosition;
  47511. private cachedForward;
  47512. /**
  47513. * Creates a LightGizmo
  47514. * @param gizmoLayer The utility layer the gizmo will be added to
  47515. */
  47516. constructor(gizmoLayer?: UtilityLayerRenderer);
  47517. private _light;
  47518. /**
  47519. * The light that the gizmo is attached to
  47520. */
  47521. light: Nullable<Light>;
  47522. /**
  47523. * Gets the material used to render the light gizmo
  47524. */
  47525. readonly material: StandardMaterial;
  47526. /**
  47527. * @hidden
  47528. * Updates the gizmo to match the attached mesh's position/rotation
  47529. */
  47530. protected _update(): void;
  47531. private static _Scale;
  47532. /**
  47533. * Creates the lines for a light mesh
  47534. */
  47535. private static _createLightLines;
  47536. /**
  47537. * Disposes of the light gizmo
  47538. */
  47539. dispose(): void;
  47540. private static _CreateHemisphericLightMesh;
  47541. private static _CreatePointLightMesh;
  47542. private static _CreateSpotLightMesh;
  47543. private static _CreateDirectionalLightMesh;
  47544. }
  47545. }
  47546. declare module "babylonjs/Gizmos/index" {
  47547. export * from "babylonjs/Gizmos/axisDragGizmo";
  47548. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47549. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47550. export * from "babylonjs/Gizmos/gizmo";
  47551. export * from "babylonjs/Gizmos/gizmoManager";
  47552. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47553. export * from "babylonjs/Gizmos/positionGizmo";
  47554. export * from "babylonjs/Gizmos/rotationGizmo";
  47555. export * from "babylonjs/Gizmos/scaleGizmo";
  47556. export * from "babylonjs/Gizmos/lightGizmo";
  47557. export * from "babylonjs/Gizmos/planeDragGizmo";
  47558. }
  47559. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47560. /** @hidden */
  47561. export var backgroundFragmentDeclaration: {
  47562. name: string;
  47563. shader: string;
  47564. };
  47565. }
  47566. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47567. /** @hidden */
  47568. export var backgroundUboDeclaration: {
  47569. name: string;
  47570. shader: string;
  47571. };
  47572. }
  47573. declare module "babylonjs/Shaders/background.fragment" {
  47574. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47575. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47576. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47577. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47578. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47579. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47580. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47581. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47582. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47583. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47584. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47585. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47586. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47587. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47588. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47589. /** @hidden */
  47590. export var backgroundPixelShader: {
  47591. name: string;
  47592. shader: string;
  47593. };
  47594. }
  47595. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47596. /** @hidden */
  47597. export var backgroundVertexDeclaration: {
  47598. name: string;
  47599. shader: string;
  47600. };
  47601. }
  47602. declare module "babylonjs/Shaders/background.vertex" {
  47603. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47604. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47606. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47607. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47608. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47609. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47610. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47611. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47612. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47613. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47614. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47615. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47616. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47617. /** @hidden */
  47618. export var backgroundVertexShader: {
  47619. name: string;
  47620. shader: string;
  47621. };
  47622. }
  47623. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47624. import { Nullable, int, float } from "babylonjs/types";
  47625. import { Scene } from "babylonjs/scene";
  47626. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47627. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47629. import { Mesh } from "babylonjs/Meshes/mesh";
  47630. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47631. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47632. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47634. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47635. import { Color3 } from "babylonjs/Maths/math.color";
  47636. import "babylonjs/Shaders/background.fragment";
  47637. import "babylonjs/Shaders/background.vertex";
  47638. /**
  47639. * Background material used to create an efficient environement around your scene.
  47640. */
  47641. export class BackgroundMaterial extends PushMaterial {
  47642. /**
  47643. * Standard reflectance value at parallel view angle.
  47644. */
  47645. static StandardReflectance0: number;
  47646. /**
  47647. * Standard reflectance value at grazing angle.
  47648. */
  47649. static StandardReflectance90: number;
  47650. protected _primaryColor: Color3;
  47651. /**
  47652. * Key light Color (multiply against the environement texture)
  47653. */
  47654. primaryColor: Color3;
  47655. protected __perceptualColor: Nullable<Color3>;
  47656. /**
  47657. * Experimental Internal Use Only.
  47658. *
  47659. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47660. * This acts as a helper to set the primary color to a more "human friendly" value.
  47661. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47662. * output color as close as possible from the chosen value.
  47663. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47664. * part of lighting setup.)
  47665. */
  47666. _perceptualColor: Nullable<Color3>;
  47667. protected _primaryColorShadowLevel: float;
  47668. /**
  47669. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47670. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47671. */
  47672. primaryColorShadowLevel: float;
  47673. protected _primaryColorHighlightLevel: float;
  47674. /**
  47675. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47676. * The primary color is used at the level chosen to define what the white area would look.
  47677. */
  47678. primaryColorHighlightLevel: float;
  47679. protected _reflectionTexture: Nullable<BaseTexture>;
  47680. /**
  47681. * Reflection Texture used in the material.
  47682. * Should be author in a specific way for the best result (refer to the documentation).
  47683. */
  47684. reflectionTexture: Nullable<BaseTexture>;
  47685. protected _reflectionBlur: float;
  47686. /**
  47687. * Reflection Texture level of blur.
  47688. *
  47689. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47690. * texture twice.
  47691. */
  47692. reflectionBlur: float;
  47693. protected _diffuseTexture: Nullable<BaseTexture>;
  47694. /**
  47695. * Diffuse Texture used in the material.
  47696. * Should be author in a specific way for the best result (refer to the documentation).
  47697. */
  47698. diffuseTexture: Nullable<BaseTexture>;
  47699. protected _shadowLights: Nullable<IShadowLight[]>;
  47700. /**
  47701. * Specify the list of lights casting shadow on the material.
  47702. * All scene shadow lights will be included if null.
  47703. */
  47704. shadowLights: Nullable<IShadowLight[]>;
  47705. protected _shadowLevel: float;
  47706. /**
  47707. * Helps adjusting the shadow to a softer level if required.
  47708. * 0 means black shadows and 1 means no shadows.
  47709. */
  47710. shadowLevel: float;
  47711. protected _sceneCenter: Vector3;
  47712. /**
  47713. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47714. * It is usually zero but might be interesting to modify according to your setup.
  47715. */
  47716. sceneCenter: Vector3;
  47717. protected _opacityFresnel: boolean;
  47718. /**
  47719. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47720. * This helps ensuring a nice transition when the camera goes under the ground.
  47721. */
  47722. opacityFresnel: boolean;
  47723. protected _reflectionFresnel: boolean;
  47724. /**
  47725. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47726. * This helps adding a mirror texture on the ground.
  47727. */
  47728. reflectionFresnel: boolean;
  47729. protected _reflectionFalloffDistance: number;
  47730. /**
  47731. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47732. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47733. */
  47734. reflectionFalloffDistance: number;
  47735. protected _reflectionAmount: number;
  47736. /**
  47737. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47738. */
  47739. reflectionAmount: number;
  47740. protected _reflectionReflectance0: number;
  47741. /**
  47742. * This specifies the weight of the reflection at grazing angle.
  47743. */
  47744. reflectionReflectance0: number;
  47745. protected _reflectionReflectance90: number;
  47746. /**
  47747. * This specifies the weight of the reflection at a perpendicular point of view.
  47748. */
  47749. reflectionReflectance90: number;
  47750. /**
  47751. * Sets the reflection reflectance fresnel values according to the default standard
  47752. * empirically know to work well :-)
  47753. */
  47754. reflectionStandardFresnelWeight: number;
  47755. protected _useRGBColor: boolean;
  47756. /**
  47757. * Helps to directly use the maps channels instead of their level.
  47758. */
  47759. useRGBColor: boolean;
  47760. protected _enableNoise: boolean;
  47761. /**
  47762. * This helps reducing the banding effect that could occur on the background.
  47763. */
  47764. enableNoise: boolean;
  47765. /**
  47766. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47767. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47768. * Recommended to be keep at 1.0 except for special cases.
  47769. */
  47770. fovMultiplier: number;
  47771. private _fovMultiplier;
  47772. /**
  47773. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47774. */
  47775. useEquirectangularFOV: boolean;
  47776. private _maxSimultaneousLights;
  47777. /**
  47778. * Number of Simultaneous lights allowed on the material.
  47779. */
  47780. maxSimultaneousLights: int;
  47781. /**
  47782. * Default configuration related to image processing available in the Background Material.
  47783. */
  47784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47785. /**
  47786. * Keep track of the image processing observer to allow dispose and replace.
  47787. */
  47788. private _imageProcessingObserver;
  47789. /**
  47790. * Attaches a new image processing configuration to the PBR Material.
  47791. * @param configuration (if null the scene configuration will be use)
  47792. */
  47793. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47794. /**
  47795. * Gets the image processing configuration used either in this material.
  47796. */
  47797. /**
  47798. * Sets the Default image processing configuration used either in the this material.
  47799. *
  47800. * If sets to null, the scene one is in use.
  47801. */
  47802. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47803. /**
  47804. * Gets wether the color curves effect is enabled.
  47805. */
  47806. /**
  47807. * Sets wether the color curves effect is enabled.
  47808. */
  47809. cameraColorCurvesEnabled: boolean;
  47810. /**
  47811. * Gets wether the color grading effect is enabled.
  47812. */
  47813. /**
  47814. * Gets wether the color grading effect is enabled.
  47815. */
  47816. cameraColorGradingEnabled: boolean;
  47817. /**
  47818. * Gets wether tonemapping is enabled or not.
  47819. */
  47820. /**
  47821. * Sets wether tonemapping is enabled or not
  47822. */
  47823. cameraToneMappingEnabled: boolean;
  47824. /**
  47825. * The camera exposure used on this material.
  47826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47827. * This corresponds to a photographic exposure.
  47828. */
  47829. /**
  47830. * The camera exposure used on this material.
  47831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47832. * This corresponds to a photographic exposure.
  47833. */
  47834. cameraExposure: float;
  47835. /**
  47836. * Gets The camera contrast used on this material.
  47837. */
  47838. /**
  47839. * Sets The camera contrast used on this material.
  47840. */
  47841. cameraContrast: float;
  47842. /**
  47843. * Gets the Color Grading 2D Lookup Texture.
  47844. */
  47845. /**
  47846. * Sets the Color Grading 2D Lookup Texture.
  47847. */
  47848. cameraColorGradingTexture: Nullable<BaseTexture>;
  47849. /**
  47850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47852. * 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;
  47853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47854. */
  47855. /**
  47856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47858. * 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;
  47859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47860. */
  47861. cameraColorCurves: Nullable<ColorCurves>;
  47862. /**
  47863. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47864. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47865. */
  47866. switchToBGR: boolean;
  47867. private _renderTargets;
  47868. private _reflectionControls;
  47869. private _white;
  47870. private _primaryShadowColor;
  47871. private _primaryHighlightColor;
  47872. /**
  47873. * Instantiates a Background Material in the given scene
  47874. * @param name The friendly name of the material
  47875. * @param scene The scene to add the material to
  47876. */
  47877. constructor(name: string, scene: Scene);
  47878. /**
  47879. * Gets a boolean indicating that current material needs to register RTT
  47880. */
  47881. readonly hasRenderTargetTextures: boolean;
  47882. /**
  47883. * The entire material has been created in order to prevent overdraw.
  47884. * @returns false
  47885. */
  47886. needAlphaTesting(): boolean;
  47887. /**
  47888. * The entire material has been created in order to prevent overdraw.
  47889. * @returns true if blending is enable
  47890. */
  47891. needAlphaBlending(): boolean;
  47892. /**
  47893. * Checks wether the material is ready to be rendered for a given mesh.
  47894. * @param mesh The mesh to render
  47895. * @param subMesh The submesh to check against
  47896. * @param useInstances Specify wether or not the material is used with instances
  47897. * @returns true if all the dependencies are ready (Textures, Effects...)
  47898. */
  47899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47900. /**
  47901. * Compute the primary color according to the chosen perceptual color.
  47902. */
  47903. private _computePrimaryColorFromPerceptualColor;
  47904. /**
  47905. * Compute the highlights and shadow colors according to their chosen levels.
  47906. */
  47907. private _computePrimaryColors;
  47908. /**
  47909. * Build the uniform buffer used in the material.
  47910. */
  47911. buildUniformLayout(): void;
  47912. /**
  47913. * Unbind the material.
  47914. */
  47915. unbind(): void;
  47916. /**
  47917. * Bind only the world matrix to the material.
  47918. * @param world The world matrix to bind.
  47919. */
  47920. bindOnlyWorldMatrix(world: Matrix): void;
  47921. /**
  47922. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47923. * @param world The world matrix to bind.
  47924. * @param subMesh The submesh to bind for.
  47925. */
  47926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47927. /**
  47928. * Checks to see if a texture is used in the material.
  47929. * @param texture - Base texture to use.
  47930. * @returns - Boolean specifying if a texture is used in the material.
  47931. */
  47932. hasTexture(texture: BaseTexture): boolean;
  47933. /**
  47934. * Dispose the material.
  47935. * @param forceDisposeEffect Force disposal of the associated effect.
  47936. * @param forceDisposeTextures Force disposal of the associated textures.
  47937. */
  47938. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47939. /**
  47940. * Clones the material.
  47941. * @param name The cloned name.
  47942. * @returns The cloned material.
  47943. */
  47944. clone(name: string): BackgroundMaterial;
  47945. /**
  47946. * Serializes the current material to its JSON representation.
  47947. * @returns The JSON representation.
  47948. */
  47949. serialize(): any;
  47950. /**
  47951. * Gets the class name of the material
  47952. * @returns "BackgroundMaterial"
  47953. */
  47954. getClassName(): string;
  47955. /**
  47956. * Parse a JSON input to create back a background material.
  47957. * @param source The JSON data to parse
  47958. * @param scene The scene to create the parsed material in
  47959. * @param rootUrl The root url of the assets the material depends upon
  47960. * @returns the instantiated BackgroundMaterial.
  47961. */
  47962. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47963. }
  47964. }
  47965. declare module "babylonjs/Helpers/environmentHelper" {
  47966. import { Observable } from "babylonjs/Misc/observable";
  47967. import { Nullable } from "babylonjs/types";
  47968. import { Scene } from "babylonjs/scene";
  47969. import { Vector3 } from "babylonjs/Maths/math.vector";
  47970. import { Color3 } from "babylonjs/Maths/math.color";
  47971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47972. import { Mesh } from "babylonjs/Meshes/mesh";
  47973. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47974. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47975. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47976. import "babylonjs/Meshes/Builders/planeBuilder";
  47977. import "babylonjs/Meshes/Builders/boxBuilder";
  47978. /**
  47979. * Represents the different options available during the creation of
  47980. * a Environment helper.
  47981. *
  47982. * This can control the default ground, skybox and image processing setup of your scene.
  47983. */
  47984. export interface IEnvironmentHelperOptions {
  47985. /**
  47986. * Specifies wether or not to create a ground.
  47987. * True by default.
  47988. */
  47989. createGround: boolean;
  47990. /**
  47991. * Specifies the ground size.
  47992. * 15 by default.
  47993. */
  47994. groundSize: number;
  47995. /**
  47996. * The texture used on the ground for the main color.
  47997. * Comes from the BabylonJS CDN by default.
  47998. *
  47999. * Remarks: Can be either a texture or a url.
  48000. */
  48001. groundTexture: string | BaseTexture;
  48002. /**
  48003. * The color mixed in the ground texture by default.
  48004. * BabylonJS clearColor by default.
  48005. */
  48006. groundColor: Color3;
  48007. /**
  48008. * Specifies the ground opacity.
  48009. * 1 by default.
  48010. */
  48011. groundOpacity: number;
  48012. /**
  48013. * Enables the ground to receive shadows.
  48014. * True by default.
  48015. */
  48016. enableGroundShadow: boolean;
  48017. /**
  48018. * Helps preventing the shadow to be fully black on the ground.
  48019. * 0.5 by default.
  48020. */
  48021. groundShadowLevel: number;
  48022. /**
  48023. * Creates a mirror texture attach to the ground.
  48024. * false by default.
  48025. */
  48026. enableGroundMirror: boolean;
  48027. /**
  48028. * Specifies the ground mirror size ratio.
  48029. * 0.3 by default as the default kernel is 64.
  48030. */
  48031. groundMirrorSizeRatio: number;
  48032. /**
  48033. * Specifies the ground mirror blur kernel size.
  48034. * 64 by default.
  48035. */
  48036. groundMirrorBlurKernel: number;
  48037. /**
  48038. * Specifies the ground mirror visibility amount.
  48039. * 1 by default
  48040. */
  48041. groundMirrorAmount: number;
  48042. /**
  48043. * Specifies the ground mirror reflectance weight.
  48044. * This uses the standard weight of the background material to setup the fresnel effect
  48045. * of the mirror.
  48046. * 1 by default.
  48047. */
  48048. groundMirrorFresnelWeight: number;
  48049. /**
  48050. * Specifies the ground mirror Falloff distance.
  48051. * This can helps reducing the size of the reflection.
  48052. * 0 by Default.
  48053. */
  48054. groundMirrorFallOffDistance: number;
  48055. /**
  48056. * Specifies the ground mirror texture type.
  48057. * Unsigned Int by Default.
  48058. */
  48059. groundMirrorTextureType: number;
  48060. /**
  48061. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48062. * the shown objects.
  48063. */
  48064. groundYBias: number;
  48065. /**
  48066. * Specifies wether or not to create a skybox.
  48067. * True by default.
  48068. */
  48069. createSkybox: boolean;
  48070. /**
  48071. * Specifies the skybox size.
  48072. * 20 by default.
  48073. */
  48074. skyboxSize: number;
  48075. /**
  48076. * The texture used on the skybox for the main color.
  48077. * Comes from the BabylonJS CDN by default.
  48078. *
  48079. * Remarks: Can be either a texture or a url.
  48080. */
  48081. skyboxTexture: string | BaseTexture;
  48082. /**
  48083. * The color mixed in the skybox texture by default.
  48084. * BabylonJS clearColor by default.
  48085. */
  48086. skyboxColor: Color3;
  48087. /**
  48088. * The background rotation around the Y axis of the scene.
  48089. * This helps aligning the key lights of your scene with the background.
  48090. * 0 by default.
  48091. */
  48092. backgroundYRotation: number;
  48093. /**
  48094. * Compute automatically the size of the elements to best fit with the scene.
  48095. */
  48096. sizeAuto: boolean;
  48097. /**
  48098. * Default position of the rootMesh if autoSize is not true.
  48099. */
  48100. rootPosition: Vector3;
  48101. /**
  48102. * Sets up the image processing in the scene.
  48103. * true by default.
  48104. */
  48105. setupImageProcessing: boolean;
  48106. /**
  48107. * The texture used as your environment texture in the scene.
  48108. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48109. *
  48110. * Remarks: Can be either a texture or a url.
  48111. */
  48112. environmentTexture: string | BaseTexture;
  48113. /**
  48114. * The value of the exposure to apply to the scene.
  48115. * 0.6 by default if setupImageProcessing is true.
  48116. */
  48117. cameraExposure: number;
  48118. /**
  48119. * The value of the contrast to apply to the scene.
  48120. * 1.6 by default if setupImageProcessing is true.
  48121. */
  48122. cameraContrast: number;
  48123. /**
  48124. * Specifies wether or not tonemapping should be enabled in the scene.
  48125. * true by default if setupImageProcessing is true.
  48126. */
  48127. toneMappingEnabled: boolean;
  48128. }
  48129. /**
  48130. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48131. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48132. * It also helps with the default setup of your imageProcessing configuration.
  48133. */
  48134. export class EnvironmentHelper {
  48135. /**
  48136. * Default ground texture URL.
  48137. */
  48138. private static _groundTextureCDNUrl;
  48139. /**
  48140. * Default skybox texture URL.
  48141. */
  48142. private static _skyboxTextureCDNUrl;
  48143. /**
  48144. * Default environment texture URL.
  48145. */
  48146. private static _environmentTextureCDNUrl;
  48147. /**
  48148. * Creates the default options for the helper.
  48149. */
  48150. private static _getDefaultOptions;
  48151. private _rootMesh;
  48152. /**
  48153. * Gets the root mesh created by the helper.
  48154. */
  48155. readonly rootMesh: Mesh;
  48156. private _skybox;
  48157. /**
  48158. * Gets the skybox created by the helper.
  48159. */
  48160. readonly skybox: Nullable<Mesh>;
  48161. private _skyboxTexture;
  48162. /**
  48163. * Gets the skybox texture created by the helper.
  48164. */
  48165. readonly skyboxTexture: Nullable<BaseTexture>;
  48166. private _skyboxMaterial;
  48167. /**
  48168. * Gets the skybox material created by the helper.
  48169. */
  48170. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48171. private _ground;
  48172. /**
  48173. * Gets the ground mesh created by the helper.
  48174. */
  48175. readonly ground: Nullable<Mesh>;
  48176. private _groundTexture;
  48177. /**
  48178. * Gets the ground texture created by the helper.
  48179. */
  48180. readonly groundTexture: Nullable<BaseTexture>;
  48181. private _groundMirror;
  48182. /**
  48183. * Gets the ground mirror created by the helper.
  48184. */
  48185. readonly groundMirror: Nullable<MirrorTexture>;
  48186. /**
  48187. * Gets the ground mirror render list to helps pushing the meshes
  48188. * you wish in the ground reflection.
  48189. */
  48190. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48191. private _groundMaterial;
  48192. /**
  48193. * Gets the ground material created by the helper.
  48194. */
  48195. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48196. /**
  48197. * Stores the creation options.
  48198. */
  48199. private readonly _scene;
  48200. private _options;
  48201. /**
  48202. * This observable will be notified with any error during the creation of the environment,
  48203. * mainly texture creation errors.
  48204. */
  48205. onErrorObservable: Observable<{
  48206. message?: string;
  48207. exception?: any;
  48208. }>;
  48209. /**
  48210. * constructor
  48211. * @param options Defines the options we want to customize the helper
  48212. * @param scene The scene to add the material to
  48213. */
  48214. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48215. /**
  48216. * Updates the background according to the new options
  48217. * @param options
  48218. */
  48219. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48220. /**
  48221. * Sets the primary color of all the available elements.
  48222. * @param color the main color to affect to the ground and the background
  48223. */
  48224. setMainColor(color: Color3): void;
  48225. /**
  48226. * Setup the image processing according to the specified options.
  48227. */
  48228. private _setupImageProcessing;
  48229. /**
  48230. * Setup the environment texture according to the specified options.
  48231. */
  48232. private _setupEnvironmentTexture;
  48233. /**
  48234. * Setup the background according to the specified options.
  48235. */
  48236. private _setupBackground;
  48237. /**
  48238. * Get the scene sizes according to the setup.
  48239. */
  48240. private _getSceneSize;
  48241. /**
  48242. * Setup the ground according to the specified options.
  48243. */
  48244. private _setupGround;
  48245. /**
  48246. * Setup the ground material according to the specified options.
  48247. */
  48248. private _setupGroundMaterial;
  48249. /**
  48250. * Setup the ground diffuse texture according to the specified options.
  48251. */
  48252. private _setupGroundDiffuseTexture;
  48253. /**
  48254. * Setup the ground mirror texture according to the specified options.
  48255. */
  48256. private _setupGroundMirrorTexture;
  48257. /**
  48258. * Setup the ground to receive the mirror texture.
  48259. */
  48260. private _setupMirrorInGroundMaterial;
  48261. /**
  48262. * Setup the skybox according to the specified options.
  48263. */
  48264. private _setupSkybox;
  48265. /**
  48266. * Setup the skybox material according to the specified options.
  48267. */
  48268. private _setupSkyboxMaterial;
  48269. /**
  48270. * Setup the skybox reflection texture according to the specified options.
  48271. */
  48272. private _setupSkyboxReflectionTexture;
  48273. private _errorHandler;
  48274. /**
  48275. * Dispose all the elements created by the Helper.
  48276. */
  48277. dispose(): void;
  48278. }
  48279. }
  48280. declare module "babylonjs/Helpers/photoDome" {
  48281. import { Observable } from "babylonjs/Misc/observable";
  48282. import { Nullable } from "babylonjs/types";
  48283. import { Scene } from "babylonjs/scene";
  48284. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48285. import { Mesh } from "babylonjs/Meshes/mesh";
  48286. import { Texture } from "babylonjs/Materials/Textures/texture";
  48287. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48288. import "babylonjs/Meshes/Builders/sphereBuilder";
  48289. /**
  48290. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48291. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48292. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48293. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48294. */
  48295. export class PhotoDome extends TransformNode {
  48296. /**
  48297. * Define the image as a Monoscopic panoramic 360 image.
  48298. */
  48299. static readonly MODE_MONOSCOPIC: number;
  48300. /**
  48301. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48302. */
  48303. static readonly MODE_TOPBOTTOM: number;
  48304. /**
  48305. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48306. */
  48307. static readonly MODE_SIDEBYSIDE: number;
  48308. private _useDirectMapping;
  48309. /**
  48310. * The texture being displayed on the sphere
  48311. */
  48312. protected _photoTexture: Texture;
  48313. /**
  48314. * Gets or sets the texture being displayed on the sphere
  48315. */
  48316. photoTexture: Texture;
  48317. /**
  48318. * Observable raised when an error occured while loading the 360 image
  48319. */
  48320. onLoadErrorObservable: Observable<string>;
  48321. /**
  48322. * The skybox material
  48323. */
  48324. protected _material: BackgroundMaterial;
  48325. /**
  48326. * The surface used for the skybox
  48327. */
  48328. protected _mesh: Mesh;
  48329. /**
  48330. * Gets the mesh used for the skybox.
  48331. */
  48332. readonly mesh: Mesh;
  48333. /**
  48334. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48335. * Also see the options.resolution property.
  48336. */
  48337. fovMultiplier: number;
  48338. private _imageMode;
  48339. /**
  48340. * Gets or set the current video mode for the video. It can be:
  48341. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48342. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48343. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48344. */
  48345. imageMode: number;
  48346. /**
  48347. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48348. * @param name Element's name, child elements will append suffixes for their own names.
  48349. * @param urlsOfPhoto defines the url of the photo to display
  48350. * @param options defines an object containing optional or exposed sub element properties
  48351. * @param onError defines a callback called when an error occured while loading the texture
  48352. */
  48353. constructor(name: string, urlOfPhoto: string, options: {
  48354. resolution?: number;
  48355. size?: number;
  48356. useDirectMapping?: boolean;
  48357. faceForward?: boolean;
  48358. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48359. private _onBeforeCameraRenderObserver;
  48360. private _changeImageMode;
  48361. /**
  48362. * Releases resources associated with this node.
  48363. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48364. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48365. */
  48366. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48367. }
  48368. }
  48369. declare module "babylonjs/Misc/rgbdTextureTools" {
  48370. import "babylonjs/Shaders/rgbdDecode.fragment";
  48371. import { Texture } from "babylonjs/Materials/Textures/texture";
  48372. /**
  48373. * Class used to host RGBD texture specific utilities
  48374. */
  48375. export class RGBDTextureTools {
  48376. /**
  48377. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48378. * @param texture the texture to expand.
  48379. */
  48380. static ExpandRGBDTexture(texture: Texture): void;
  48381. }
  48382. }
  48383. declare module "babylonjs/Misc/brdfTextureTools" {
  48384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48385. import { Scene } from "babylonjs/scene";
  48386. /**
  48387. * Class used to host texture specific utilities
  48388. */
  48389. export class BRDFTextureTools {
  48390. /**
  48391. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48392. * @param scene defines the hosting scene
  48393. * @returns the environment BRDF texture
  48394. */
  48395. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48396. private static _environmentBRDFBase64Texture;
  48397. }
  48398. }
  48399. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48400. import { Nullable } from "babylonjs/types";
  48401. import { Color3 } from "babylonjs/Maths/math.color";
  48402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48403. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48404. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48405. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48406. import { Engine } from "babylonjs/Engines/engine";
  48407. import { Scene } from "babylonjs/scene";
  48408. /**
  48409. * @hidden
  48410. */
  48411. export interface IMaterialClearCoatDefines {
  48412. CLEARCOAT: boolean;
  48413. CLEARCOAT_DEFAULTIOR: boolean;
  48414. CLEARCOAT_TEXTURE: boolean;
  48415. CLEARCOAT_TEXTUREDIRECTUV: number;
  48416. CLEARCOAT_BUMP: boolean;
  48417. CLEARCOAT_BUMPDIRECTUV: number;
  48418. CLEARCOAT_TINT: boolean;
  48419. CLEARCOAT_TINT_TEXTURE: boolean;
  48420. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48421. /** @hidden */
  48422. _areTexturesDirty: boolean;
  48423. }
  48424. /**
  48425. * Define the code related to the clear coat parameters of the pbr material.
  48426. */
  48427. export class PBRClearCoatConfiguration {
  48428. /**
  48429. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48430. * The default fits with a polyurethane material.
  48431. */
  48432. private static readonly _DefaultIndexOfRefraction;
  48433. private _isEnabled;
  48434. /**
  48435. * Defines if the clear coat is enabled in the material.
  48436. */
  48437. isEnabled: boolean;
  48438. /**
  48439. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48440. */
  48441. intensity: number;
  48442. /**
  48443. * Defines the clear coat layer roughness.
  48444. */
  48445. roughness: number;
  48446. private _indexOfRefraction;
  48447. /**
  48448. * Defines the index of refraction of the clear coat.
  48449. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48450. * The default fits with a polyurethane material.
  48451. * Changing the default value is more performance intensive.
  48452. */
  48453. indexOfRefraction: number;
  48454. private _texture;
  48455. /**
  48456. * Stores the clear coat values in a texture.
  48457. */
  48458. texture: Nullable<BaseTexture>;
  48459. private _bumpTexture;
  48460. /**
  48461. * Define the clear coat specific bump texture.
  48462. */
  48463. bumpTexture: Nullable<BaseTexture>;
  48464. private _isTintEnabled;
  48465. /**
  48466. * Defines if the clear coat tint is enabled in the material.
  48467. */
  48468. isTintEnabled: boolean;
  48469. /**
  48470. * Defines the clear coat tint of the material.
  48471. * This is only use if tint is enabled
  48472. */
  48473. tintColor: Color3;
  48474. /**
  48475. * Defines the distance at which the tint color should be found in the
  48476. * clear coat media.
  48477. * This is only use if tint is enabled
  48478. */
  48479. tintColorAtDistance: number;
  48480. /**
  48481. * Defines the clear coat layer thickness.
  48482. * This is only use if tint is enabled
  48483. */
  48484. tintThickness: number;
  48485. private _tintTexture;
  48486. /**
  48487. * Stores the clear tint values in a texture.
  48488. * rgb is tint
  48489. * a is a thickness factor
  48490. */
  48491. tintTexture: Nullable<BaseTexture>;
  48492. /** @hidden */
  48493. private _internalMarkAllSubMeshesAsTexturesDirty;
  48494. /** @hidden */
  48495. _markAllSubMeshesAsTexturesDirty(): void;
  48496. /**
  48497. * Instantiate a new istance of clear coat configuration.
  48498. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48499. */
  48500. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48501. /**
  48502. * Gets wehter the submesh is ready to be used or not.
  48503. * @param defines the list of "defines" to update.
  48504. * @param scene defines the scene the material belongs to.
  48505. * @param engine defines the engine the material belongs to.
  48506. * @param disableBumpMap defines wether the material disables bump or not.
  48507. * @returns - boolean indicating that the submesh is ready or not.
  48508. */
  48509. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48510. /**
  48511. * Checks to see if a texture is used in the material.
  48512. * @param defines the list of "defines" to update.
  48513. * @param scene defines the scene to the material belongs to.
  48514. */
  48515. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48516. /**
  48517. * Binds the material data.
  48518. * @param uniformBuffer defines the Uniform buffer to fill in.
  48519. * @param scene defines the scene the material belongs to.
  48520. * @param engine defines the engine the material belongs to.
  48521. * @param disableBumpMap defines wether the material disables bump or not.
  48522. * @param isFrozen defines wether the material is frozen or not.
  48523. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48524. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48525. */
  48526. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48527. /**
  48528. * Checks to see if a texture is used in the material.
  48529. * @param texture - Base texture to use.
  48530. * @returns - Boolean specifying if a texture is used in the material.
  48531. */
  48532. hasTexture(texture: BaseTexture): boolean;
  48533. /**
  48534. * Returns an array of the actively used textures.
  48535. * @param activeTextures Array of BaseTextures
  48536. */
  48537. getActiveTextures(activeTextures: BaseTexture[]): void;
  48538. /**
  48539. * Returns the animatable textures.
  48540. * @param animatables Array of animatable textures.
  48541. */
  48542. getAnimatables(animatables: IAnimatable[]): void;
  48543. /**
  48544. * Disposes the resources of the material.
  48545. * @param forceDisposeTextures - Forces the disposal of all textures.
  48546. */
  48547. dispose(forceDisposeTextures?: boolean): void;
  48548. /**
  48549. * Get the current class name of the texture useful for serialization or dynamic coding.
  48550. * @returns "PBRClearCoatConfiguration"
  48551. */
  48552. getClassName(): string;
  48553. /**
  48554. * Add fallbacks to the effect fallbacks list.
  48555. * @param defines defines the Base texture to use.
  48556. * @param fallbacks defines the current fallback list.
  48557. * @param currentRank defines the current fallback rank.
  48558. * @returns the new fallback rank.
  48559. */
  48560. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48561. /**
  48562. * Add the required uniforms to the current list.
  48563. * @param uniforms defines the current uniform list.
  48564. */
  48565. static AddUniforms(uniforms: string[]): void;
  48566. /**
  48567. * Add the required samplers to the current list.
  48568. * @param samplers defines the current sampler list.
  48569. */
  48570. static AddSamplers(samplers: string[]): void;
  48571. /**
  48572. * Add the required uniforms to the current buffer.
  48573. * @param uniformBuffer defines the current uniform buffer.
  48574. */
  48575. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48576. /**
  48577. * Makes a duplicate of the current configuration into another one.
  48578. * @param clearCoatConfiguration define the config where to copy the info
  48579. */
  48580. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48581. /**
  48582. * Serializes this clear coat configuration.
  48583. * @returns - An object with the serialized config.
  48584. */
  48585. serialize(): any;
  48586. /**
  48587. * Parses a anisotropy Configuration from a serialized object.
  48588. * @param source - Serialized object.
  48589. * @param scene Defines the scene we are parsing for
  48590. * @param rootUrl Defines the rootUrl to load from
  48591. */
  48592. parse(source: any, scene: Scene, rootUrl: string): void;
  48593. }
  48594. }
  48595. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48596. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48598. import { Vector2 } from "babylonjs/Maths/math.vector";
  48599. import { Scene } from "babylonjs/scene";
  48600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48601. import { Nullable } from "babylonjs/types";
  48602. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48603. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48604. /**
  48605. * @hidden
  48606. */
  48607. export interface IMaterialAnisotropicDefines {
  48608. ANISOTROPIC: boolean;
  48609. ANISOTROPIC_TEXTURE: boolean;
  48610. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48611. MAINUV1: boolean;
  48612. _areTexturesDirty: boolean;
  48613. _needUVs: boolean;
  48614. }
  48615. /**
  48616. * Define the code related to the anisotropic parameters of the pbr material.
  48617. */
  48618. export class PBRAnisotropicConfiguration {
  48619. private _isEnabled;
  48620. /**
  48621. * Defines if the anisotropy is enabled in the material.
  48622. */
  48623. isEnabled: boolean;
  48624. /**
  48625. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48626. */
  48627. intensity: number;
  48628. /**
  48629. * Defines if the effect is along the tangents, bitangents or in between.
  48630. * By default, the effect is "strectching" the highlights along the tangents.
  48631. */
  48632. direction: Vector2;
  48633. private _texture;
  48634. /**
  48635. * Stores the anisotropy values in a texture.
  48636. * rg is direction (like normal from -1 to 1)
  48637. * b is a intensity
  48638. */
  48639. texture: Nullable<BaseTexture>;
  48640. /** @hidden */
  48641. private _internalMarkAllSubMeshesAsTexturesDirty;
  48642. /** @hidden */
  48643. _markAllSubMeshesAsTexturesDirty(): void;
  48644. /**
  48645. * Instantiate a new istance of anisotropy configuration.
  48646. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48647. */
  48648. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48649. /**
  48650. * Specifies that the submesh is ready to be used.
  48651. * @param defines the list of "defines" to update.
  48652. * @param scene defines the scene the material belongs to.
  48653. * @returns - boolean indicating that the submesh is ready or not.
  48654. */
  48655. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48656. /**
  48657. * Checks to see if a texture is used in the material.
  48658. * @param defines the list of "defines" to update.
  48659. * @param mesh the mesh we are preparing the defines for.
  48660. * @param scene defines the scene the material belongs to.
  48661. */
  48662. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48663. /**
  48664. * Binds the material data.
  48665. * @param uniformBuffer defines the Uniform buffer to fill in.
  48666. * @param scene defines the scene the material belongs to.
  48667. * @param isFrozen defines wether the material is frozen or not.
  48668. */
  48669. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48670. /**
  48671. * Checks to see if a texture is used in the material.
  48672. * @param texture - Base texture to use.
  48673. * @returns - Boolean specifying if a texture is used in the material.
  48674. */
  48675. hasTexture(texture: BaseTexture): boolean;
  48676. /**
  48677. * Returns an array of the actively used textures.
  48678. * @param activeTextures Array of BaseTextures
  48679. */
  48680. getActiveTextures(activeTextures: BaseTexture[]): void;
  48681. /**
  48682. * Returns the animatable textures.
  48683. * @param animatables Array of animatable textures.
  48684. */
  48685. getAnimatables(animatables: IAnimatable[]): void;
  48686. /**
  48687. * Disposes the resources of the material.
  48688. * @param forceDisposeTextures - Forces the disposal of all textures.
  48689. */
  48690. dispose(forceDisposeTextures?: boolean): void;
  48691. /**
  48692. * Get the current class name of the texture useful for serialization or dynamic coding.
  48693. * @returns "PBRAnisotropicConfiguration"
  48694. */
  48695. getClassName(): string;
  48696. /**
  48697. * Add fallbacks to the effect fallbacks list.
  48698. * @param defines defines the Base texture to use.
  48699. * @param fallbacks defines the current fallback list.
  48700. * @param currentRank defines the current fallback rank.
  48701. * @returns the new fallback rank.
  48702. */
  48703. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48704. /**
  48705. * Add the required uniforms to the current list.
  48706. * @param uniforms defines the current uniform list.
  48707. */
  48708. static AddUniforms(uniforms: string[]): void;
  48709. /**
  48710. * Add the required uniforms to the current buffer.
  48711. * @param uniformBuffer defines the current uniform buffer.
  48712. */
  48713. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48714. /**
  48715. * Add the required samplers to the current list.
  48716. * @param samplers defines the current sampler list.
  48717. */
  48718. static AddSamplers(samplers: string[]): void;
  48719. /**
  48720. * Makes a duplicate of the current configuration into another one.
  48721. * @param anisotropicConfiguration define the config where to copy the info
  48722. */
  48723. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48724. /**
  48725. * Serializes this anisotropy configuration.
  48726. * @returns - An object with the serialized config.
  48727. */
  48728. serialize(): any;
  48729. /**
  48730. * Parses a anisotropy Configuration from a serialized object.
  48731. * @param source - Serialized object.
  48732. * @param scene Defines the scene we are parsing for
  48733. * @param rootUrl Defines the rootUrl to load from
  48734. */
  48735. parse(source: any, scene: Scene, rootUrl: string): void;
  48736. }
  48737. }
  48738. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48739. import { Scene } from "babylonjs/scene";
  48740. /**
  48741. * @hidden
  48742. */
  48743. export interface IMaterialBRDFDefines {
  48744. BRDF_V_HEIGHT_CORRELATED: boolean;
  48745. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48746. SPHERICAL_HARMONICS: boolean;
  48747. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48748. /** @hidden */
  48749. _areMiscDirty: boolean;
  48750. }
  48751. /**
  48752. * Define the code related to the BRDF parameters of the pbr material.
  48753. */
  48754. export class PBRBRDFConfiguration {
  48755. /**
  48756. * Default value used for the energy conservation.
  48757. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48758. */
  48759. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48760. /**
  48761. * Default value used for the Smith Visibility Height Correlated mode.
  48762. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48763. */
  48764. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48765. /**
  48766. * Default value used for the IBL diffuse part.
  48767. * This can help switching back to the polynomials mode globally which is a tiny bit
  48768. * less GPU intensive at the drawback of a lower quality.
  48769. */
  48770. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48771. /**
  48772. * Default value used for activating energy conservation for the specular workflow.
  48773. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48774. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48775. */
  48776. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48777. private _useEnergyConservation;
  48778. /**
  48779. * Defines if the material uses energy conservation.
  48780. */
  48781. useEnergyConservation: boolean;
  48782. private _useSmithVisibilityHeightCorrelated;
  48783. /**
  48784. * LEGACY Mode set to false
  48785. * Defines if the material uses height smith correlated visibility term.
  48786. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48787. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48788. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48789. * Not relying on height correlated will also disable energy conservation.
  48790. */
  48791. useSmithVisibilityHeightCorrelated: boolean;
  48792. private _useSphericalHarmonics;
  48793. /**
  48794. * LEGACY Mode set to false
  48795. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48796. * diffuse part of the IBL.
  48797. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48798. * to the ground truth.
  48799. */
  48800. useSphericalHarmonics: boolean;
  48801. private _useSpecularGlossinessInputEnergyConservation;
  48802. /**
  48803. * Defines if the material uses energy conservation, when the specular workflow is active.
  48804. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48805. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48806. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48807. */
  48808. useSpecularGlossinessInputEnergyConservation: boolean;
  48809. /** @hidden */
  48810. private _internalMarkAllSubMeshesAsMiscDirty;
  48811. /** @hidden */
  48812. _markAllSubMeshesAsMiscDirty(): void;
  48813. /**
  48814. * Instantiate a new istance of clear coat configuration.
  48815. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48816. */
  48817. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48818. /**
  48819. * Checks to see if a texture is used in the material.
  48820. * @param defines the list of "defines" to update.
  48821. */
  48822. prepareDefines(defines: IMaterialBRDFDefines): void;
  48823. /**
  48824. * Get the current class name of the texture useful for serialization or dynamic coding.
  48825. * @returns "PBRClearCoatConfiguration"
  48826. */
  48827. getClassName(): string;
  48828. /**
  48829. * Makes a duplicate of the current configuration into another one.
  48830. * @param brdfConfiguration define the config where to copy the info
  48831. */
  48832. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48833. /**
  48834. * Serializes this BRDF configuration.
  48835. * @returns - An object with the serialized config.
  48836. */
  48837. serialize(): any;
  48838. /**
  48839. * Parses a anisotropy Configuration from a serialized object.
  48840. * @param source - Serialized object.
  48841. * @param scene Defines the scene we are parsing for
  48842. * @param rootUrl Defines the rootUrl to load from
  48843. */
  48844. parse(source: any, scene: Scene, rootUrl: string): void;
  48845. }
  48846. }
  48847. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48848. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48849. import { Color3 } from "babylonjs/Maths/math.color";
  48850. import { Scene } from "babylonjs/scene";
  48851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48852. import { Nullable } from "babylonjs/types";
  48853. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48854. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48855. /**
  48856. * @hidden
  48857. */
  48858. export interface IMaterialSheenDefines {
  48859. SHEEN: boolean;
  48860. SHEEN_TEXTURE: boolean;
  48861. SHEEN_TEXTUREDIRECTUV: number;
  48862. SHEEN_LINKWITHALBEDO: boolean;
  48863. /** @hidden */
  48864. _areTexturesDirty: boolean;
  48865. }
  48866. /**
  48867. * Define the code related to the Sheen parameters of the pbr material.
  48868. */
  48869. export class PBRSheenConfiguration {
  48870. private _isEnabled;
  48871. /**
  48872. * Defines if the material uses sheen.
  48873. */
  48874. isEnabled: boolean;
  48875. private _linkSheenWithAlbedo;
  48876. /**
  48877. * Defines if the sheen is linked to the sheen color.
  48878. */
  48879. linkSheenWithAlbedo: boolean;
  48880. /**
  48881. * Defines the sheen intensity.
  48882. */
  48883. intensity: number;
  48884. /**
  48885. * Defines the sheen color.
  48886. */
  48887. color: Color3;
  48888. private _texture;
  48889. /**
  48890. * Stores the sheen tint values in a texture.
  48891. * rgb is tint
  48892. * a is a intensity
  48893. */
  48894. texture: Nullable<BaseTexture>;
  48895. /** @hidden */
  48896. private _internalMarkAllSubMeshesAsTexturesDirty;
  48897. /** @hidden */
  48898. _markAllSubMeshesAsTexturesDirty(): void;
  48899. /**
  48900. * Instantiate a new istance of clear coat configuration.
  48901. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48902. */
  48903. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48904. /**
  48905. * Specifies that the submesh is ready to be used.
  48906. * @param defines the list of "defines" to update.
  48907. * @param scene defines the scene the material belongs to.
  48908. * @returns - boolean indicating that the submesh is ready or not.
  48909. */
  48910. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48911. /**
  48912. * Checks to see if a texture is used in the material.
  48913. * @param defines the list of "defines" to update.
  48914. * @param scene defines the scene the material belongs to.
  48915. */
  48916. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48917. /**
  48918. * Binds the material data.
  48919. * @param uniformBuffer defines the Uniform buffer to fill in.
  48920. * @param scene defines the scene the material belongs to.
  48921. * @param isFrozen defines wether the material is frozen or not.
  48922. */
  48923. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48924. /**
  48925. * Checks to see if a texture is used in the material.
  48926. * @param texture - Base texture to use.
  48927. * @returns - Boolean specifying if a texture is used in the material.
  48928. */
  48929. hasTexture(texture: BaseTexture): boolean;
  48930. /**
  48931. * Returns an array of the actively used textures.
  48932. * @param activeTextures Array of BaseTextures
  48933. */
  48934. getActiveTextures(activeTextures: BaseTexture[]): void;
  48935. /**
  48936. * Returns the animatable textures.
  48937. * @param animatables Array of animatable textures.
  48938. */
  48939. getAnimatables(animatables: IAnimatable[]): void;
  48940. /**
  48941. * Disposes the resources of the material.
  48942. * @param forceDisposeTextures - Forces the disposal of all textures.
  48943. */
  48944. dispose(forceDisposeTextures?: boolean): void;
  48945. /**
  48946. * Get the current class name of the texture useful for serialization or dynamic coding.
  48947. * @returns "PBRSheenConfiguration"
  48948. */
  48949. getClassName(): string;
  48950. /**
  48951. * Add fallbacks to the effect fallbacks list.
  48952. * @param defines defines the Base texture to use.
  48953. * @param fallbacks defines the current fallback list.
  48954. * @param currentRank defines the current fallback rank.
  48955. * @returns the new fallback rank.
  48956. */
  48957. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48958. /**
  48959. * Add the required uniforms to the current list.
  48960. * @param uniforms defines the current uniform list.
  48961. */
  48962. static AddUniforms(uniforms: string[]): void;
  48963. /**
  48964. * Add the required uniforms to the current buffer.
  48965. * @param uniformBuffer defines the current uniform buffer.
  48966. */
  48967. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48968. /**
  48969. * Add the required samplers to the current list.
  48970. * @param samplers defines the current sampler list.
  48971. */
  48972. static AddSamplers(samplers: string[]): void;
  48973. /**
  48974. * Makes a duplicate of the current configuration into another one.
  48975. * @param sheenConfiguration define the config where to copy the info
  48976. */
  48977. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48978. /**
  48979. * Serializes this BRDF configuration.
  48980. * @returns - An object with the serialized config.
  48981. */
  48982. serialize(): any;
  48983. /**
  48984. * Parses a anisotropy Configuration from a serialized object.
  48985. * @param source - Serialized object.
  48986. * @param scene Defines the scene we are parsing for
  48987. * @param rootUrl Defines the rootUrl to load from
  48988. */
  48989. parse(source: any, scene: Scene, rootUrl: string): void;
  48990. }
  48991. }
  48992. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48993. import { Nullable } from "babylonjs/types";
  48994. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48995. import { Color3 } from "babylonjs/Maths/math.color";
  48996. import { SmartArray } from "babylonjs/Misc/smartArray";
  48997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48998. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48999. import { Effect } from "babylonjs/Materials/effect";
  49000. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49001. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49002. import { Engine } from "babylonjs/Engines/engine";
  49003. import { Scene } from "babylonjs/scene";
  49004. /**
  49005. * @hidden
  49006. */
  49007. export interface IMaterialSubSurfaceDefines {
  49008. SUBSURFACE: boolean;
  49009. SS_REFRACTION: boolean;
  49010. SS_TRANSLUCENCY: boolean;
  49011. SS_SCATERRING: boolean;
  49012. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49013. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49014. SS_REFRACTIONMAP_3D: boolean;
  49015. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49016. SS_LODINREFRACTIONALPHA: boolean;
  49017. SS_GAMMAREFRACTION: boolean;
  49018. SS_RGBDREFRACTION: boolean;
  49019. SS_LINEARSPECULARREFRACTION: boolean;
  49020. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49021. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49022. /** @hidden */
  49023. _areTexturesDirty: boolean;
  49024. }
  49025. /**
  49026. * Define the code related to the sub surface parameters of the pbr material.
  49027. */
  49028. export class PBRSubSurfaceConfiguration {
  49029. private _isRefractionEnabled;
  49030. /**
  49031. * Defines if the refraction is enabled in the material.
  49032. */
  49033. isRefractionEnabled: boolean;
  49034. private _isTranslucencyEnabled;
  49035. /**
  49036. * Defines if the translucency is enabled in the material.
  49037. */
  49038. isTranslucencyEnabled: boolean;
  49039. private _isScatteringEnabled;
  49040. /**
  49041. * Defines the refraction intensity of the material.
  49042. * The refraction when enabled replaces the Diffuse part of the material.
  49043. * The intensity helps transitionning between diffuse and refraction.
  49044. */
  49045. refractionIntensity: number;
  49046. /**
  49047. * Defines the translucency intensity of the material.
  49048. * When translucency has been enabled, this defines how much of the "translucency"
  49049. * is addded to the diffuse part of the material.
  49050. */
  49051. translucencyIntensity: number;
  49052. /**
  49053. * Defines the scattering intensity of the material.
  49054. * When scattering has been enabled, this defines how much of the "scattered light"
  49055. * is addded to the diffuse part of the material.
  49056. */
  49057. scatteringIntensity: number;
  49058. private _thicknessTexture;
  49059. /**
  49060. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49061. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49062. * 0 would mean minimumThickness
  49063. * 1 would mean maximumThickness
  49064. * The other channels might be use as a mask to vary the different effects intensity.
  49065. */
  49066. thicknessTexture: Nullable<BaseTexture>;
  49067. private _refractionTexture;
  49068. /**
  49069. * Defines the texture to use for refraction.
  49070. */
  49071. refractionTexture: Nullable<BaseTexture>;
  49072. private _indexOfRefraction;
  49073. /**
  49074. * Defines the index of refraction used in the material.
  49075. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49076. */
  49077. indexOfRefraction: number;
  49078. private _invertRefractionY;
  49079. /**
  49080. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49081. */
  49082. invertRefractionY: boolean;
  49083. private _linkRefractionWithTransparency;
  49084. /**
  49085. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49086. * Materials half opaque for instance using refraction could benefit from this control.
  49087. */
  49088. linkRefractionWithTransparency: boolean;
  49089. /**
  49090. * Defines the minimum thickness stored in the thickness map.
  49091. * If no thickness map is defined, this value will be used to simulate thickness.
  49092. */
  49093. minimumThickness: number;
  49094. /**
  49095. * Defines the maximum thickness stored in the thickness map.
  49096. */
  49097. maximumThickness: number;
  49098. /**
  49099. * Defines the volume tint of the material.
  49100. * This is used for both translucency and scattering.
  49101. */
  49102. tintColor: Color3;
  49103. /**
  49104. * Defines the distance at which the tint color should be found in the media.
  49105. * This is used for refraction only.
  49106. */
  49107. tintColorAtDistance: number;
  49108. /**
  49109. * Defines how far each channel transmit through the media.
  49110. * It is defined as a color to simplify it selection.
  49111. */
  49112. diffusionDistance: Color3;
  49113. private _useMaskFromThicknessTexture;
  49114. /**
  49115. * Stores the intensity of the different subsurface effects in the thickness texture.
  49116. * * the green channel is the translucency intensity.
  49117. * * the blue channel is the scattering intensity.
  49118. * * the alpha channel is the refraction intensity.
  49119. */
  49120. useMaskFromThicknessTexture: boolean;
  49121. /** @hidden */
  49122. private _internalMarkAllSubMeshesAsTexturesDirty;
  49123. /** @hidden */
  49124. _markAllSubMeshesAsTexturesDirty(): void;
  49125. /**
  49126. * Instantiate a new istance of sub surface configuration.
  49127. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49128. */
  49129. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49130. /**
  49131. * Gets wehter the submesh is ready to be used or not.
  49132. * @param defines the list of "defines" to update.
  49133. * @param scene defines the scene the material belongs to.
  49134. * @returns - boolean indicating that the submesh is ready or not.
  49135. */
  49136. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49137. /**
  49138. * Checks to see if a texture is used in the material.
  49139. * @param defines the list of "defines" to update.
  49140. * @param scene defines the scene to the material belongs to.
  49141. */
  49142. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49143. /**
  49144. * Binds the material data.
  49145. * @param uniformBuffer defines the Uniform buffer to fill in.
  49146. * @param scene defines the scene the material belongs to.
  49147. * @param engine defines the engine the material belongs to.
  49148. * @param isFrozen defines wether the material is frozen or not.
  49149. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49150. */
  49151. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49152. /**
  49153. * Unbinds the material from the mesh.
  49154. * @param activeEffect defines the effect that should be unbound from.
  49155. * @returns true if unbound, otherwise false
  49156. */
  49157. unbind(activeEffect: Effect): boolean;
  49158. /**
  49159. * Returns the texture used for refraction or null if none is used.
  49160. * @param scene defines the scene the material belongs to.
  49161. * @returns - Refraction texture if present. If no refraction texture and refraction
  49162. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49163. */
  49164. private _getRefractionTexture;
  49165. /**
  49166. * Returns true if alpha blending should be disabled.
  49167. */
  49168. readonly disableAlphaBlending: boolean;
  49169. /**
  49170. * Fills the list of render target textures.
  49171. * @param renderTargets the list of render targets to update
  49172. */
  49173. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49174. /**
  49175. * Checks to see if a texture is used in the material.
  49176. * @param texture - Base texture to use.
  49177. * @returns - Boolean specifying if a texture is used in the material.
  49178. */
  49179. hasTexture(texture: BaseTexture): boolean;
  49180. /**
  49181. * Gets a boolean indicating that current material needs to register RTT
  49182. * @returns true if this uses a render target otherwise false.
  49183. */
  49184. hasRenderTargetTextures(): boolean;
  49185. /**
  49186. * Returns an array of the actively used textures.
  49187. * @param activeTextures Array of BaseTextures
  49188. */
  49189. getActiveTextures(activeTextures: BaseTexture[]): void;
  49190. /**
  49191. * Returns the animatable textures.
  49192. * @param animatables Array of animatable textures.
  49193. */
  49194. getAnimatables(animatables: IAnimatable[]): void;
  49195. /**
  49196. * Disposes the resources of the material.
  49197. * @param forceDisposeTextures - Forces the disposal of all textures.
  49198. */
  49199. dispose(forceDisposeTextures?: boolean): void;
  49200. /**
  49201. * Get the current class name of the texture useful for serialization or dynamic coding.
  49202. * @returns "PBRSubSurfaceConfiguration"
  49203. */
  49204. getClassName(): string;
  49205. /**
  49206. * Add fallbacks to the effect fallbacks list.
  49207. * @param defines defines the Base texture to use.
  49208. * @param fallbacks defines the current fallback list.
  49209. * @param currentRank defines the current fallback rank.
  49210. * @returns the new fallback rank.
  49211. */
  49212. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49213. /**
  49214. * Add the required uniforms to the current list.
  49215. * @param uniforms defines the current uniform list.
  49216. */
  49217. static AddUniforms(uniforms: string[]): void;
  49218. /**
  49219. * Add the required samplers to the current list.
  49220. * @param samplers defines the current sampler list.
  49221. */
  49222. static AddSamplers(samplers: string[]): void;
  49223. /**
  49224. * Add the required uniforms to the current buffer.
  49225. * @param uniformBuffer defines the current uniform buffer.
  49226. */
  49227. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49228. /**
  49229. * Makes a duplicate of the current configuration into another one.
  49230. * @param configuration define the config where to copy the info
  49231. */
  49232. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49233. /**
  49234. * Serializes this Sub Surface configuration.
  49235. * @returns - An object with the serialized config.
  49236. */
  49237. serialize(): any;
  49238. /**
  49239. * Parses a anisotropy Configuration from a serialized object.
  49240. * @param source - Serialized object.
  49241. * @param scene Defines the scene we are parsing for
  49242. * @param rootUrl Defines the rootUrl to load from
  49243. */
  49244. parse(source: any, scene: Scene, rootUrl: string): void;
  49245. }
  49246. }
  49247. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49248. /** @hidden */
  49249. export var pbrFragmentDeclaration: {
  49250. name: string;
  49251. shader: string;
  49252. };
  49253. }
  49254. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49255. /** @hidden */
  49256. export var pbrUboDeclaration: {
  49257. name: string;
  49258. shader: string;
  49259. };
  49260. }
  49261. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49262. /** @hidden */
  49263. export var pbrFragmentExtraDeclaration: {
  49264. name: string;
  49265. shader: string;
  49266. };
  49267. }
  49268. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49269. /** @hidden */
  49270. export var pbrFragmentSamplersDeclaration: {
  49271. name: string;
  49272. shader: string;
  49273. };
  49274. }
  49275. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49276. /** @hidden */
  49277. export var pbrHelperFunctions: {
  49278. name: string;
  49279. shader: string;
  49280. };
  49281. }
  49282. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49283. /** @hidden */
  49284. export var harmonicsFunctions: {
  49285. name: string;
  49286. shader: string;
  49287. };
  49288. }
  49289. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49290. /** @hidden */
  49291. export var pbrDirectLightingSetupFunctions: {
  49292. name: string;
  49293. shader: string;
  49294. };
  49295. }
  49296. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49297. /** @hidden */
  49298. export var pbrDirectLightingFalloffFunctions: {
  49299. name: string;
  49300. shader: string;
  49301. };
  49302. }
  49303. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49304. /** @hidden */
  49305. export var pbrBRDFFunctions: {
  49306. name: string;
  49307. shader: string;
  49308. };
  49309. }
  49310. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49311. /** @hidden */
  49312. export var pbrDirectLightingFunctions: {
  49313. name: string;
  49314. shader: string;
  49315. };
  49316. }
  49317. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49318. /** @hidden */
  49319. export var pbrIBLFunctions: {
  49320. name: string;
  49321. shader: string;
  49322. };
  49323. }
  49324. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49325. /** @hidden */
  49326. export var pbrDebug: {
  49327. name: string;
  49328. shader: string;
  49329. };
  49330. }
  49331. declare module "babylonjs/Shaders/pbr.fragment" {
  49332. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49333. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49334. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49335. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49336. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49337. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49338. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49339. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49340. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49341. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49342. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49343. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49344. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49345. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49346. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49347. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49348. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49349. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49350. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49351. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49352. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49353. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49354. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49355. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49356. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49357. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49358. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49359. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49360. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49361. /** @hidden */
  49362. export var pbrPixelShader: {
  49363. name: string;
  49364. shader: string;
  49365. };
  49366. }
  49367. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49368. /** @hidden */
  49369. export var pbrVertexDeclaration: {
  49370. name: string;
  49371. shader: string;
  49372. };
  49373. }
  49374. declare module "babylonjs/Shaders/pbr.vertex" {
  49375. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49376. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49378. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49379. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49380. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49381. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49382. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49383. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49385. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49386. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49388. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49389. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49390. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49391. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49392. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49393. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49394. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49395. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49396. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49397. /** @hidden */
  49398. export var pbrVertexShader: {
  49399. name: string;
  49400. shader: string;
  49401. };
  49402. }
  49403. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49404. import { Nullable } from "babylonjs/types";
  49405. import { Scene } from "babylonjs/scene";
  49406. import { Matrix } from "babylonjs/Maths/math.vector";
  49407. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49409. import { Mesh } from "babylonjs/Meshes/mesh";
  49410. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49411. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49412. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49413. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49414. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49415. import { Color3 } from "babylonjs/Maths/math.color";
  49416. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49417. import { Material } from "babylonjs/Materials/material";
  49418. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49419. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49420. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49421. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49422. import "babylonjs/Shaders/pbr.fragment";
  49423. import "babylonjs/Shaders/pbr.vertex";
  49424. /**
  49425. * Manages the defines for the PBR Material.
  49426. * @hidden
  49427. */
  49428. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49429. PBR: boolean;
  49430. MAINUV1: boolean;
  49431. MAINUV2: boolean;
  49432. UV1: boolean;
  49433. UV2: boolean;
  49434. ALBEDO: boolean;
  49435. ALBEDODIRECTUV: number;
  49436. VERTEXCOLOR: boolean;
  49437. AMBIENT: boolean;
  49438. AMBIENTDIRECTUV: number;
  49439. AMBIENTINGRAYSCALE: boolean;
  49440. OPACITY: boolean;
  49441. VERTEXALPHA: boolean;
  49442. OPACITYDIRECTUV: number;
  49443. OPACITYRGB: boolean;
  49444. ALPHATEST: boolean;
  49445. DEPTHPREPASS: boolean;
  49446. ALPHABLEND: boolean;
  49447. ALPHAFROMALBEDO: boolean;
  49448. ALPHATESTVALUE: string;
  49449. SPECULAROVERALPHA: boolean;
  49450. RADIANCEOVERALPHA: boolean;
  49451. ALPHAFRESNEL: boolean;
  49452. LINEARALPHAFRESNEL: boolean;
  49453. PREMULTIPLYALPHA: boolean;
  49454. EMISSIVE: boolean;
  49455. EMISSIVEDIRECTUV: number;
  49456. REFLECTIVITY: boolean;
  49457. REFLECTIVITYDIRECTUV: number;
  49458. SPECULARTERM: boolean;
  49459. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49460. MICROSURFACEAUTOMATIC: boolean;
  49461. LODBASEDMICROSFURACE: boolean;
  49462. MICROSURFACEMAP: boolean;
  49463. MICROSURFACEMAPDIRECTUV: number;
  49464. METALLICWORKFLOW: boolean;
  49465. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49466. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49467. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49468. AOSTOREINMETALMAPRED: boolean;
  49469. ENVIRONMENTBRDF: boolean;
  49470. ENVIRONMENTBRDF_RGBD: boolean;
  49471. NORMAL: boolean;
  49472. TANGENT: boolean;
  49473. BUMP: boolean;
  49474. BUMPDIRECTUV: number;
  49475. OBJECTSPACE_NORMALMAP: boolean;
  49476. PARALLAX: boolean;
  49477. PARALLAXOCCLUSION: boolean;
  49478. NORMALXYSCALE: boolean;
  49479. LIGHTMAP: boolean;
  49480. LIGHTMAPDIRECTUV: number;
  49481. USELIGHTMAPASSHADOWMAP: boolean;
  49482. GAMMALIGHTMAP: boolean;
  49483. RGBDLIGHTMAP: boolean;
  49484. REFLECTION: boolean;
  49485. REFLECTIONMAP_3D: boolean;
  49486. REFLECTIONMAP_SPHERICAL: boolean;
  49487. REFLECTIONMAP_PLANAR: boolean;
  49488. REFLECTIONMAP_CUBIC: boolean;
  49489. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49490. REFLECTIONMAP_PROJECTION: boolean;
  49491. REFLECTIONMAP_SKYBOX: boolean;
  49492. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49493. REFLECTIONMAP_EXPLICIT: boolean;
  49494. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49495. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49496. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49497. INVERTCUBICMAP: boolean;
  49498. USESPHERICALFROMREFLECTIONMAP: boolean;
  49499. USEIRRADIANCEMAP: boolean;
  49500. SPHERICAL_HARMONICS: boolean;
  49501. USESPHERICALINVERTEX: boolean;
  49502. REFLECTIONMAP_OPPOSITEZ: boolean;
  49503. LODINREFLECTIONALPHA: boolean;
  49504. GAMMAREFLECTION: boolean;
  49505. RGBDREFLECTION: boolean;
  49506. LINEARSPECULARREFLECTION: boolean;
  49507. RADIANCEOCCLUSION: boolean;
  49508. HORIZONOCCLUSION: boolean;
  49509. INSTANCES: boolean;
  49510. NUM_BONE_INFLUENCERS: number;
  49511. BonesPerMesh: number;
  49512. BONETEXTURE: boolean;
  49513. NONUNIFORMSCALING: boolean;
  49514. MORPHTARGETS: boolean;
  49515. MORPHTARGETS_NORMAL: boolean;
  49516. MORPHTARGETS_TANGENT: boolean;
  49517. MORPHTARGETS_UV: boolean;
  49518. NUM_MORPH_INFLUENCERS: number;
  49519. IMAGEPROCESSING: boolean;
  49520. VIGNETTE: boolean;
  49521. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49522. VIGNETTEBLENDMODEOPAQUE: boolean;
  49523. TONEMAPPING: boolean;
  49524. TONEMAPPING_ACES: boolean;
  49525. CONTRAST: boolean;
  49526. COLORCURVES: boolean;
  49527. COLORGRADING: boolean;
  49528. COLORGRADING3D: boolean;
  49529. SAMPLER3DGREENDEPTH: boolean;
  49530. SAMPLER3DBGRMAP: boolean;
  49531. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49532. EXPOSURE: boolean;
  49533. MULTIVIEW: boolean;
  49534. USEPHYSICALLIGHTFALLOFF: boolean;
  49535. USEGLTFLIGHTFALLOFF: boolean;
  49536. TWOSIDEDLIGHTING: boolean;
  49537. SHADOWFLOAT: boolean;
  49538. CLIPPLANE: boolean;
  49539. CLIPPLANE2: boolean;
  49540. CLIPPLANE3: boolean;
  49541. CLIPPLANE4: boolean;
  49542. POINTSIZE: boolean;
  49543. FOG: boolean;
  49544. LOGARITHMICDEPTH: boolean;
  49545. FORCENORMALFORWARD: boolean;
  49546. SPECULARAA: boolean;
  49547. CLEARCOAT: boolean;
  49548. CLEARCOAT_DEFAULTIOR: boolean;
  49549. CLEARCOAT_TEXTURE: boolean;
  49550. CLEARCOAT_TEXTUREDIRECTUV: number;
  49551. CLEARCOAT_BUMP: boolean;
  49552. CLEARCOAT_BUMPDIRECTUV: number;
  49553. CLEARCOAT_TINT: boolean;
  49554. CLEARCOAT_TINT_TEXTURE: boolean;
  49555. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49556. ANISOTROPIC: boolean;
  49557. ANISOTROPIC_TEXTURE: boolean;
  49558. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49559. BRDF_V_HEIGHT_CORRELATED: boolean;
  49560. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49561. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49562. SHEEN: boolean;
  49563. SHEEN_TEXTURE: boolean;
  49564. SHEEN_TEXTUREDIRECTUV: number;
  49565. SHEEN_LINKWITHALBEDO: boolean;
  49566. SUBSURFACE: boolean;
  49567. SS_REFRACTION: boolean;
  49568. SS_TRANSLUCENCY: boolean;
  49569. SS_SCATERRING: boolean;
  49570. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49571. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49572. SS_REFRACTIONMAP_3D: boolean;
  49573. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49574. SS_LODINREFRACTIONALPHA: boolean;
  49575. SS_GAMMAREFRACTION: boolean;
  49576. SS_RGBDREFRACTION: boolean;
  49577. SS_LINEARSPECULARREFRACTION: boolean;
  49578. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49579. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49580. UNLIT: boolean;
  49581. DEBUGMODE: number;
  49582. /**
  49583. * Initializes the PBR Material defines.
  49584. */
  49585. constructor();
  49586. /**
  49587. * Resets the PBR Material defines.
  49588. */
  49589. reset(): void;
  49590. }
  49591. /**
  49592. * The Physically based material base class of BJS.
  49593. *
  49594. * This offers the main features of a standard PBR material.
  49595. * For more information, please refer to the documentation :
  49596. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49597. */
  49598. export abstract class PBRBaseMaterial extends PushMaterial {
  49599. /**
  49600. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49601. */
  49602. static readonly PBRMATERIAL_OPAQUE: number;
  49603. /**
  49604. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49605. */
  49606. static readonly PBRMATERIAL_ALPHATEST: number;
  49607. /**
  49608. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49609. */
  49610. static readonly PBRMATERIAL_ALPHABLEND: number;
  49611. /**
  49612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49613. * They are also discarded below the alpha cutoff threshold to improve performances.
  49614. */
  49615. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49616. /**
  49617. * Defines the default value of how much AO map is occluding the analytical lights
  49618. * (point spot...).
  49619. */
  49620. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49621. /**
  49622. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49623. */
  49624. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49625. /**
  49626. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49627. * to enhance interoperability with other engines.
  49628. */
  49629. static readonly LIGHTFALLOFF_GLTF: number;
  49630. /**
  49631. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49632. * to enhance interoperability with other materials.
  49633. */
  49634. static readonly LIGHTFALLOFF_STANDARD: number;
  49635. /**
  49636. * Intensity of the direct lights e.g. the four lights available in your scene.
  49637. * This impacts both the direct diffuse and specular highlights.
  49638. */
  49639. protected _directIntensity: number;
  49640. /**
  49641. * Intensity of the emissive part of the material.
  49642. * This helps controlling the emissive effect without modifying the emissive color.
  49643. */
  49644. protected _emissiveIntensity: number;
  49645. /**
  49646. * Intensity of the environment e.g. how much the environment will light the object
  49647. * either through harmonics for rough material or through the refelction for shiny ones.
  49648. */
  49649. protected _environmentIntensity: number;
  49650. /**
  49651. * This is a special control allowing the reduction of the specular highlights coming from the
  49652. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49653. */
  49654. protected _specularIntensity: number;
  49655. /**
  49656. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49657. */
  49658. private _lightingInfos;
  49659. /**
  49660. * Debug Control allowing disabling the bump map on this material.
  49661. */
  49662. protected _disableBumpMap: boolean;
  49663. /**
  49664. * AKA Diffuse Texture in standard nomenclature.
  49665. */
  49666. protected _albedoTexture: Nullable<BaseTexture>;
  49667. /**
  49668. * AKA Occlusion Texture in other nomenclature.
  49669. */
  49670. protected _ambientTexture: Nullable<BaseTexture>;
  49671. /**
  49672. * AKA Occlusion Texture Intensity in other nomenclature.
  49673. */
  49674. protected _ambientTextureStrength: number;
  49675. /**
  49676. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49677. * 1 means it completely occludes it
  49678. * 0 mean it has no impact
  49679. */
  49680. protected _ambientTextureImpactOnAnalyticalLights: number;
  49681. /**
  49682. * Stores the alpha values in a texture.
  49683. */
  49684. protected _opacityTexture: Nullable<BaseTexture>;
  49685. /**
  49686. * Stores the reflection values in a texture.
  49687. */
  49688. protected _reflectionTexture: Nullable<BaseTexture>;
  49689. /**
  49690. * Stores the emissive values in a texture.
  49691. */
  49692. protected _emissiveTexture: Nullable<BaseTexture>;
  49693. /**
  49694. * AKA Specular texture in other nomenclature.
  49695. */
  49696. protected _reflectivityTexture: Nullable<BaseTexture>;
  49697. /**
  49698. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49699. */
  49700. protected _metallicTexture: Nullable<BaseTexture>;
  49701. /**
  49702. * Specifies the metallic scalar of the metallic/roughness workflow.
  49703. * Can also be used to scale the metalness values of the metallic texture.
  49704. */
  49705. protected _metallic: Nullable<number>;
  49706. /**
  49707. * Specifies the roughness scalar of the metallic/roughness workflow.
  49708. * Can also be used to scale the roughness values of the metallic texture.
  49709. */
  49710. protected _roughness: Nullable<number>;
  49711. /**
  49712. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49713. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49714. */
  49715. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49716. /**
  49717. * Stores surface normal data used to displace a mesh in a texture.
  49718. */
  49719. protected _bumpTexture: Nullable<BaseTexture>;
  49720. /**
  49721. * Stores the pre-calculated light information of a mesh in a texture.
  49722. */
  49723. protected _lightmapTexture: Nullable<BaseTexture>;
  49724. /**
  49725. * The color of a material in ambient lighting.
  49726. */
  49727. protected _ambientColor: Color3;
  49728. /**
  49729. * AKA Diffuse Color in other nomenclature.
  49730. */
  49731. protected _albedoColor: Color3;
  49732. /**
  49733. * AKA Specular Color in other nomenclature.
  49734. */
  49735. protected _reflectivityColor: Color3;
  49736. /**
  49737. * The color applied when light is reflected from a material.
  49738. */
  49739. protected _reflectionColor: Color3;
  49740. /**
  49741. * The color applied when light is emitted from a material.
  49742. */
  49743. protected _emissiveColor: Color3;
  49744. /**
  49745. * AKA Glossiness in other nomenclature.
  49746. */
  49747. protected _microSurface: number;
  49748. /**
  49749. * Specifies that the material will use the light map as a show map.
  49750. */
  49751. protected _useLightmapAsShadowmap: boolean;
  49752. /**
  49753. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49754. * makes the reflect vector face the model (under horizon).
  49755. */
  49756. protected _useHorizonOcclusion: boolean;
  49757. /**
  49758. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49759. * too much the area relying on ambient texture to define their ambient occlusion.
  49760. */
  49761. protected _useRadianceOcclusion: boolean;
  49762. /**
  49763. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49764. */
  49765. protected _useAlphaFromAlbedoTexture: boolean;
  49766. /**
  49767. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49768. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49769. */
  49770. protected _useSpecularOverAlpha: boolean;
  49771. /**
  49772. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49773. */
  49774. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49775. /**
  49776. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49777. */
  49778. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49779. /**
  49780. * Specifies if the metallic texture contains the roughness information in its green channel.
  49781. */
  49782. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49783. /**
  49784. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49785. */
  49786. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49787. /**
  49788. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49789. */
  49790. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49791. /**
  49792. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49793. */
  49794. protected _useAmbientInGrayScale: boolean;
  49795. /**
  49796. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49797. * The material will try to infer what glossiness each pixel should be.
  49798. */
  49799. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49800. /**
  49801. * Defines the falloff type used in this material.
  49802. * It by default is Physical.
  49803. */
  49804. protected _lightFalloff: number;
  49805. /**
  49806. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49807. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49808. */
  49809. protected _useRadianceOverAlpha: boolean;
  49810. /**
  49811. * Allows using an object space normal map (instead of tangent space).
  49812. */
  49813. protected _useObjectSpaceNormalMap: boolean;
  49814. /**
  49815. * Allows using the bump map in parallax mode.
  49816. */
  49817. protected _useParallax: boolean;
  49818. /**
  49819. * Allows using the bump map in parallax occlusion mode.
  49820. */
  49821. protected _useParallaxOcclusion: boolean;
  49822. /**
  49823. * Controls the scale bias of the parallax mode.
  49824. */
  49825. protected _parallaxScaleBias: number;
  49826. /**
  49827. * If sets to true, disables all the lights affecting the material.
  49828. */
  49829. protected _disableLighting: boolean;
  49830. /**
  49831. * Number of Simultaneous lights allowed on the material.
  49832. */
  49833. protected _maxSimultaneousLights: number;
  49834. /**
  49835. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49836. */
  49837. protected _invertNormalMapX: boolean;
  49838. /**
  49839. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49840. */
  49841. protected _invertNormalMapY: boolean;
  49842. /**
  49843. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49844. */
  49845. protected _twoSidedLighting: boolean;
  49846. /**
  49847. * Defines the alpha limits in alpha test mode.
  49848. */
  49849. protected _alphaCutOff: number;
  49850. /**
  49851. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49852. */
  49853. protected _forceAlphaTest: boolean;
  49854. /**
  49855. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49856. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49857. */
  49858. protected _useAlphaFresnel: boolean;
  49859. /**
  49860. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49861. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49862. */
  49863. protected _useLinearAlphaFresnel: boolean;
  49864. /**
  49865. * The transparency mode of the material.
  49866. */
  49867. protected _transparencyMode: Nullable<number>;
  49868. /**
  49869. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49870. * from cos thetav and roughness:
  49871. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49872. */
  49873. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49874. /**
  49875. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49876. */
  49877. protected _forceIrradianceInFragment: boolean;
  49878. /**
  49879. * Force normal to face away from face.
  49880. */
  49881. protected _forceNormalForward: boolean;
  49882. /**
  49883. * Enables specular anti aliasing in the PBR shader.
  49884. * It will both interacts on the Geometry for analytical and IBL lighting.
  49885. * It also prefilter the roughness map based on the bump values.
  49886. */
  49887. protected _enableSpecularAntiAliasing: boolean;
  49888. /**
  49889. * Default configuration related to image processing available in the PBR Material.
  49890. */
  49891. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49892. /**
  49893. * Keep track of the image processing observer to allow dispose and replace.
  49894. */
  49895. private _imageProcessingObserver;
  49896. /**
  49897. * Attaches a new image processing configuration to the PBR Material.
  49898. * @param configuration
  49899. */
  49900. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49901. /**
  49902. * Stores the available render targets.
  49903. */
  49904. private _renderTargets;
  49905. /**
  49906. * Sets the global ambient color for the material used in lighting calculations.
  49907. */
  49908. private _globalAmbientColor;
  49909. /**
  49910. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49911. */
  49912. private _useLogarithmicDepth;
  49913. /**
  49914. * If set to true, no lighting calculations will be applied.
  49915. */
  49916. private _unlit;
  49917. private _debugMode;
  49918. /**
  49919. * @hidden
  49920. * This is reserved for the inspector.
  49921. * Defines the material debug mode.
  49922. * It helps seeing only some components of the material while troubleshooting.
  49923. */
  49924. debugMode: number;
  49925. /**
  49926. * @hidden
  49927. * This is reserved for the inspector.
  49928. * Specify from where on screen the debug mode should start.
  49929. * The value goes from -1 (full screen) to 1 (not visible)
  49930. * It helps with side by side comparison against the final render
  49931. * This defaults to -1
  49932. */
  49933. private debugLimit;
  49934. /**
  49935. * @hidden
  49936. * This is reserved for the inspector.
  49937. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49938. * You can use the factor to better multiply the final value.
  49939. */
  49940. private debugFactor;
  49941. /**
  49942. * Defines the clear coat layer parameters for the material.
  49943. */
  49944. readonly clearCoat: PBRClearCoatConfiguration;
  49945. /**
  49946. * Defines the anisotropic parameters for the material.
  49947. */
  49948. readonly anisotropy: PBRAnisotropicConfiguration;
  49949. /**
  49950. * Defines the BRDF parameters for the material.
  49951. */
  49952. readonly brdf: PBRBRDFConfiguration;
  49953. /**
  49954. * Defines the Sheen parameters for the material.
  49955. */
  49956. readonly sheen: PBRSheenConfiguration;
  49957. /**
  49958. * Defines the SubSurface parameters for the material.
  49959. */
  49960. readonly subSurface: PBRSubSurfaceConfiguration;
  49961. /**
  49962. * Custom callback helping to override the default shader used in the material.
  49963. */
  49964. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49965. protected _rebuildInParallel: boolean;
  49966. /**
  49967. * Instantiates a new PBRMaterial instance.
  49968. *
  49969. * @param name The material name
  49970. * @param scene The scene the material will be use in.
  49971. */
  49972. constructor(name: string, scene: Scene);
  49973. /**
  49974. * Gets a boolean indicating that current material needs to register RTT
  49975. */
  49976. readonly hasRenderTargetTextures: boolean;
  49977. /**
  49978. * Gets the name of the material class.
  49979. */
  49980. getClassName(): string;
  49981. /**
  49982. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49983. */
  49984. /**
  49985. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49986. */
  49987. useLogarithmicDepth: boolean;
  49988. /**
  49989. * Gets the current transparency mode.
  49990. */
  49991. /**
  49992. * Sets the transparency mode of the material.
  49993. *
  49994. * | Value | Type | Description |
  49995. * | ----- | ----------------------------------- | ----------- |
  49996. * | 0 | OPAQUE | |
  49997. * | 1 | ALPHATEST | |
  49998. * | 2 | ALPHABLEND | |
  49999. * | 3 | ALPHATESTANDBLEND | |
  50000. *
  50001. */
  50002. transparencyMode: Nullable<number>;
  50003. /**
  50004. * Returns true if alpha blending should be disabled.
  50005. */
  50006. private readonly _disableAlphaBlending;
  50007. /**
  50008. * Specifies whether or not this material should be rendered in alpha blend mode.
  50009. */
  50010. needAlphaBlending(): boolean;
  50011. /**
  50012. * Specifies if the mesh will require alpha blending.
  50013. * @param mesh - BJS mesh.
  50014. */
  50015. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50016. /**
  50017. * Specifies whether or not this material should be rendered in alpha test mode.
  50018. */
  50019. needAlphaTesting(): boolean;
  50020. /**
  50021. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50022. */
  50023. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50024. /**
  50025. * Gets the texture used for the alpha test.
  50026. */
  50027. getAlphaTestTexture(): Nullable<BaseTexture>;
  50028. /**
  50029. * Specifies that the submesh is ready to be used.
  50030. * @param mesh - BJS mesh.
  50031. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50032. * @param useInstances - Specifies that instances should be used.
  50033. * @returns - boolean indicating that the submesh is ready or not.
  50034. */
  50035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50036. /**
  50037. * Specifies if the material uses metallic roughness workflow.
  50038. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50039. */
  50040. isMetallicWorkflow(): boolean;
  50041. private _prepareEffect;
  50042. private _prepareDefines;
  50043. /**
  50044. * Force shader compilation
  50045. */
  50046. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50047. clipPlane: boolean;
  50048. }>): void;
  50049. /**
  50050. * Initializes the uniform buffer layout for the shader.
  50051. */
  50052. buildUniformLayout(): void;
  50053. /**
  50054. * Unbinds the material from the mesh
  50055. */
  50056. unbind(): void;
  50057. /**
  50058. * Binds the submesh data.
  50059. * @param world - The world matrix.
  50060. * @param mesh - The BJS mesh.
  50061. * @param subMesh - A submesh of the BJS mesh.
  50062. */
  50063. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50064. /**
  50065. * Returns the animatable textures.
  50066. * @returns - Array of animatable textures.
  50067. */
  50068. getAnimatables(): IAnimatable[];
  50069. /**
  50070. * Returns the texture used for reflections.
  50071. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50072. */
  50073. private _getReflectionTexture;
  50074. /**
  50075. * Returns an array of the actively used textures.
  50076. * @returns - Array of BaseTextures
  50077. */
  50078. getActiveTextures(): BaseTexture[];
  50079. /**
  50080. * Checks to see if a texture is used in the material.
  50081. * @param texture - Base texture to use.
  50082. * @returns - Boolean specifying if a texture is used in the material.
  50083. */
  50084. hasTexture(texture: BaseTexture): boolean;
  50085. /**
  50086. * Disposes the resources of the material.
  50087. * @param forceDisposeEffect - Forces the disposal of effects.
  50088. * @param forceDisposeTextures - Forces the disposal of all textures.
  50089. */
  50090. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50091. }
  50092. }
  50093. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50094. import { Nullable } from "babylonjs/types";
  50095. import { Scene } from "babylonjs/scene";
  50096. import { Color3 } from "babylonjs/Maths/math.color";
  50097. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50098. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50099. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50100. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50101. /**
  50102. * The Physically based material of BJS.
  50103. *
  50104. * This offers the main features of a standard PBR material.
  50105. * For more information, please refer to the documentation :
  50106. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50107. */
  50108. export class PBRMaterial extends PBRBaseMaterial {
  50109. /**
  50110. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50111. */
  50112. static readonly PBRMATERIAL_OPAQUE: number;
  50113. /**
  50114. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50115. */
  50116. static readonly PBRMATERIAL_ALPHATEST: number;
  50117. /**
  50118. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50119. */
  50120. static readonly PBRMATERIAL_ALPHABLEND: number;
  50121. /**
  50122. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50123. * They are also discarded below the alpha cutoff threshold to improve performances.
  50124. */
  50125. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50126. /**
  50127. * Defines the default value of how much AO map is occluding the analytical lights
  50128. * (point spot...).
  50129. */
  50130. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50131. /**
  50132. * Intensity of the direct lights e.g. the four lights available in your scene.
  50133. * This impacts both the direct diffuse and specular highlights.
  50134. */
  50135. directIntensity: number;
  50136. /**
  50137. * Intensity of the emissive part of the material.
  50138. * This helps controlling the emissive effect without modifying the emissive color.
  50139. */
  50140. emissiveIntensity: number;
  50141. /**
  50142. * Intensity of the environment e.g. how much the environment will light the object
  50143. * either through harmonics for rough material or through the refelction for shiny ones.
  50144. */
  50145. environmentIntensity: number;
  50146. /**
  50147. * This is a special control allowing the reduction of the specular highlights coming from the
  50148. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50149. */
  50150. specularIntensity: number;
  50151. /**
  50152. * Debug Control allowing disabling the bump map on this material.
  50153. */
  50154. disableBumpMap: boolean;
  50155. /**
  50156. * AKA Diffuse Texture in standard nomenclature.
  50157. */
  50158. albedoTexture: BaseTexture;
  50159. /**
  50160. * AKA Occlusion Texture in other nomenclature.
  50161. */
  50162. ambientTexture: BaseTexture;
  50163. /**
  50164. * AKA Occlusion Texture Intensity in other nomenclature.
  50165. */
  50166. ambientTextureStrength: number;
  50167. /**
  50168. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50169. * 1 means it completely occludes it
  50170. * 0 mean it has no impact
  50171. */
  50172. ambientTextureImpactOnAnalyticalLights: number;
  50173. /**
  50174. * Stores the alpha values in a texture.
  50175. */
  50176. opacityTexture: BaseTexture;
  50177. /**
  50178. * Stores the reflection values in a texture.
  50179. */
  50180. reflectionTexture: Nullable<BaseTexture>;
  50181. /**
  50182. * Stores the emissive values in a texture.
  50183. */
  50184. emissiveTexture: BaseTexture;
  50185. /**
  50186. * AKA Specular texture in other nomenclature.
  50187. */
  50188. reflectivityTexture: BaseTexture;
  50189. /**
  50190. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50191. */
  50192. metallicTexture: BaseTexture;
  50193. /**
  50194. * Specifies the metallic scalar of the metallic/roughness workflow.
  50195. * Can also be used to scale the metalness values of the metallic texture.
  50196. */
  50197. metallic: Nullable<number>;
  50198. /**
  50199. * Specifies the roughness scalar of the metallic/roughness workflow.
  50200. * Can also be used to scale the roughness values of the metallic texture.
  50201. */
  50202. roughness: Nullable<number>;
  50203. /**
  50204. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50205. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50206. */
  50207. microSurfaceTexture: BaseTexture;
  50208. /**
  50209. * Stores surface normal data used to displace a mesh in a texture.
  50210. */
  50211. bumpTexture: BaseTexture;
  50212. /**
  50213. * Stores the pre-calculated light information of a mesh in a texture.
  50214. */
  50215. lightmapTexture: BaseTexture;
  50216. /**
  50217. * Stores the refracted light information in a texture.
  50218. */
  50219. refractionTexture: Nullable<BaseTexture>;
  50220. /**
  50221. * The color of a material in ambient lighting.
  50222. */
  50223. ambientColor: Color3;
  50224. /**
  50225. * AKA Diffuse Color in other nomenclature.
  50226. */
  50227. albedoColor: Color3;
  50228. /**
  50229. * AKA Specular Color in other nomenclature.
  50230. */
  50231. reflectivityColor: Color3;
  50232. /**
  50233. * The color reflected from the material.
  50234. */
  50235. reflectionColor: Color3;
  50236. /**
  50237. * The color emitted from the material.
  50238. */
  50239. emissiveColor: Color3;
  50240. /**
  50241. * AKA Glossiness in other nomenclature.
  50242. */
  50243. microSurface: number;
  50244. /**
  50245. * source material index of refraction (IOR)' / 'destination material IOR.
  50246. */
  50247. indexOfRefraction: number;
  50248. /**
  50249. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50250. */
  50251. invertRefractionY: boolean;
  50252. /**
  50253. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50254. * Materials half opaque for instance using refraction could benefit from this control.
  50255. */
  50256. linkRefractionWithTransparency: boolean;
  50257. /**
  50258. * If true, the light map contains occlusion information instead of lighting info.
  50259. */
  50260. useLightmapAsShadowmap: boolean;
  50261. /**
  50262. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50263. */
  50264. useAlphaFromAlbedoTexture: boolean;
  50265. /**
  50266. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50267. */
  50268. forceAlphaTest: boolean;
  50269. /**
  50270. * Defines the alpha limits in alpha test mode.
  50271. */
  50272. alphaCutOff: number;
  50273. /**
  50274. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50275. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50276. */
  50277. useSpecularOverAlpha: boolean;
  50278. /**
  50279. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50280. */
  50281. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50282. /**
  50283. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50284. */
  50285. useRoughnessFromMetallicTextureAlpha: boolean;
  50286. /**
  50287. * Specifies if the metallic texture contains the roughness information in its green channel.
  50288. */
  50289. useRoughnessFromMetallicTextureGreen: boolean;
  50290. /**
  50291. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50292. */
  50293. useMetallnessFromMetallicTextureBlue: boolean;
  50294. /**
  50295. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50296. */
  50297. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50298. /**
  50299. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50300. */
  50301. useAmbientInGrayScale: boolean;
  50302. /**
  50303. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50304. * The material will try to infer what glossiness each pixel should be.
  50305. */
  50306. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50307. /**
  50308. * BJS is using an harcoded light falloff based on a manually sets up range.
  50309. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50310. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50311. */
  50312. /**
  50313. * BJS is using an harcoded light falloff based on a manually sets up range.
  50314. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50315. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50316. */
  50317. usePhysicalLightFalloff: boolean;
  50318. /**
  50319. * In order to support the falloff compatibility with gltf, a special mode has been added
  50320. * to reproduce the gltf light falloff.
  50321. */
  50322. /**
  50323. * In order to support the falloff compatibility with gltf, a special mode has been added
  50324. * to reproduce the gltf light falloff.
  50325. */
  50326. useGLTFLightFalloff: boolean;
  50327. /**
  50328. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50329. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50330. */
  50331. useRadianceOverAlpha: boolean;
  50332. /**
  50333. * Allows using an object space normal map (instead of tangent space).
  50334. */
  50335. useObjectSpaceNormalMap: boolean;
  50336. /**
  50337. * Allows using the bump map in parallax mode.
  50338. */
  50339. useParallax: boolean;
  50340. /**
  50341. * Allows using the bump map in parallax occlusion mode.
  50342. */
  50343. useParallaxOcclusion: boolean;
  50344. /**
  50345. * Controls the scale bias of the parallax mode.
  50346. */
  50347. parallaxScaleBias: number;
  50348. /**
  50349. * If sets to true, disables all the lights affecting the material.
  50350. */
  50351. disableLighting: boolean;
  50352. /**
  50353. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50354. */
  50355. forceIrradianceInFragment: boolean;
  50356. /**
  50357. * Number of Simultaneous lights allowed on the material.
  50358. */
  50359. maxSimultaneousLights: number;
  50360. /**
  50361. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50362. */
  50363. invertNormalMapX: boolean;
  50364. /**
  50365. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50366. */
  50367. invertNormalMapY: boolean;
  50368. /**
  50369. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50370. */
  50371. twoSidedLighting: boolean;
  50372. /**
  50373. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50374. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50375. */
  50376. useAlphaFresnel: boolean;
  50377. /**
  50378. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50379. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50380. */
  50381. useLinearAlphaFresnel: boolean;
  50382. /**
  50383. * Let user defines the brdf lookup texture used for IBL.
  50384. * A default 8bit version is embedded but you could point at :
  50385. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50386. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50387. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50388. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50389. */
  50390. environmentBRDFTexture: Nullable<BaseTexture>;
  50391. /**
  50392. * Force normal to face away from face.
  50393. */
  50394. forceNormalForward: boolean;
  50395. /**
  50396. * Enables specular anti aliasing in the PBR shader.
  50397. * It will both interacts on the Geometry for analytical and IBL lighting.
  50398. * It also prefilter the roughness map based on the bump values.
  50399. */
  50400. enableSpecularAntiAliasing: boolean;
  50401. /**
  50402. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50403. * makes the reflect vector face the model (under horizon).
  50404. */
  50405. useHorizonOcclusion: boolean;
  50406. /**
  50407. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50408. * too much the area relying on ambient texture to define their ambient occlusion.
  50409. */
  50410. useRadianceOcclusion: boolean;
  50411. /**
  50412. * If set to true, no lighting calculations will be applied.
  50413. */
  50414. unlit: boolean;
  50415. /**
  50416. * Gets the image processing configuration used either in this material.
  50417. */
  50418. /**
  50419. * Sets the Default image processing configuration used either in the this material.
  50420. *
  50421. * If sets to null, the scene one is in use.
  50422. */
  50423. imageProcessingConfiguration: ImageProcessingConfiguration;
  50424. /**
  50425. * Gets wether the color curves effect is enabled.
  50426. */
  50427. /**
  50428. * Sets wether the color curves effect is enabled.
  50429. */
  50430. cameraColorCurvesEnabled: boolean;
  50431. /**
  50432. * Gets wether the color grading effect is enabled.
  50433. */
  50434. /**
  50435. * Gets wether the color grading effect is enabled.
  50436. */
  50437. cameraColorGradingEnabled: boolean;
  50438. /**
  50439. * Gets wether tonemapping is enabled or not.
  50440. */
  50441. /**
  50442. * Sets wether tonemapping is enabled or not
  50443. */
  50444. cameraToneMappingEnabled: boolean;
  50445. /**
  50446. * The camera exposure used on this material.
  50447. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50448. * This corresponds to a photographic exposure.
  50449. */
  50450. /**
  50451. * The camera exposure used on this material.
  50452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50453. * This corresponds to a photographic exposure.
  50454. */
  50455. cameraExposure: number;
  50456. /**
  50457. * Gets The camera contrast used on this material.
  50458. */
  50459. /**
  50460. * Sets The camera contrast used on this material.
  50461. */
  50462. cameraContrast: number;
  50463. /**
  50464. * Gets the Color Grading 2D Lookup Texture.
  50465. */
  50466. /**
  50467. * Sets the Color Grading 2D Lookup Texture.
  50468. */
  50469. cameraColorGradingTexture: Nullable<BaseTexture>;
  50470. /**
  50471. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50472. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50473. * 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;
  50474. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50475. */
  50476. /**
  50477. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50478. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50479. * 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;
  50480. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50481. */
  50482. cameraColorCurves: Nullable<ColorCurves>;
  50483. /**
  50484. * Instantiates a new PBRMaterial instance.
  50485. *
  50486. * @param name The material name
  50487. * @param scene The scene the material will be use in.
  50488. */
  50489. constructor(name: string, scene: Scene);
  50490. /**
  50491. * Returns the name of this material class.
  50492. */
  50493. getClassName(): string;
  50494. /**
  50495. * Makes a duplicate of the current material.
  50496. * @param name - name to use for the new material.
  50497. */
  50498. clone(name: string): PBRMaterial;
  50499. /**
  50500. * Serializes this PBR Material.
  50501. * @returns - An object with the serialized material.
  50502. */
  50503. serialize(): any;
  50504. /**
  50505. * Parses a PBR Material from a serialized object.
  50506. * @param source - Serialized object.
  50507. * @param scene - BJS scene instance.
  50508. * @param rootUrl - url for the scene object
  50509. * @returns - PBRMaterial
  50510. */
  50511. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50512. }
  50513. }
  50514. declare module "babylonjs/Misc/dds" {
  50515. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50517. import { Nullable } from "babylonjs/types";
  50518. import { Scene } from "babylonjs/scene";
  50519. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50520. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50521. /**
  50522. * Direct draw surface info
  50523. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50524. */
  50525. export interface DDSInfo {
  50526. /**
  50527. * Width of the texture
  50528. */
  50529. width: number;
  50530. /**
  50531. * Width of the texture
  50532. */
  50533. height: number;
  50534. /**
  50535. * Number of Mipmaps for the texture
  50536. * @see https://en.wikipedia.org/wiki/Mipmap
  50537. */
  50538. mipmapCount: number;
  50539. /**
  50540. * If the textures format is a known fourCC format
  50541. * @see https://www.fourcc.org/
  50542. */
  50543. isFourCC: boolean;
  50544. /**
  50545. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50546. */
  50547. isRGB: boolean;
  50548. /**
  50549. * If the texture is a lumincance format
  50550. */
  50551. isLuminance: boolean;
  50552. /**
  50553. * If this is a cube texture
  50554. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50555. */
  50556. isCube: boolean;
  50557. /**
  50558. * If the texture is a compressed format eg. FOURCC_DXT1
  50559. */
  50560. isCompressed: boolean;
  50561. /**
  50562. * The dxgiFormat of the texture
  50563. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50564. */
  50565. dxgiFormat: number;
  50566. /**
  50567. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50568. */
  50569. textureType: number;
  50570. /**
  50571. * Sphericle polynomial created for the dds texture
  50572. */
  50573. sphericalPolynomial?: SphericalPolynomial;
  50574. }
  50575. /**
  50576. * Class used to provide DDS decompression tools
  50577. */
  50578. export class DDSTools {
  50579. /**
  50580. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50581. */
  50582. static StoreLODInAlphaChannel: boolean;
  50583. /**
  50584. * Gets DDS information from an array buffer
  50585. * @param arrayBuffer defines the array buffer to read data from
  50586. * @returns the DDS information
  50587. */
  50588. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50589. private static _FloatView;
  50590. private static _Int32View;
  50591. private static _ToHalfFloat;
  50592. private static _FromHalfFloat;
  50593. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50594. private static _GetHalfFloatRGBAArrayBuffer;
  50595. private static _GetFloatRGBAArrayBuffer;
  50596. private static _GetFloatAsUIntRGBAArrayBuffer;
  50597. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50598. private static _GetRGBAArrayBuffer;
  50599. private static _ExtractLongWordOrder;
  50600. private static _GetRGBArrayBuffer;
  50601. private static _GetLuminanceArrayBuffer;
  50602. /**
  50603. * Uploads DDS Levels to a Babylon Texture
  50604. * @hidden
  50605. */
  50606. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50607. }
  50608. module "babylonjs/Engines/thinEngine" {
  50609. interface ThinEngine {
  50610. /**
  50611. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50612. * @param rootUrl defines the url where the file to load is located
  50613. * @param scene defines the current scene
  50614. * @param lodScale defines scale to apply to the mip map selection
  50615. * @param lodOffset defines offset to apply to the mip map selection
  50616. * @param onLoad defines an optional callback raised when the texture is loaded
  50617. * @param onError defines an optional callback raised if there is an issue to load the texture
  50618. * @param format defines the format of the data
  50619. * @param forcedExtension defines the extension to use to pick the right loader
  50620. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50621. * @returns the cube texture as an InternalTexture
  50622. */
  50623. 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;
  50624. }
  50625. }
  50626. }
  50627. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50628. import { Nullable } from "babylonjs/types";
  50629. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50630. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50631. /**
  50632. * Implementation of the DDS Texture Loader.
  50633. * @hidden
  50634. */
  50635. export class _DDSTextureLoader implements IInternalTextureLoader {
  50636. /**
  50637. * Defines wether the loader supports cascade loading the different faces.
  50638. */
  50639. readonly supportCascades: boolean;
  50640. /**
  50641. * This returns if the loader support the current file information.
  50642. * @param extension defines the file extension of the file being loaded
  50643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50644. * @param fallback defines the fallback internal texture if any
  50645. * @param isBase64 defines whether the texture is encoded as a base64
  50646. * @param isBuffer defines whether the texture data are stored as a buffer
  50647. * @returns true if the loader can load the specified file
  50648. */
  50649. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50650. /**
  50651. * Transform the url before loading if required.
  50652. * @param rootUrl the url of the texture
  50653. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50654. * @returns the transformed texture
  50655. */
  50656. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50657. /**
  50658. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50659. * @param rootUrl the url of the texture
  50660. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50661. * @returns the fallback texture
  50662. */
  50663. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50664. /**
  50665. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50666. * @param data contains the texture data
  50667. * @param texture defines the BabylonJS internal texture
  50668. * @param createPolynomials will be true if polynomials have been requested
  50669. * @param onLoad defines the callback to trigger once the texture is ready
  50670. * @param onError defines the callback to trigger in case of error
  50671. */
  50672. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50673. /**
  50674. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50675. * @param data contains the texture data
  50676. * @param texture defines the BabylonJS internal texture
  50677. * @param callback defines the method to call once ready to upload
  50678. */
  50679. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50680. }
  50681. }
  50682. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50683. import { Nullable } from "babylonjs/types";
  50684. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50685. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50686. /**
  50687. * Implementation of the ENV Texture Loader.
  50688. * @hidden
  50689. */
  50690. export class _ENVTextureLoader implements IInternalTextureLoader {
  50691. /**
  50692. * Defines wether the loader supports cascade loading the different faces.
  50693. */
  50694. readonly supportCascades: boolean;
  50695. /**
  50696. * This returns if the loader support the current file information.
  50697. * @param extension defines the file extension of the file being loaded
  50698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50699. * @param fallback defines the fallback internal texture if any
  50700. * @param isBase64 defines whether the texture is encoded as a base64
  50701. * @param isBuffer defines whether the texture data are stored as a buffer
  50702. * @returns true if the loader can load the specified file
  50703. */
  50704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50705. /**
  50706. * Transform the url before loading if required.
  50707. * @param rootUrl the url of the texture
  50708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50709. * @returns the transformed texture
  50710. */
  50711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50712. /**
  50713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50714. * @param rootUrl the url of the texture
  50715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50716. * @returns the fallback texture
  50717. */
  50718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50719. /**
  50720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50721. * @param data contains the texture data
  50722. * @param texture defines the BabylonJS internal texture
  50723. * @param createPolynomials will be true if polynomials have been requested
  50724. * @param onLoad defines the callback to trigger once the texture is ready
  50725. * @param onError defines the callback to trigger in case of error
  50726. */
  50727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50728. /**
  50729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50730. * @param data contains the texture data
  50731. * @param texture defines the BabylonJS internal texture
  50732. * @param callback defines the method to call once ready to upload
  50733. */
  50734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50735. }
  50736. }
  50737. declare module "babylonjs/Misc/khronosTextureContainer" {
  50738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50739. /**
  50740. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50741. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50742. */
  50743. export class KhronosTextureContainer {
  50744. /** contents of the KTX container file */
  50745. arrayBuffer: any;
  50746. private static HEADER_LEN;
  50747. private static COMPRESSED_2D;
  50748. private static COMPRESSED_3D;
  50749. private static TEX_2D;
  50750. private static TEX_3D;
  50751. /**
  50752. * Gets the openGL type
  50753. */
  50754. glType: number;
  50755. /**
  50756. * Gets the openGL type size
  50757. */
  50758. glTypeSize: number;
  50759. /**
  50760. * Gets the openGL format
  50761. */
  50762. glFormat: number;
  50763. /**
  50764. * Gets the openGL internal format
  50765. */
  50766. glInternalFormat: number;
  50767. /**
  50768. * Gets the base internal format
  50769. */
  50770. glBaseInternalFormat: number;
  50771. /**
  50772. * Gets image width in pixel
  50773. */
  50774. pixelWidth: number;
  50775. /**
  50776. * Gets image height in pixel
  50777. */
  50778. pixelHeight: number;
  50779. /**
  50780. * Gets image depth in pixels
  50781. */
  50782. pixelDepth: number;
  50783. /**
  50784. * Gets the number of array elements
  50785. */
  50786. numberOfArrayElements: number;
  50787. /**
  50788. * Gets the number of faces
  50789. */
  50790. numberOfFaces: number;
  50791. /**
  50792. * Gets the number of mipmap levels
  50793. */
  50794. numberOfMipmapLevels: number;
  50795. /**
  50796. * Gets the bytes of key value data
  50797. */
  50798. bytesOfKeyValueData: number;
  50799. /**
  50800. * Gets the load type
  50801. */
  50802. loadType: number;
  50803. /**
  50804. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50805. */
  50806. isInvalid: boolean;
  50807. /**
  50808. * Creates a new KhronosTextureContainer
  50809. * @param arrayBuffer contents of the KTX container file
  50810. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50811. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50812. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50813. */
  50814. constructor(
  50815. /** contents of the KTX container file */
  50816. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50817. /**
  50818. * Uploads KTX content to a Babylon Texture.
  50819. * It is assumed that the texture has already been created & is currently bound
  50820. * @hidden
  50821. */
  50822. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50823. private _upload2DCompressedLevels;
  50824. }
  50825. }
  50826. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50827. import { Nullable } from "babylonjs/types";
  50828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50829. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50830. /**
  50831. * Implementation of the KTX Texture Loader.
  50832. * @hidden
  50833. */
  50834. export class _KTXTextureLoader implements IInternalTextureLoader {
  50835. /**
  50836. * Defines wether the loader supports cascade loading the different faces.
  50837. */
  50838. readonly supportCascades: boolean;
  50839. /**
  50840. * This returns if the loader support the current file information.
  50841. * @param extension defines the file extension of the file being loaded
  50842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50843. * @param fallback defines the fallback internal texture if any
  50844. * @param isBase64 defines whether the texture is encoded as a base64
  50845. * @param isBuffer defines whether the texture data are stored as a buffer
  50846. * @returns true if the loader can load the specified file
  50847. */
  50848. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50849. /**
  50850. * Transform the url before loading if required.
  50851. * @param rootUrl the url of the texture
  50852. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50853. * @returns the transformed texture
  50854. */
  50855. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50856. /**
  50857. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50858. * @param rootUrl the url of the texture
  50859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50860. * @returns the fallback texture
  50861. */
  50862. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50863. /**
  50864. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50865. * @param data contains the texture data
  50866. * @param texture defines the BabylonJS internal texture
  50867. * @param createPolynomials will be true if polynomials have been requested
  50868. * @param onLoad defines the callback to trigger once the texture is ready
  50869. * @param onError defines the callback to trigger in case of error
  50870. */
  50871. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50872. /**
  50873. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50874. * @param data contains the texture data
  50875. * @param texture defines the BabylonJS internal texture
  50876. * @param callback defines the method to call once ready to upload
  50877. */
  50878. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50879. }
  50880. }
  50881. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50882. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50883. import { Scene } from "babylonjs/scene";
  50884. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50885. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50886. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50887. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50888. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50889. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50891. /**
  50892. * Options for the default xr helper
  50893. */
  50894. export class WebXRDefaultExperienceOptions {
  50895. /**
  50896. * Floor meshes that should be used for teleporting
  50897. */
  50898. floorMeshes: Array<AbstractMesh>;
  50899. }
  50900. /**
  50901. * Default experience which provides a similar setup to the previous webVRExperience
  50902. */
  50903. export class WebXRDefaultExperience {
  50904. /**
  50905. * Base experience
  50906. */
  50907. baseExperience: WebXRExperienceHelper;
  50908. /**
  50909. * Input experience extension
  50910. */
  50911. input: WebXRInput;
  50912. /**
  50913. * Loads the controller models
  50914. */
  50915. controllerModelLoader: WebXRControllerModelLoader;
  50916. /**
  50917. * Enables laser pointer and selection
  50918. */
  50919. pointerSelection: WebXRControllerPointerSelection;
  50920. /**
  50921. * Enables teleportation
  50922. */
  50923. teleportation: WebXRControllerTeleportation;
  50924. /**
  50925. * Enables ui for enetering/exiting xr
  50926. */
  50927. enterExitUI: WebXREnterExitUI;
  50928. /**
  50929. * Default output canvas xr should render to
  50930. */
  50931. outputCanvas: WebXRManagedOutputCanvas;
  50932. /**
  50933. * Creates the default xr experience
  50934. * @param scene scene
  50935. * @param options options for basic configuration
  50936. * @returns resulting WebXRDefaultExperience
  50937. */
  50938. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50939. private constructor();
  50940. /**
  50941. * DIsposes of the experience helper
  50942. */
  50943. dispose(): void;
  50944. }
  50945. }
  50946. declare module "babylonjs/Helpers/sceneHelpers" {
  50947. import { Nullable } from "babylonjs/types";
  50948. import { Mesh } from "babylonjs/Meshes/mesh";
  50949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50950. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50951. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50952. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50953. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50954. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50955. import "babylonjs/Meshes/Builders/boxBuilder";
  50956. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50957. /** @hidden */
  50958. export var _forceSceneHelpersToBundle: boolean;
  50959. module "babylonjs/scene" {
  50960. interface Scene {
  50961. /**
  50962. * Creates a default light for the scene.
  50963. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50964. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50965. */
  50966. createDefaultLight(replace?: boolean): void;
  50967. /**
  50968. * Creates a default camera for the scene.
  50969. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50970. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50971. * @param replace has default false, when true replaces the active camera in the scene
  50972. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50973. */
  50974. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50975. /**
  50976. * Creates a default camera and a default light.
  50977. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50978. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50979. * @param replace has the default false, when true replaces the active camera/light in the scene
  50980. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50981. */
  50982. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50983. /**
  50984. * Creates a new sky box
  50985. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50986. * @param environmentTexture defines the texture to use as environment texture
  50987. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50988. * @param scale defines the overall scale of the skybox
  50989. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50990. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50991. * @returns a new mesh holding the sky box
  50992. */
  50993. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50994. /**
  50995. * Creates a new environment
  50996. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50997. * @param options defines the options you can use to configure the environment
  50998. * @returns the new EnvironmentHelper
  50999. */
  51000. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51001. /**
  51002. * Creates a new VREXperienceHelper
  51003. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51004. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51005. * @returns a new VREXperienceHelper
  51006. */
  51007. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51008. /**
  51009. * Creates a new WebXRDefaultExperience
  51010. * @see http://doc.babylonjs.com/how_to/webxr
  51011. * @param options experience options
  51012. * @returns a promise for a new WebXRDefaultExperience
  51013. */
  51014. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51015. }
  51016. }
  51017. }
  51018. declare module "babylonjs/Helpers/videoDome" {
  51019. import { Scene } from "babylonjs/scene";
  51020. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51021. import { Mesh } from "babylonjs/Meshes/mesh";
  51022. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51023. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51024. import "babylonjs/Meshes/Builders/sphereBuilder";
  51025. /**
  51026. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51027. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51028. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51029. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51030. */
  51031. export class VideoDome extends TransformNode {
  51032. /**
  51033. * Define the video source as a Monoscopic panoramic 360 video.
  51034. */
  51035. static readonly MODE_MONOSCOPIC: number;
  51036. /**
  51037. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51038. */
  51039. static readonly MODE_TOPBOTTOM: number;
  51040. /**
  51041. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51042. */
  51043. static readonly MODE_SIDEBYSIDE: number;
  51044. private _halfDome;
  51045. private _useDirectMapping;
  51046. /**
  51047. * The video texture being displayed on the sphere
  51048. */
  51049. protected _videoTexture: VideoTexture;
  51050. /**
  51051. * Gets the video texture being displayed on the sphere
  51052. */
  51053. readonly videoTexture: VideoTexture;
  51054. /**
  51055. * The skybox material
  51056. */
  51057. protected _material: BackgroundMaterial;
  51058. /**
  51059. * The surface used for the skybox
  51060. */
  51061. protected _mesh: Mesh;
  51062. /**
  51063. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51064. */
  51065. private _halfDomeMask;
  51066. /**
  51067. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51068. * Also see the options.resolution property.
  51069. */
  51070. fovMultiplier: number;
  51071. private _videoMode;
  51072. /**
  51073. * Gets or set the current video mode for the video. It can be:
  51074. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51075. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51076. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51077. */
  51078. videoMode: number;
  51079. /**
  51080. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51081. *
  51082. */
  51083. /**
  51084. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51085. */
  51086. halfDome: boolean;
  51087. /**
  51088. * Oberserver used in Stereoscopic VR Mode.
  51089. */
  51090. private _onBeforeCameraRenderObserver;
  51091. /**
  51092. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51093. * @param name Element's name, child elements will append suffixes for their own names.
  51094. * @param urlsOrVideo defines the url(s) or the video element to use
  51095. * @param options An object containing optional or exposed sub element properties
  51096. */
  51097. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51098. resolution?: number;
  51099. clickToPlay?: boolean;
  51100. autoPlay?: boolean;
  51101. loop?: boolean;
  51102. size?: number;
  51103. poster?: string;
  51104. faceForward?: boolean;
  51105. useDirectMapping?: boolean;
  51106. halfDomeMode?: boolean;
  51107. }, scene: Scene);
  51108. private _changeVideoMode;
  51109. /**
  51110. * Releases resources associated with this node.
  51111. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51112. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51113. */
  51114. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51115. }
  51116. }
  51117. declare module "babylonjs/Helpers/index" {
  51118. export * from "babylonjs/Helpers/environmentHelper";
  51119. export * from "babylonjs/Helpers/photoDome";
  51120. export * from "babylonjs/Helpers/sceneHelpers";
  51121. export * from "babylonjs/Helpers/videoDome";
  51122. }
  51123. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51124. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51125. import { IDisposable } from "babylonjs/scene";
  51126. import { Engine } from "babylonjs/Engines/engine";
  51127. /**
  51128. * This class can be used to get instrumentation data from a Babylon engine
  51129. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51130. */
  51131. export class EngineInstrumentation implements IDisposable {
  51132. /**
  51133. * Define the instrumented engine.
  51134. */
  51135. engine: Engine;
  51136. private _captureGPUFrameTime;
  51137. private _gpuFrameTimeToken;
  51138. private _gpuFrameTime;
  51139. private _captureShaderCompilationTime;
  51140. private _shaderCompilationTime;
  51141. private _onBeginFrameObserver;
  51142. private _onEndFrameObserver;
  51143. private _onBeforeShaderCompilationObserver;
  51144. private _onAfterShaderCompilationObserver;
  51145. /**
  51146. * Gets the perf counter used for GPU frame time
  51147. */
  51148. readonly gpuFrameTimeCounter: PerfCounter;
  51149. /**
  51150. * Gets the GPU frame time capture status
  51151. */
  51152. /**
  51153. * Enable or disable the GPU frame time capture
  51154. */
  51155. captureGPUFrameTime: boolean;
  51156. /**
  51157. * Gets the perf counter used for shader compilation time
  51158. */
  51159. readonly shaderCompilationTimeCounter: PerfCounter;
  51160. /**
  51161. * Gets the shader compilation time capture status
  51162. */
  51163. /**
  51164. * Enable or disable the shader compilation time capture
  51165. */
  51166. captureShaderCompilationTime: boolean;
  51167. /**
  51168. * Instantiates a new engine instrumentation.
  51169. * This class can be used to get instrumentation data from a Babylon engine
  51170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51171. * @param engine Defines the engine to instrument
  51172. */
  51173. constructor(
  51174. /**
  51175. * Define the instrumented engine.
  51176. */
  51177. engine: Engine);
  51178. /**
  51179. * Dispose and release associated resources.
  51180. */
  51181. dispose(): void;
  51182. }
  51183. }
  51184. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51185. import { Scene, IDisposable } from "babylonjs/scene";
  51186. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51187. /**
  51188. * This class can be used to get instrumentation data from a Babylon engine
  51189. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51190. */
  51191. export class SceneInstrumentation implements IDisposable {
  51192. /**
  51193. * Defines the scene to instrument
  51194. */
  51195. scene: Scene;
  51196. private _captureActiveMeshesEvaluationTime;
  51197. private _activeMeshesEvaluationTime;
  51198. private _captureRenderTargetsRenderTime;
  51199. private _renderTargetsRenderTime;
  51200. private _captureFrameTime;
  51201. private _frameTime;
  51202. private _captureRenderTime;
  51203. private _renderTime;
  51204. private _captureInterFrameTime;
  51205. private _interFrameTime;
  51206. private _captureParticlesRenderTime;
  51207. private _particlesRenderTime;
  51208. private _captureSpritesRenderTime;
  51209. private _spritesRenderTime;
  51210. private _capturePhysicsTime;
  51211. private _physicsTime;
  51212. private _captureAnimationsTime;
  51213. private _animationsTime;
  51214. private _captureCameraRenderTime;
  51215. private _cameraRenderTime;
  51216. private _onBeforeActiveMeshesEvaluationObserver;
  51217. private _onAfterActiveMeshesEvaluationObserver;
  51218. private _onBeforeRenderTargetsRenderObserver;
  51219. private _onAfterRenderTargetsRenderObserver;
  51220. private _onAfterRenderObserver;
  51221. private _onBeforeDrawPhaseObserver;
  51222. private _onAfterDrawPhaseObserver;
  51223. private _onBeforeAnimationsObserver;
  51224. private _onBeforeParticlesRenderingObserver;
  51225. private _onAfterParticlesRenderingObserver;
  51226. private _onBeforeSpritesRenderingObserver;
  51227. private _onAfterSpritesRenderingObserver;
  51228. private _onBeforePhysicsObserver;
  51229. private _onAfterPhysicsObserver;
  51230. private _onAfterAnimationsObserver;
  51231. private _onBeforeCameraRenderObserver;
  51232. private _onAfterCameraRenderObserver;
  51233. /**
  51234. * Gets the perf counter used for active meshes evaluation time
  51235. */
  51236. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51237. /**
  51238. * Gets the active meshes evaluation time capture status
  51239. */
  51240. /**
  51241. * Enable or disable the active meshes evaluation time capture
  51242. */
  51243. captureActiveMeshesEvaluationTime: boolean;
  51244. /**
  51245. * Gets the perf counter used for render targets render time
  51246. */
  51247. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51248. /**
  51249. * Gets the render targets render time capture status
  51250. */
  51251. /**
  51252. * Enable or disable the render targets render time capture
  51253. */
  51254. captureRenderTargetsRenderTime: boolean;
  51255. /**
  51256. * Gets the perf counter used for particles render time
  51257. */
  51258. readonly particlesRenderTimeCounter: PerfCounter;
  51259. /**
  51260. * Gets the particles render time capture status
  51261. */
  51262. /**
  51263. * Enable or disable the particles render time capture
  51264. */
  51265. captureParticlesRenderTime: boolean;
  51266. /**
  51267. * Gets the perf counter used for sprites render time
  51268. */
  51269. readonly spritesRenderTimeCounter: PerfCounter;
  51270. /**
  51271. * Gets the sprites render time capture status
  51272. */
  51273. /**
  51274. * Enable or disable the sprites render time capture
  51275. */
  51276. captureSpritesRenderTime: boolean;
  51277. /**
  51278. * Gets the perf counter used for physics time
  51279. */
  51280. readonly physicsTimeCounter: PerfCounter;
  51281. /**
  51282. * Gets the physics time capture status
  51283. */
  51284. /**
  51285. * Enable or disable the physics time capture
  51286. */
  51287. capturePhysicsTime: boolean;
  51288. /**
  51289. * Gets the perf counter used for animations time
  51290. */
  51291. readonly animationsTimeCounter: PerfCounter;
  51292. /**
  51293. * Gets the animations time capture status
  51294. */
  51295. /**
  51296. * Enable or disable the animations time capture
  51297. */
  51298. captureAnimationsTime: boolean;
  51299. /**
  51300. * Gets the perf counter used for frame time capture
  51301. */
  51302. readonly frameTimeCounter: PerfCounter;
  51303. /**
  51304. * Gets the frame time capture status
  51305. */
  51306. /**
  51307. * Enable or disable the frame time capture
  51308. */
  51309. captureFrameTime: boolean;
  51310. /**
  51311. * Gets the perf counter used for inter-frames time capture
  51312. */
  51313. readonly interFrameTimeCounter: PerfCounter;
  51314. /**
  51315. * Gets the inter-frames time capture status
  51316. */
  51317. /**
  51318. * Enable or disable the inter-frames time capture
  51319. */
  51320. captureInterFrameTime: boolean;
  51321. /**
  51322. * Gets the perf counter used for render time capture
  51323. */
  51324. readonly renderTimeCounter: PerfCounter;
  51325. /**
  51326. * Gets the render time capture status
  51327. */
  51328. /**
  51329. * Enable or disable the render time capture
  51330. */
  51331. captureRenderTime: boolean;
  51332. /**
  51333. * Gets the perf counter used for camera render time capture
  51334. */
  51335. readonly cameraRenderTimeCounter: PerfCounter;
  51336. /**
  51337. * Gets the camera render time capture status
  51338. */
  51339. /**
  51340. * Enable or disable the camera render time capture
  51341. */
  51342. captureCameraRenderTime: boolean;
  51343. /**
  51344. * Gets the perf counter used for draw calls
  51345. */
  51346. readonly drawCallsCounter: PerfCounter;
  51347. /**
  51348. * Instantiates a new scene instrumentation.
  51349. * This class can be used to get instrumentation data from a Babylon engine
  51350. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51351. * @param scene Defines the scene to instrument
  51352. */
  51353. constructor(
  51354. /**
  51355. * Defines the scene to instrument
  51356. */
  51357. scene: Scene);
  51358. /**
  51359. * Dispose and release associated resources.
  51360. */
  51361. dispose(): void;
  51362. }
  51363. }
  51364. declare module "babylonjs/Instrumentation/index" {
  51365. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51366. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51367. export * from "babylonjs/Instrumentation/timeToken";
  51368. }
  51369. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51370. /** @hidden */
  51371. export var glowMapGenerationPixelShader: {
  51372. name: string;
  51373. shader: string;
  51374. };
  51375. }
  51376. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51377. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51378. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51379. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51380. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51381. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51382. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51383. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51384. /** @hidden */
  51385. export var glowMapGenerationVertexShader: {
  51386. name: string;
  51387. shader: string;
  51388. };
  51389. }
  51390. declare module "babylonjs/Layers/effectLayer" {
  51391. import { Observable } from "babylonjs/Misc/observable";
  51392. import { Nullable } from "babylonjs/types";
  51393. import { Camera } from "babylonjs/Cameras/camera";
  51394. import { Scene } from "babylonjs/scene";
  51395. import { ISize } from "babylonjs/Maths/math.size";
  51396. import { Color4 } from "babylonjs/Maths/math.color";
  51397. import { Engine } from "babylonjs/Engines/engine";
  51398. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51400. import { Mesh } from "babylonjs/Meshes/mesh";
  51401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51402. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51403. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51404. import { Effect } from "babylonjs/Materials/effect";
  51405. import { Material } from "babylonjs/Materials/material";
  51406. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51407. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51408. /**
  51409. * Effect layer options. This helps customizing the behaviour
  51410. * of the effect layer.
  51411. */
  51412. export interface IEffectLayerOptions {
  51413. /**
  51414. * Multiplication factor apply to the canvas size to compute the render target size
  51415. * used to generated the objects (the smaller the faster).
  51416. */
  51417. mainTextureRatio: number;
  51418. /**
  51419. * Enforces a fixed size texture to ensure effect stability across devices.
  51420. */
  51421. mainTextureFixedSize?: number;
  51422. /**
  51423. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51424. */
  51425. alphaBlendingMode: number;
  51426. /**
  51427. * The camera attached to the layer.
  51428. */
  51429. camera: Nullable<Camera>;
  51430. /**
  51431. * The rendering group to draw the layer in.
  51432. */
  51433. renderingGroupId: number;
  51434. }
  51435. /**
  51436. * The effect layer Helps adding post process effect blended with the main pass.
  51437. *
  51438. * This can be for instance use to generate glow or higlight effects on the scene.
  51439. *
  51440. * The effect layer class can not be used directly and is intented to inherited from to be
  51441. * customized per effects.
  51442. */
  51443. export abstract class EffectLayer {
  51444. private _vertexBuffers;
  51445. private _indexBuffer;
  51446. private _cachedDefines;
  51447. private _effectLayerMapGenerationEffect;
  51448. private _effectLayerOptions;
  51449. private _mergeEffect;
  51450. protected _scene: Scene;
  51451. protected _engine: Engine;
  51452. protected _maxSize: number;
  51453. protected _mainTextureDesiredSize: ISize;
  51454. protected _mainTexture: RenderTargetTexture;
  51455. protected _shouldRender: boolean;
  51456. protected _postProcesses: PostProcess[];
  51457. protected _textures: BaseTexture[];
  51458. protected _emissiveTextureAndColor: {
  51459. texture: Nullable<BaseTexture>;
  51460. color: Color4;
  51461. };
  51462. /**
  51463. * The name of the layer
  51464. */
  51465. name: string;
  51466. /**
  51467. * The clear color of the texture used to generate the glow map.
  51468. */
  51469. neutralColor: Color4;
  51470. /**
  51471. * Specifies wether the highlight layer is enabled or not.
  51472. */
  51473. isEnabled: boolean;
  51474. /**
  51475. * Gets the camera attached to the layer.
  51476. */
  51477. readonly camera: Nullable<Camera>;
  51478. /**
  51479. * Gets the rendering group id the layer should render in.
  51480. */
  51481. renderingGroupId: number;
  51482. /**
  51483. * An event triggered when the effect layer has been disposed.
  51484. */
  51485. onDisposeObservable: Observable<EffectLayer>;
  51486. /**
  51487. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51488. */
  51489. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51490. /**
  51491. * An event triggered when the generated texture is being merged in the scene.
  51492. */
  51493. onBeforeComposeObservable: Observable<EffectLayer>;
  51494. /**
  51495. * An event triggered when the generated texture has been merged in the scene.
  51496. */
  51497. onAfterComposeObservable: Observable<EffectLayer>;
  51498. /**
  51499. * An event triggered when the efffect layer changes its size.
  51500. */
  51501. onSizeChangedObservable: Observable<EffectLayer>;
  51502. /** @hidden */
  51503. static _SceneComponentInitialization: (scene: Scene) => void;
  51504. /**
  51505. * Instantiates a new effect Layer and references it in the scene.
  51506. * @param name The name of the layer
  51507. * @param scene The scene to use the layer in
  51508. */
  51509. constructor(
  51510. /** The Friendly of the effect in the scene */
  51511. name: string, scene: Scene);
  51512. /**
  51513. * Get the effect name of the layer.
  51514. * @return The effect name
  51515. */
  51516. abstract getEffectName(): string;
  51517. /**
  51518. * Checks for the readiness of the element composing the layer.
  51519. * @param subMesh the mesh to check for
  51520. * @param useInstances specify wether or not to use instances to render the mesh
  51521. * @return true if ready otherwise, false
  51522. */
  51523. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51524. /**
  51525. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51526. * @returns true if the effect requires stencil during the main canvas render pass.
  51527. */
  51528. abstract needStencil(): boolean;
  51529. /**
  51530. * Create the merge effect. This is the shader use to blit the information back
  51531. * to the main canvas at the end of the scene rendering.
  51532. * @returns The effect containing the shader used to merge the effect on the main canvas
  51533. */
  51534. protected abstract _createMergeEffect(): Effect;
  51535. /**
  51536. * Creates the render target textures and post processes used in the effect layer.
  51537. */
  51538. protected abstract _createTextureAndPostProcesses(): void;
  51539. /**
  51540. * Implementation specific of rendering the generating effect on the main canvas.
  51541. * @param effect The effect used to render through
  51542. */
  51543. protected abstract _internalRender(effect: Effect): void;
  51544. /**
  51545. * Sets the required values for both the emissive texture and and the main color.
  51546. */
  51547. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51548. /**
  51549. * Free any resources and references associated to a mesh.
  51550. * Internal use
  51551. * @param mesh The mesh to free.
  51552. */
  51553. abstract _disposeMesh(mesh: Mesh): void;
  51554. /**
  51555. * Serializes this layer (Glow or Highlight for example)
  51556. * @returns a serialized layer object
  51557. */
  51558. abstract serialize?(): any;
  51559. /**
  51560. * Initializes the effect layer with the required options.
  51561. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51562. */
  51563. protected _init(options: Partial<IEffectLayerOptions>): void;
  51564. /**
  51565. * Generates the index buffer of the full screen quad blending to the main canvas.
  51566. */
  51567. private _generateIndexBuffer;
  51568. /**
  51569. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51570. */
  51571. private _generateVertexBuffer;
  51572. /**
  51573. * Sets the main texture desired size which is the closest power of two
  51574. * of the engine canvas size.
  51575. */
  51576. private _setMainTextureSize;
  51577. /**
  51578. * Creates the main texture for the effect layer.
  51579. */
  51580. protected _createMainTexture(): void;
  51581. /**
  51582. * Adds specific effects defines.
  51583. * @param defines The defines to add specifics to.
  51584. */
  51585. protected _addCustomEffectDefines(defines: string[]): void;
  51586. /**
  51587. * Checks for the readiness of the element composing the layer.
  51588. * @param subMesh the mesh to check for
  51589. * @param useInstances specify wether or not to use instances to render the mesh
  51590. * @param emissiveTexture the associated emissive texture used to generate the glow
  51591. * @return true if ready otherwise, false
  51592. */
  51593. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51594. /**
  51595. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51596. */
  51597. render(): void;
  51598. /**
  51599. * Determine if a given mesh will be used in the current effect.
  51600. * @param mesh mesh to test
  51601. * @returns true if the mesh will be used
  51602. */
  51603. hasMesh(mesh: AbstractMesh): boolean;
  51604. /**
  51605. * Returns true if the layer contains information to display, otherwise false.
  51606. * @returns true if the glow layer should be rendered
  51607. */
  51608. shouldRender(): boolean;
  51609. /**
  51610. * Returns true if the mesh should render, otherwise false.
  51611. * @param mesh The mesh to render
  51612. * @returns true if it should render otherwise false
  51613. */
  51614. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51615. /**
  51616. * Returns true if the mesh can be rendered, otherwise false.
  51617. * @param mesh The mesh to render
  51618. * @param material The material used on the mesh
  51619. * @returns true if it can be rendered otherwise false
  51620. */
  51621. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51622. /**
  51623. * Returns true if the mesh should render, otherwise false.
  51624. * @param mesh The mesh to render
  51625. * @returns true if it should render otherwise false
  51626. */
  51627. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51628. /**
  51629. * Renders the submesh passed in parameter to the generation map.
  51630. */
  51631. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51632. /**
  51633. * Rebuild the required buffers.
  51634. * @hidden Internal use only.
  51635. */
  51636. _rebuild(): void;
  51637. /**
  51638. * Dispose only the render target textures and post process.
  51639. */
  51640. private _disposeTextureAndPostProcesses;
  51641. /**
  51642. * Dispose the highlight layer and free resources.
  51643. */
  51644. dispose(): void;
  51645. /**
  51646. * Gets the class name of the effect layer
  51647. * @returns the string with the class name of the effect layer
  51648. */
  51649. getClassName(): string;
  51650. /**
  51651. * Creates an effect layer from parsed effect layer data
  51652. * @param parsedEffectLayer defines effect layer data
  51653. * @param scene defines the current scene
  51654. * @param rootUrl defines the root URL containing the effect layer information
  51655. * @returns a parsed effect Layer
  51656. */
  51657. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51658. }
  51659. }
  51660. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51661. import { Scene } from "babylonjs/scene";
  51662. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51663. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51664. import { AbstractScene } from "babylonjs/abstractScene";
  51665. module "babylonjs/abstractScene" {
  51666. interface AbstractScene {
  51667. /**
  51668. * The list of effect layers (highlights/glow) added to the scene
  51669. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51670. * @see http://doc.babylonjs.com/how_to/glow_layer
  51671. */
  51672. effectLayers: Array<EffectLayer>;
  51673. /**
  51674. * Removes the given effect layer from this scene.
  51675. * @param toRemove defines the effect layer to remove
  51676. * @returns the index of the removed effect layer
  51677. */
  51678. removeEffectLayer(toRemove: EffectLayer): number;
  51679. /**
  51680. * Adds the given effect layer to this scene
  51681. * @param newEffectLayer defines the effect layer to add
  51682. */
  51683. addEffectLayer(newEffectLayer: EffectLayer): void;
  51684. }
  51685. }
  51686. /**
  51687. * Defines the layer scene component responsible to manage any effect layers
  51688. * in a given scene.
  51689. */
  51690. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51691. /**
  51692. * The component name helpfull to identify the component in the list of scene components.
  51693. */
  51694. readonly name: string;
  51695. /**
  51696. * The scene the component belongs to.
  51697. */
  51698. scene: Scene;
  51699. private _engine;
  51700. private _renderEffects;
  51701. private _needStencil;
  51702. private _previousStencilState;
  51703. /**
  51704. * Creates a new instance of the component for the given scene
  51705. * @param scene Defines the scene to register the component in
  51706. */
  51707. constructor(scene: Scene);
  51708. /**
  51709. * Registers the component in a given scene
  51710. */
  51711. register(): void;
  51712. /**
  51713. * Rebuilds the elements related to this component in case of
  51714. * context lost for instance.
  51715. */
  51716. rebuild(): void;
  51717. /**
  51718. * Serializes the component data to the specified json object
  51719. * @param serializationObject The object to serialize to
  51720. */
  51721. serialize(serializationObject: any): void;
  51722. /**
  51723. * Adds all the elements from the container to the scene
  51724. * @param container the container holding the elements
  51725. */
  51726. addFromContainer(container: AbstractScene): void;
  51727. /**
  51728. * Removes all the elements in the container from the scene
  51729. * @param container contains the elements to remove
  51730. * @param dispose if the removed element should be disposed (default: false)
  51731. */
  51732. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51733. /**
  51734. * Disposes the component and the associated ressources.
  51735. */
  51736. dispose(): void;
  51737. private _isReadyForMesh;
  51738. private _renderMainTexture;
  51739. private _setStencil;
  51740. private _setStencilBack;
  51741. private _draw;
  51742. private _drawCamera;
  51743. private _drawRenderingGroup;
  51744. }
  51745. }
  51746. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51747. /** @hidden */
  51748. export var glowMapMergePixelShader: {
  51749. name: string;
  51750. shader: string;
  51751. };
  51752. }
  51753. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51754. /** @hidden */
  51755. export var glowMapMergeVertexShader: {
  51756. name: string;
  51757. shader: string;
  51758. };
  51759. }
  51760. declare module "babylonjs/Layers/glowLayer" {
  51761. import { Nullable } from "babylonjs/types";
  51762. import { Camera } from "babylonjs/Cameras/camera";
  51763. import { Scene } from "babylonjs/scene";
  51764. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51766. import { Mesh } from "babylonjs/Meshes/mesh";
  51767. import { Texture } from "babylonjs/Materials/Textures/texture";
  51768. import { Effect } from "babylonjs/Materials/effect";
  51769. import { Material } from "babylonjs/Materials/material";
  51770. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51771. import { Color4 } from "babylonjs/Maths/math.color";
  51772. import "babylonjs/Shaders/glowMapMerge.fragment";
  51773. import "babylonjs/Shaders/glowMapMerge.vertex";
  51774. import "babylonjs/Layers/effectLayerSceneComponent";
  51775. module "babylonjs/abstractScene" {
  51776. interface AbstractScene {
  51777. /**
  51778. * Return a the first highlight layer of the scene with a given name.
  51779. * @param name The name of the highlight layer to look for.
  51780. * @return The highlight layer if found otherwise null.
  51781. */
  51782. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51783. }
  51784. }
  51785. /**
  51786. * Glow layer options. This helps customizing the behaviour
  51787. * of the glow layer.
  51788. */
  51789. export interface IGlowLayerOptions {
  51790. /**
  51791. * Multiplication factor apply to the canvas size to compute the render target size
  51792. * used to generated the glowing objects (the smaller the faster).
  51793. */
  51794. mainTextureRatio: number;
  51795. /**
  51796. * Enforces a fixed size texture to ensure resize independant blur.
  51797. */
  51798. mainTextureFixedSize?: number;
  51799. /**
  51800. * How big is the kernel of the blur texture.
  51801. */
  51802. blurKernelSize: number;
  51803. /**
  51804. * The camera attached to the layer.
  51805. */
  51806. camera: Nullable<Camera>;
  51807. /**
  51808. * Enable MSAA by chosing the number of samples.
  51809. */
  51810. mainTextureSamples?: number;
  51811. /**
  51812. * The rendering group to draw the layer in.
  51813. */
  51814. renderingGroupId: number;
  51815. }
  51816. /**
  51817. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51818. *
  51819. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51820. * glowy meshes to your scene.
  51821. *
  51822. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51823. */
  51824. export class GlowLayer extends EffectLayer {
  51825. /**
  51826. * Effect Name of the layer.
  51827. */
  51828. static readonly EffectName: string;
  51829. /**
  51830. * The default blur kernel size used for the glow.
  51831. */
  51832. static DefaultBlurKernelSize: number;
  51833. /**
  51834. * The default texture size ratio used for the glow.
  51835. */
  51836. static DefaultTextureRatio: number;
  51837. /**
  51838. * Sets the kernel size of the blur.
  51839. */
  51840. /**
  51841. * Gets the kernel size of the blur.
  51842. */
  51843. blurKernelSize: number;
  51844. /**
  51845. * Sets the glow intensity.
  51846. */
  51847. /**
  51848. * Gets the glow intensity.
  51849. */
  51850. intensity: number;
  51851. private _options;
  51852. private _intensity;
  51853. private _horizontalBlurPostprocess1;
  51854. private _verticalBlurPostprocess1;
  51855. private _horizontalBlurPostprocess2;
  51856. private _verticalBlurPostprocess2;
  51857. private _blurTexture1;
  51858. private _blurTexture2;
  51859. private _postProcesses1;
  51860. private _postProcesses2;
  51861. private _includedOnlyMeshes;
  51862. private _excludedMeshes;
  51863. /**
  51864. * Callback used to let the user override the color selection on a per mesh basis
  51865. */
  51866. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51867. /**
  51868. * Callback used to let the user override the texture selection on a per mesh basis
  51869. */
  51870. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51871. /**
  51872. * Instantiates a new glow Layer and references it to the scene.
  51873. * @param name The name of the layer
  51874. * @param scene The scene to use the layer in
  51875. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51876. */
  51877. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51878. /**
  51879. * Get the effect name of the layer.
  51880. * @return The effect name
  51881. */
  51882. getEffectName(): string;
  51883. /**
  51884. * Create the merge effect. This is the shader use to blit the information back
  51885. * to the main canvas at the end of the scene rendering.
  51886. */
  51887. protected _createMergeEffect(): Effect;
  51888. /**
  51889. * Creates the render target textures and post processes used in the glow layer.
  51890. */
  51891. protected _createTextureAndPostProcesses(): void;
  51892. /**
  51893. * Checks for the readiness of the element composing the layer.
  51894. * @param subMesh the mesh to check for
  51895. * @param useInstances specify wether or not to use instances to render the mesh
  51896. * @param emissiveTexture the associated emissive texture used to generate the glow
  51897. * @return true if ready otherwise, false
  51898. */
  51899. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51900. /**
  51901. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51902. */
  51903. needStencil(): boolean;
  51904. /**
  51905. * Returns true if the mesh can be rendered, otherwise false.
  51906. * @param mesh The mesh to render
  51907. * @param material The material used on the mesh
  51908. * @returns true if it can be rendered otherwise false
  51909. */
  51910. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51911. /**
  51912. * Implementation specific of rendering the generating effect on the main canvas.
  51913. * @param effect The effect used to render through
  51914. */
  51915. protected _internalRender(effect: Effect): void;
  51916. /**
  51917. * Sets the required values for both the emissive texture and and the main color.
  51918. */
  51919. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51920. /**
  51921. * Returns true if the mesh should render, otherwise false.
  51922. * @param mesh The mesh to render
  51923. * @returns true if it should render otherwise false
  51924. */
  51925. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51926. /**
  51927. * Adds specific effects defines.
  51928. * @param defines The defines to add specifics to.
  51929. */
  51930. protected _addCustomEffectDefines(defines: string[]): void;
  51931. /**
  51932. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51933. * @param mesh The mesh to exclude from the glow layer
  51934. */
  51935. addExcludedMesh(mesh: Mesh): void;
  51936. /**
  51937. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51938. * @param mesh The mesh to remove
  51939. */
  51940. removeExcludedMesh(mesh: Mesh): void;
  51941. /**
  51942. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51943. * @param mesh The mesh to include in the glow layer
  51944. */
  51945. addIncludedOnlyMesh(mesh: Mesh): void;
  51946. /**
  51947. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51948. * @param mesh The mesh to remove
  51949. */
  51950. removeIncludedOnlyMesh(mesh: Mesh): void;
  51951. /**
  51952. * Determine if a given mesh will be used in the glow layer
  51953. * @param mesh The mesh to test
  51954. * @returns true if the mesh will be highlighted by the current glow layer
  51955. */
  51956. hasMesh(mesh: AbstractMesh): boolean;
  51957. /**
  51958. * Free any resources and references associated to a mesh.
  51959. * Internal use
  51960. * @param mesh The mesh to free.
  51961. * @hidden
  51962. */
  51963. _disposeMesh(mesh: Mesh): void;
  51964. /**
  51965. * Gets the class name of the effect layer
  51966. * @returns the string with the class name of the effect layer
  51967. */
  51968. getClassName(): string;
  51969. /**
  51970. * Serializes this glow layer
  51971. * @returns a serialized glow layer object
  51972. */
  51973. serialize(): any;
  51974. /**
  51975. * Creates a Glow Layer from parsed glow layer data
  51976. * @param parsedGlowLayer defines glow layer data
  51977. * @param scene defines the current scene
  51978. * @param rootUrl defines the root URL containing the glow layer information
  51979. * @returns a parsed Glow Layer
  51980. */
  51981. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51982. }
  51983. }
  51984. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51985. /** @hidden */
  51986. export var glowBlurPostProcessPixelShader: {
  51987. name: string;
  51988. shader: string;
  51989. };
  51990. }
  51991. declare module "babylonjs/Layers/highlightLayer" {
  51992. import { Observable } from "babylonjs/Misc/observable";
  51993. import { Nullable } from "babylonjs/types";
  51994. import { Camera } from "babylonjs/Cameras/camera";
  51995. import { Scene } from "babylonjs/scene";
  51996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51998. import { Mesh } from "babylonjs/Meshes/mesh";
  51999. import { Effect } from "babylonjs/Materials/effect";
  52000. import { Material } from "babylonjs/Materials/material";
  52001. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52002. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52003. import "babylonjs/Shaders/glowMapMerge.fragment";
  52004. import "babylonjs/Shaders/glowMapMerge.vertex";
  52005. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52006. module "babylonjs/abstractScene" {
  52007. interface AbstractScene {
  52008. /**
  52009. * Return a the first highlight layer of the scene with a given name.
  52010. * @param name The name of the highlight layer to look for.
  52011. * @return The highlight layer if found otherwise null.
  52012. */
  52013. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52014. }
  52015. }
  52016. /**
  52017. * Highlight layer options. This helps customizing the behaviour
  52018. * of the highlight layer.
  52019. */
  52020. export interface IHighlightLayerOptions {
  52021. /**
  52022. * Multiplication factor apply to the canvas size to compute the render target size
  52023. * used to generated the glowing objects (the smaller the faster).
  52024. */
  52025. mainTextureRatio: number;
  52026. /**
  52027. * Enforces a fixed size texture to ensure resize independant blur.
  52028. */
  52029. mainTextureFixedSize?: number;
  52030. /**
  52031. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52032. * of the picture to blur (the smaller the faster).
  52033. */
  52034. blurTextureSizeRatio: number;
  52035. /**
  52036. * How big in texel of the blur texture is the vertical blur.
  52037. */
  52038. blurVerticalSize: number;
  52039. /**
  52040. * How big in texel of the blur texture is the horizontal blur.
  52041. */
  52042. blurHorizontalSize: number;
  52043. /**
  52044. * Alpha blending mode used to apply the blur. Default is combine.
  52045. */
  52046. alphaBlendingMode: number;
  52047. /**
  52048. * The camera attached to the layer.
  52049. */
  52050. camera: Nullable<Camera>;
  52051. /**
  52052. * Should we display highlight as a solid stroke?
  52053. */
  52054. isStroke?: boolean;
  52055. /**
  52056. * The rendering group to draw the layer in.
  52057. */
  52058. renderingGroupId: number;
  52059. }
  52060. /**
  52061. * The highlight layer Helps adding a glow effect around a mesh.
  52062. *
  52063. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52064. * glowy meshes to your scene.
  52065. *
  52066. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52067. */
  52068. export class HighlightLayer extends EffectLayer {
  52069. name: string;
  52070. /**
  52071. * Effect Name of the highlight layer.
  52072. */
  52073. static readonly EffectName: string;
  52074. /**
  52075. * The neutral color used during the preparation of the glow effect.
  52076. * This is black by default as the blend operation is a blend operation.
  52077. */
  52078. static NeutralColor: Color4;
  52079. /**
  52080. * Stencil value used for glowing meshes.
  52081. */
  52082. static GlowingMeshStencilReference: number;
  52083. /**
  52084. * Stencil value used for the other meshes in the scene.
  52085. */
  52086. static NormalMeshStencilReference: number;
  52087. /**
  52088. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52089. */
  52090. innerGlow: boolean;
  52091. /**
  52092. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52093. */
  52094. outerGlow: boolean;
  52095. /**
  52096. * Specifies the horizontal size of the blur.
  52097. */
  52098. /**
  52099. * Gets the horizontal size of the blur.
  52100. */
  52101. blurHorizontalSize: number;
  52102. /**
  52103. * Specifies the vertical size of the blur.
  52104. */
  52105. /**
  52106. * Gets the vertical size of the blur.
  52107. */
  52108. blurVerticalSize: number;
  52109. /**
  52110. * An event triggered when the highlight layer is being blurred.
  52111. */
  52112. onBeforeBlurObservable: Observable<HighlightLayer>;
  52113. /**
  52114. * An event triggered when the highlight layer has been blurred.
  52115. */
  52116. onAfterBlurObservable: Observable<HighlightLayer>;
  52117. private _instanceGlowingMeshStencilReference;
  52118. private _options;
  52119. private _downSamplePostprocess;
  52120. private _horizontalBlurPostprocess;
  52121. private _verticalBlurPostprocess;
  52122. private _blurTexture;
  52123. private _meshes;
  52124. private _excludedMeshes;
  52125. /**
  52126. * Instantiates a new highlight Layer and references it to the scene..
  52127. * @param name The name of the layer
  52128. * @param scene The scene to use the layer in
  52129. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52130. */
  52131. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52132. /**
  52133. * Get the effect name of the layer.
  52134. * @return The effect name
  52135. */
  52136. getEffectName(): string;
  52137. /**
  52138. * Create the merge effect. This is the shader use to blit the information back
  52139. * to the main canvas at the end of the scene rendering.
  52140. */
  52141. protected _createMergeEffect(): Effect;
  52142. /**
  52143. * Creates the render target textures and post processes used in the highlight layer.
  52144. */
  52145. protected _createTextureAndPostProcesses(): void;
  52146. /**
  52147. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52148. */
  52149. needStencil(): boolean;
  52150. /**
  52151. * Checks for the readiness of the element composing the layer.
  52152. * @param subMesh the mesh to check for
  52153. * @param useInstances specify wether or not to use instances to render the mesh
  52154. * @param emissiveTexture the associated emissive texture used to generate the glow
  52155. * @return true if ready otherwise, false
  52156. */
  52157. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52158. /**
  52159. * Implementation specific of rendering the generating effect on the main canvas.
  52160. * @param effect The effect used to render through
  52161. */
  52162. protected _internalRender(effect: Effect): void;
  52163. /**
  52164. * Returns true if the layer contains information to display, otherwise false.
  52165. */
  52166. shouldRender(): boolean;
  52167. /**
  52168. * Returns true if the mesh should render, otherwise false.
  52169. * @param mesh The mesh to render
  52170. * @returns true if it should render otherwise false
  52171. */
  52172. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52173. /**
  52174. * Sets the required values for both the emissive texture and and the main color.
  52175. */
  52176. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52177. /**
  52178. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52179. * @param mesh The mesh to exclude from the highlight layer
  52180. */
  52181. addExcludedMesh(mesh: Mesh): void;
  52182. /**
  52183. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52184. * @param mesh The mesh to highlight
  52185. */
  52186. removeExcludedMesh(mesh: Mesh): void;
  52187. /**
  52188. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52189. * @param mesh mesh to test
  52190. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52191. */
  52192. hasMesh(mesh: AbstractMesh): boolean;
  52193. /**
  52194. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52195. * @param mesh The mesh to highlight
  52196. * @param color The color of the highlight
  52197. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52198. */
  52199. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52200. /**
  52201. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52202. * @param mesh The mesh to highlight
  52203. */
  52204. removeMesh(mesh: Mesh): void;
  52205. /**
  52206. * Force the stencil to the normal expected value for none glowing parts
  52207. */
  52208. private _defaultStencilReference;
  52209. /**
  52210. * Free any resources and references associated to a mesh.
  52211. * Internal use
  52212. * @param mesh The mesh to free.
  52213. * @hidden
  52214. */
  52215. _disposeMesh(mesh: Mesh): void;
  52216. /**
  52217. * Dispose the highlight layer and free resources.
  52218. */
  52219. dispose(): void;
  52220. /**
  52221. * Gets the class name of the effect layer
  52222. * @returns the string with the class name of the effect layer
  52223. */
  52224. getClassName(): string;
  52225. /**
  52226. * Serializes this Highlight layer
  52227. * @returns a serialized Highlight layer object
  52228. */
  52229. serialize(): any;
  52230. /**
  52231. * Creates a Highlight layer from parsed Highlight layer data
  52232. * @param parsedHightlightLayer defines the Highlight layer data
  52233. * @param scene defines the current scene
  52234. * @param rootUrl defines the root URL containing the Highlight layer information
  52235. * @returns a parsed Highlight layer
  52236. */
  52237. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52238. }
  52239. }
  52240. declare module "babylonjs/Layers/layerSceneComponent" {
  52241. import { Scene } from "babylonjs/scene";
  52242. import { ISceneComponent } from "babylonjs/sceneComponent";
  52243. import { Layer } from "babylonjs/Layers/layer";
  52244. import { AbstractScene } from "babylonjs/abstractScene";
  52245. module "babylonjs/abstractScene" {
  52246. interface AbstractScene {
  52247. /**
  52248. * The list of layers (background and foreground) of the scene
  52249. */
  52250. layers: Array<Layer>;
  52251. }
  52252. }
  52253. /**
  52254. * Defines the layer scene component responsible to manage any layers
  52255. * in a given scene.
  52256. */
  52257. export class LayerSceneComponent implements ISceneComponent {
  52258. /**
  52259. * The component name helpfull to identify the component in the list of scene components.
  52260. */
  52261. readonly name: string;
  52262. /**
  52263. * The scene the component belongs to.
  52264. */
  52265. scene: Scene;
  52266. private _engine;
  52267. /**
  52268. * Creates a new instance of the component for the given scene
  52269. * @param scene Defines the scene to register the component in
  52270. */
  52271. constructor(scene: Scene);
  52272. /**
  52273. * Registers the component in a given scene
  52274. */
  52275. register(): void;
  52276. /**
  52277. * Rebuilds the elements related to this component in case of
  52278. * context lost for instance.
  52279. */
  52280. rebuild(): void;
  52281. /**
  52282. * Disposes the component and the associated ressources.
  52283. */
  52284. dispose(): void;
  52285. private _draw;
  52286. private _drawCameraPredicate;
  52287. private _drawCameraBackground;
  52288. private _drawCameraForeground;
  52289. private _drawRenderTargetPredicate;
  52290. private _drawRenderTargetBackground;
  52291. private _drawRenderTargetForeground;
  52292. /**
  52293. * Adds all the elements from the container to the scene
  52294. * @param container the container holding the elements
  52295. */
  52296. addFromContainer(container: AbstractScene): void;
  52297. /**
  52298. * Removes all the elements in the container from the scene
  52299. * @param container contains the elements to remove
  52300. * @param dispose if the removed element should be disposed (default: false)
  52301. */
  52302. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52303. }
  52304. }
  52305. declare module "babylonjs/Shaders/layer.fragment" {
  52306. /** @hidden */
  52307. export var layerPixelShader: {
  52308. name: string;
  52309. shader: string;
  52310. };
  52311. }
  52312. declare module "babylonjs/Shaders/layer.vertex" {
  52313. /** @hidden */
  52314. export var layerVertexShader: {
  52315. name: string;
  52316. shader: string;
  52317. };
  52318. }
  52319. declare module "babylonjs/Layers/layer" {
  52320. import { Observable } from "babylonjs/Misc/observable";
  52321. import { Nullable } from "babylonjs/types";
  52322. import { Scene } from "babylonjs/scene";
  52323. import { Vector2 } from "babylonjs/Maths/math.vector";
  52324. import { Color4 } from "babylonjs/Maths/math.color";
  52325. import { Texture } from "babylonjs/Materials/Textures/texture";
  52326. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52327. import "babylonjs/Shaders/layer.fragment";
  52328. import "babylonjs/Shaders/layer.vertex";
  52329. /**
  52330. * This represents a full screen 2d layer.
  52331. * This can be useful to display a picture in the background of your scene for instance.
  52332. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52333. */
  52334. export class Layer {
  52335. /**
  52336. * Define the name of the layer.
  52337. */
  52338. name: string;
  52339. /**
  52340. * Define the texture the layer should display.
  52341. */
  52342. texture: Nullable<Texture>;
  52343. /**
  52344. * Is the layer in background or foreground.
  52345. */
  52346. isBackground: boolean;
  52347. /**
  52348. * Define the color of the layer (instead of texture).
  52349. */
  52350. color: Color4;
  52351. /**
  52352. * Define the scale of the layer in order to zoom in out of the texture.
  52353. */
  52354. scale: Vector2;
  52355. /**
  52356. * Define an offset for the layer in order to shift the texture.
  52357. */
  52358. offset: Vector2;
  52359. /**
  52360. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52361. */
  52362. alphaBlendingMode: number;
  52363. /**
  52364. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52365. * Alpha test will not mix with the background color in case of transparency.
  52366. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52367. */
  52368. alphaTest: boolean;
  52369. /**
  52370. * Define a mask to restrict the layer to only some of the scene cameras.
  52371. */
  52372. layerMask: number;
  52373. /**
  52374. * Define the list of render target the layer is visible into.
  52375. */
  52376. renderTargetTextures: RenderTargetTexture[];
  52377. /**
  52378. * Define if the layer is only used in renderTarget or if it also
  52379. * renders in the main frame buffer of the canvas.
  52380. */
  52381. renderOnlyInRenderTargetTextures: boolean;
  52382. private _scene;
  52383. private _vertexBuffers;
  52384. private _indexBuffer;
  52385. private _effect;
  52386. private _alphaTestEffect;
  52387. /**
  52388. * An event triggered when the layer is disposed.
  52389. */
  52390. onDisposeObservable: Observable<Layer>;
  52391. private _onDisposeObserver;
  52392. /**
  52393. * Back compatibility with callback before the onDisposeObservable existed.
  52394. * The set callback will be triggered when the layer has been disposed.
  52395. */
  52396. onDispose: () => void;
  52397. /**
  52398. * An event triggered before rendering the scene
  52399. */
  52400. onBeforeRenderObservable: Observable<Layer>;
  52401. private _onBeforeRenderObserver;
  52402. /**
  52403. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52404. * The set callback will be triggered just before rendering the layer.
  52405. */
  52406. onBeforeRender: () => void;
  52407. /**
  52408. * An event triggered after rendering the scene
  52409. */
  52410. onAfterRenderObservable: Observable<Layer>;
  52411. private _onAfterRenderObserver;
  52412. /**
  52413. * Back compatibility with callback before the onAfterRenderObservable existed.
  52414. * The set callback will be triggered just after rendering the layer.
  52415. */
  52416. onAfterRender: () => void;
  52417. /**
  52418. * Instantiates a new layer.
  52419. * This represents a full screen 2d layer.
  52420. * This can be useful to display a picture in the background of your scene for instance.
  52421. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52422. * @param name Define the name of the layer in the scene
  52423. * @param imgUrl Define the url of the texture to display in the layer
  52424. * @param scene Define the scene the layer belongs to
  52425. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52426. * @param color Defines a color for the layer
  52427. */
  52428. constructor(
  52429. /**
  52430. * Define the name of the layer.
  52431. */
  52432. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52433. private _createIndexBuffer;
  52434. /** @hidden */
  52435. _rebuild(): void;
  52436. /**
  52437. * Renders the layer in the scene.
  52438. */
  52439. render(): void;
  52440. /**
  52441. * Disposes and releases the associated ressources.
  52442. */
  52443. dispose(): void;
  52444. }
  52445. }
  52446. declare module "babylonjs/Layers/index" {
  52447. export * from "babylonjs/Layers/effectLayer";
  52448. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52449. export * from "babylonjs/Layers/glowLayer";
  52450. export * from "babylonjs/Layers/highlightLayer";
  52451. export * from "babylonjs/Layers/layer";
  52452. export * from "babylonjs/Layers/layerSceneComponent";
  52453. }
  52454. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52455. /** @hidden */
  52456. export var lensFlarePixelShader: {
  52457. name: string;
  52458. shader: string;
  52459. };
  52460. }
  52461. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52462. /** @hidden */
  52463. export var lensFlareVertexShader: {
  52464. name: string;
  52465. shader: string;
  52466. };
  52467. }
  52468. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52469. import { Scene } from "babylonjs/scene";
  52470. import { Vector3 } from "babylonjs/Maths/math.vector";
  52471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52472. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52473. import "babylonjs/Shaders/lensFlare.fragment";
  52474. import "babylonjs/Shaders/lensFlare.vertex";
  52475. import { Viewport } from "babylonjs/Maths/math.viewport";
  52476. /**
  52477. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52478. * It is usually composed of several `lensFlare`.
  52479. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52480. */
  52481. export class LensFlareSystem {
  52482. /**
  52483. * Define the name of the lens flare system
  52484. */
  52485. name: string;
  52486. /**
  52487. * List of lens flares used in this system.
  52488. */
  52489. lensFlares: LensFlare[];
  52490. /**
  52491. * Define a limit from the border the lens flare can be visible.
  52492. */
  52493. borderLimit: number;
  52494. /**
  52495. * Define a viewport border we do not want to see the lens flare in.
  52496. */
  52497. viewportBorder: number;
  52498. /**
  52499. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52500. */
  52501. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52502. /**
  52503. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52504. */
  52505. layerMask: number;
  52506. /**
  52507. * Define the id of the lens flare system in the scene.
  52508. * (equal to name by default)
  52509. */
  52510. id: string;
  52511. private _scene;
  52512. private _emitter;
  52513. private _vertexBuffers;
  52514. private _indexBuffer;
  52515. private _effect;
  52516. private _positionX;
  52517. private _positionY;
  52518. private _isEnabled;
  52519. /** @hidden */
  52520. static _SceneComponentInitialization: (scene: Scene) => void;
  52521. /**
  52522. * Instantiates a lens flare system.
  52523. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52524. * It is usually composed of several `lensFlare`.
  52525. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52526. * @param name Define the name of the lens flare system in the scene
  52527. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52528. * @param scene Define the scene the lens flare system belongs to
  52529. */
  52530. constructor(
  52531. /**
  52532. * Define the name of the lens flare system
  52533. */
  52534. name: string, emitter: any, scene: Scene);
  52535. /**
  52536. * Define if the lens flare system is enabled.
  52537. */
  52538. isEnabled: boolean;
  52539. /**
  52540. * Get the scene the effects belongs to.
  52541. * @returns the scene holding the lens flare system
  52542. */
  52543. getScene(): Scene;
  52544. /**
  52545. * Get the emitter of the lens flare system.
  52546. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52547. * @returns the emitter of the lens flare system
  52548. */
  52549. getEmitter(): any;
  52550. /**
  52551. * Set the emitter of the lens flare system.
  52552. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52553. * @param newEmitter Define the new emitter of the system
  52554. */
  52555. setEmitter(newEmitter: any): void;
  52556. /**
  52557. * Get the lens flare system emitter position.
  52558. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52559. * @returns the position
  52560. */
  52561. getEmitterPosition(): Vector3;
  52562. /**
  52563. * @hidden
  52564. */
  52565. computeEffectivePosition(globalViewport: Viewport): boolean;
  52566. /** @hidden */
  52567. _isVisible(): boolean;
  52568. /**
  52569. * @hidden
  52570. */
  52571. render(): boolean;
  52572. /**
  52573. * Dispose and release the lens flare with its associated resources.
  52574. */
  52575. dispose(): void;
  52576. /**
  52577. * Parse a lens flare system from a JSON repressentation
  52578. * @param parsedLensFlareSystem Define the JSON to parse
  52579. * @param scene Define the scene the parsed system should be instantiated in
  52580. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52581. * @returns the parsed system
  52582. */
  52583. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52584. /**
  52585. * Serialize the current Lens Flare System into a JSON representation.
  52586. * @returns the serialized JSON
  52587. */
  52588. serialize(): any;
  52589. }
  52590. }
  52591. declare module "babylonjs/LensFlares/lensFlare" {
  52592. import { Nullable } from "babylonjs/types";
  52593. import { Color3 } from "babylonjs/Maths/math.color";
  52594. import { Texture } from "babylonjs/Materials/Textures/texture";
  52595. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52596. /**
  52597. * This represents one of the lens effect in a `lensFlareSystem`.
  52598. * It controls one of the indiviual texture used in the effect.
  52599. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52600. */
  52601. export class LensFlare {
  52602. /**
  52603. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52604. */
  52605. size: number;
  52606. /**
  52607. * 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.
  52608. */
  52609. position: number;
  52610. /**
  52611. * Define the lens color.
  52612. */
  52613. color: Color3;
  52614. /**
  52615. * Define the lens texture.
  52616. */
  52617. texture: Nullable<Texture>;
  52618. /**
  52619. * Define the alpha mode to render this particular lens.
  52620. */
  52621. alphaMode: number;
  52622. private _system;
  52623. /**
  52624. * Creates a new Lens Flare.
  52625. * This represents one of the lens effect in a `lensFlareSystem`.
  52626. * It controls one of the indiviual texture used in the effect.
  52627. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52628. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52629. * @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.
  52630. * @param color Define the lens color
  52631. * @param imgUrl Define the lens texture url
  52632. * @param system Define the `lensFlareSystem` this flare is part of
  52633. * @returns The newly created Lens Flare
  52634. */
  52635. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52636. /**
  52637. * Instantiates a new Lens Flare.
  52638. * This represents one of the lens effect in a `lensFlareSystem`.
  52639. * It controls one of the indiviual texture used in the effect.
  52640. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52641. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52642. * @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.
  52643. * @param color Define the lens color
  52644. * @param imgUrl Define the lens texture url
  52645. * @param system Define the `lensFlareSystem` this flare is part of
  52646. */
  52647. constructor(
  52648. /**
  52649. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52650. */
  52651. size: number,
  52652. /**
  52653. * 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.
  52654. */
  52655. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52656. /**
  52657. * Dispose and release the lens flare with its associated resources.
  52658. */
  52659. dispose(): void;
  52660. }
  52661. }
  52662. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52663. import { Nullable } from "babylonjs/types";
  52664. import { Scene } from "babylonjs/scene";
  52665. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52666. import { AbstractScene } from "babylonjs/abstractScene";
  52667. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52668. module "babylonjs/abstractScene" {
  52669. interface AbstractScene {
  52670. /**
  52671. * The list of lens flare system added to the scene
  52672. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52673. */
  52674. lensFlareSystems: Array<LensFlareSystem>;
  52675. /**
  52676. * Removes the given lens flare system from this scene.
  52677. * @param toRemove The lens flare system to remove
  52678. * @returns The index of the removed lens flare system
  52679. */
  52680. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52681. /**
  52682. * Adds the given lens flare system to this scene
  52683. * @param newLensFlareSystem The lens flare system to add
  52684. */
  52685. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52686. /**
  52687. * Gets a lens flare system using its name
  52688. * @param name defines the name to look for
  52689. * @returns the lens flare system or null if not found
  52690. */
  52691. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52692. /**
  52693. * Gets a lens flare system using its id
  52694. * @param id defines the id to look for
  52695. * @returns the lens flare system or null if not found
  52696. */
  52697. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52698. }
  52699. }
  52700. /**
  52701. * Defines the lens flare scene component responsible to manage any lens flares
  52702. * in a given scene.
  52703. */
  52704. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52705. /**
  52706. * The component name helpfull to identify the component in the list of scene components.
  52707. */
  52708. readonly name: string;
  52709. /**
  52710. * The scene the component belongs to.
  52711. */
  52712. scene: Scene;
  52713. /**
  52714. * Creates a new instance of the component for the given scene
  52715. * @param scene Defines the scene to register the component in
  52716. */
  52717. constructor(scene: Scene);
  52718. /**
  52719. * Registers the component in a given scene
  52720. */
  52721. register(): void;
  52722. /**
  52723. * Rebuilds the elements related to this component in case of
  52724. * context lost for instance.
  52725. */
  52726. rebuild(): void;
  52727. /**
  52728. * Adds all the elements from the container to the scene
  52729. * @param container the container holding the elements
  52730. */
  52731. addFromContainer(container: AbstractScene): void;
  52732. /**
  52733. * Removes all the elements in the container from the scene
  52734. * @param container contains the elements to remove
  52735. * @param dispose if the removed element should be disposed (default: false)
  52736. */
  52737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52738. /**
  52739. * Serializes the component data to the specified json object
  52740. * @param serializationObject The object to serialize to
  52741. */
  52742. serialize(serializationObject: any): void;
  52743. /**
  52744. * Disposes the component and the associated ressources.
  52745. */
  52746. dispose(): void;
  52747. private _draw;
  52748. }
  52749. }
  52750. declare module "babylonjs/LensFlares/index" {
  52751. export * from "babylonjs/LensFlares/lensFlare";
  52752. export * from "babylonjs/LensFlares/lensFlareSystem";
  52753. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52754. }
  52755. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52756. import { Scene } from "babylonjs/scene";
  52757. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52758. import { AbstractScene } from "babylonjs/abstractScene";
  52759. /**
  52760. * Defines the shadow generator component responsible to manage any shadow generators
  52761. * in a given scene.
  52762. */
  52763. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52764. /**
  52765. * The component name helpfull to identify the component in the list of scene components.
  52766. */
  52767. readonly name: string;
  52768. /**
  52769. * The scene the component belongs to.
  52770. */
  52771. scene: Scene;
  52772. /**
  52773. * Creates a new instance of the component for the given scene
  52774. * @param scene Defines the scene to register the component in
  52775. */
  52776. constructor(scene: Scene);
  52777. /**
  52778. * Registers the component in a given scene
  52779. */
  52780. register(): void;
  52781. /**
  52782. * Rebuilds the elements related to this component in case of
  52783. * context lost for instance.
  52784. */
  52785. rebuild(): void;
  52786. /**
  52787. * Serializes the component data to the specified json object
  52788. * @param serializationObject The object to serialize to
  52789. */
  52790. serialize(serializationObject: any): void;
  52791. /**
  52792. * Adds all the elements from the container to the scene
  52793. * @param container the container holding the elements
  52794. */
  52795. addFromContainer(container: AbstractScene): void;
  52796. /**
  52797. * Removes all the elements in the container from the scene
  52798. * @param container contains the elements to remove
  52799. * @param dispose if the removed element should be disposed (default: false)
  52800. */
  52801. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52802. /**
  52803. * Rebuilds the elements related to this component in case of
  52804. * context lost for instance.
  52805. */
  52806. dispose(): void;
  52807. private _gatherRenderTargets;
  52808. }
  52809. }
  52810. declare module "babylonjs/Lights/Shadows/index" {
  52811. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52812. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52813. }
  52814. declare module "babylonjs/Lights/pointLight" {
  52815. import { Scene } from "babylonjs/scene";
  52816. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52817. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52818. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52819. import { Effect } from "babylonjs/Materials/effect";
  52820. /**
  52821. * A point light is a light defined by an unique point in world space.
  52822. * The light is emitted in every direction from this point.
  52823. * A good example of a point light is a standard light bulb.
  52824. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52825. */
  52826. export class PointLight extends ShadowLight {
  52827. private _shadowAngle;
  52828. /**
  52829. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52830. * This specifies what angle the shadow will use to be created.
  52831. *
  52832. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52833. */
  52834. /**
  52835. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52836. * This specifies what angle the shadow will use to be created.
  52837. *
  52838. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52839. */
  52840. shadowAngle: number;
  52841. /**
  52842. * Gets the direction if it has been set.
  52843. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52844. */
  52845. /**
  52846. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52847. */
  52848. direction: Vector3;
  52849. /**
  52850. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52851. * A PointLight emits the light in every direction.
  52852. * It can cast shadows.
  52853. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52854. * ```javascript
  52855. * var pointLight = new PointLight("pl", camera.position, scene);
  52856. * ```
  52857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52858. * @param name The light friendly name
  52859. * @param position The position of the point light in the scene
  52860. * @param scene The scene the lights belongs to
  52861. */
  52862. constructor(name: string, position: Vector3, scene: Scene);
  52863. /**
  52864. * Returns the string "PointLight"
  52865. * @returns the class name
  52866. */
  52867. getClassName(): string;
  52868. /**
  52869. * Returns the integer 0.
  52870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52871. */
  52872. getTypeID(): number;
  52873. /**
  52874. * Specifies wether or not the shadowmap should be a cube texture.
  52875. * @returns true if the shadowmap needs to be a cube texture.
  52876. */
  52877. needCube(): boolean;
  52878. /**
  52879. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52880. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52881. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52882. */
  52883. getShadowDirection(faceIndex?: number): Vector3;
  52884. /**
  52885. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52886. * - fov = PI / 2
  52887. * - aspect ratio : 1.0
  52888. * - z-near and far equal to the active camera minZ and maxZ.
  52889. * Returns the PointLight.
  52890. */
  52891. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52892. protected _buildUniformLayout(): void;
  52893. /**
  52894. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52895. * @param effect The effect to update
  52896. * @param lightIndex The index of the light in the effect to update
  52897. * @returns The point light
  52898. */
  52899. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52900. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52901. /**
  52902. * Prepares the list of defines specific to the light type.
  52903. * @param defines the list of defines
  52904. * @param lightIndex defines the index of the light for the effect
  52905. */
  52906. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52907. }
  52908. }
  52909. declare module "babylonjs/Lights/index" {
  52910. export * from "babylonjs/Lights/light";
  52911. export * from "babylonjs/Lights/shadowLight";
  52912. export * from "babylonjs/Lights/Shadows/index";
  52913. export * from "babylonjs/Lights/directionalLight";
  52914. export * from "babylonjs/Lights/hemisphericLight";
  52915. export * from "babylonjs/Lights/pointLight";
  52916. export * from "babylonjs/Lights/spotLight";
  52917. }
  52918. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52919. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52920. /**
  52921. * Header information of HDR texture files.
  52922. */
  52923. export interface HDRInfo {
  52924. /**
  52925. * The height of the texture in pixels.
  52926. */
  52927. height: number;
  52928. /**
  52929. * The width of the texture in pixels.
  52930. */
  52931. width: number;
  52932. /**
  52933. * The index of the beginning of the data in the binary file.
  52934. */
  52935. dataPosition: number;
  52936. }
  52937. /**
  52938. * This groups tools to convert HDR texture to native colors array.
  52939. */
  52940. export class HDRTools {
  52941. private static Ldexp;
  52942. private static Rgbe2float;
  52943. private static readStringLine;
  52944. /**
  52945. * Reads header information from an RGBE texture stored in a native array.
  52946. * More information on this format are available here:
  52947. * https://en.wikipedia.org/wiki/RGBE_image_format
  52948. *
  52949. * @param uint8array The binary file stored in native array.
  52950. * @return The header information.
  52951. */
  52952. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52953. /**
  52954. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52955. * This RGBE texture needs to store the information as a panorama.
  52956. *
  52957. * More information on this format are available here:
  52958. * https://en.wikipedia.org/wiki/RGBE_image_format
  52959. *
  52960. * @param buffer The binary file stored in an array buffer.
  52961. * @param size The expected size of the extracted cubemap.
  52962. * @return The Cube Map information.
  52963. */
  52964. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52965. /**
  52966. * Returns the pixels data extracted from an RGBE texture.
  52967. * This pixels will be stored left to right up to down in the R G B order in one array.
  52968. *
  52969. * More information on this format are available here:
  52970. * https://en.wikipedia.org/wiki/RGBE_image_format
  52971. *
  52972. * @param uint8array The binary file stored in an array buffer.
  52973. * @param hdrInfo The header information of the file.
  52974. * @return The pixels data in RGB right to left up to down order.
  52975. */
  52976. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52977. private static RGBE_ReadPixels_RLE;
  52978. }
  52979. }
  52980. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52981. import { Nullable } from "babylonjs/types";
  52982. import { Scene } from "babylonjs/scene";
  52983. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52985. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52986. /**
  52987. * This represents a texture coming from an HDR input.
  52988. *
  52989. * The only supported format is currently panorama picture stored in RGBE format.
  52990. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52991. */
  52992. export class HDRCubeTexture extends BaseTexture {
  52993. private static _facesMapping;
  52994. private _generateHarmonics;
  52995. private _noMipmap;
  52996. private _textureMatrix;
  52997. private _size;
  52998. private _onLoad;
  52999. private _onError;
  53000. /**
  53001. * The texture URL.
  53002. */
  53003. url: string;
  53004. /**
  53005. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53006. */
  53007. coordinatesMode: number;
  53008. protected _isBlocking: boolean;
  53009. /**
  53010. * Sets wether or not the texture is blocking during loading.
  53011. */
  53012. /**
  53013. * Gets wether or not the texture is blocking during loading.
  53014. */
  53015. isBlocking: boolean;
  53016. protected _rotationY: number;
  53017. /**
  53018. * Sets texture matrix rotation angle around Y axis in radians.
  53019. */
  53020. /**
  53021. * Gets texture matrix rotation angle around Y axis radians.
  53022. */
  53023. rotationY: number;
  53024. /**
  53025. * Gets or sets the center of the bounding box associated with the cube texture
  53026. * It must define where the camera used to render the texture was set
  53027. */
  53028. boundingBoxPosition: Vector3;
  53029. private _boundingBoxSize;
  53030. /**
  53031. * Gets or sets the size of the bounding box associated with the cube texture
  53032. * When defined, the cubemap will switch to local mode
  53033. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53034. * @example https://www.babylonjs-playground.com/#RNASML
  53035. */
  53036. boundingBoxSize: Vector3;
  53037. /**
  53038. * Instantiates an HDRTexture from the following parameters.
  53039. *
  53040. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53041. * @param scene The scene the texture will be used in
  53042. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53043. * @param noMipmap Forces to not generate the mipmap if true
  53044. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53045. * @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)
  53046. * @param reserved Reserved flag for internal use.
  53047. */
  53048. 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>);
  53049. /**
  53050. * Get the current class name of the texture useful for serialization or dynamic coding.
  53051. * @returns "HDRCubeTexture"
  53052. */
  53053. getClassName(): string;
  53054. /**
  53055. * Occurs when the file is raw .hdr file.
  53056. */
  53057. private loadTexture;
  53058. clone(): HDRCubeTexture;
  53059. delayLoad(): void;
  53060. /**
  53061. * Get the texture reflection matrix used to rotate/transform the reflection.
  53062. * @returns the reflection matrix
  53063. */
  53064. getReflectionTextureMatrix(): Matrix;
  53065. /**
  53066. * Set the texture reflection matrix used to rotate/transform the reflection.
  53067. * @param value Define the reflection matrix to set
  53068. */
  53069. setReflectionTextureMatrix(value: Matrix): void;
  53070. /**
  53071. * Parses a JSON representation of an HDR Texture in order to create the texture
  53072. * @param parsedTexture Define the JSON representation
  53073. * @param scene Define the scene the texture should be created in
  53074. * @param rootUrl Define the root url in case we need to load relative dependencies
  53075. * @returns the newly created texture after parsing
  53076. */
  53077. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53078. serialize(): any;
  53079. }
  53080. }
  53081. declare module "babylonjs/Physics/physicsEngine" {
  53082. import { Nullable } from "babylonjs/types";
  53083. import { Vector3 } from "babylonjs/Maths/math.vector";
  53084. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53085. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53086. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53087. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53088. /**
  53089. * Class used to control physics engine
  53090. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53091. */
  53092. export class PhysicsEngine implements IPhysicsEngine {
  53093. private _physicsPlugin;
  53094. /**
  53095. * Global value used to control the smallest number supported by the simulation
  53096. */
  53097. static Epsilon: number;
  53098. private _impostors;
  53099. private _joints;
  53100. /**
  53101. * Gets the gravity vector used by the simulation
  53102. */
  53103. gravity: Vector3;
  53104. /**
  53105. * Factory used to create the default physics plugin.
  53106. * @returns The default physics plugin
  53107. */
  53108. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53109. /**
  53110. * Creates a new Physics Engine
  53111. * @param gravity defines the gravity vector used by the simulation
  53112. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53113. */
  53114. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53115. /**
  53116. * Sets the gravity vector used by the simulation
  53117. * @param gravity defines the gravity vector to use
  53118. */
  53119. setGravity(gravity: Vector3): void;
  53120. /**
  53121. * Set the time step of the physics engine.
  53122. * Default is 1/60.
  53123. * To slow it down, enter 1/600 for example.
  53124. * To speed it up, 1/30
  53125. * @param newTimeStep defines the new timestep to apply to this world.
  53126. */
  53127. setTimeStep(newTimeStep?: number): void;
  53128. /**
  53129. * Get the time step of the physics engine.
  53130. * @returns the current time step
  53131. */
  53132. getTimeStep(): number;
  53133. /**
  53134. * Release all resources
  53135. */
  53136. dispose(): void;
  53137. /**
  53138. * Gets the name of the current physics plugin
  53139. * @returns the name of the plugin
  53140. */
  53141. getPhysicsPluginName(): string;
  53142. /**
  53143. * Adding a new impostor for the impostor tracking.
  53144. * This will be done by the impostor itself.
  53145. * @param impostor the impostor to add
  53146. */
  53147. addImpostor(impostor: PhysicsImpostor): void;
  53148. /**
  53149. * Remove an impostor from the engine.
  53150. * This impostor and its mesh will not longer be updated by the physics engine.
  53151. * @param impostor the impostor to remove
  53152. */
  53153. removeImpostor(impostor: PhysicsImpostor): void;
  53154. /**
  53155. * Add a joint to the physics engine
  53156. * @param mainImpostor defines the main impostor to which the joint is added.
  53157. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53158. * @param joint defines the joint that will connect both impostors.
  53159. */
  53160. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53161. /**
  53162. * Removes a joint from the simulation
  53163. * @param mainImpostor defines the impostor used with the joint
  53164. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53165. * @param joint defines the joint to remove
  53166. */
  53167. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53168. /**
  53169. * Called by the scene. No need to call it.
  53170. * @param delta defines the timespam between frames
  53171. */
  53172. _step(delta: number): void;
  53173. /**
  53174. * Gets the current plugin used to run the simulation
  53175. * @returns current plugin
  53176. */
  53177. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53178. /**
  53179. * Gets the list of physic impostors
  53180. * @returns an array of PhysicsImpostor
  53181. */
  53182. getImpostors(): Array<PhysicsImpostor>;
  53183. /**
  53184. * Gets the impostor for a physics enabled object
  53185. * @param object defines the object impersonated by the impostor
  53186. * @returns the PhysicsImpostor or null if not found
  53187. */
  53188. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53189. /**
  53190. * Gets the impostor for a physics body object
  53191. * @param body defines physics body used by the impostor
  53192. * @returns the PhysicsImpostor or null if not found
  53193. */
  53194. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53195. /**
  53196. * Does a raycast in the physics world
  53197. * @param from when should the ray start?
  53198. * @param to when should the ray end?
  53199. * @returns PhysicsRaycastResult
  53200. */
  53201. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53202. }
  53203. }
  53204. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53205. import { Nullable } from "babylonjs/types";
  53206. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53208. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53209. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53210. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53211. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53212. /** @hidden */
  53213. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53214. private _useDeltaForWorldStep;
  53215. world: any;
  53216. name: string;
  53217. private _physicsMaterials;
  53218. private _fixedTimeStep;
  53219. private _cannonRaycastResult;
  53220. private _raycastResult;
  53221. private _physicsBodysToRemoveAfterStep;
  53222. BJSCANNON: any;
  53223. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53224. setGravity(gravity: Vector3): void;
  53225. setTimeStep(timeStep: number): void;
  53226. getTimeStep(): number;
  53227. executeStep(delta: number): void;
  53228. private _removeMarkedPhysicsBodiesFromWorld;
  53229. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53230. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53231. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53232. private _processChildMeshes;
  53233. removePhysicsBody(impostor: PhysicsImpostor): void;
  53234. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53235. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53236. private _addMaterial;
  53237. private _checkWithEpsilon;
  53238. private _createShape;
  53239. private _createHeightmap;
  53240. private _minus90X;
  53241. private _plus90X;
  53242. private _tmpPosition;
  53243. private _tmpDeltaPosition;
  53244. private _tmpUnityRotation;
  53245. private _updatePhysicsBodyTransformation;
  53246. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53247. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53248. isSupported(): boolean;
  53249. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53250. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53251. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53252. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53253. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53254. getBodyMass(impostor: PhysicsImpostor): number;
  53255. getBodyFriction(impostor: PhysicsImpostor): number;
  53256. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53257. getBodyRestitution(impostor: PhysicsImpostor): number;
  53258. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53259. sleepBody(impostor: PhysicsImpostor): void;
  53260. wakeUpBody(impostor: PhysicsImpostor): void;
  53261. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53262. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53263. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53264. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53265. getRadius(impostor: PhysicsImpostor): number;
  53266. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53267. dispose(): void;
  53268. private _extendNamespace;
  53269. /**
  53270. * Does a raycast in the physics world
  53271. * @param from when should the ray start?
  53272. * @param to when should the ray end?
  53273. * @returns PhysicsRaycastResult
  53274. */
  53275. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53276. }
  53277. }
  53278. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53279. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53280. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53281. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53283. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53284. import { Nullable } from "babylonjs/types";
  53285. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53286. /** @hidden */
  53287. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53288. world: any;
  53289. name: string;
  53290. BJSOIMO: any;
  53291. private _raycastResult;
  53292. constructor(iterations?: number, oimoInjection?: any);
  53293. setGravity(gravity: Vector3): void;
  53294. setTimeStep(timeStep: number): void;
  53295. getTimeStep(): number;
  53296. private _tmpImpostorsArray;
  53297. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53298. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53299. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53300. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53301. private _tmpPositionVector;
  53302. removePhysicsBody(impostor: PhysicsImpostor): void;
  53303. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53304. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53305. isSupported(): boolean;
  53306. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53307. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53308. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53309. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53310. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53311. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53312. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53313. getBodyMass(impostor: PhysicsImpostor): number;
  53314. getBodyFriction(impostor: PhysicsImpostor): number;
  53315. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53316. getBodyRestitution(impostor: PhysicsImpostor): number;
  53317. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53318. sleepBody(impostor: PhysicsImpostor): void;
  53319. wakeUpBody(impostor: PhysicsImpostor): void;
  53320. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53321. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53322. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53323. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53324. getRadius(impostor: PhysicsImpostor): number;
  53325. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53326. dispose(): void;
  53327. /**
  53328. * Does a raycast in the physics world
  53329. * @param from when should the ray start?
  53330. * @param to when should the ray end?
  53331. * @returns PhysicsRaycastResult
  53332. */
  53333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53334. }
  53335. }
  53336. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53337. import { Nullable } from "babylonjs/types";
  53338. import { Scene } from "babylonjs/scene";
  53339. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53340. import { Color4 } from "babylonjs/Maths/math.color";
  53341. import { Mesh } from "babylonjs/Meshes/mesh";
  53342. /**
  53343. * Class containing static functions to help procedurally build meshes
  53344. */
  53345. export class RibbonBuilder {
  53346. /**
  53347. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53348. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53349. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53350. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53351. * * 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
  53352. * * 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
  53353. * * 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
  53354. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53355. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53356. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53357. * * 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
  53358. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53359. * * 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
  53360. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53362. * @param name defines the name of the mesh
  53363. * @param options defines the options used to create the mesh
  53364. * @param scene defines the hosting scene
  53365. * @returns the ribbon mesh
  53366. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53367. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53368. */
  53369. static CreateRibbon(name: string, options: {
  53370. pathArray: Vector3[][];
  53371. closeArray?: boolean;
  53372. closePath?: boolean;
  53373. offset?: number;
  53374. updatable?: boolean;
  53375. sideOrientation?: number;
  53376. frontUVs?: Vector4;
  53377. backUVs?: Vector4;
  53378. instance?: Mesh;
  53379. invertUV?: boolean;
  53380. uvs?: Vector2[];
  53381. colors?: Color4[];
  53382. }, scene?: Nullable<Scene>): Mesh;
  53383. }
  53384. }
  53385. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53386. import { Nullable } from "babylonjs/types";
  53387. import { Scene } from "babylonjs/scene";
  53388. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53389. import { Mesh } from "babylonjs/Meshes/mesh";
  53390. /**
  53391. * Class containing static functions to help procedurally build meshes
  53392. */
  53393. export class ShapeBuilder {
  53394. /**
  53395. * 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.
  53396. * * 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.
  53397. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53398. * * 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.
  53399. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53400. * * 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
  53401. * * 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
  53402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53407. * @param name defines the name of the mesh
  53408. * @param options defines the options used to create the mesh
  53409. * @param scene defines the hosting scene
  53410. * @returns the extruded shape mesh
  53411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53413. */
  53414. static ExtrudeShape(name: string, options: {
  53415. shape: Vector3[];
  53416. path: Vector3[];
  53417. scale?: number;
  53418. rotation?: number;
  53419. cap?: number;
  53420. updatable?: boolean;
  53421. sideOrientation?: number;
  53422. frontUVs?: Vector4;
  53423. backUVs?: Vector4;
  53424. instance?: Mesh;
  53425. invertUV?: boolean;
  53426. }, scene?: Nullable<Scene>): Mesh;
  53427. /**
  53428. * Creates an custom extruded shape mesh.
  53429. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53430. * * 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.
  53431. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53432. * * 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
  53433. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53434. * * 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
  53435. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53436. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53437. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53438. * * 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
  53439. * * 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
  53440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53445. * @param name defines the name of the mesh
  53446. * @param options defines the options used to create the mesh
  53447. * @param scene defines the hosting scene
  53448. * @returns the custom extruded shape mesh
  53449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53452. */
  53453. static ExtrudeShapeCustom(name: string, options: {
  53454. shape: Vector3[];
  53455. path: Vector3[];
  53456. scaleFunction?: any;
  53457. rotationFunction?: any;
  53458. ribbonCloseArray?: boolean;
  53459. ribbonClosePath?: boolean;
  53460. cap?: number;
  53461. updatable?: boolean;
  53462. sideOrientation?: number;
  53463. frontUVs?: Vector4;
  53464. backUVs?: Vector4;
  53465. instance?: Mesh;
  53466. invertUV?: boolean;
  53467. }, scene?: Nullable<Scene>): Mesh;
  53468. private static _ExtrudeShapeGeneric;
  53469. }
  53470. }
  53471. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53472. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53473. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53474. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53475. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53476. import { Nullable } from "babylonjs/types";
  53477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53478. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53479. /**
  53480. * AmmoJS Physics plugin
  53481. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53482. * @see https://github.com/kripken/ammo.js/
  53483. */
  53484. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53485. private _useDeltaForWorldStep;
  53486. /**
  53487. * Reference to the Ammo library
  53488. */
  53489. bjsAMMO: any;
  53490. /**
  53491. * Created ammoJS world which physics bodies are added to
  53492. */
  53493. world: any;
  53494. /**
  53495. * Name of the plugin
  53496. */
  53497. name: string;
  53498. private _timeStep;
  53499. private _fixedTimeStep;
  53500. private _maxSteps;
  53501. private _tmpQuaternion;
  53502. private _tmpAmmoTransform;
  53503. private _tmpAmmoQuaternion;
  53504. private _tmpAmmoConcreteContactResultCallback;
  53505. private _collisionConfiguration;
  53506. private _dispatcher;
  53507. private _overlappingPairCache;
  53508. private _solver;
  53509. private _softBodySolver;
  53510. private _tmpAmmoVectorA;
  53511. private _tmpAmmoVectorB;
  53512. private _tmpAmmoVectorC;
  53513. private _tmpAmmoVectorD;
  53514. private _tmpContactCallbackResult;
  53515. private _tmpAmmoVectorRCA;
  53516. private _tmpAmmoVectorRCB;
  53517. private _raycastResult;
  53518. private static readonly DISABLE_COLLISION_FLAG;
  53519. private static readonly KINEMATIC_FLAG;
  53520. private static readonly DISABLE_DEACTIVATION_FLAG;
  53521. /**
  53522. * Initializes the ammoJS plugin
  53523. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53524. * @param ammoInjection can be used to inject your own ammo reference
  53525. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53526. */
  53527. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53528. /**
  53529. * Sets the gravity of the physics world (m/(s^2))
  53530. * @param gravity Gravity to set
  53531. */
  53532. setGravity(gravity: Vector3): void;
  53533. /**
  53534. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53535. * @param timeStep timestep to use in seconds
  53536. */
  53537. setTimeStep(timeStep: number): void;
  53538. /**
  53539. * 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)
  53540. * @param fixedTimeStep fixedTimeStep to use in seconds
  53541. */
  53542. setFixedTimeStep(fixedTimeStep: number): void;
  53543. /**
  53544. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53545. * @param maxSteps the maximum number of steps by the physics engine per frame
  53546. */
  53547. setMaxSteps(maxSteps: number): void;
  53548. /**
  53549. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53550. * @returns the current timestep in seconds
  53551. */
  53552. getTimeStep(): number;
  53553. private _isImpostorInContact;
  53554. private _isImpostorPairInContact;
  53555. private _stepSimulation;
  53556. /**
  53557. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53558. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53559. * After the step the babylon meshes are set to the position of the physics imposters
  53560. * @param delta amount of time to step forward
  53561. * @param impostors array of imposters to update before/after the step
  53562. */
  53563. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53564. /**
  53565. * Update babylon mesh to match physics world object
  53566. * @param impostor imposter to match
  53567. */
  53568. private _afterSoftStep;
  53569. /**
  53570. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53571. * @param impostor imposter to match
  53572. */
  53573. private _ropeStep;
  53574. /**
  53575. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53576. * @param impostor imposter to match
  53577. */
  53578. private _softbodyOrClothStep;
  53579. private _tmpVector;
  53580. private _tmpMatrix;
  53581. /**
  53582. * Applies an impulse on the imposter
  53583. * @param impostor imposter to apply impulse to
  53584. * @param force amount of force to be applied to the imposter
  53585. * @param contactPoint the location to apply the impulse on the imposter
  53586. */
  53587. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53588. /**
  53589. * Applies a force on the imposter
  53590. * @param impostor imposter to apply force
  53591. * @param force amount of force to be applied to the imposter
  53592. * @param contactPoint the location to apply the force on the imposter
  53593. */
  53594. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53595. /**
  53596. * Creates a physics body using the plugin
  53597. * @param impostor the imposter to create the physics body on
  53598. */
  53599. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53600. /**
  53601. * Removes the physics body from the imposter and disposes of the body's memory
  53602. * @param impostor imposter to remove the physics body from
  53603. */
  53604. removePhysicsBody(impostor: PhysicsImpostor): void;
  53605. /**
  53606. * Generates a joint
  53607. * @param impostorJoint the imposter joint to create the joint with
  53608. */
  53609. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53610. /**
  53611. * Removes a joint
  53612. * @param impostorJoint the imposter joint to remove the joint from
  53613. */
  53614. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53615. private _addMeshVerts;
  53616. /**
  53617. * Initialise the soft body vertices to match its object's (mesh) vertices
  53618. * Softbody vertices (nodes) are in world space and to match this
  53619. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53620. * @param impostor to create the softbody for
  53621. */
  53622. private _softVertexData;
  53623. /**
  53624. * Create an impostor's soft body
  53625. * @param impostor to create the softbody for
  53626. */
  53627. private _createSoftbody;
  53628. /**
  53629. * Create cloth for an impostor
  53630. * @param impostor to create the softbody for
  53631. */
  53632. private _createCloth;
  53633. /**
  53634. * Create rope for an impostor
  53635. * @param impostor to create the softbody for
  53636. */
  53637. private _createRope;
  53638. private _addHullVerts;
  53639. private _createShape;
  53640. /**
  53641. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53642. * @param impostor imposter containing the physics body and babylon object
  53643. */
  53644. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53645. /**
  53646. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53647. * @param impostor imposter containing the physics body and babylon object
  53648. * @param newPosition new position
  53649. * @param newRotation new rotation
  53650. */
  53651. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53652. /**
  53653. * If this plugin is supported
  53654. * @returns true if its supported
  53655. */
  53656. isSupported(): boolean;
  53657. /**
  53658. * Sets the linear velocity of the physics body
  53659. * @param impostor imposter to set the velocity on
  53660. * @param velocity velocity to set
  53661. */
  53662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53663. /**
  53664. * Sets the angular velocity of the physics body
  53665. * @param impostor imposter to set the velocity on
  53666. * @param velocity velocity to set
  53667. */
  53668. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53669. /**
  53670. * gets the linear velocity
  53671. * @param impostor imposter to get linear velocity from
  53672. * @returns linear velocity
  53673. */
  53674. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53675. /**
  53676. * gets the angular velocity
  53677. * @param impostor imposter to get angular velocity from
  53678. * @returns angular velocity
  53679. */
  53680. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53681. /**
  53682. * Sets the mass of physics body
  53683. * @param impostor imposter to set the mass on
  53684. * @param mass mass to set
  53685. */
  53686. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53687. /**
  53688. * Gets the mass of the physics body
  53689. * @param impostor imposter to get the mass from
  53690. * @returns mass
  53691. */
  53692. getBodyMass(impostor: PhysicsImpostor): number;
  53693. /**
  53694. * Gets friction of the impostor
  53695. * @param impostor impostor to get friction from
  53696. * @returns friction value
  53697. */
  53698. getBodyFriction(impostor: PhysicsImpostor): number;
  53699. /**
  53700. * Sets friction of the impostor
  53701. * @param impostor impostor to set friction on
  53702. * @param friction friction value
  53703. */
  53704. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53705. /**
  53706. * Gets restitution of the impostor
  53707. * @param impostor impostor to get restitution from
  53708. * @returns restitution value
  53709. */
  53710. getBodyRestitution(impostor: PhysicsImpostor): number;
  53711. /**
  53712. * Sets resitution of the impostor
  53713. * @param impostor impostor to set resitution on
  53714. * @param restitution resitution value
  53715. */
  53716. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53717. /**
  53718. * Gets pressure inside the impostor
  53719. * @param impostor impostor to get pressure from
  53720. * @returns pressure value
  53721. */
  53722. getBodyPressure(impostor: PhysicsImpostor): number;
  53723. /**
  53724. * Sets pressure inside a soft body impostor
  53725. * Cloth and rope must remain 0 pressure
  53726. * @param impostor impostor to set pressure on
  53727. * @param pressure pressure value
  53728. */
  53729. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53730. /**
  53731. * Gets stiffness of the impostor
  53732. * @param impostor impostor to get stiffness from
  53733. * @returns pressure value
  53734. */
  53735. getBodyStiffness(impostor: PhysicsImpostor): number;
  53736. /**
  53737. * Sets stiffness of the impostor
  53738. * @param impostor impostor to set stiffness on
  53739. * @param stiffness stiffness value from 0 to 1
  53740. */
  53741. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53742. /**
  53743. * Gets velocityIterations of the impostor
  53744. * @param impostor impostor to get velocity iterations from
  53745. * @returns velocityIterations value
  53746. */
  53747. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53748. /**
  53749. * Sets velocityIterations of the impostor
  53750. * @param impostor impostor to set velocity iterations on
  53751. * @param velocityIterations velocityIterations value
  53752. */
  53753. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53754. /**
  53755. * Gets positionIterations of the impostor
  53756. * @param impostor impostor to get position iterations from
  53757. * @returns positionIterations value
  53758. */
  53759. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53760. /**
  53761. * Sets positionIterations of the impostor
  53762. * @param impostor impostor to set position on
  53763. * @param positionIterations positionIterations value
  53764. */
  53765. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53766. /**
  53767. * Append an anchor to a cloth object
  53768. * @param impostor is the cloth impostor to add anchor to
  53769. * @param otherImpostor is the rigid impostor to anchor to
  53770. * @param width ratio across width from 0 to 1
  53771. * @param height ratio up height from 0 to 1
  53772. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53773. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53774. */
  53775. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53776. /**
  53777. * Append an hook to a rope object
  53778. * @param impostor is the rope impostor to add hook to
  53779. * @param otherImpostor is the rigid impostor to hook to
  53780. * @param length ratio along the rope from 0 to 1
  53781. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53782. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53783. */
  53784. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53785. /**
  53786. * Sleeps the physics body and stops it from being active
  53787. * @param impostor impostor to sleep
  53788. */
  53789. sleepBody(impostor: PhysicsImpostor): void;
  53790. /**
  53791. * Activates the physics body
  53792. * @param impostor impostor to activate
  53793. */
  53794. wakeUpBody(impostor: PhysicsImpostor): void;
  53795. /**
  53796. * Updates the distance parameters of the joint
  53797. * @param joint joint to update
  53798. * @param maxDistance maximum distance of the joint
  53799. * @param minDistance minimum distance of the joint
  53800. */
  53801. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53802. /**
  53803. * Sets a motor on the joint
  53804. * @param joint joint to set motor on
  53805. * @param speed speed of the motor
  53806. * @param maxForce maximum force of the motor
  53807. * @param motorIndex index of the motor
  53808. */
  53809. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53810. /**
  53811. * Sets the motors limit
  53812. * @param joint joint to set limit on
  53813. * @param upperLimit upper limit
  53814. * @param lowerLimit lower limit
  53815. */
  53816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53817. /**
  53818. * Syncs the position and rotation of a mesh with the impostor
  53819. * @param mesh mesh to sync
  53820. * @param impostor impostor to update the mesh with
  53821. */
  53822. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53823. /**
  53824. * Gets the radius of the impostor
  53825. * @param impostor impostor to get radius from
  53826. * @returns the radius
  53827. */
  53828. getRadius(impostor: PhysicsImpostor): number;
  53829. /**
  53830. * Gets the box size of the impostor
  53831. * @param impostor impostor to get box size from
  53832. * @param result the resulting box size
  53833. */
  53834. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53835. /**
  53836. * Disposes of the impostor
  53837. */
  53838. dispose(): void;
  53839. /**
  53840. * Does a raycast in the physics world
  53841. * @param from when should the ray start?
  53842. * @param to when should the ray end?
  53843. * @returns PhysicsRaycastResult
  53844. */
  53845. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53846. }
  53847. }
  53848. declare module "babylonjs/Probes/reflectionProbe" {
  53849. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53850. import { Vector3 } from "babylonjs/Maths/math.vector";
  53851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53852. import { Nullable } from "babylonjs/types";
  53853. import { Scene } from "babylonjs/scene";
  53854. module "babylonjs/abstractScene" {
  53855. interface AbstractScene {
  53856. /**
  53857. * The list of reflection probes added to the scene
  53858. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53859. */
  53860. reflectionProbes: Array<ReflectionProbe>;
  53861. /**
  53862. * Removes the given reflection probe from this scene.
  53863. * @param toRemove The reflection probe to remove
  53864. * @returns The index of the removed reflection probe
  53865. */
  53866. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53867. /**
  53868. * Adds the given reflection probe to this scene.
  53869. * @param newReflectionProbe The reflection probe to add
  53870. */
  53871. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53872. }
  53873. }
  53874. /**
  53875. * Class used to generate realtime reflection / refraction cube textures
  53876. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53877. */
  53878. export class ReflectionProbe {
  53879. /** defines the name of the probe */
  53880. name: string;
  53881. private _scene;
  53882. private _renderTargetTexture;
  53883. private _projectionMatrix;
  53884. private _viewMatrix;
  53885. private _target;
  53886. private _add;
  53887. private _attachedMesh;
  53888. private _invertYAxis;
  53889. /** Gets or sets probe position (center of the cube map) */
  53890. position: Vector3;
  53891. /**
  53892. * Creates a new reflection probe
  53893. * @param name defines the name of the probe
  53894. * @param size defines the texture resolution (for each face)
  53895. * @param scene defines the hosting scene
  53896. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53897. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53898. */
  53899. constructor(
  53900. /** defines the name of the probe */
  53901. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53902. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53903. samples: number;
  53904. /** Gets or sets the refresh rate to use (on every frame by default) */
  53905. refreshRate: number;
  53906. /**
  53907. * Gets the hosting scene
  53908. * @returns a Scene
  53909. */
  53910. getScene(): Scene;
  53911. /** Gets the internal CubeTexture used to render to */
  53912. readonly cubeTexture: RenderTargetTexture;
  53913. /** Gets the list of meshes to render */
  53914. readonly renderList: Nullable<AbstractMesh[]>;
  53915. /**
  53916. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53917. * @param mesh defines the mesh to attach to
  53918. */
  53919. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53920. /**
  53921. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53922. * @param renderingGroupId The rendering group id corresponding to its index
  53923. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53924. */
  53925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53926. /**
  53927. * Clean all associated resources
  53928. */
  53929. dispose(): void;
  53930. /**
  53931. * Converts the reflection probe information to a readable string for debug purpose.
  53932. * @param fullDetails Supports for multiple levels of logging within scene loading
  53933. * @returns the human readable reflection probe info
  53934. */
  53935. toString(fullDetails?: boolean): string;
  53936. /**
  53937. * Get the class name of the relfection probe.
  53938. * @returns "ReflectionProbe"
  53939. */
  53940. getClassName(): string;
  53941. /**
  53942. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53943. * @returns The JSON representation of the texture
  53944. */
  53945. serialize(): any;
  53946. /**
  53947. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53948. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53949. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53950. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53951. * @returns The parsed reflection probe if successful
  53952. */
  53953. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53954. }
  53955. }
  53956. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53957. /** @hidden */
  53958. export var _BabylonLoaderRegistered: boolean;
  53959. }
  53960. declare module "babylonjs/Loading/Plugins/index" {
  53961. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53962. }
  53963. declare module "babylonjs/Loading/index" {
  53964. export * from "babylonjs/Loading/loadingScreen";
  53965. export * from "babylonjs/Loading/Plugins/index";
  53966. export * from "babylonjs/Loading/sceneLoader";
  53967. export * from "babylonjs/Loading/sceneLoaderFlags";
  53968. }
  53969. declare module "babylonjs/Materials/Background/index" {
  53970. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53971. }
  53972. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53973. import { Scene } from "babylonjs/scene";
  53974. import { Color3 } from "babylonjs/Maths/math.color";
  53975. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53977. /**
  53978. * The Physically based simple base material of BJS.
  53979. *
  53980. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53981. * It is used as the base class for both the specGloss and metalRough conventions.
  53982. */
  53983. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53984. /**
  53985. * Number of Simultaneous lights allowed on the material.
  53986. */
  53987. maxSimultaneousLights: number;
  53988. /**
  53989. * If sets to true, disables all the lights affecting the material.
  53990. */
  53991. disableLighting: boolean;
  53992. /**
  53993. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53994. */
  53995. environmentTexture: BaseTexture;
  53996. /**
  53997. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53998. */
  53999. invertNormalMapX: boolean;
  54000. /**
  54001. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54002. */
  54003. invertNormalMapY: boolean;
  54004. /**
  54005. * Normal map used in the model.
  54006. */
  54007. normalTexture: BaseTexture;
  54008. /**
  54009. * Emissivie color used to self-illuminate the model.
  54010. */
  54011. emissiveColor: Color3;
  54012. /**
  54013. * Emissivie texture used to self-illuminate the model.
  54014. */
  54015. emissiveTexture: BaseTexture;
  54016. /**
  54017. * Occlusion Channel Strenght.
  54018. */
  54019. occlusionStrength: number;
  54020. /**
  54021. * Occlusion Texture of the material (adding extra occlusion effects).
  54022. */
  54023. occlusionTexture: BaseTexture;
  54024. /**
  54025. * Defines the alpha limits in alpha test mode.
  54026. */
  54027. alphaCutOff: number;
  54028. /**
  54029. * Gets the current double sided mode.
  54030. */
  54031. /**
  54032. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54033. */
  54034. doubleSided: boolean;
  54035. /**
  54036. * Stores the pre-calculated light information of a mesh in a texture.
  54037. */
  54038. lightmapTexture: BaseTexture;
  54039. /**
  54040. * If true, the light map contains occlusion information instead of lighting info.
  54041. */
  54042. useLightmapAsShadowmap: boolean;
  54043. /**
  54044. * Instantiates a new PBRMaterial instance.
  54045. *
  54046. * @param name The material name
  54047. * @param scene The scene the material will be use in.
  54048. */
  54049. constructor(name: string, scene: Scene);
  54050. getClassName(): string;
  54051. }
  54052. }
  54053. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54054. import { Scene } from "babylonjs/scene";
  54055. import { Color3 } from "babylonjs/Maths/math.color";
  54056. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54057. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54058. /**
  54059. * The PBR material of BJS following the metal roughness convention.
  54060. *
  54061. * This fits to the PBR convention in the GLTF definition:
  54062. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54063. */
  54064. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54065. /**
  54066. * The base color has two different interpretations depending on the value of metalness.
  54067. * When the material is a metal, the base color is the specific measured reflectance value
  54068. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54069. * of the material.
  54070. */
  54071. baseColor: Color3;
  54072. /**
  54073. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54074. * well as opacity information in the alpha channel.
  54075. */
  54076. baseTexture: BaseTexture;
  54077. /**
  54078. * Specifies the metallic scalar value of the material.
  54079. * Can also be used to scale the metalness values of the metallic texture.
  54080. */
  54081. metallic: number;
  54082. /**
  54083. * Specifies the roughness scalar value of the material.
  54084. * Can also be used to scale the roughness values of the metallic texture.
  54085. */
  54086. roughness: number;
  54087. /**
  54088. * Texture containing both the metallic value in the B channel and the
  54089. * roughness value in the G channel to keep better precision.
  54090. */
  54091. metallicRoughnessTexture: BaseTexture;
  54092. /**
  54093. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54094. *
  54095. * @param name The material name
  54096. * @param scene The scene the material will be use in.
  54097. */
  54098. constructor(name: string, scene: Scene);
  54099. /**
  54100. * Return the currrent class name of the material.
  54101. */
  54102. getClassName(): string;
  54103. /**
  54104. * Makes a duplicate of the current material.
  54105. * @param name - name to use for the new material.
  54106. */
  54107. clone(name: string): PBRMetallicRoughnessMaterial;
  54108. /**
  54109. * Serialize the material to a parsable JSON object.
  54110. */
  54111. serialize(): any;
  54112. /**
  54113. * Parses a JSON object correponding to the serialize function.
  54114. */
  54115. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54116. }
  54117. }
  54118. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54119. import { Scene } from "babylonjs/scene";
  54120. import { Color3 } from "babylonjs/Maths/math.color";
  54121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54122. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54123. /**
  54124. * The PBR material of BJS following the specular glossiness convention.
  54125. *
  54126. * This fits to the PBR convention in the GLTF definition:
  54127. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54128. */
  54129. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54130. /**
  54131. * Specifies the diffuse color of the material.
  54132. */
  54133. diffuseColor: Color3;
  54134. /**
  54135. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54136. * channel.
  54137. */
  54138. diffuseTexture: BaseTexture;
  54139. /**
  54140. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54141. */
  54142. specularColor: Color3;
  54143. /**
  54144. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54145. */
  54146. glossiness: number;
  54147. /**
  54148. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54149. */
  54150. specularGlossinessTexture: BaseTexture;
  54151. /**
  54152. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54153. *
  54154. * @param name The material name
  54155. * @param scene The scene the material will be use in.
  54156. */
  54157. constructor(name: string, scene: Scene);
  54158. /**
  54159. * Return the currrent class name of the material.
  54160. */
  54161. getClassName(): string;
  54162. /**
  54163. * Makes a duplicate of the current material.
  54164. * @param name - name to use for the new material.
  54165. */
  54166. clone(name: string): PBRSpecularGlossinessMaterial;
  54167. /**
  54168. * Serialize the material to a parsable JSON object.
  54169. */
  54170. serialize(): any;
  54171. /**
  54172. * Parses a JSON object correponding to the serialize function.
  54173. */
  54174. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54175. }
  54176. }
  54177. declare module "babylonjs/Materials/PBR/index" {
  54178. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54179. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54180. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54181. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54182. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54183. }
  54184. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54185. import { Nullable } from "babylonjs/types";
  54186. import { Scene } from "babylonjs/scene";
  54187. import { Matrix } from "babylonjs/Maths/math.vector";
  54188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54189. /**
  54190. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54191. * It can help converting any input color in a desired output one. This can then be used to create effects
  54192. * from sepia, black and white to sixties or futuristic rendering...
  54193. *
  54194. * The only supported format is currently 3dl.
  54195. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54196. */
  54197. export class ColorGradingTexture extends BaseTexture {
  54198. /**
  54199. * The current texture matrix. (will always be identity in color grading texture)
  54200. */
  54201. private _textureMatrix;
  54202. /**
  54203. * The texture URL.
  54204. */
  54205. url: string;
  54206. /**
  54207. * Empty line regex stored for GC.
  54208. */
  54209. private static _noneEmptyLineRegex;
  54210. private _engine;
  54211. /**
  54212. * Instantiates a ColorGradingTexture from the following parameters.
  54213. *
  54214. * @param url The location of the color gradind data (currently only supporting 3dl)
  54215. * @param scene The scene the texture will be used in
  54216. */
  54217. constructor(url: string, scene: Scene);
  54218. /**
  54219. * Returns the texture matrix used in most of the material.
  54220. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54221. */
  54222. getTextureMatrix(): Matrix;
  54223. /**
  54224. * Occurs when the file being loaded is a .3dl LUT file.
  54225. */
  54226. private load3dlTexture;
  54227. /**
  54228. * Starts the loading process of the texture.
  54229. */
  54230. private loadTexture;
  54231. /**
  54232. * Clones the color gradind texture.
  54233. */
  54234. clone(): ColorGradingTexture;
  54235. /**
  54236. * Called during delayed load for textures.
  54237. */
  54238. delayLoad(): void;
  54239. /**
  54240. * Parses a color grading texture serialized by Babylon.
  54241. * @param parsedTexture The texture information being parsedTexture
  54242. * @param scene The scene to load the texture in
  54243. * @param rootUrl The root url of the data assets to load
  54244. * @return A color gradind texture
  54245. */
  54246. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54247. /**
  54248. * Serializes the LUT texture to json format.
  54249. */
  54250. serialize(): any;
  54251. }
  54252. }
  54253. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54255. import { Scene } from "babylonjs/scene";
  54256. import { Nullable } from "babylonjs/types";
  54257. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54258. /**
  54259. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54260. */
  54261. export class EquiRectangularCubeTexture extends BaseTexture {
  54262. /** The six faces of the cube. */
  54263. private static _FacesMapping;
  54264. private _noMipmap;
  54265. private _onLoad;
  54266. private _onError;
  54267. /** The size of the cubemap. */
  54268. private _size;
  54269. /** The buffer of the image. */
  54270. private _buffer;
  54271. /** The width of the input image. */
  54272. private _width;
  54273. /** The height of the input image. */
  54274. private _height;
  54275. /** The URL to the image. */
  54276. url: string;
  54277. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54278. coordinatesMode: number;
  54279. /**
  54280. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54281. * @param url The location of the image
  54282. * @param scene The scene the texture will be used in
  54283. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54284. * @param noMipmap Forces to not generate the mipmap if true
  54285. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54286. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54287. * @param onLoad — defines a callback called when texture is loaded
  54288. * @param onError — defines a callback called if there is an error
  54289. */
  54290. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54291. /**
  54292. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54293. */
  54294. private loadImage;
  54295. /**
  54296. * Convert the image buffer into a cubemap and create a CubeTexture.
  54297. */
  54298. private loadTexture;
  54299. /**
  54300. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54301. * @param buffer The ArrayBuffer that should be converted.
  54302. * @returns The buffer as Float32Array.
  54303. */
  54304. private getFloat32ArrayFromArrayBuffer;
  54305. /**
  54306. * Get the current class name of the texture useful for serialization or dynamic coding.
  54307. * @returns "EquiRectangularCubeTexture"
  54308. */
  54309. getClassName(): string;
  54310. /**
  54311. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54312. * @returns A clone of the current EquiRectangularCubeTexture.
  54313. */
  54314. clone(): EquiRectangularCubeTexture;
  54315. }
  54316. }
  54317. declare module "babylonjs/Misc/tga" {
  54318. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54319. /**
  54320. * Based on jsTGALoader - Javascript loader for TGA file
  54321. * By Vincent Thibault
  54322. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54323. */
  54324. export class TGATools {
  54325. private static _TYPE_INDEXED;
  54326. private static _TYPE_RGB;
  54327. private static _TYPE_GREY;
  54328. private static _TYPE_RLE_INDEXED;
  54329. private static _TYPE_RLE_RGB;
  54330. private static _TYPE_RLE_GREY;
  54331. private static _ORIGIN_MASK;
  54332. private static _ORIGIN_SHIFT;
  54333. private static _ORIGIN_BL;
  54334. private static _ORIGIN_BR;
  54335. private static _ORIGIN_UL;
  54336. private static _ORIGIN_UR;
  54337. /**
  54338. * Gets the header of a TGA file
  54339. * @param data defines the TGA data
  54340. * @returns the header
  54341. */
  54342. static GetTGAHeader(data: Uint8Array): any;
  54343. /**
  54344. * Uploads TGA content to a Babylon Texture
  54345. * @hidden
  54346. */
  54347. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54348. /** @hidden */
  54349. 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;
  54350. /** @hidden */
  54351. 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;
  54352. /** @hidden */
  54353. 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;
  54354. /** @hidden */
  54355. 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;
  54356. /** @hidden */
  54357. 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;
  54358. /** @hidden */
  54359. 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;
  54360. }
  54361. }
  54362. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54363. import { Nullable } from "babylonjs/types";
  54364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54365. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54366. /**
  54367. * Implementation of the TGA Texture Loader.
  54368. * @hidden
  54369. */
  54370. export class _TGATextureLoader implements IInternalTextureLoader {
  54371. /**
  54372. * Defines wether the loader supports cascade loading the different faces.
  54373. */
  54374. readonly supportCascades: boolean;
  54375. /**
  54376. * This returns if the loader support the current file information.
  54377. * @param extension defines the file extension of the file being loaded
  54378. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54379. * @param fallback defines the fallback internal texture if any
  54380. * @param isBase64 defines whether the texture is encoded as a base64
  54381. * @param isBuffer defines whether the texture data are stored as a buffer
  54382. * @returns true if the loader can load the specified file
  54383. */
  54384. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54385. /**
  54386. * Transform the url before loading if required.
  54387. * @param rootUrl the url of the texture
  54388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54389. * @returns the transformed texture
  54390. */
  54391. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54392. /**
  54393. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54394. * @param rootUrl the url of the texture
  54395. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54396. * @returns the fallback texture
  54397. */
  54398. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54399. /**
  54400. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54401. * @param data contains the texture data
  54402. * @param texture defines the BabylonJS internal texture
  54403. * @param createPolynomials will be true if polynomials have been requested
  54404. * @param onLoad defines the callback to trigger once the texture is ready
  54405. * @param onError defines the callback to trigger in case of error
  54406. */
  54407. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54408. /**
  54409. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54410. * @param data contains the texture data
  54411. * @param texture defines the BabylonJS internal texture
  54412. * @param callback defines the method to call once ready to upload
  54413. */
  54414. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54415. }
  54416. }
  54417. declare module "babylonjs/Misc/basis" {
  54418. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54419. /**
  54420. * Info about the .basis files
  54421. */
  54422. class BasisFileInfo {
  54423. /**
  54424. * If the file has alpha
  54425. */
  54426. hasAlpha: boolean;
  54427. /**
  54428. * Info about each image of the basis file
  54429. */
  54430. images: Array<{
  54431. levels: Array<{
  54432. width: number;
  54433. height: number;
  54434. transcodedPixels: ArrayBufferView;
  54435. }>;
  54436. }>;
  54437. }
  54438. /**
  54439. * Result of transcoding a basis file
  54440. */
  54441. class TranscodeResult {
  54442. /**
  54443. * Info about the .basis file
  54444. */
  54445. fileInfo: BasisFileInfo;
  54446. /**
  54447. * Format to use when loading the file
  54448. */
  54449. format: number;
  54450. }
  54451. /**
  54452. * Configuration options for the Basis transcoder
  54453. */
  54454. export class BasisTranscodeConfiguration {
  54455. /**
  54456. * Supported compression formats used to determine the supported output format of the transcoder
  54457. */
  54458. supportedCompressionFormats?: {
  54459. /**
  54460. * etc1 compression format
  54461. */
  54462. etc1?: boolean;
  54463. /**
  54464. * s3tc compression format
  54465. */
  54466. s3tc?: boolean;
  54467. /**
  54468. * pvrtc compression format
  54469. */
  54470. pvrtc?: boolean;
  54471. /**
  54472. * etc2 compression format
  54473. */
  54474. etc2?: boolean;
  54475. };
  54476. /**
  54477. * If mipmap levels should be loaded for transcoded images (Default: true)
  54478. */
  54479. loadMipmapLevels?: boolean;
  54480. /**
  54481. * Index of a single image to load (Default: all images)
  54482. */
  54483. loadSingleImage?: number;
  54484. }
  54485. /**
  54486. * Used to load .Basis files
  54487. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54488. */
  54489. export class BasisTools {
  54490. private static _IgnoreSupportedFormats;
  54491. /**
  54492. * URL to use when loading the basis transcoder
  54493. */
  54494. static JSModuleURL: string;
  54495. /**
  54496. * URL to use when loading the wasm module for the transcoder
  54497. */
  54498. static WasmModuleURL: string;
  54499. /**
  54500. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54501. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54502. * @returns internal format corresponding to the Basis format
  54503. */
  54504. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54505. private static _WorkerPromise;
  54506. private static _Worker;
  54507. private static _actionId;
  54508. private static _CreateWorkerAsync;
  54509. /**
  54510. * Transcodes a loaded image file to compressed pixel data
  54511. * @param imageData image data to transcode
  54512. * @param config configuration options for the transcoding
  54513. * @returns a promise resulting in the transcoded image
  54514. */
  54515. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54516. /**
  54517. * Loads a texture from the transcode result
  54518. * @param texture texture load to
  54519. * @param transcodeResult the result of transcoding the basis file to load from
  54520. */
  54521. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54522. }
  54523. }
  54524. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54525. import { Nullable } from "babylonjs/types";
  54526. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54527. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54528. /**
  54529. * Loader for .basis file format
  54530. */
  54531. export class _BasisTextureLoader implements IInternalTextureLoader {
  54532. /**
  54533. * Defines whether the loader supports cascade loading the different faces.
  54534. */
  54535. readonly supportCascades: boolean;
  54536. /**
  54537. * This returns if the loader support the current file information.
  54538. * @param extension defines the file extension of the file being loaded
  54539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54540. * @param fallback defines the fallback internal texture if any
  54541. * @param isBase64 defines whether the texture is encoded as a base64
  54542. * @param isBuffer defines whether the texture data are stored as a buffer
  54543. * @returns true if the loader can load the specified file
  54544. */
  54545. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54546. /**
  54547. * Transform the url before loading if required.
  54548. * @param rootUrl the url of the texture
  54549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54550. * @returns the transformed texture
  54551. */
  54552. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54553. /**
  54554. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54555. * @param rootUrl the url of the texture
  54556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54557. * @returns the fallback texture
  54558. */
  54559. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54560. /**
  54561. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54562. * @param data contains the texture data
  54563. * @param texture defines the BabylonJS internal texture
  54564. * @param createPolynomials will be true if polynomials have been requested
  54565. * @param onLoad defines the callback to trigger once the texture is ready
  54566. * @param onError defines the callback to trigger in case of error
  54567. */
  54568. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54569. /**
  54570. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54571. * @param data contains the texture data
  54572. * @param texture defines the BabylonJS internal texture
  54573. * @param callback defines the method to call once ready to upload
  54574. */
  54575. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54576. }
  54577. }
  54578. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54579. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54580. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54581. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54582. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54583. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54584. }
  54585. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54586. import { Scene } from "babylonjs/scene";
  54587. import { Texture } from "babylonjs/Materials/Textures/texture";
  54588. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54589. /**
  54590. * 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.
  54591. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54592. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54593. */
  54594. export class CustomProceduralTexture extends ProceduralTexture {
  54595. private _animate;
  54596. private _time;
  54597. private _config;
  54598. private _texturePath;
  54599. /**
  54600. * Instantiates a new Custom Procedural Texture.
  54601. * 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.
  54602. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54603. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54604. * @param name Define the name of the texture
  54605. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54606. * @param size Define the size of the texture to create
  54607. * @param scene Define the scene the texture belongs to
  54608. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54609. * @param generateMipMaps Define if the texture should creates mip maps or not
  54610. */
  54611. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54612. private _loadJson;
  54613. /**
  54614. * Is the texture ready to be used ? (rendered at least once)
  54615. * @returns true if ready, otherwise, false.
  54616. */
  54617. isReady(): boolean;
  54618. /**
  54619. * Render the texture to its associated render target.
  54620. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54621. */
  54622. render(useCameraPostProcess?: boolean): void;
  54623. /**
  54624. * Update the list of dependant textures samplers in the shader.
  54625. */
  54626. updateTextures(): void;
  54627. /**
  54628. * Update the uniform values of the procedural texture in the shader.
  54629. */
  54630. updateShaderUniforms(): void;
  54631. /**
  54632. * Define if the texture animates or not.
  54633. */
  54634. animate: boolean;
  54635. }
  54636. }
  54637. declare module "babylonjs/Shaders/noise.fragment" {
  54638. /** @hidden */
  54639. export var noisePixelShader: {
  54640. name: string;
  54641. shader: string;
  54642. };
  54643. }
  54644. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54645. import { Nullable } from "babylonjs/types";
  54646. import { Scene } from "babylonjs/scene";
  54647. import { Texture } from "babylonjs/Materials/Textures/texture";
  54648. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54649. import "babylonjs/Shaders/noise.fragment";
  54650. /**
  54651. * Class used to generate noise procedural textures
  54652. */
  54653. export class NoiseProceduralTexture extends ProceduralTexture {
  54654. private _time;
  54655. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54656. brightness: number;
  54657. /** Defines the number of octaves to process */
  54658. octaves: number;
  54659. /** Defines the level of persistence (0.8 by default) */
  54660. persistence: number;
  54661. /** Gets or sets animation speed factor (default is 1) */
  54662. animationSpeedFactor: number;
  54663. /**
  54664. * Creates a new NoiseProceduralTexture
  54665. * @param name defines the name fo the texture
  54666. * @param size defines the size of the texture (default is 256)
  54667. * @param scene defines the hosting scene
  54668. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54669. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54670. */
  54671. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54672. private _updateShaderUniforms;
  54673. protected _getDefines(): string;
  54674. /** Generate the current state of the procedural texture */
  54675. render(useCameraPostProcess?: boolean): void;
  54676. /**
  54677. * Serializes this noise procedural texture
  54678. * @returns a serialized noise procedural texture object
  54679. */
  54680. serialize(): any;
  54681. /**
  54682. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54683. * @param parsedTexture defines parsed texture data
  54684. * @param scene defines the current scene
  54685. * @param rootUrl defines the root URL containing noise procedural texture information
  54686. * @returns a parsed NoiseProceduralTexture
  54687. */
  54688. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54689. }
  54690. }
  54691. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54692. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54693. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54694. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54695. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54696. }
  54697. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54698. import { Nullable } from "babylonjs/types";
  54699. import { Scene } from "babylonjs/scene";
  54700. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54701. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54702. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54703. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54704. /**
  54705. * Raw cube texture where the raw buffers are passed in
  54706. */
  54707. export class RawCubeTexture extends CubeTexture {
  54708. /**
  54709. * Creates a cube texture where the raw buffers are passed in.
  54710. * @param scene defines the scene the texture is attached to
  54711. * @param data defines the array of data to use to create each face
  54712. * @param size defines the size of the textures
  54713. * @param format defines the format of the data
  54714. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54715. * @param generateMipMaps defines if the engine should generate the mip levels
  54716. * @param invertY defines if data must be stored with Y axis inverted
  54717. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54718. * @param compression defines the compression used (null by default)
  54719. */
  54720. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54721. /**
  54722. * Updates the raw cube texture.
  54723. * @param data defines the data to store
  54724. * @param format defines the data format
  54725. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54726. * @param invertY defines if data must be stored with Y axis inverted
  54727. * @param compression defines the compression used (null by default)
  54728. * @param level defines which level of the texture to update
  54729. */
  54730. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54731. /**
  54732. * Updates a raw cube texture with RGBD encoded data.
  54733. * @param data defines the array of data [mipmap][face] to use to create each face
  54734. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54735. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54736. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54737. * @returns a promsie that resolves when the operation is complete
  54738. */
  54739. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54740. /**
  54741. * Clones the raw cube texture.
  54742. * @return a new cube texture
  54743. */
  54744. clone(): CubeTexture;
  54745. /** @hidden */
  54746. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54747. }
  54748. }
  54749. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54750. import { Scene } from "babylonjs/scene";
  54751. import { Texture } from "babylonjs/Materials/Textures/texture";
  54752. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54753. /**
  54754. * Class used to store 3D textures containing user data
  54755. */
  54756. export class RawTexture3D extends Texture {
  54757. /** Gets or sets the texture format to use */
  54758. format: number;
  54759. private _engine;
  54760. /**
  54761. * Create a new RawTexture3D
  54762. * @param data defines the data of the texture
  54763. * @param width defines the width of the texture
  54764. * @param height defines the height of the texture
  54765. * @param depth defines the depth of the texture
  54766. * @param format defines the texture format to use
  54767. * @param scene defines the hosting scene
  54768. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54769. * @param invertY defines if texture must be stored with Y axis inverted
  54770. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54771. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54772. */
  54773. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54774. /** Gets or sets the texture format to use */
  54775. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54776. /**
  54777. * Update the texture with new data
  54778. * @param data defines the data to store in the texture
  54779. */
  54780. update(data: ArrayBufferView): void;
  54781. }
  54782. }
  54783. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54784. import { Scene } from "babylonjs/scene";
  54785. import { Plane } from "babylonjs/Maths/math.plane";
  54786. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54787. /**
  54788. * Creates a refraction texture used by refraction channel of the standard material.
  54789. * It is like a mirror but to see through a material.
  54790. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54791. */
  54792. export class RefractionTexture extends RenderTargetTexture {
  54793. /**
  54794. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54795. * 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.
  54796. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54797. */
  54798. refractionPlane: Plane;
  54799. /**
  54800. * Define how deep under the surface we should see.
  54801. */
  54802. depth: number;
  54803. /**
  54804. * Creates a refraction texture used by refraction channel of the standard material.
  54805. * It is like a mirror but to see through a material.
  54806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54807. * @param name Define the texture name
  54808. * @param size Define the size of the underlying texture
  54809. * @param scene Define the scene the refraction belongs to
  54810. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54811. */
  54812. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54813. /**
  54814. * Clone the refraction texture.
  54815. * @returns the cloned texture
  54816. */
  54817. clone(): RefractionTexture;
  54818. /**
  54819. * Serialize the texture to a JSON representation you could use in Parse later on
  54820. * @returns the serialized JSON representation
  54821. */
  54822. serialize(): any;
  54823. }
  54824. }
  54825. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54826. import { Nullable } from "babylonjs/types";
  54827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54828. import { Matrix } from "babylonjs/Maths/math.vector";
  54829. import { Engine } from "babylonjs/Engines/engine";
  54830. import { Scene } from "babylonjs/scene";
  54831. /**
  54832. * Defines the options related to the creation of an HtmlElementTexture
  54833. */
  54834. export interface IHtmlElementTextureOptions {
  54835. /**
  54836. * Defines wether mip maps should be created or not.
  54837. */
  54838. generateMipMaps?: boolean;
  54839. /**
  54840. * Defines the sampling mode of the texture.
  54841. */
  54842. samplingMode?: number;
  54843. /**
  54844. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54845. */
  54846. engine: Nullable<Engine>;
  54847. /**
  54848. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54849. */
  54850. scene: Nullable<Scene>;
  54851. }
  54852. /**
  54853. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54854. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54855. * is automatically managed.
  54856. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54857. * in your application.
  54858. *
  54859. * As the update is not automatic, you need to call them manually.
  54860. */
  54861. export class HtmlElementTexture extends BaseTexture {
  54862. /**
  54863. * The texture URL.
  54864. */
  54865. element: HTMLVideoElement | HTMLCanvasElement;
  54866. private static readonly DefaultOptions;
  54867. private _textureMatrix;
  54868. private _engine;
  54869. private _isVideo;
  54870. private _generateMipMaps;
  54871. private _samplingMode;
  54872. /**
  54873. * Instantiates a HtmlElementTexture from the following parameters.
  54874. *
  54875. * @param name Defines the name of the texture
  54876. * @param element Defines the video or canvas the texture is filled with
  54877. * @param options Defines the other none mandatory texture creation options
  54878. */
  54879. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54880. private _createInternalTexture;
  54881. /**
  54882. * Returns the texture matrix used in most of the material.
  54883. */
  54884. getTextureMatrix(): Matrix;
  54885. /**
  54886. * Updates the content of the texture.
  54887. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54888. */
  54889. update(invertY?: Nullable<boolean>): void;
  54890. }
  54891. }
  54892. declare module "babylonjs/Materials/Textures/index" {
  54893. export * from "babylonjs/Materials/Textures/baseTexture";
  54894. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54895. export * from "babylonjs/Materials/Textures/cubeTexture";
  54896. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54897. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54898. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54899. export * from "babylonjs/Materials/Textures/internalTexture";
  54900. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54901. export * from "babylonjs/Materials/Textures/Loaders/index";
  54902. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54903. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54904. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54905. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54906. export * from "babylonjs/Materials/Textures/rawTexture";
  54907. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54908. export * from "babylonjs/Materials/Textures/refractionTexture";
  54909. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54910. export * from "babylonjs/Materials/Textures/texture";
  54911. export * from "babylonjs/Materials/Textures/videoTexture";
  54912. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54913. }
  54914. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54915. /**
  54916. * Enum used to define the target of a block
  54917. */
  54918. export enum NodeMaterialBlockTargets {
  54919. /** Vertex shader */
  54920. Vertex = 1,
  54921. /** Fragment shader */
  54922. Fragment = 2,
  54923. /** Neutral */
  54924. Neutral = 4,
  54925. /** Vertex and Fragment */
  54926. VertexAndFragment = 3
  54927. }
  54928. }
  54929. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54930. /**
  54931. * Defines the kind of connection point for node based material
  54932. */
  54933. export enum NodeMaterialBlockConnectionPointTypes {
  54934. /** Float */
  54935. Float = 1,
  54936. /** Int */
  54937. Int = 2,
  54938. /** Vector2 */
  54939. Vector2 = 4,
  54940. /** Vector3 */
  54941. Vector3 = 8,
  54942. /** Vector4 */
  54943. Vector4 = 16,
  54944. /** Color3 */
  54945. Color3 = 32,
  54946. /** Color4 */
  54947. Color4 = 64,
  54948. /** Matrix */
  54949. Matrix = 128,
  54950. /** Detect type based on connection */
  54951. AutoDetect = 1024,
  54952. /** Output type that will be defined by input type */
  54953. BasedOnInput = 2048
  54954. }
  54955. }
  54956. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54957. /**
  54958. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54959. */
  54960. export enum NodeMaterialBlockConnectionPointMode {
  54961. /** Value is an uniform */
  54962. Uniform = 0,
  54963. /** Value is a mesh attribute */
  54964. Attribute = 1,
  54965. /** Value is a varying between vertex and fragment shaders */
  54966. Varying = 2,
  54967. /** Mode is undefined */
  54968. Undefined = 3
  54969. }
  54970. }
  54971. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54972. /**
  54973. * Enum used to define system values e.g. values automatically provided by the system
  54974. */
  54975. export enum NodeMaterialSystemValues {
  54976. /** World */
  54977. World = 1,
  54978. /** View */
  54979. View = 2,
  54980. /** Projection */
  54981. Projection = 3,
  54982. /** ViewProjection */
  54983. ViewProjection = 4,
  54984. /** WorldView */
  54985. WorldView = 5,
  54986. /** WorldViewProjection */
  54987. WorldViewProjection = 6,
  54988. /** CameraPosition */
  54989. CameraPosition = 7,
  54990. /** Fog Color */
  54991. FogColor = 8,
  54992. /** Delta time */
  54993. DeltaTime = 9
  54994. }
  54995. }
  54996. declare module "babylonjs/Materials/Node/Enums/index" {
  54997. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54998. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54999. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55000. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55001. }
  55002. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55004. /**
  55005. * Root class for all node material optimizers
  55006. */
  55007. export class NodeMaterialOptimizer {
  55008. /**
  55009. * Function used to optimize a NodeMaterial graph
  55010. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55011. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55012. */
  55013. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55014. }
  55015. }
  55016. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55017. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55018. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55019. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55020. import { Scene } from "babylonjs/scene";
  55021. /**
  55022. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55023. */
  55024. export class TransformBlock extends NodeMaterialBlock {
  55025. /**
  55026. * Defines the value to use to complement W value to transform it to a Vector4
  55027. */
  55028. complementW: number;
  55029. /**
  55030. * Defines the value to use to complement z value to transform it to a Vector4
  55031. */
  55032. complementZ: number;
  55033. /**
  55034. * Creates a new TransformBlock
  55035. * @param name defines the block name
  55036. */
  55037. constructor(name: string);
  55038. /**
  55039. * Gets the current class name
  55040. * @returns the class name
  55041. */
  55042. getClassName(): string;
  55043. /**
  55044. * Gets the vector input
  55045. */
  55046. readonly vector: NodeMaterialConnectionPoint;
  55047. /**
  55048. * Gets the output component
  55049. */
  55050. readonly output: NodeMaterialConnectionPoint;
  55051. /**
  55052. * Gets the matrix transform input
  55053. */
  55054. readonly transform: NodeMaterialConnectionPoint;
  55055. protected _buildBlock(state: NodeMaterialBuildState): this;
  55056. serialize(): any;
  55057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55058. protected _dumpPropertiesCode(): string;
  55059. }
  55060. }
  55061. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55065. /**
  55066. * Block used to output the vertex position
  55067. */
  55068. export class VertexOutputBlock extends NodeMaterialBlock {
  55069. /**
  55070. * Creates a new VertexOutputBlock
  55071. * @param name defines the block name
  55072. */
  55073. constructor(name: string);
  55074. /**
  55075. * Gets the current class name
  55076. * @returns the class name
  55077. */
  55078. getClassName(): string;
  55079. /**
  55080. * Gets the vector input component
  55081. */
  55082. readonly vector: NodeMaterialConnectionPoint;
  55083. protected _buildBlock(state: NodeMaterialBuildState): this;
  55084. }
  55085. }
  55086. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55090. /**
  55091. * Block used to output the final color
  55092. */
  55093. export class FragmentOutputBlock extends NodeMaterialBlock {
  55094. /**
  55095. * Create a new FragmentOutputBlock
  55096. * @param name defines the block name
  55097. */
  55098. constructor(name: string);
  55099. /**
  55100. * Gets the current class name
  55101. * @returns the class name
  55102. */
  55103. getClassName(): string;
  55104. /**
  55105. * Gets the rgba input component
  55106. */
  55107. readonly rgba: NodeMaterialConnectionPoint;
  55108. /**
  55109. * Gets the rgb input component
  55110. */
  55111. readonly rgb: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the a input component
  55114. */
  55115. readonly a: NodeMaterialConnectionPoint;
  55116. protected _buildBlock(state: NodeMaterialBuildState): this;
  55117. }
  55118. }
  55119. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55123. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55125. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55126. import { Effect } from "babylonjs/Materials/effect";
  55127. import { Mesh } from "babylonjs/Meshes/mesh";
  55128. import { Nullable } from "babylonjs/types";
  55129. import { Scene } from "babylonjs/scene";
  55130. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55131. /**
  55132. * Block used to read a reflection texture from a sampler
  55133. */
  55134. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55135. private _define3DName;
  55136. private _defineCubicName;
  55137. private _defineExplicitName;
  55138. private _defineProjectionName;
  55139. private _defineLocalCubicName;
  55140. private _defineSphericalName;
  55141. private _definePlanarName;
  55142. private _defineEquirectangularName;
  55143. private _defineMirroredEquirectangularFixedName;
  55144. private _defineEquirectangularFixedName;
  55145. private _defineSkyboxName;
  55146. private _cubeSamplerName;
  55147. private _2DSamplerName;
  55148. private _positionUVWName;
  55149. private _directionWName;
  55150. private _reflectionCoordsName;
  55151. private _reflection2DCoordsName;
  55152. private _reflectionColorName;
  55153. private _reflectionMatrixName;
  55154. /**
  55155. * Gets or sets the texture associated with the node
  55156. */
  55157. texture: Nullable<BaseTexture>;
  55158. /**
  55159. * Create a new TextureBlock
  55160. * @param name defines the block name
  55161. */
  55162. constructor(name: string);
  55163. /**
  55164. * Gets the current class name
  55165. * @returns the class name
  55166. */
  55167. getClassName(): string;
  55168. /**
  55169. * Gets the world position input component
  55170. */
  55171. readonly position: NodeMaterialConnectionPoint;
  55172. /**
  55173. * Gets the world position input component
  55174. */
  55175. readonly worldPosition: NodeMaterialConnectionPoint;
  55176. /**
  55177. * Gets the world normal input component
  55178. */
  55179. readonly worldNormal: NodeMaterialConnectionPoint;
  55180. /**
  55181. * Gets the world input component
  55182. */
  55183. readonly world: NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the camera (or eye) position component
  55186. */
  55187. readonly cameraPosition: NodeMaterialConnectionPoint;
  55188. /**
  55189. * Gets the view input component
  55190. */
  55191. readonly view: NodeMaterialConnectionPoint;
  55192. /**
  55193. * Gets the rgb output component
  55194. */
  55195. readonly rgb: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the r output component
  55198. */
  55199. readonly r: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the g output component
  55202. */
  55203. readonly g: NodeMaterialConnectionPoint;
  55204. /**
  55205. * Gets the b output component
  55206. */
  55207. readonly b: NodeMaterialConnectionPoint;
  55208. autoConfigure(material: NodeMaterial): void;
  55209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55210. isReady(): boolean;
  55211. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55212. private _injectVertexCode;
  55213. private _writeOutput;
  55214. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55215. serialize(): any;
  55216. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55217. }
  55218. }
  55219. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55220. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55221. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55222. import { Scene } from "babylonjs/scene";
  55223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55224. import { Matrix } from "babylonjs/Maths/math.vector";
  55225. import { Mesh } from "babylonjs/Meshes/mesh";
  55226. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55227. import { Observable } from "babylonjs/Misc/observable";
  55228. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55229. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55230. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55231. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55232. import { Nullable } from "babylonjs/types";
  55233. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55234. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55235. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55236. /**
  55237. * Interface used to configure the node material editor
  55238. */
  55239. export interface INodeMaterialEditorOptions {
  55240. /** Define the URl to load node editor script */
  55241. editorURL?: string;
  55242. }
  55243. /** @hidden */
  55244. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55245. /** BONES */
  55246. NUM_BONE_INFLUENCERS: number;
  55247. BonesPerMesh: number;
  55248. BONETEXTURE: boolean;
  55249. /** MORPH TARGETS */
  55250. MORPHTARGETS: boolean;
  55251. MORPHTARGETS_NORMAL: boolean;
  55252. MORPHTARGETS_TANGENT: boolean;
  55253. MORPHTARGETS_UV: boolean;
  55254. NUM_MORPH_INFLUENCERS: number;
  55255. /** IMAGE PROCESSING */
  55256. IMAGEPROCESSING: boolean;
  55257. VIGNETTE: boolean;
  55258. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55259. VIGNETTEBLENDMODEOPAQUE: boolean;
  55260. TONEMAPPING: boolean;
  55261. TONEMAPPING_ACES: boolean;
  55262. CONTRAST: boolean;
  55263. EXPOSURE: boolean;
  55264. COLORCURVES: boolean;
  55265. COLORGRADING: boolean;
  55266. COLORGRADING3D: boolean;
  55267. SAMPLER3DGREENDEPTH: boolean;
  55268. SAMPLER3DBGRMAP: boolean;
  55269. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55270. /** MISC. */
  55271. BUMPDIRECTUV: number;
  55272. constructor();
  55273. setValue(name: string, value: boolean): void;
  55274. }
  55275. /**
  55276. * Class used to configure NodeMaterial
  55277. */
  55278. export interface INodeMaterialOptions {
  55279. /**
  55280. * Defines if blocks should emit comments
  55281. */
  55282. emitComments: boolean;
  55283. }
  55284. /**
  55285. * Class used to create a node based material built by assembling shader blocks
  55286. */
  55287. export class NodeMaterial extends PushMaterial {
  55288. private static _BuildIdGenerator;
  55289. private _options;
  55290. private _vertexCompilationState;
  55291. private _fragmentCompilationState;
  55292. private _sharedData;
  55293. private _buildId;
  55294. private _buildWasSuccessful;
  55295. private _cachedWorldViewMatrix;
  55296. private _cachedWorldViewProjectionMatrix;
  55297. private _optimizers;
  55298. private _animationFrame;
  55299. /** Define the URl to load node editor script */
  55300. static EditorURL: string;
  55301. private BJSNODEMATERIALEDITOR;
  55302. /** Get the inspector from bundle or global */
  55303. private _getGlobalNodeMaterialEditor;
  55304. /**
  55305. * 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)
  55306. */
  55307. ignoreAlpha: boolean;
  55308. /**
  55309. * Defines the maximum number of lights that can be used in the material
  55310. */
  55311. maxSimultaneousLights: number;
  55312. /**
  55313. * Observable raised when the material is built
  55314. */
  55315. onBuildObservable: Observable<NodeMaterial>;
  55316. /**
  55317. * Gets or sets the root nodes of the material vertex shader
  55318. */
  55319. _vertexOutputNodes: NodeMaterialBlock[];
  55320. /**
  55321. * Gets or sets the root nodes of the material fragment (pixel) shader
  55322. */
  55323. _fragmentOutputNodes: NodeMaterialBlock[];
  55324. /** Gets or sets options to control the node material overall behavior */
  55325. options: INodeMaterialOptions;
  55326. /**
  55327. * Default configuration related to image processing available in the standard Material.
  55328. */
  55329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55330. /**
  55331. * Gets the image processing configuration used either in this material.
  55332. */
  55333. /**
  55334. * Sets the Default image processing configuration used either in the this material.
  55335. *
  55336. * If sets to null, the scene one is in use.
  55337. */
  55338. imageProcessingConfiguration: ImageProcessingConfiguration;
  55339. /**
  55340. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55341. */
  55342. attachedBlocks: NodeMaterialBlock[];
  55343. /**
  55344. * Create a new node based material
  55345. * @param name defines the material name
  55346. * @param scene defines the hosting scene
  55347. * @param options defines creation option
  55348. */
  55349. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55350. /**
  55351. * Gets the current class name of the material e.g. "NodeMaterial"
  55352. * @returns the class name
  55353. */
  55354. getClassName(): string;
  55355. /**
  55356. * Keep track of the image processing observer to allow dispose and replace.
  55357. */
  55358. private _imageProcessingObserver;
  55359. /**
  55360. * Attaches a new image processing configuration to the Standard Material.
  55361. * @param configuration
  55362. */
  55363. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55364. /**
  55365. * Get a block by its name
  55366. * @param name defines the name of the block to retrieve
  55367. * @returns the required block or null if not found
  55368. */
  55369. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55370. /**
  55371. * Get a block by its name
  55372. * @param predicate defines the predicate used to find the good candidate
  55373. * @returns the required block or null if not found
  55374. */
  55375. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55376. /**
  55377. * Get an input block by its name
  55378. * @param predicate defines the predicate used to find the good candidate
  55379. * @returns the required input block or null if not found
  55380. */
  55381. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55382. /**
  55383. * Gets the list of input blocks attached to this material
  55384. * @returns an array of InputBlocks
  55385. */
  55386. getInputBlocks(): InputBlock[];
  55387. /**
  55388. * Adds a new optimizer to the list of optimizers
  55389. * @param optimizer defines the optimizers to add
  55390. * @returns the current material
  55391. */
  55392. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55393. /**
  55394. * Remove an optimizer from the list of optimizers
  55395. * @param optimizer defines the optimizers to remove
  55396. * @returns the current material
  55397. */
  55398. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55399. /**
  55400. * Add a new block to the list of output nodes
  55401. * @param node defines the node to add
  55402. * @returns the current material
  55403. */
  55404. addOutputNode(node: NodeMaterialBlock): this;
  55405. /**
  55406. * Remove a block from the list of root nodes
  55407. * @param node defines the node to remove
  55408. * @returns the current material
  55409. */
  55410. removeOutputNode(node: NodeMaterialBlock): this;
  55411. private _addVertexOutputNode;
  55412. private _removeVertexOutputNode;
  55413. private _addFragmentOutputNode;
  55414. private _removeFragmentOutputNode;
  55415. /**
  55416. * Specifies if the material will require alpha blending
  55417. * @returns a boolean specifying if alpha blending is needed
  55418. */
  55419. needAlphaBlending(): boolean;
  55420. /**
  55421. * Specifies if this material should be rendered in alpha test mode
  55422. * @returns a boolean specifying if an alpha test is needed.
  55423. */
  55424. needAlphaTesting(): boolean;
  55425. private _initializeBlock;
  55426. private _resetDualBlocks;
  55427. /**
  55428. * Build the material and generates the inner effect
  55429. * @param verbose defines if the build should log activity
  55430. */
  55431. build(verbose?: boolean): void;
  55432. /**
  55433. * Runs an otpimization phase to try to improve the shader code
  55434. */
  55435. optimize(): void;
  55436. private _prepareDefinesForAttributes;
  55437. /**
  55438. * Get if the submesh is ready to be used and all its information available.
  55439. * Child classes can use it to update shaders
  55440. * @param mesh defines the mesh to check
  55441. * @param subMesh defines which submesh to check
  55442. * @param useInstances specifies that instances should be used
  55443. * @returns a boolean indicating that the submesh is ready or not
  55444. */
  55445. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55446. /**
  55447. * Get a string representing the shaders built by the current node graph
  55448. */
  55449. readonly compiledShaders: string;
  55450. /**
  55451. * Binds the world matrix to the material
  55452. * @param world defines the world transformation matrix
  55453. */
  55454. bindOnlyWorldMatrix(world: Matrix): void;
  55455. /**
  55456. * Binds the submesh to this material by preparing the effect and shader to draw
  55457. * @param world defines the world transformation matrix
  55458. * @param mesh defines the mesh containing the submesh
  55459. * @param subMesh defines the submesh to bind the material to
  55460. */
  55461. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55462. /**
  55463. * Gets the active textures from the material
  55464. * @returns an array of textures
  55465. */
  55466. getActiveTextures(): BaseTexture[];
  55467. /**
  55468. * Gets the list of texture blocks
  55469. * @returns an array of texture blocks
  55470. */
  55471. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55472. /**
  55473. * Specifies if the material uses a texture
  55474. * @param texture defines the texture to check against the material
  55475. * @returns a boolean specifying if the material uses the texture
  55476. */
  55477. hasTexture(texture: BaseTexture): boolean;
  55478. /**
  55479. * Disposes the material
  55480. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55481. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55482. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55483. */
  55484. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55485. /** Creates the node editor window. */
  55486. private _createNodeEditor;
  55487. /**
  55488. * Launch the node material editor
  55489. * @param config Define the configuration of the editor
  55490. * @return a promise fulfilled when the node editor is visible
  55491. */
  55492. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55493. /**
  55494. * Clear the current material
  55495. */
  55496. clear(): void;
  55497. /**
  55498. * Clear the current material and set it to a default state
  55499. */
  55500. setToDefault(): void;
  55501. /**
  55502. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55503. * @param url defines the url to load from
  55504. * @returns a promise that will fullfil when the material is fully loaded
  55505. */
  55506. loadAsync(url: string): Promise<unknown>;
  55507. private _gatherBlocks;
  55508. /**
  55509. * Generate a string containing the code declaration required to create an equivalent of this material
  55510. * @returns a string
  55511. */
  55512. generateCode(): string;
  55513. /**
  55514. * Serializes this material in a JSON representation
  55515. * @returns the serialized material object
  55516. */
  55517. serialize(): any;
  55518. private _restoreConnections;
  55519. /**
  55520. * Clear the current graph and load a new one from a serialization object
  55521. * @param source defines the JSON representation of the material
  55522. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55523. */
  55524. loadFromSerialization(source: any, rootUrl?: string): void;
  55525. /**
  55526. * Creates a node material from parsed material data
  55527. * @param source defines the JSON representation of the material
  55528. * @param scene defines the hosting scene
  55529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55530. * @returns a new node material
  55531. */
  55532. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55533. /**
  55534. * Creates a new node material set to default basic configuration
  55535. * @param name defines the name of the material
  55536. * @param scene defines the hosting scene
  55537. * @returns a new NodeMaterial
  55538. */
  55539. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55540. }
  55541. }
  55542. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55543. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55544. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55545. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55546. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55548. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55549. import { Effect } from "babylonjs/Materials/effect";
  55550. import { Mesh } from "babylonjs/Meshes/mesh";
  55551. import { Nullable } from "babylonjs/types";
  55552. import { Texture } from "babylonjs/Materials/Textures/texture";
  55553. import { Scene } from "babylonjs/scene";
  55554. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55555. /**
  55556. * Block used to read a texture from a sampler
  55557. */
  55558. export class TextureBlock extends NodeMaterialBlock {
  55559. private _defineName;
  55560. private _linearDefineName;
  55561. private _samplerName;
  55562. private _transformedUVName;
  55563. private _textureTransformName;
  55564. private _textureInfoName;
  55565. private _mainUVName;
  55566. private _mainUVDefineName;
  55567. /**
  55568. * Gets or sets the texture associated with the node
  55569. */
  55570. texture: Nullable<Texture>;
  55571. /**
  55572. * Create a new TextureBlock
  55573. * @param name defines the block name
  55574. */
  55575. constructor(name: string);
  55576. /**
  55577. * Gets the current class name
  55578. * @returns the class name
  55579. */
  55580. getClassName(): string;
  55581. /**
  55582. * Gets the uv input component
  55583. */
  55584. readonly uv: NodeMaterialConnectionPoint;
  55585. /**
  55586. * Gets the rgba output component
  55587. */
  55588. readonly rgba: NodeMaterialConnectionPoint;
  55589. /**
  55590. * Gets the rgb output component
  55591. */
  55592. readonly rgb: NodeMaterialConnectionPoint;
  55593. /**
  55594. * Gets the r output component
  55595. */
  55596. readonly r: NodeMaterialConnectionPoint;
  55597. /**
  55598. * Gets the g output component
  55599. */
  55600. readonly g: NodeMaterialConnectionPoint;
  55601. /**
  55602. * Gets the b output component
  55603. */
  55604. readonly b: NodeMaterialConnectionPoint;
  55605. /**
  55606. * Gets the a output component
  55607. */
  55608. readonly a: NodeMaterialConnectionPoint;
  55609. readonly target: NodeMaterialBlockTargets;
  55610. autoConfigure(material: NodeMaterial): void;
  55611. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55613. isReady(): boolean;
  55614. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55615. private readonly _isMixed;
  55616. private _injectVertexCode;
  55617. private _writeOutput;
  55618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55619. protected _dumpPropertiesCode(): string;
  55620. serialize(): any;
  55621. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55622. }
  55623. }
  55624. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55625. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55627. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55628. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55629. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55630. import { Scene } from "babylonjs/scene";
  55631. /**
  55632. * Class used to store shared data between 2 NodeMaterialBuildState
  55633. */
  55634. export class NodeMaterialBuildStateSharedData {
  55635. /**
  55636. * Gets the list of emitted varyings
  55637. */
  55638. temps: string[];
  55639. /**
  55640. * Gets the list of emitted varyings
  55641. */
  55642. varyings: string[];
  55643. /**
  55644. * Gets the varying declaration string
  55645. */
  55646. varyingDeclaration: string;
  55647. /**
  55648. * Input blocks
  55649. */
  55650. inputBlocks: InputBlock[];
  55651. /**
  55652. * Input blocks
  55653. */
  55654. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55655. /**
  55656. * Bindable blocks (Blocks that need to set data to the effect)
  55657. */
  55658. bindableBlocks: NodeMaterialBlock[];
  55659. /**
  55660. * List of blocks that can provide a compilation fallback
  55661. */
  55662. blocksWithFallbacks: NodeMaterialBlock[];
  55663. /**
  55664. * List of blocks that can provide a define update
  55665. */
  55666. blocksWithDefines: NodeMaterialBlock[];
  55667. /**
  55668. * List of blocks that can provide a repeatable content
  55669. */
  55670. repeatableContentBlocks: NodeMaterialBlock[];
  55671. /**
  55672. * List of blocks that can provide a dynamic list of uniforms
  55673. */
  55674. dynamicUniformBlocks: NodeMaterialBlock[];
  55675. /**
  55676. * List of blocks that can block the isReady function for the material
  55677. */
  55678. blockingBlocks: NodeMaterialBlock[];
  55679. /**
  55680. * Gets the list of animated inputs
  55681. */
  55682. animatedInputs: InputBlock[];
  55683. /**
  55684. * Build Id used to avoid multiple recompilations
  55685. */
  55686. buildId: number;
  55687. /** List of emitted variables */
  55688. variableNames: {
  55689. [key: string]: number;
  55690. };
  55691. /** List of emitted defines */
  55692. defineNames: {
  55693. [key: string]: number;
  55694. };
  55695. /** Should emit comments? */
  55696. emitComments: boolean;
  55697. /** Emit build activity */
  55698. verbose: boolean;
  55699. /** Gets or sets the hosting scene */
  55700. scene: Scene;
  55701. /**
  55702. * Gets the compilation hints emitted at compilation time
  55703. */
  55704. hints: {
  55705. needWorldViewMatrix: boolean;
  55706. needWorldViewProjectionMatrix: boolean;
  55707. needAlphaBlending: boolean;
  55708. needAlphaTesting: boolean;
  55709. };
  55710. /**
  55711. * List of compilation checks
  55712. */
  55713. checks: {
  55714. emitVertex: boolean;
  55715. emitFragment: boolean;
  55716. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55717. };
  55718. /** Creates a new shared data */
  55719. constructor();
  55720. /**
  55721. * Emits console errors and exceptions if there is a failing check
  55722. */
  55723. emitErrors(): void;
  55724. }
  55725. }
  55726. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55727. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55728. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55729. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55730. /**
  55731. * Class used to store node based material build state
  55732. */
  55733. export class NodeMaterialBuildState {
  55734. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55735. supportUniformBuffers: boolean;
  55736. /**
  55737. * Gets the list of emitted attributes
  55738. */
  55739. attributes: string[];
  55740. /**
  55741. * Gets the list of emitted uniforms
  55742. */
  55743. uniforms: string[];
  55744. /**
  55745. * Gets the list of emitted constants
  55746. */
  55747. constants: string[];
  55748. /**
  55749. * Gets the list of emitted uniform buffers
  55750. */
  55751. uniformBuffers: string[];
  55752. /**
  55753. * Gets the list of emitted samplers
  55754. */
  55755. samplers: string[];
  55756. /**
  55757. * Gets the list of emitted functions
  55758. */
  55759. functions: {
  55760. [key: string]: string;
  55761. };
  55762. /**
  55763. * Gets the list of emitted extensions
  55764. */
  55765. extensions: {
  55766. [key: string]: string;
  55767. };
  55768. /**
  55769. * Gets the target of the compilation state
  55770. */
  55771. target: NodeMaterialBlockTargets;
  55772. /**
  55773. * Gets the list of emitted counters
  55774. */
  55775. counters: {
  55776. [key: string]: number;
  55777. };
  55778. /**
  55779. * Shared data between multiple NodeMaterialBuildState instances
  55780. */
  55781. sharedData: NodeMaterialBuildStateSharedData;
  55782. /** @hidden */
  55783. _vertexState: NodeMaterialBuildState;
  55784. /** @hidden */
  55785. _attributeDeclaration: string;
  55786. /** @hidden */
  55787. _uniformDeclaration: string;
  55788. /** @hidden */
  55789. _constantDeclaration: string;
  55790. /** @hidden */
  55791. _samplerDeclaration: string;
  55792. /** @hidden */
  55793. _varyingTransfer: string;
  55794. private _repeatableContentAnchorIndex;
  55795. /** @hidden */
  55796. _builtCompilationString: string;
  55797. /**
  55798. * Gets the emitted compilation strings
  55799. */
  55800. compilationString: string;
  55801. /**
  55802. * Finalize the compilation strings
  55803. * @param state defines the current compilation state
  55804. */
  55805. finalize(state: NodeMaterialBuildState): void;
  55806. /** @hidden */
  55807. readonly _repeatableContentAnchor: string;
  55808. /** @hidden */
  55809. _getFreeVariableName(prefix: string): string;
  55810. /** @hidden */
  55811. _getFreeDefineName(prefix: string): string;
  55812. /** @hidden */
  55813. _excludeVariableName(name: string): void;
  55814. /** @hidden */
  55815. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55816. /** @hidden */
  55817. _emitExtension(name: string, extension: string): void;
  55818. /** @hidden */
  55819. _emitFunction(name: string, code: string, comments: string): void;
  55820. /** @hidden */
  55821. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55822. replaceStrings?: {
  55823. search: RegExp;
  55824. replace: string;
  55825. }[];
  55826. repeatKey?: string;
  55827. }): string;
  55828. /** @hidden */
  55829. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55830. repeatKey?: string;
  55831. removeAttributes?: boolean;
  55832. removeUniforms?: boolean;
  55833. removeVaryings?: boolean;
  55834. removeIfDef?: boolean;
  55835. replaceStrings?: {
  55836. search: RegExp;
  55837. replace: string;
  55838. }[];
  55839. }, storeKey?: string): void;
  55840. /** @hidden */
  55841. _registerTempVariable(name: string): boolean;
  55842. /** @hidden */
  55843. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55844. /** @hidden */
  55845. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55846. }
  55847. }
  55848. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55849. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55850. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55851. import { Nullable } from "babylonjs/types";
  55852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55853. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55854. import { Effect } from "babylonjs/Materials/effect";
  55855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55856. import { Mesh } from "babylonjs/Meshes/mesh";
  55857. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55858. import { Scene } from "babylonjs/scene";
  55859. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55860. /**
  55861. * Defines a block that can be used inside a node based material
  55862. */
  55863. export class NodeMaterialBlock {
  55864. private _buildId;
  55865. private _buildTarget;
  55866. private _target;
  55867. private _isFinalMerger;
  55868. private _isInput;
  55869. /** @hidden */
  55870. _codeVariableName: string;
  55871. /** @hidden */
  55872. _inputs: NodeMaterialConnectionPoint[];
  55873. /** @hidden */
  55874. _outputs: NodeMaterialConnectionPoint[];
  55875. /** @hidden */
  55876. _preparationId: number;
  55877. /**
  55878. * Gets or sets the name of the block
  55879. */
  55880. name: string;
  55881. /**
  55882. * Gets or sets the unique id of the node
  55883. */
  55884. uniqueId: number;
  55885. /**
  55886. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55887. */
  55888. readonly isFinalMerger: boolean;
  55889. /**
  55890. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55891. */
  55892. readonly isInput: boolean;
  55893. /**
  55894. * Gets or sets the build Id
  55895. */
  55896. buildId: number;
  55897. /**
  55898. * Gets or sets the target of the block
  55899. */
  55900. target: NodeMaterialBlockTargets;
  55901. /**
  55902. * Gets the list of input points
  55903. */
  55904. readonly inputs: NodeMaterialConnectionPoint[];
  55905. /** Gets the list of output points */
  55906. readonly outputs: NodeMaterialConnectionPoint[];
  55907. /**
  55908. * Find an input by its name
  55909. * @param name defines the name of the input to look for
  55910. * @returns the input or null if not found
  55911. */
  55912. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55913. /**
  55914. * Find an output by its name
  55915. * @param name defines the name of the outputto look for
  55916. * @returns the output or null if not found
  55917. */
  55918. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55919. /**
  55920. * Creates a new NodeMaterialBlock
  55921. * @param name defines the block name
  55922. * @param target defines the target of that block (Vertex by default)
  55923. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55924. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55925. */
  55926. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55927. /**
  55928. * Initialize the block and prepare the context for build
  55929. * @param state defines the state that will be used for the build
  55930. */
  55931. initialize(state: NodeMaterialBuildState): void;
  55932. /**
  55933. * Bind data to effect. Will only be called for blocks with isBindable === true
  55934. * @param effect defines the effect to bind data to
  55935. * @param nodeMaterial defines the hosting NodeMaterial
  55936. * @param mesh defines the mesh that will be rendered
  55937. */
  55938. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55939. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55940. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55941. protected _writeFloat(value: number): string;
  55942. /**
  55943. * Gets the current class name e.g. "NodeMaterialBlock"
  55944. * @returns the class name
  55945. */
  55946. getClassName(): string;
  55947. /**
  55948. * Register a new input. Must be called inside a block constructor
  55949. * @param name defines the connection point name
  55950. * @param type defines the connection point type
  55951. * @param isOptional defines a boolean indicating that this input can be omitted
  55952. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55953. * @returns the current block
  55954. */
  55955. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55956. /**
  55957. * Register a new output. Must be called inside a block constructor
  55958. * @param name defines the connection point name
  55959. * @param type defines the connection point type
  55960. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55961. * @returns the current block
  55962. */
  55963. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55964. /**
  55965. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55966. * @param forOutput defines an optional connection point to check compatibility with
  55967. * @returns the first available input or null
  55968. */
  55969. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55970. /**
  55971. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55972. * @param forBlock defines an optional block to check compatibility with
  55973. * @returns the first available input or null
  55974. */
  55975. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55976. /**
  55977. * Gets the sibling of the given output
  55978. * @param current defines the current output
  55979. * @returns the next output in the list or null
  55980. */
  55981. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55982. /**
  55983. * Connect current block with another block
  55984. * @param other defines the block to connect with
  55985. * @param options define the various options to help pick the right connections
  55986. * @returns the current block
  55987. */
  55988. connectTo(other: NodeMaterialBlock, options?: {
  55989. input?: string;
  55990. output?: string;
  55991. outputSwizzle?: string;
  55992. }): this | undefined;
  55993. protected _buildBlock(state: NodeMaterialBuildState): void;
  55994. /**
  55995. * Add uniforms, samplers and uniform buffers at compilation time
  55996. * @param state defines the state to update
  55997. * @param nodeMaterial defines the node material requesting the update
  55998. * @param defines defines the material defines to update
  55999. */
  56000. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56001. /**
  56002. * Add potential fallbacks if shader compilation fails
  56003. * @param mesh defines the mesh to be rendered
  56004. * @param fallbacks defines the current prioritized list of fallbacks
  56005. */
  56006. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56007. /**
  56008. * Initialize defines for shader compilation
  56009. * @param mesh defines the mesh to be rendered
  56010. * @param nodeMaterial defines the node material requesting the update
  56011. * @param defines defines the material defines to update
  56012. * @param useInstances specifies that instances should be used
  56013. */
  56014. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56015. /**
  56016. * Update defines for shader compilation
  56017. * @param mesh defines the mesh to be rendered
  56018. * @param nodeMaterial defines the node material requesting the update
  56019. * @param defines defines the material defines to update
  56020. * @param useInstances specifies that instances should be used
  56021. */
  56022. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56023. /**
  56024. * Lets the block try to connect some inputs automatically
  56025. * @param material defines the hosting NodeMaterial
  56026. */
  56027. autoConfigure(material: NodeMaterial): void;
  56028. /**
  56029. * Function called when a block is declared as repeatable content generator
  56030. * @param vertexShaderState defines the current compilation state for the vertex shader
  56031. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56032. * @param mesh defines the mesh to be rendered
  56033. * @param defines defines the material defines to update
  56034. */
  56035. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56036. /**
  56037. * Checks if the block is ready
  56038. * @param mesh defines the mesh to be rendered
  56039. * @param nodeMaterial defines the node material requesting the update
  56040. * @param defines defines the material defines to update
  56041. * @param useInstances specifies that instances should be used
  56042. * @returns true if the block is ready
  56043. */
  56044. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56045. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56046. private _processBuild;
  56047. /**
  56048. * Compile the current node and generate the shader code
  56049. * @param state defines the current compilation state (uniforms, samplers, current string)
  56050. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56051. * @returns true if already built
  56052. */
  56053. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56054. protected _inputRename(name: string): string;
  56055. protected _outputRename(name: string): string;
  56056. protected _dumpPropertiesCode(): string;
  56057. /** @hidden */
  56058. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56059. /**
  56060. * Clone the current block to a new identical block
  56061. * @param scene defines the hosting scene
  56062. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56063. * @returns a copy of the current block
  56064. */
  56065. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56066. /**
  56067. * Serializes this block in a JSON representation
  56068. * @returns the serialized block object
  56069. */
  56070. serialize(): any;
  56071. /** @hidden */
  56072. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56073. }
  56074. }
  56075. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56076. /**
  56077. * Enum defining the type of animations supported by InputBlock
  56078. */
  56079. export enum AnimatedInputBlockTypes {
  56080. /** No animation */
  56081. None = 0,
  56082. /** Time based animation. Will only work for floats */
  56083. Time = 1
  56084. }
  56085. }
  56086. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56088. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56089. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56090. import { Nullable } from "babylonjs/types";
  56091. import { Effect } from "babylonjs/Materials/effect";
  56092. import { Matrix } from "babylonjs/Maths/math.vector";
  56093. import { Scene } from "babylonjs/scene";
  56094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56096. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56097. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56098. /**
  56099. * Block used to expose an input value
  56100. */
  56101. export class InputBlock extends NodeMaterialBlock {
  56102. private _mode;
  56103. private _associatedVariableName;
  56104. private _storedValue;
  56105. private _valueCallback;
  56106. private _type;
  56107. private _animationType;
  56108. /** Gets or set a value used to limit the range of float values */
  56109. min: number;
  56110. /** Gets or set a value used to limit the range of float values */
  56111. max: number;
  56112. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56113. matrixMode: number;
  56114. /** @hidden */
  56115. _systemValue: Nullable<NodeMaterialSystemValues>;
  56116. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56117. visibleInInspector: boolean;
  56118. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56119. isConstant: boolean;
  56120. /**
  56121. * Gets or sets the connection point type (default is float)
  56122. */
  56123. readonly type: NodeMaterialBlockConnectionPointTypes;
  56124. /**
  56125. * Creates a new InputBlock
  56126. * @param name defines the block name
  56127. * @param target defines the target of that block (Vertex by default)
  56128. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56129. */
  56130. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56131. /**
  56132. * Gets the output component
  56133. */
  56134. readonly output: NodeMaterialConnectionPoint;
  56135. /**
  56136. * Set the source of this connection point to a vertex attribute
  56137. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56138. * @returns the current connection point
  56139. */
  56140. setAsAttribute(attributeName?: string): InputBlock;
  56141. /**
  56142. * Set the source of this connection point to a system value
  56143. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56144. * @returns the current connection point
  56145. */
  56146. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56147. /**
  56148. * Gets or sets the value of that point.
  56149. * Please note that this value will be ignored if valueCallback is defined
  56150. */
  56151. value: any;
  56152. /**
  56153. * Gets or sets a callback used to get the value of that point.
  56154. * Please note that setting this value will force the connection point to ignore the value property
  56155. */
  56156. valueCallback: () => any;
  56157. /**
  56158. * Gets or sets the associated variable name in the shader
  56159. */
  56160. associatedVariableName: string;
  56161. /** Gets or sets the type of animation applied to the input */
  56162. animationType: AnimatedInputBlockTypes;
  56163. /**
  56164. * Gets a boolean indicating that this connection point not defined yet
  56165. */
  56166. readonly isUndefined: boolean;
  56167. /**
  56168. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56169. * In this case the connection point name must be the name of the uniform to use.
  56170. * Can only be set on inputs
  56171. */
  56172. isUniform: boolean;
  56173. /**
  56174. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56175. * In this case the connection point name must be the name of the attribute to use
  56176. * Can only be set on inputs
  56177. */
  56178. isAttribute: boolean;
  56179. /**
  56180. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56181. * Can only be set on exit points
  56182. */
  56183. isVarying: boolean;
  56184. /**
  56185. * Gets a boolean indicating that the current connection point is a system value
  56186. */
  56187. readonly isSystemValue: boolean;
  56188. /**
  56189. * Gets or sets the current well known value or null if not defined as a system value
  56190. */
  56191. systemValue: Nullable<NodeMaterialSystemValues>;
  56192. /**
  56193. * Gets the current class name
  56194. * @returns the class name
  56195. */
  56196. getClassName(): string;
  56197. /**
  56198. * Animate the input if animationType !== None
  56199. * @param scene defines the rendering scene
  56200. */
  56201. animate(scene: Scene): void;
  56202. private _emitDefine;
  56203. initialize(state: NodeMaterialBuildState): void;
  56204. /**
  56205. * Set the input block to its default value (based on its type)
  56206. */
  56207. setDefaultValue(): void;
  56208. private _emitConstant;
  56209. private _emit;
  56210. /** @hidden */
  56211. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56212. /** @hidden */
  56213. _transmit(effect: Effect, scene: Scene): void;
  56214. protected _buildBlock(state: NodeMaterialBuildState): void;
  56215. protected _dumpPropertiesCode(): string;
  56216. serialize(): any;
  56217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56218. }
  56219. }
  56220. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56221. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56222. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56223. import { Nullable } from "babylonjs/types";
  56224. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56226. /**
  56227. * Defines a connection point for a block
  56228. */
  56229. export class NodeMaterialConnectionPoint {
  56230. /** @hidden */
  56231. _ownerBlock: NodeMaterialBlock;
  56232. /** @hidden */
  56233. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56234. private _endpoints;
  56235. private _associatedVariableName;
  56236. /** @hidden */
  56237. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56238. /** @hidden */
  56239. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56240. private _type;
  56241. /** @hidden */
  56242. _enforceAssociatedVariableName: boolean;
  56243. /**
  56244. * Gets or sets the additional types supported by this connection point
  56245. */
  56246. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56247. /**
  56248. * Gets or sets the additional types excluded by this connection point
  56249. */
  56250. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56251. /**
  56252. * Gets or sets the associated variable name in the shader
  56253. */
  56254. associatedVariableName: string;
  56255. /**
  56256. * Gets or sets the connection point type (default is float)
  56257. */
  56258. type: NodeMaterialBlockConnectionPointTypes;
  56259. /**
  56260. * Gets or sets the connection point name
  56261. */
  56262. name: string;
  56263. /**
  56264. * Gets or sets a boolean indicating that this connection point can be omitted
  56265. */
  56266. isOptional: boolean;
  56267. /**
  56268. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56269. */
  56270. define: string;
  56271. /** Gets or sets the target of that connection point */
  56272. target: NodeMaterialBlockTargets;
  56273. /**
  56274. * Gets a boolean indicating that the current point is connected
  56275. */
  56276. readonly isConnected: boolean;
  56277. /**
  56278. * Gets a boolean indicating that the current point is connected to an input block
  56279. */
  56280. readonly isConnectedToInputBlock: boolean;
  56281. /**
  56282. * Gets a the connected input block (if any)
  56283. */
  56284. readonly connectInputBlock: Nullable<InputBlock>;
  56285. /** Get the other side of the connection (if any) */
  56286. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56287. /** Get the block that owns this connection point */
  56288. readonly ownerBlock: NodeMaterialBlock;
  56289. /** Get the block connected on the other side of this connection (if any) */
  56290. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56291. /** Get the block connected on the endpoints of this connection (if any) */
  56292. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56293. /** Gets the list of connected endpoints */
  56294. readonly endpoints: NodeMaterialConnectionPoint[];
  56295. /** Gets a boolean indicating if that output point is connected to at least one input */
  56296. readonly hasEndpoints: boolean;
  56297. /**
  56298. * Creates a new connection point
  56299. * @param name defines the connection point name
  56300. * @param ownerBlock defines the block hosting this connection point
  56301. */
  56302. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56303. /**
  56304. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56305. * @returns the class name
  56306. */
  56307. getClassName(): string;
  56308. /**
  56309. * Gets an boolean indicating if the current point can be connected to another point
  56310. * @param connectionPoint defines the other connection point
  56311. * @returns true if the connection is possible
  56312. */
  56313. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56314. /**
  56315. * Connect this point to another connection point
  56316. * @param connectionPoint defines the other connection point
  56317. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56318. * @returns the current connection point
  56319. */
  56320. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56321. /**
  56322. * Disconnect this point from one of his endpoint
  56323. * @param endpoint defines the other connection point
  56324. * @returns the current connection point
  56325. */
  56326. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56327. /**
  56328. * Serializes this point in a JSON representation
  56329. * @returns the serialized point object
  56330. */
  56331. serialize(): any;
  56332. }
  56333. }
  56334. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56338. import { Mesh } from "babylonjs/Meshes/mesh";
  56339. import { Effect } from "babylonjs/Materials/effect";
  56340. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56341. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56342. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56343. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56344. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56345. /**
  56346. * Block used to add support for vertex skinning (bones)
  56347. */
  56348. export class BonesBlock extends NodeMaterialBlock {
  56349. /**
  56350. * Creates a new BonesBlock
  56351. * @param name defines the block name
  56352. */
  56353. constructor(name: string);
  56354. /**
  56355. * Initialize the block and prepare the context for build
  56356. * @param state defines the state that will be used for the build
  56357. */
  56358. initialize(state: NodeMaterialBuildState): void;
  56359. /**
  56360. * Gets the current class name
  56361. * @returns the class name
  56362. */
  56363. getClassName(): string;
  56364. /**
  56365. * Gets the matrix indices input component
  56366. */
  56367. readonly matricesIndices: NodeMaterialConnectionPoint;
  56368. /**
  56369. * Gets the matrix weights input component
  56370. */
  56371. readonly matricesWeights: NodeMaterialConnectionPoint;
  56372. /**
  56373. * Gets the extra matrix indices input component
  56374. */
  56375. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56376. /**
  56377. * Gets the extra matrix weights input component
  56378. */
  56379. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56380. /**
  56381. * Gets the world input component
  56382. */
  56383. readonly world: NodeMaterialConnectionPoint;
  56384. /**
  56385. * Gets the output component
  56386. */
  56387. readonly output: NodeMaterialConnectionPoint;
  56388. autoConfigure(material: NodeMaterial): void;
  56389. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56390. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56391. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56392. protected _buildBlock(state: NodeMaterialBuildState): this;
  56393. }
  56394. }
  56395. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56400. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56401. /**
  56402. * Block used to add support for instances
  56403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56404. */
  56405. export class InstancesBlock extends NodeMaterialBlock {
  56406. /**
  56407. * Creates a new InstancesBlock
  56408. * @param name defines the block name
  56409. */
  56410. constructor(name: string);
  56411. /**
  56412. * Gets the current class name
  56413. * @returns the class name
  56414. */
  56415. getClassName(): string;
  56416. /**
  56417. * Gets the first world row input component
  56418. */
  56419. readonly world0: NodeMaterialConnectionPoint;
  56420. /**
  56421. * Gets the second world row input component
  56422. */
  56423. readonly world1: NodeMaterialConnectionPoint;
  56424. /**
  56425. * Gets the third world row input component
  56426. */
  56427. readonly world2: NodeMaterialConnectionPoint;
  56428. /**
  56429. * Gets the forth world row input component
  56430. */
  56431. readonly world3: NodeMaterialConnectionPoint;
  56432. /**
  56433. * Gets the world input component
  56434. */
  56435. readonly world: NodeMaterialConnectionPoint;
  56436. /**
  56437. * Gets the output component
  56438. */
  56439. readonly output: NodeMaterialConnectionPoint;
  56440. autoConfigure(material: NodeMaterial): void;
  56441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56442. protected _buildBlock(state: NodeMaterialBuildState): this;
  56443. }
  56444. }
  56445. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56450. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56451. import { Effect } from "babylonjs/Materials/effect";
  56452. import { Mesh } from "babylonjs/Meshes/mesh";
  56453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56455. /**
  56456. * Block used to add morph targets support to vertex shader
  56457. */
  56458. export class MorphTargetsBlock extends NodeMaterialBlock {
  56459. private _repeatableContentAnchor;
  56460. private _repeatebleContentGenerated;
  56461. /**
  56462. * Create a new MorphTargetsBlock
  56463. * @param name defines the block name
  56464. */
  56465. constructor(name: string);
  56466. /**
  56467. * Gets the current class name
  56468. * @returns the class name
  56469. */
  56470. getClassName(): string;
  56471. /**
  56472. * Gets the position input component
  56473. */
  56474. readonly position: NodeMaterialConnectionPoint;
  56475. /**
  56476. * Gets the normal input component
  56477. */
  56478. readonly normal: NodeMaterialConnectionPoint;
  56479. /**
  56480. * Gets the tangent input component
  56481. */
  56482. readonly tangent: NodeMaterialConnectionPoint;
  56483. /**
  56484. * Gets the tangent input component
  56485. */
  56486. readonly uv: NodeMaterialConnectionPoint;
  56487. /**
  56488. * Gets the position output component
  56489. */
  56490. readonly positionOutput: NodeMaterialConnectionPoint;
  56491. /**
  56492. * Gets the normal output component
  56493. */
  56494. readonly normalOutput: NodeMaterialConnectionPoint;
  56495. /**
  56496. * Gets the tangent output component
  56497. */
  56498. readonly tangentOutput: NodeMaterialConnectionPoint;
  56499. /**
  56500. * Gets the tangent output component
  56501. */
  56502. readonly uvOutput: NodeMaterialConnectionPoint;
  56503. initialize(state: NodeMaterialBuildState): void;
  56504. autoConfigure(material: NodeMaterial): void;
  56505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56506. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56507. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56508. protected _buildBlock(state: NodeMaterialBuildState): this;
  56509. }
  56510. }
  56511. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56512. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56514. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56515. import { Nullable } from "babylonjs/types";
  56516. import { Scene } from "babylonjs/scene";
  56517. import { Effect } from "babylonjs/Materials/effect";
  56518. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56519. import { Mesh } from "babylonjs/Meshes/mesh";
  56520. import { Light } from "babylonjs/Lights/light";
  56521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56522. /**
  56523. * Block used to get data information from a light
  56524. */
  56525. export class LightInformationBlock extends NodeMaterialBlock {
  56526. private _lightDataUniformName;
  56527. private _lightColorUniformName;
  56528. private _lightTypeDefineName;
  56529. /**
  56530. * Gets or sets the light associated with this block
  56531. */
  56532. light: Nullable<Light>;
  56533. /**
  56534. * Creates a new LightInformationBlock
  56535. * @param name defines the block name
  56536. */
  56537. constructor(name: string);
  56538. /**
  56539. * Gets the current class name
  56540. * @returns the class name
  56541. */
  56542. getClassName(): string;
  56543. /**
  56544. * Gets the world position input component
  56545. */
  56546. readonly worldPosition: NodeMaterialConnectionPoint;
  56547. /**
  56548. * Gets the direction output component
  56549. */
  56550. readonly direction: NodeMaterialConnectionPoint;
  56551. /**
  56552. * Gets the direction output component
  56553. */
  56554. readonly color: NodeMaterialConnectionPoint;
  56555. /**
  56556. * Gets the direction output component
  56557. */
  56558. readonly intensity: NodeMaterialConnectionPoint;
  56559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56560. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56561. protected _buildBlock(state: NodeMaterialBuildState): this;
  56562. serialize(): any;
  56563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56564. }
  56565. }
  56566. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56567. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56568. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56569. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56570. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56571. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56572. }
  56573. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56578. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56579. import { Effect } from "babylonjs/Materials/effect";
  56580. import { Mesh } from "babylonjs/Meshes/mesh";
  56581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56582. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56583. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56584. /**
  56585. * Block used to add image processing support to fragment shader
  56586. */
  56587. export class ImageProcessingBlock extends NodeMaterialBlock {
  56588. /**
  56589. * Create a new ImageProcessingBlock
  56590. * @param name defines the block name
  56591. */
  56592. constructor(name: string);
  56593. /**
  56594. * Gets the current class name
  56595. * @returns the class name
  56596. */
  56597. getClassName(): string;
  56598. /**
  56599. * Gets the color input component
  56600. */
  56601. readonly color: NodeMaterialConnectionPoint;
  56602. /**
  56603. * Gets the output component
  56604. */
  56605. readonly output: NodeMaterialConnectionPoint;
  56606. /**
  56607. * Initialize the block and prepare the context for build
  56608. * @param state defines the state that will be used for the build
  56609. */
  56610. initialize(state: NodeMaterialBuildState): void;
  56611. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56612. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56613. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56614. protected _buildBlock(state: NodeMaterialBuildState): this;
  56615. }
  56616. }
  56617. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56618. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56619. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56621. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56623. import { Effect } from "babylonjs/Materials/effect";
  56624. import { Mesh } from "babylonjs/Meshes/mesh";
  56625. import { Scene } from "babylonjs/scene";
  56626. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56627. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56628. /**
  56629. * Block used to pertub normals based on a normal map
  56630. */
  56631. export class PerturbNormalBlock extends NodeMaterialBlock {
  56632. private _tangentSpaceParameterName;
  56633. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56634. invertX: boolean;
  56635. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56636. invertY: boolean;
  56637. /**
  56638. * Create a new PerturbNormalBlock
  56639. * @param name defines the block name
  56640. */
  56641. constructor(name: string);
  56642. /**
  56643. * Gets the current class name
  56644. * @returns the class name
  56645. */
  56646. getClassName(): string;
  56647. /**
  56648. * Gets the world position input component
  56649. */
  56650. readonly worldPosition: NodeMaterialConnectionPoint;
  56651. /**
  56652. * Gets the world normal input component
  56653. */
  56654. readonly worldNormal: NodeMaterialConnectionPoint;
  56655. /**
  56656. * Gets the uv input component
  56657. */
  56658. readonly uv: NodeMaterialConnectionPoint;
  56659. /**
  56660. * Gets the normal map color input component
  56661. */
  56662. readonly normalMapColor: NodeMaterialConnectionPoint;
  56663. /**
  56664. * Gets the strength input component
  56665. */
  56666. readonly strength: NodeMaterialConnectionPoint;
  56667. /**
  56668. * Gets the output component
  56669. */
  56670. readonly output: NodeMaterialConnectionPoint;
  56671. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56672. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56673. autoConfigure(material: NodeMaterial): void;
  56674. protected _buildBlock(state: NodeMaterialBuildState): this;
  56675. protected _dumpPropertiesCode(): string;
  56676. serialize(): any;
  56677. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56678. }
  56679. }
  56680. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56684. /**
  56685. * Block used to discard a pixel if a value is smaller than a cutoff
  56686. */
  56687. export class DiscardBlock extends NodeMaterialBlock {
  56688. /**
  56689. * Create a new DiscardBlock
  56690. * @param name defines the block name
  56691. */
  56692. constructor(name: string);
  56693. /**
  56694. * Gets the current class name
  56695. * @returns the class name
  56696. */
  56697. getClassName(): string;
  56698. /**
  56699. * Gets the color input component
  56700. */
  56701. readonly value: NodeMaterialConnectionPoint;
  56702. /**
  56703. * Gets the cutoff input component
  56704. */
  56705. readonly cutoff: NodeMaterialConnectionPoint;
  56706. protected _buildBlock(state: NodeMaterialBuildState): this;
  56707. }
  56708. }
  56709. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56710. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56711. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56712. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56713. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56714. }
  56715. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56718. import { Mesh } from "babylonjs/Meshes/mesh";
  56719. import { Effect } from "babylonjs/Materials/effect";
  56720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56721. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56722. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56723. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56724. /**
  56725. * Block used to add support for scene fog
  56726. */
  56727. export class FogBlock extends NodeMaterialBlock {
  56728. private _fogDistanceName;
  56729. private _fogParameters;
  56730. /**
  56731. * Create a new FogBlock
  56732. * @param name defines the block name
  56733. */
  56734. constructor(name: string);
  56735. /**
  56736. * Gets the current class name
  56737. * @returns the class name
  56738. */
  56739. getClassName(): string;
  56740. /**
  56741. * Gets the world position input component
  56742. */
  56743. readonly worldPosition: NodeMaterialConnectionPoint;
  56744. /**
  56745. * Gets the view input component
  56746. */
  56747. readonly view: NodeMaterialConnectionPoint;
  56748. /**
  56749. * Gets the color input component
  56750. */
  56751. readonly input: NodeMaterialConnectionPoint;
  56752. /**
  56753. * Gets the fog color input component
  56754. */
  56755. readonly fogColor: NodeMaterialConnectionPoint;
  56756. /**
  56757. * Gets the output component
  56758. */
  56759. readonly output: NodeMaterialConnectionPoint;
  56760. autoConfigure(material: NodeMaterial): void;
  56761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56763. protected _buildBlock(state: NodeMaterialBuildState): this;
  56764. }
  56765. }
  56766. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56771. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56772. import { Effect } from "babylonjs/Materials/effect";
  56773. import { Mesh } from "babylonjs/Meshes/mesh";
  56774. import { Light } from "babylonjs/Lights/light";
  56775. import { Nullable } from "babylonjs/types";
  56776. import { Scene } from "babylonjs/scene";
  56777. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56778. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56779. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56780. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56781. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56782. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56783. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56784. /**
  56785. * Block used to add light in the fragment shader
  56786. */
  56787. export class LightBlock extends NodeMaterialBlock {
  56788. private _lightId;
  56789. /**
  56790. * Gets or sets the light associated with this block
  56791. */
  56792. light: Nullable<Light>;
  56793. /**
  56794. * Create a new LightBlock
  56795. * @param name defines the block name
  56796. */
  56797. constructor(name: string);
  56798. /**
  56799. * Gets the current class name
  56800. * @returns the class name
  56801. */
  56802. getClassName(): string;
  56803. /**
  56804. * Gets the world position input component
  56805. */
  56806. readonly worldPosition: NodeMaterialConnectionPoint;
  56807. /**
  56808. * Gets the world normal input component
  56809. */
  56810. readonly worldNormal: NodeMaterialConnectionPoint;
  56811. /**
  56812. * Gets the camera (or eye) position component
  56813. */
  56814. readonly cameraPosition: NodeMaterialConnectionPoint;
  56815. /**
  56816. * Gets the glossiness component
  56817. */
  56818. readonly glossiness: NodeMaterialConnectionPoint;
  56819. /**
  56820. * Gets the glossinness power component
  56821. */
  56822. readonly glossPower: NodeMaterialConnectionPoint;
  56823. /**
  56824. * Gets the diffuse color component
  56825. */
  56826. readonly diffuseColor: NodeMaterialConnectionPoint;
  56827. /**
  56828. * Gets the specular color component
  56829. */
  56830. readonly specularColor: NodeMaterialConnectionPoint;
  56831. /**
  56832. * Gets the diffuse output component
  56833. */
  56834. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56835. /**
  56836. * Gets the specular output component
  56837. */
  56838. readonly specularOutput: NodeMaterialConnectionPoint;
  56839. autoConfigure(material: NodeMaterial): void;
  56840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56841. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56842. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56843. private _injectVertexCode;
  56844. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56845. serialize(): any;
  56846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56847. }
  56848. }
  56849. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56850. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56851. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56852. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56853. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56854. }
  56855. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56856. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56857. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56858. }
  56859. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56863. /**
  56864. * Block used to multiply 2 values
  56865. */
  56866. export class MultiplyBlock extends NodeMaterialBlock {
  56867. /**
  56868. * Creates a new MultiplyBlock
  56869. * @param name defines the block name
  56870. */
  56871. constructor(name: string);
  56872. /**
  56873. * Gets the current class name
  56874. * @returns the class name
  56875. */
  56876. getClassName(): string;
  56877. /**
  56878. * Gets the left operand input component
  56879. */
  56880. readonly left: NodeMaterialConnectionPoint;
  56881. /**
  56882. * Gets the right operand input component
  56883. */
  56884. readonly right: NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the output component
  56887. */
  56888. readonly output: NodeMaterialConnectionPoint;
  56889. protected _buildBlock(state: NodeMaterialBuildState): this;
  56890. }
  56891. }
  56892. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56896. /**
  56897. * Block used to add 2 vectors
  56898. */
  56899. export class AddBlock extends NodeMaterialBlock {
  56900. /**
  56901. * Creates a new AddBlock
  56902. * @param name defines the block name
  56903. */
  56904. constructor(name: string);
  56905. /**
  56906. * Gets the current class name
  56907. * @returns the class name
  56908. */
  56909. getClassName(): string;
  56910. /**
  56911. * Gets the left operand input component
  56912. */
  56913. readonly left: NodeMaterialConnectionPoint;
  56914. /**
  56915. * Gets the right operand input component
  56916. */
  56917. readonly right: NodeMaterialConnectionPoint;
  56918. /**
  56919. * Gets the output component
  56920. */
  56921. readonly output: NodeMaterialConnectionPoint;
  56922. protected _buildBlock(state: NodeMaterialBuildState): this;
  56923. }
  56924. }
  56925. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56929. /**
  56930. * Block used to scale a vector by a float
  56931. */
  56932. export class ScaleBlock extends NodeMaterialBlock {
  56933. /**
  56934. * Creates a new ScaleBlock
  56935. * @param name defines the block name
  56936. */
  56937. constructor(name: string);
  56938. /**
  56939. * Gets the current class name
  56940. * @returns the class name
  56941. */
  56942. getClassName(): string;
  56943. /**
  56944. * Gets the input component
  56945. */
  56946. readonly input: NodeMaterialConnectionPoint;
  56947. /**
  56948. * Gets the factor input component
  56949. */
  56950. readonly factor: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the output component
  56953. */
  56954. readonly output: NodeMaterialConnectionPoint;
  56955. protected _buildBlock(state: NodeMaterialBuildState): this;
  56956. }
  56957. }
  56958. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56962. import { Scene } from "babylonjs/scene";
  56963. /**
  56964. * Block used to clamp a float
  56965. */
  56966. export class ClampBlock extends NodeMaterialBlock {
  56967. /** Gets or sets the minimum range */
  56968. minimum: number;
  56969. /** Gets or sets the maximum range */
  56970. maximum: number;
  56971. /**
  56972. * Creates a new ClampBlock
  56973. * @param name defines the block name
  56974. */
  56975. constructor(name: string);
  56976. /**
  56977. * Gets the current class name
  56978. * @returns the class name
  56979. */
  56980. getClassName(): string;
  56981. /**
  56982. * Gets the value input component
  56983. */
  56984. readonly value: NodeMaterialConnectionPoint;
  56985. /**
  56986. * Gets the output component
  56987. */
  56988. readonly output: NodeMaterialConnectionPoint;
  56989. protected _buildBlock(state: NodeMaterialBuildState): this;
  56990. protected _dumpPropertiesCode(): string;
  56991. serialize(): any;
  56992. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56993. }
  56994. }
  56995. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56999. /**
  57000. * Block used to apply a cross product between 2 vectors
  57001. */
  57002. export class CrossBlock extends NodeMaterialBlock {
  57003. /**
  57004. * Creates a new CrossBlock
  57005. * @param name defines the block name
  57006. */
  57007. constructor(name: string);
  57008. /**
  57009. * Gets the current class name
  57010. * @returns the class name
  57011. */
  57012. getClassName(): string;
  57013. /**
  57014. * Gets the left operand input component
  57015. */
  57016. readonly left: NodeMaterialConnectionPoint;
  57017. /**
  57018. * Gets the right operand input component
  57019. */
  57020. readonly right: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the output component
  57023. */
  57024. readonly output: NodeMaterialConnectionPoint;
  57025. protected _buildBlock(state: NodeMaterialBuildState): this;
  57026. }
  57027. }
  57028. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57029. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57030. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57031. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57032. /**
  57033. * Block used to apply a dot product between 2 vectors
  57034. */
  57035. export class DotBlock extends NodeMaterialBlock {
  57036. /**
  57037. * Creates a new DotBlock
  57038. * @param name defines the block name
  57039. */
  57040. constructor(name: string);
  57041. /**
  57042. * Gets the current class name
  57043. * @returns the class name
  57044. */
  57045. getClassName(): string;
  57046. /**
  57047. * Gets the left operand input component
  57048. */
  57049. readonly left: NodeMaterialConnectionPoint;
  57050. /**
  57051. * Gets the right operand input component
  57052. */
  57053. readonly right: NodeMaterialConnectionPoint;
  57054. /**
  57055. * Gets the output component
  57056. */
  57057. readonly output: NodeMaterialConnectionPoint;
  57058. protected _buildBlock(state: NodeMaterialBuildState): this;
  57059. }
  57060. }
  57061. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57062. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57063. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57064. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57065. import { Vector2 } from "babylonjs/Maths/math.vector";
  57066. import { Scene } from "babylonjs/scene";
  57067. /**
  57068. * Block used to remap a float from a range to a new one
  57069. */
  57070. export class RemapBlock extends NodeMaterialBlock {
  57071. /**
  57072. * Gets or sets the source range
  57073. */
  57074. sourceRange: Vector2;
  57075. /**
  57076. * Gets or sets the target range
  57077. */
  57078. targetRange: Vector2;
  57079. /**
  57080. * Creates a new RemapBlock
  57081. * @param name defines the block name
  57082. */
  57083. constructor(name: string);
  57084. /**
  57085. * Gets the current class name
  57086. * @returns the class name
  57087. */
  57088. getClassName(): string;
  57089. /**
  57090. * Gets the input component
  57091. */
  57092. readonly input: NodeMaterialConnectionPoint;
  57093. /**
  57094. * Gets the source min input component
  57095. */
  57096. readonly sourceMin: NodeMaterialConnectionPoint;
  57097. /**
  57098. * Gets the source max input component
  57099. */
  57100. readonly sourceMax: NodeMaterialConnectionPoint;
  57101. /**
  57102. * Gets the target min input component
  57103. */
  57104. readonly targetMin: NodeMaterialConnectionPoint;
  57105. /**
  57106. * Gets the target max input component
  57107. */
  57108. readonly targetMax: NodeMaterialConnectionPoint;
  57109. /**
  57110. * Gets the output component
  57111. */
  57112. readonly output: NodeMaterialConnectionPoint;
  57113. protected _buildBlock(state: NodeMaterialBuildState): this;
  57114. protected _dumpPropertiesCode(): string;
  57115. serialize(): any;
  57116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57117. }
  57118. }
  57119. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57120. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57121. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57122. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57123. /**
  57124. * Block used to normalize a vector
  57125. */
  57126. export class NormalizeBlock extends NodeMaterialBlock {
  57127. /**
  57128. * Creates a new NormalizeBlock
  57129. * @param name defines the block name
  57130. */
  57131. constructor(name: string);
  57132. /**
  57133. * Gets the current class name
  57134. * @returns the class name
  57135. */
  57136. getClassName(): string;
  57137. /**
  57138. * Gets the input component
  57139. */
  57140. readonly input: NodeMaterialConnectionPoint;
  57141. /**
  57142. * Gets the output component
  57143. */
  57144. readonly output: NodeMaterialConnectionPoint;
  57145. protected _buildBlock(state: NodeMaterialBuildState): this;
  57146. }
  57147. }
  57148. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57149. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57150. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57151. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57152. import { Scene } from "babylonjs/scene";
  57153. /**
  57154. * Operations supported by the Trigonometry block
  57155. */
  57156. export enum TrigonometryBlockOperations {
  57157. /** Cos */
  57158. Cos = 0,
  57159. /** Sin */
  57160. Sin = 1,
  57161. /** Abs */
  57162. Abs = 2,
  57163. /** Exp */
  57164. Exp = 3,
  57165. /** Exp2 */
  57166. Exp2 = 4,
  57167. /** Round */
  57168. Round = 5,
  57169. /** Floor */
  57170. Floor = 6,
  57171. /** Ceiling */
  57172. Ceiling = 7,
  57173. /** Square root */
  57174. Sqrt = 8,
  57175. /** Log */
  57176. Log = 9,
  57177. /** Tangent */
  57178. Tan = 10,
  57179. /** Arc tangent */
  57180. ArcTan = 11,
  57181. /** Arc cosinus */
  57182. ArcCos = 12,
  57183. /** Arc sinus */
  57184. ArcSin = 13,
  57185. /** Fraction */
  57186. Fract = 14,
  57187. /** Sign */
  57188. Sign = 15,
  57189. /** To radians (from degrees) */
  57190. Radians = 16,
  57191. /** To degrees (from radians) */
  57192. Degrees = 17
  57193. }
  57194. /**
  57195. * Block used to apply trigonometry operation to floats
  57196. */
  57197. export class TrigonometryBlock extends NodeMaterialBlock {
  57198. /**
  57199. * Gets or sets the operation applied by the block
  57200. */
  57201. operation: TrigonometryBlockOperations;
  57202. /**
  57203. * Creates a new TrigonometryBlock
  57204. * @param name defines the block name
  57205. */
  57206. constructor(name: string);
  57207. /**
  57208. * Gets the current class name
  57209. * @returns the class name
  57210. */
  57211. getClassName(): string;
  57212. /**
  57213. * Gets the input component
  57214. */
  57215. readonly input: NodeMaterialConnectionPoint;
  57216. /**
  57217. * Gets the output component
  57218. */
  57219. readonly output: NodeMaterialConnectionPoint;
  57220. protected _buildBlock(state: NodeMaterialBuildState): this;
  57221. serialize(): any;
  57222. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57223. }
  57224. }
  57225. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57226. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57227. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57228. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57229. /**
  57230. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57231. */
  57232. export class ColorMergerBlock extends NodeMaterialBlock {
  57233. /**
  57234. * Create a new ColorMergerBlock
  57235. * @param name defines the block name
  57236. */
  57237. constructor(name: string);
  57238. /**
  57239. * Gets the current class name
  57240. * @returns the class name
  57241. */
  57242. getClassName(): string;
  57243. /**
  57244. * Gets the r component (input)
  57245. */
  57246. readonly r: NodeMaterialConnectionPoint;
  57247. /**
  57248. * Gets the g component (input)
  57249. */
  57250. readonly g: NodeMaterialConnectionPoint;
  57251. /**
  57252. * Gets the b component (input)
  57253. */
  57254. readonly b: NodeMaterialConnectionPoint;
  57255. /**
  57256. * Gets the a component (input)
  57257. */
  57258. readonly a: NodeMaterialConnectionPoint;
  57259. /**
  57260. * Gets the rgba component (output)
  57261. */
  57262. readonly rgba: NodeMaterialConnectionPoint;
  57263. /**
  57264. * Gets the rgb component (output)
  57265. */
  57266. readonly rgb: NodeMaterialConnectionPoint;
  57267. protected _buildBlock(state: NodeMaterialBuildState): this;
  57268. }
  57269. }
  57270. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57271. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57272. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57273. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57274. /**
  57275. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57276. */
  57277. export class VectorMergerBlock extends NodeMaterialBlock {
  57278. /**
  57279. * Create a new VectorMergerBlock
  57280. * @param name defines the block name
  57281. */
  57282. constructor(name: string);
  57283. /**
  57284. * Gets the current class name
  57285. * @returns the class name
  57286. */
  57287. getClassName(): string;
  57288. /**
  57289. * Gets the x component (input)
  57290. */
  57291. readonly x: NodeMaterialConnectionPoint;
  57292. /**
  57293. * Gets the y component (input)
  57294. */
  57295. readonly y: NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the z component (input)
  57298. */
  57299. readonly z: NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the w component (input)
  57302. */
  57303. readonly w: NodeMaterialConnectionPoint;
  57304. /**
  57305. * Gets the xyzw component (output)
  57306. */
  57307. readonly xyzw: NodeMaterialConnectionPoint;
  57308. /**
  57309. * Gets the xyz component (output)
  57310. */
  57311. readonly xyz: NodeMaterialConnectionPoint;
  57312. /**
  57313. * Gets the xy component (output)
  57314. */
  57315. readonly xy: NodeMaterialConnectionPoint;
  57316. protected _buildBlock(state: NodeMaterialBuildState): this;
  57317. }
  57318. }
  57319. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57323. /**
  57324. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57325. */
  57326. export class ColorSplitterBlock extends NodeMaterialBlock {
  57327. /**
  57328. * Create a new ColorSplitterBlock
  57329. * @param name defines the block name
  57330. */
  57331. constructor(name: string);
  57332. /**
  57333. * Gets the current class name
  57334. * @returns the class name
  57335. */
  57336. getClassName(): string;
  57337. /**
  57338. * Gets the rgba component (input)
  57339. */
  57340. readonly rgba: NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the rgb component (input)
  57343. */
  57344. readonly rgbIn: NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the rgb component (output)
  57347. */
  57348. readonly rgbOut: NodeMaterialConnectionPoint;
  57349. /**
  57350. * Gets the r component (output)
  57351. */
  57352. readonly r: NodeMaterialConnectionPoint;
  57353. /**
  57354. * Gets the g component (output)
  57355. */
  57356. readonly g: NodeMaterialConnectionPoint;
  57357. /**
  57358. * Gets the b component (output)
  57359. */
  57360. readonly b: NodeMaterialConnectionPoint;
  57361. /**
  57362. * Gets the a component (output)
  57363. */
  57364. readonly a: NodeMaterialConnectionPoint;
  57365. protected _inputRename(name: string): string;
  57366. protected _outputRename(name: string): string;
  57367. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57368. }
  57369. }
  57370. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57374. /**
  57375. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57376. */
  57377. export class VectorSplitterBlock extends NodeMaterialBlock {
  57378. /**
  57379. * Create a new VectorSplitterBlock
  57380. * @param name defines the block name
  57381. */
  57382. constructor(name: string);
  57383. /**
  57384. * Gets the current class name
  57385. * @returns the class name
  57386. */
  57387. getClassName(): string;
  57388. /**
  57389. * Gets the xyzw component (input)
  57390. */
  57391. readonly xyzw: NodeMaterialConnectionPoint;
  57392. /**
  57393. * Gets the xyz component (input)
  57394. */
  57395. readonly xyzIn: NodeMaterialConnectionPoint;
  57396. /**
  57397. * Gets the xy component (input)
  57398. */
  57399. readonly xyIn: NodeMaterialConnectionPoint;
  57400. /**
  57401. * Gets the xyz component (output)
  57402. */
  57403. readonly xyzOut: NodeMaterialConnectionPoint;
  57404. /**
  57405. * Gets the xy component (output)
  57406. */
  57407. readonly xyOut: NodeMaterialConnectionPoint;
  57408. /**
  57409. * Gets the x component (output)
  57410. */
  57411. readonly x: NodeMaterialConnectionPoint;
  57412. /**
  57413. * Gets the y component (output)
  57414. */
  57415. readonly y: NodeMaterialConnectionPoint;
  57416. /**
  57417. * Gets the z component (output)
  57418. */
  57419. readonly z: NodeMaterialConnectionPoint;
  57420. /**
  57421. * Gets the w component (output)
  57422. */
  57423. readonly w: NodeMaterialConnectionPoint;
  57424. protected _inputRename(name: string): string;
  57425. protected _outputRename(name: string): string;
  57426. protected _buildBlock(state: NodeMaterialBuildState): this;
  57427. }
  57428. }
  57429. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57433. /**
  57434. * Block used to lerp 2 values
  57435. */
  57436. export class LerpBlock extends NodeMaterialBlock {
  57437. /**
  57438. * Creates a new LerpBlock
  57439. * @param name defines the block name
  57440. */
  57441. constructor(name: string);
  57442. /**
  57443. * Gets the current class name
  57444. * @returns the class name
  57445. */
  57446. getClassName(): string;
  57447. /**
  57448. * Gets the left operand input component
  57449. */
  57450. readonly left: NodeMaterialConnectionPoint;
  57451. /**
  57452. * Gets the right operand input component
  57453. */
  57454. readonly right: NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the gradient operand input component
  57457. */
  57458. readonly gradient: NodeMaterialConnectionPoint;
  57459. /**
  57460. * Gets the output component
  57461. */
  57462. readonly output: NodeMaterialConnectionPoint;
  57463. protected _buildBlock(state: NodeMaterialBuildState): this;
  57464. }
  57465. }
  57466. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57470. /**
  57471. * Block used to divide 2 vectors
  57472. */
  57473. export class DivideBlock extends NodeMaterialBlock {
  57474. /**
  57475. * Creates a new DivideBlock
  57476. * @param name defines the block name
  57477. */
  57478. constructor(name: string);
  57479. /**
  57480. * Gets the current class name
  57481. * @returns the class name
  57482. */
  57483. getClassName(): string;
  57484. /**
  57485. * Gets the left operand input component
  57486. */
  57487. readonly left: NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the right operand input component
  57490. */
  57491. readonly right: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the output component
  57494. */
  57495. readonly output: NodeMaterialConnectionPoint;
  57496. protected _buildBlock(state: NodeMaterialBuildState): this;
  57497. }
  57498. }
  57499. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57502. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57503. /**
  57504. * Block used to subtract 2 vectors
  57505. */
  57506. export class SubtractBlock extends NodeMaterialBlock {
  57507. /**
  57508. * Creates a new SubtractBlock
  57509. * @param name defines the block name
  57510. */
  57511. constructor(name: string);
  57512. /**
  57513. * Gets the current class name
  57514. * @returns the class name
  57515. */
  57516. getClassName(): string;
  57517. /**
  57518. * Gets the left operand input component
  57519. */
  57520. readonly left: NodeMaterialConnectionPoint;
  57521. /**
  57522. * Gets the right operand input component
  57523. */
  57524. readonly right: NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the output component
  57527. */
  57528. readonly output: NodeMaterialConnectionPoint;
  57529. protected _buildBlock(state: NodeMaterialBuildState): this;
  57530. }
  57531. }
  57532. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57536. /**
  57537. * Block used to step a value
  57538. */
  57539. export class StepBlock extends NodeMaterialBlock {
  57540. /**
  57541. * Creates a new StepBlock
  57542. * @param name defines the block name
  57543. */
  57544. constructor(name: string);
  57545. /**
  57546. * Gets the current class name
  57547. * @returns the class name
  57548. */
  57549. getClassName(): string;
  57550. /**
  57551. * Gets the value operand input component
  57552. */
  57553. readonly value: NodeMaterialConnectionPoint;
  57554. /**
  57555. * Gets the edge operand input component
  57556. */
  57557. readonly edge: NodeMaterialConnectionPoint;
  57558. /**
  57559. * Gets the output component
  57560. */
  57561. readonly output: NodeMaterialConnectionPoint;
  57562. protected _buildBlock(state: NodeMaterialBuildState): this;
  57563. }
  57564. }
  57565. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57569. /**
  57570. * Block used to get the opposite (1 - x) of a value
  57571. */
  57572. export class OneMinusBlock extends NodeMaterialBlock {
  57573. /**
  57574. * Creates a new OneMinusBlock
  57575. * @param name defines the block name
  57576. */
  57577. constructor(name: string);
  57578. /**
  57579. * Gets the current class name
  57580. * @returns the class name
  57581. */
  57582. getClassName(): string;
  57583. /**
  57584. * Gets the input component
  57585. */
  57586. readonly input: NodeMaterialConnectionPoint;
  57587. /**
  57588. * Gets the output component
  57589. */
  57590. readonly output: NodeMaterialConnectionPoint;
  57591. protected _buildBlock(state: NodeMaterialBuildState): this;
  57592. }
  57593. }
  57594. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57598. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57599. /**
  57600. * Block used to get the view direction
  57601. */
  57602. export class ViewDirectionBlock extends NodeMaterialBlock {
  57603. /**
  57604. * Creates a new ViewDirectionBlock
  57605. * @param name defines the block name
  57606. */
  57607. constructor(name: string);
  57608. /**
  57609. * Gets the current class name
  57610. * @returns the class name
  57611. */
  57612. getClassName(): string;
  57613. /**
  57614. * Gets the world position component
  57615. */
  57616. readonly worldPosition: NodeMaterialConnectionPoint;
  57617. /**
  57618. * Gets the camera position component
  57619. */
  57620. readonly cameraPosition: NodeMaterialConnectionPoint;
  57621. /**
  57622. * Gets the output component
  57623. */
  57624. readonly output: NodeMaterialConnectionPoint;
  57625. autoConfigure(material: NodeMaterial): void;
  57626. protected _buildBlock(state: NodeMaterialBuildState): this;
  57627. }
  57628. }
  57629. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57630. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57631. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57632. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57633. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57634. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57635. /**
  57636. * Block used to compute fresnel value
  57637. */
  57638. export class FresnelBlock extends NodeMaterialBlock {
  57639. /**
  57640. * Create a new FresnelBlock
  57641. * @param name defines the block name
  57642. */
  57643. constructor(name: string);
  57644. /**
  57645. * Gets the current class name
  57646. * @returns the class name
  57647. */
  57648. getClassName(): string;
  57649. /**
  57650. * Gets the world normal input component
  57651. */
  57652. readonly worldNormal: NodeMaterialConnectionPoint;
  57653. /**
  57654. * Gets the view direction input component
  57655. */
  57656. readonly viewDirection: NodeMaterialConnectionPoint;
  57657. /**
  57658. * Gets the bias input component
  57659. */
  57660. readonly bias: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the camera (or eye) position component
  57663. */
  57664. readonly power: NodeMaterialConnectionPoint;
  57665. /**
  57666. * Gets the fresnel output component
  57667. */
  57668. readonly fresnel: NodeMaterialConnectionPoint;
  57669. autoConfigure(material: NodeMaterial): void;
  57670. protected _buildBlock(state: NodeMaterialBuildState): this;
  57671. }
  57672. }
  57673. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57674. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57675. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57676. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57677. /**
  57678. * Block used to get the max of 2 values
  57679. */
  57680. export class MaxBlock extends NodeMaterialBlock {
  57681. /**
  57682. * Creates a new MaxBlock
  57683. * @param name defines the block name
  57684. */
  57685. constructor(name: string);
  57686. /**
  57687. * Gets the current class name
  57688. * @returns the class name
  57689. */
  57690. getClassName(): string;
  57691. /**
  57692. * Gets the left operand input component
  57693. */
  57694. readonly left: NodeMaterialConnectionPoint;
  57695. /**
  57696. * Gets the right operand input component
  57697. */
  57698. readonly right: NodeMaterialConnectionPoint;
  57699. /**
  57700. * Gets the output component
  57701. */
  57702. readonly output: NodeMaterialConnectionPoint;
  57703. protected _buildBlock(state: NodeMaterialBuildState): this;
  57704. }
  57705. }
  57706. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57707. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57709. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57710. /**
  57711. * Block used to get the min of 2 values
  57712. */
  57713. export class MinBlock extends NodeMaterialBlock {
  57714. /**
  57715. * Creates a new MinBlock
  57716. * @param name defines the block name
  57717. */
  57718. constructor(name: string);
  57719. /**
  57720. * Gets the current class name
  57721. * @returns the class name
  57722. */
  57723. getClassName(): string;
  57724. /**
  57725. * Gets the left operand input component
  57726. */
  57727. readonly left: NodeMaterialConnectionPoint;
  57728. /**
  57729. * Gets the right operand input component
  57730. */
  57731. readonly right: NodeMaterialConnectionPoint;
  57732. /**
  57733. * Gets the output component
  57734. */
  57735. readonly output: NodeMaterialConnectionPoint;
  57736. protected _buildBlock(state: NodeMaterialBuildState): this;
  57737. }
  57738. }
  57739. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57742. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57743. /**
  57744. * Block used to get the distance between 2 values
  57745. */
  57746. export class DistanceBlock extends NodeMaterialBlock {
  57747. /**
  57748. * Creates a new DistanceBlock
  57749. * @param name defines the block name
  57750. */
  57751. constructor(name: string);
  57752. /**
  57753. * Gets the current class name
  57754. * @returns the class name
  57755. */
  57756. getClassName(): string;
  57757. /**
  57758. * Gets the left operand input component
  57759. */
  57760. readonly left: NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the right operand input component
  57763. */
  57764. readonly right: NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the output component
  57767. */
  57768. readonly output: NodeMaterialConnectionPoint;
  57769. protected _buildBlock(state: NodeMaterialBuildState): this;
  57770. }
  57771. }
  57772. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57773. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57774. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57775. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57776. /**
  57777. * Block used to get the length of a vector
  57778. */
  57779. export class LengthBlock extends NodeMaterialBlock {
  57780. /**
  57781. * Creates a new LengthBlock
  57782. * @param name defines the block name
  57783. */
  57784. constructor(name: string);
  57785. /**
  57786. * Gets the current class name
  57787. * @returns the class name
  57788. */
  57789. getClassName(): string;
  57790. /**
  57791. * Gets the value input component
  57792. */
  57793. readonly value: NodeMaterialConnectionPoint;
  57794. /**
  57795. * Gets the output component
  57796. */
  57797. readonly output: NodeMaterialConnectionPoint;
  57798. protected _buildBlock(state: NodeMaterialBuildState): this;
  57799. }
  57800. }
  57801. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57802. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57805. /**
  57806. * Block used to get negative version of a value (i.e. x * -1)
  57807. */
  57808. export class NegateBlock extends NodeMaterialBlock {
  57809. /**
  57810. * Creates a new NegateBlock
  57811. * @param name defines the block name
  57812. */
  57813. constructor(name: string);
  57814. /**
  57815. * Gets the current class name
  57816. * @returns the class name
  57817. */
  57818. getClassName(): string;
  57819. /**
  57820. * Gets the value input component
  57821. */
  57822. readonly value: NodeMaterialConnectionPoint;
  57823. /**
  57824. * Gets the output component
  57825. */
  57826. readonly output: NodeMaterialConnectionPoint;
  57827. protected _buildBlock(state: NodeMaterialBuildState): this;
  57828. }
  57829. }
  57830. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57831. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57832. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57834. /**
  57835. * Block used to get the value of the first parameter raised to the power of the second
  57836. */
  57837. export class PowBlock extends NodeMaterialBlock {
  57838. /**
  57839. * Creates a new PowBlock
  57840. * @param name defines the block name
  57841. */
  57842. constructor(name: string);
  57843. /**
  57844. * Gets the current class name
  57845. * @returns the class name
  57846. */
  57847. getClassName(): string;
  57848. /**
  57849. * Gets the value operand input component
  57850. */
  57851. readonly value: NodeMaterialConnectionPoint;
  57852. /**
  57853. * Gets the power operand input component
  57854. */
  57855. readonly power: NodeMaterialConnectionPoint;
  57856. /**
  57857. * Gets the output component
  57858. */
  57859. readonly output: NodeMaterialConnectionPoint;
  57860. protected _buildBlock(state: NodeMaterialBuildState): this;
  57861. }
  57862. }
  57863. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57864. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57865. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57867. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57868. /**
  57869. * Block used to get a random number
  57870. */
  57871. export class RandomNumberBlock extends NodeMaterialBlock {
  57872. /**
  57873. * Creates a new RandomNumberBlock
  57874. * @param name defines the block name
  57875. */
  57876. constructor(name: string);
  57877. /**
  57878. * Gets the current class name
  57879. * @returns the class name
  57880. */
  57881. getClassName(): string;
  57882. /**
  57883. * Gets the seed input component
  57884. */
  57885. readonly seed: NodeMaterialConnectionPoint;
  57886. /**
  57887. * Gets the output component
  57888. */
  57889. readonly output: NodeMaterialConnectionPoint;
  57890. protected _buildBlock(state: NodeMaterialBuildState): this;
  57891. }
  57892. }
  57893. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57897. /**
  57898. * Block used to compute arc tangent of 2 values
  57899. */
  57900. export class ArcTan2Block extends NodeMaterialBlock {
  57901. /**
  57902. * Creates a new ArcTan2Block
  57903. * @param name defines the block name
  57904. */
  57905. constructor(name: string);
  57906. /**
  57907. * Gets the current class name
  57908. * @returns the class name
  57909. */
  57910. getClassName(): string;
  57911. /**
  57912. * Gets the x operand input component
  57913. */
  57914. readonly x: NodeMaterialConnectionPoint;
  57915. /**
  57916. * Gets the y operand input component
  57917. */
  57918. readonly y: NodeMaterialConnectionPoint;
  57919. /**
  57920. * Gets the output component
  57921. */
  57922. readonly output: NodeMaterialConnectionPoint;
  57923. protected _buildBlock(state: NodeMaterialBuildState): this;
  57924. }
  57925. }
  57926. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57930. /**
  57931. * Block used to smooth step a value
  57932. */
  57933. export class SmoothStepBlock extends NodeMaterialBlock {
  57934. /**
  57935. * Creates a new SmoothStepBlock
  57936. * @param name defines the block name
  57937. */
  57938. constructor(name: string);
  57939. /**
  57940. * Gets the current class name
  57941. * @returns the class name
  57942. */
  57943. getClassName(): string;
  57944. /**
  57945. * Gets the value operand input component
  57946. */
  57947. readonly value: NodeMaterialConnectionPoint;
  57948. /**
  57949. * Gets the first edge operand input component
  57950. */
  57951. readonly edge0: NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the second edge operand input component
  57954. */
  57955. readonly edge1: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the output component
  57958. */
  57959. readonly output: NodeMaterialConnectionPoint;
  57960. protected _buildBlock(state: NodeMaterialBuildState): this;
  57961. }
  57962. }
  57963. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  57964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57967. /**
  57968. * Block used to get the reciprocal (1 / x) of a value
  57969. */
  57970. export class ReciprocalBlock extends NodeMaterialBlock {
  57971. /**
  57972. * Creates a new ReciprocalBlock
  57973. * @param name defines the block name
  57974. */
  57975. constructor(name: string);
  57976. /**
  57977. * Gets the current class name
  57978. * @returns the class name
  57979. */
  57980. getClassName(): string;
  57981. /**
  57982. * Gets the input component
  57983. */
  57984. readonly input: NodeMaterialConnectionPoint;
  57985. /**
  57986. * Gets the output component
  57987. */
  57988. readonly output: NodeMaterialConnectionPoint;
  57989. protected _buildBlock(state: NodeMaterialBuildState): this;
  57990. }
  57991. }
  57992. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  57993. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57994. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57995. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57996. /**
  57997. * Block used to replace a color by another one
  57998. */
  57999. export class ReplaceColorBlock extends NodeMaterialBlock {
  58000. /**
  58001. * Creates a new ReplaceColorBlock
  58002. * @param name defines the block name
  58003. */
  58004. constructor(name: string);
  58005. /**
  58006. * Gets the current class name
  58007. * @returns the class name
  58008. */
  58009. getClassName(): string;
  58010. /**
  58011. * Gets the value input component
  58012. */
  58013. readonly value: NodeMaterialConnectionPoint;
  58014. /**
  58015. * Gets the reference input component
  58016. */
  58017. readonly reference: NodeMaterialConnectionPoint;
  58018. /**
  58019. * Gets the distance input component
  58020. */
  58021. readonly distance: NodeMaterialConnectionPoint;
  58022. /**
  58023. * Gets the replacement input component
  58024. */
  58025. readonly replacement: NodeMaterialConnectionPoint;
  58026. /**
  58027. * Gets the output component
  58028. */
  58029. readonly output: NodeMaterialConnectionPoint;
  58030. protected _buildBlock(state: NodeMaterialBuildState): this;
  58031. }
  58032. }
  58033. declare module "babylonjs/Materials/Node/Blocks/index" {
  58034. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58035. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58036. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58037. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58038. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58039. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58040. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58041. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58042. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58043. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58044. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58045. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58046. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58047. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58048. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58049. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58050. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58051. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58052. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58053. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58054. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58055. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58056. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58057. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58058. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58059. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58060. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58061. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58062. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58063. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58064. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58065. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58066. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58067. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58068. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58069. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58070. }
  58071. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58072. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58073. }
  58074. declare module "babylonjs/Materials/Node/index" {
  58075. export * from "babylonjs/Materials/Node/Enums/index";
  58076. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58077. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58078. export * from "babylonjs/Materials/Node/nodeMaterial";
  58079. export * from "babylonjs/Materials/Node/Blocks/index";
  58080. export * from "babylonjs/Materials/Node/Optimizers/index";
  58081. }
  58082. declare module "babylonjs/Materials/effectRenderer" {
  58083. import { Nullable } from "babylonjs/types";
  58084. import { Texture } from "babylonjs/Materials/Textures/texture";
  58085. import { Engine } from "babylonjs/Engines/engine";
  58086. import { Viewport } from "babylonjs/Maths/math.viewport";
  58087. import { Observable } from "babylonjs/Misc/observable";
  58088. import { Effect } from "babylonjs/Materials/effect";
  58089. import "babylonjs/Shaders/postprocess.vertex";
  58090. /**
  58091. * Effect Render Options
  58092. */
  58093. export interface IEffectRendererOptions {
  58094. /**
  58095. * Defines the vertices positions.
  58096. */
  58097. positions?: number[];
  58098. /**
  58099. * Defines the indices.
  58100. */
  58101. indices?: number[];
  58102. }
  58103. /**
  58104. * Helper class to render one or more effects
  58105. */
  58106. export class EffectRenderer {
  58107. private engine;
  58108. private static _DefaultOptions;
  58109. private _vertexBuffers;
  58110. private _indexBuffer;
  58111. private _ringBufferIndex;
  58112. private _ringScreenBuffer;
  58113. private _fullscreenViewport;
  58114. private _getNextFrameBuffer;
  58115. /**
  58116. * Creates an effect renderer
  58117. * @param engine the engine to use for rendering
  58118. * @param options defines the options of the effect renderer
  58119. */
  58120. constructor(engine: Engine, options?: IEffectRendererOptions);
  58121. /**
  58122. * Sets the current viewport in normalized coordinates 0-1
  58123. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58124. */
  58125. setViewport(viewport?: Viewport): void;
  58126. /**
  58127. * Binds the embedded attributes buffer to the effect.
  58128. * @param effect Defines the effect to bind the attributes for
  58129. */
  58130. bindBuffers(effect: Effect): void;
  58131. /**
  58132. * Sets the current effect wrapper to use during draw.
  58133. * The effect needs to be ready before calling this api.
  58134. * This also sets the default full screen position attribute.
  58135. * @param effectWrapper Defines the effect to draw with
  58136. */
  58137. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58138. /**
  58139. * Draws a full screen quad.
  58140. */
  58141. draw(): void;
  58142. /**
  58143. * renders one or more effects to a specified texture
  58144. * @param effectWrappers list of effects to renderer
  58145. * @param outputTexture texture to draw to, if null it will render to the screen
  58146. */
  58147. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58148. /**
  58149. * Disposes of the effect renderer
  58150. */
  58151. dispose(): void;
  58152. }
  58153. /**
  58154. * Options to create an EffectWrapper
  58155. */
  58156. interface EffectWrapperCreationOptions {
  58157. /**
  58158. * Engine to use to create the effect
  58159. */
  58160. engine: Engine;
  58161. /**
  58162. * Fragment shader for the effect
  58163. */
  58164. fragmentShader: string;
  58165. /**
  58166. * Vertex shader for the effect
  58167. */
  58168. vertexShader?: string;
  58169. /**
  58170. * Attributes to use in the shader
  58171. */
  58172. attributeNames?: Array<string>;
  58173. /**
  58174. * Uniforms to use in the shader
  58175. */
  58176. uniformNames?: Array<string>;
  58177. /**
  58178. * Texture sampler names to use in the shader
  58179. */
  58180. samplerNames?: Array<string>;
  58181. /**
  58182. * The friendly name of the effect displayed in Spector.
  58183. */
  58184. name?: string;
  58185. }
  58186. /**
  58187. * Wraps an effect to be used for rendering
  58188. */
  58189. export class EffectWrapper {
  58190. /**
  58191. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58192. */
  58193. onApplyObservable: Observable<{}>;
  58194. /**
  58195. * The underlying effect
  58196. */
  58197. effect: Effect;
  58198. /**
  58199. * Creates an effect to be renderer
  58200. * @param creationOptions options to create the effect
  58201. */
  58202. constructor(creationOptions: EffectWrapperCreationOptions);
  58203. /**
  58204. * Disposes of the effect wrapper
  58205. */
  58206. dispose(): void;
  58207. }
  58208. }
  58209. declare module "babylonjs/Materials/index" {
  58210. export * from "babylonjs/Materials/Background/index";
  58211. export * from "babylonjs/Materials/colorCurves";
  58212. export * from "babylonjs/Materials/iEffectFallbacks";
  58213. export * from "babylonjs/Materials/effectFallbacks";
  58214. export * from "babylonjs/Materials/effect";
  58215. export * from "babylonjs/Materials/fresnelParameters";
  58216. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58217. export * from "babylonjs/Materials/material";
  58218. export * from "babylonjs/Materials/materialDefines";
  58219. export * from "babylonjs/Materials/materialHelper";
  58220. export * from "babylonjs/Materials/multiMaterial";
  58221. export * from "babylonjs/Materials/PBR/index";
  58222. export * from "babylonjs/Materials/pushMaterial";
  58223. export * from "babylonjs/Materials/shaderMaterial";
  58224. export * from "babylonjs/Materials/standardMaterial";
  58225. export * from "babylonjs/Materials/Textures/index";
  58226. export * from "babylonjs/Materials/uniformBuffer";
  58227. export * from "babylonjs/Materials/materialFlags";
  58228. export * from "babylonjs/Materials/Node/index";
  58229. export * from "babylonjs/Materials/effectRenderer";
  58230. }
  58231. declare module "babylonjs/Maths/index" {
  58232. export * from "babylonjs/Maths/math.scalar";
  58233. export * from "babylonjs/Maths/math";
  58234. export * from "babylonjs/Maths/sphericalPolynomial";
  58235. }
  58236. declare module "babylonjs/Misc/workerPool" {
  58237. import { IDisposable } from "babylonjs/scene";
  58238. /**
  58239. * Helper class to push actions to a pool of workers.
  58240. */
  58241. export class WorkerPool implements IDisposable {
  58242. private _workerInfos;
  58243. private _pendingActions;
  58244. /**
  58245. * Constructor
  58246. * @param workers Array of workers to use for actions
  58247. */
  58248. constructor(workers: Array<Worker>);
  58249. /**
  58250. * Terminates all workers and clears any pending actions.
  58251. */
  58252. dispose(): void;
  58253. /**
  58254. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58255. * pended until a worker has completed its action.
  58256. * @param action The action to perform. Call onComplete when the action is complete.
  58257. */
  58258. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58259. private _execute;
  58260. }
  58261. }
  58262. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58263. import { IDisposable } from "babylonjs/scene";
  58264. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58265. /**
  58266. * Configuration for Draco compression
  58267. */
  58268. export interface IDracoCompressionConfiguration {
  58269. /**
  58270. * Configuration for the decoder.
  58271. */
  58272. decoder: {
  58273. /**
  58274. * The url to the WebAssembly module.
  58275. */
  58276. wasmUrl?: string;
  58277. /**
  58278. * The url to the WebAssembly binary.
  58279. */
  58280. wasmBinaryUrl?: string;
  58281. /**
  58282. * The url to the fallback JavaScript module.
  58283. */
  58284. fallbackUrl?: string;
  58285. };
  58286. }
  58287. /**
  58288. * Draco compression (https://google.github.io/draco/)
  58289. *
  58290. * This class wraps the Draco module.
  58291. *
  58292. * **Encoder**
  58293. *
  58294. * The encoder is not currently implemented.
  58295. *
  58296. * **Decoder**
  58297. *
  58298. * 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.
  58299. *
  58300. * To update the configuration, use the following code:
  58301. * ```javascript
  58302. * DracoCompression.Configuration = {
  58303. * decoder: {
  58304. * wasmUrl: "<url to the WebAssembly library>",
  58305. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58306. * fallbackUrl: "<url to the fallback JavaScript library>",
  58307. * }
  58308. * };
  58309. * ```
  58310. *
  58311. * 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.
  58312. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58313. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58314. *
  58315. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58316. * ```javascript
  58317. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58318. * ```
  58319. *
  58320. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58321. */
  58322. export class DracoCompression implements IDisposable {
  58323. private _workerPoolPromise?;
  58324. private _decoderModulePromise?;
  58325. /**
  58326. * The configuration. Defaults to the following urls:
  58327. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58328. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58329. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58330. */
  58331. static Configuration: IDracoCompressionConfiguration;
  58332. /**
  58333. * Returns true if the decoder configuration is available.
  58334. */
  58335. static readonly DecoderAvailable: boolean;
  58336. /**
  58337. * Default number of workers to create when creating the draco compression object.
  58338. */
  58339. static DefaultNumWorkers: number;
  58340. private static GetDefaultNumWorkers;
  58341. private static _Default;
  58342. /**
  58343. * Default instance for the draco compression object.
  58344. */
  58345. static readonly Default: DracoCompression;
  58346. /**
  58347. * Constructor
  58348. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58349. */
  58350. constructor(numWorkers?: number);
  58351. /**
  58352. * Stop all async operations and release resources.
  58353. */
  58354. dispose(): void;
  58355. /**
  58356. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58357. * @returns a promise that resolves when ready
  58358. */
  58359. whenReadyAsync(): Promise<void>;
  58360. /**
  58361. * Decode Draco compressed mesh data to vertex data.
  58362. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58363. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58364. * @returns A promise that resolves with the decoded vertex data
  58365. */
  58366. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58367. [kind: string]: number;
  58368. }): Promise<VertexData>;
  58369. }
  58370. }
  58371. declare module "babylonjs/Meshes/Compression/index" {
  58372. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58373. }
  58374. declare module "babylonjs/Meshes/csg" {
  58375. import { Nullable } from "babylonjs/types";
  58376. import { Scene } from "babylonjs/scene";
  58377. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58378. import { Mesh } from "babylonjs/Meshes/mesh";
  58379. import { Material } from "babylonjs/Materials/material";
  58380. /**
  58381. * Class for building Constructive Solid Geometry
  58382. */
  58383. export class CSG {
  58384. private polygons;
  58385. /**
  58386. * The world matrix
  58387. */
  58388. matrix: Matrix;
  58389. /**
  58390. * Stores the position
  58391. */
  58392. position: Vector3;
  58393. /**
  58394. * Stores the rotation
  58395. */
  58396. rotation: Vector3;
  58397. /**
  58398. * Stores the rotation quaternion
  58399. */
  58400. rotationQuaternion: Nullable<Quaternion>;
  58401. /**
  58402. * Stores the scaling vector
  58403. */
  58404. scaling: Vector3;
  58405. /**
  58406. * Convert the Mesh to CSG
  58407. * @param mesh The Mesh to convert to CSG
  58408. * @returns A new CSG from the Mesh
  58409. */
  58410. static FromMesh(mesh: Mesh): CSG;
  58411. /**
  58412. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58413. * @param polygons Polygons used to construct a CSG solid
  58414. */
  58415. private static FromPolygons;
  58416. /**
  58417. * Clones, or makes a deep copy, of the CSG
  58418. * @returns A new CSG
  58419. */
  58420. clone(): CSG;
  58421. /**
  58422. * Unions this CSG with another CSG
  58423. * @param csg The CSG to union against this CSG
  58424. * @returns The unioned CSG
  58425. */
  58426. union(csg: CSG): CSG;
  58427. /**
  58428. * Unions this CSG with another CSG in place
  58429. * @param csg The CSG to union against this CSG
  58430. */
  58431. unionInPlace(csg: CSG): void;
  58432. /**
  58433. * Subtracts this CSG with another CSG
  58434. * @param csg The CSG to subtract against this CSG
  58435. * @returns A new CSG
  58436. */
  58437. subtract(csg: CSG): CSG;
  58438. /**
  58439. * Subtracts this CSG with another CSG in place
  58440. * @param csg The CSG to subtact against this CSG
  58441. */
  58442. subtractInPlace(csg: CSG): void;
  58443. /**
  58444. * Intersect this CSG with another CSG
  58445. * @param csg The CSG to intersect against this CSG
  58446. * @returns A new CSG
  58447. */
  58448. intersect(csg: CSG): CSG;
  58449. /**
  58450. * Intersects this CSG with another CSG in place
  58451. * @param csg The CSG to intersect against this CSG
  58452. */
  58453. intersectInPlace(csg: CSG): void;
  58454. /**
  58455. * Return a new CSG solid with solid and empty space switched. This solid is
  58456. * not modified.
  58457. * @returns A new CSG solid with solid and empty space switched
  58458. */
  58459. inverse(): CSG;
  58460. /**
  58461. * Inverses the CSG in place
  58462. */
  58463. inverseInPlace(): void;
  58464. /**
  58465. * This is used to keep meshes transformations so they can be restored
  58466. * when we build back a Babylon Mesh
  58467. * NB : All CSG operations are performed in world coordinates
  58468. * @param csg The CSG to copy the transform attributes from
  58469. * @returns This CSG
  58470. */
  58471. copyTransformAttributes(csg: CSG): CSG;
  58472. /**
  58473. * Build Raw mesh from CSG
  58474. * Coordinates here are in world space
  58475. * @param name The name of the mesh geometry
  58476. * @param scene The Scene
  58477. * @param keepSubMeshes Specifies if the submeshes should be kept
  58478. * @returns A new Mesh
  58479. */
  58480. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58481. /**
  58482. * Build Mesh from CSG taking material and transforms into account
  58483. * @param name The name of the Mesh
  58484. * @param material The material of the Mesh
  58485. * @param scene The Scene
  58486. * @param keepSubMeshes Specifies if submeshes should be kept
  58487. * @returns The new Mesh
  58488. */
  58489. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58490. }
  58491. }
  58492. declare module "babylonjs/Meshes/trailMesh" {
  58493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58494. import { Mesh } from "babylonjs/Meshes/mesh";
  58495. import { Scene } from "babylonjs/scene";
  58496. /**
  58497. * Class used to create a trail following a mesh
  58498. */
  58499. export class TrailMesh extends Mesh {
  58500. private _generator;
  58501. private _autoStart;
  58502. private _running;
  58503. private _diameter;
  58504. private _length;
  58505. private _sectionPolygonPointsCount;
  58506. private _sectionVectors;
  58507. private _sectionNormalVectors;
  58508. private _beforeRenderObserver;
  58509. /**
  58510. * @constructor
  58511. * @param name The value used by scene.getMeshByName() to do a lookup.
  58512. * @param generator The mesh to generate a trail.
  58513. * @param scene The scene to add this mesh to.
  58514. * @param diameter Diameter of trailing mesh. Default is 1.
  58515. * @param length Length of trailing mesh. Default is 60.
  58516. * @param autoStart Automatically start trailing mesh. Default true.
  58517. */
  58518. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58519. /**
  58520. * "TrailMesh"
  58521. * @returns "TrailMesh"
  58522. */
  58523. getClassName(): string;
  58524. private _createMesh;
  58525. /**
  58526. * Start trailing mesh.
  58527. */
  58528. start(): void;
  58529. /**
  58530. * Stop trailing mesh.
  58531. */
  58532. stop(): void;
  58533. /**
  58534. * Update trailing mesh geometry.
  58535. */
  58536. update(): void;
  58537. /**
  58538. * Returns a new TrailMesh object.
  58539. * @param name is a string, the name given to the new mesh
  58540. * @param newGenerator use new generator object for cloned trail mesh
  58541. * @returns a new mesh
  58542. */
  58543. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58544. /**
  58545. * Serializes this trail mesh
  58546. * @param serializationObject object to write serialization to
  58547. */
  58548. serialize(serializationObject: any): void;
  58549. /**
  58550. * Parses a serialized trail mesh
  58551. * @param parsedMesh the serialized mesh
  58552. * @param scene the scene to create the trail mesh in
  58553. * @returns the created trail mesh
  58554. */
  58555. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58556. }
  58557. }
  58558. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58559. import { Nullable } from "babylonjs/types";
  58560. import { Scene } from "babylonjs/scene";
  58561. import { Vector4 } from "babylonjs/Maths/math.vector";
  58562. import { Color4 } from "babylonjs/Maths/math.color";
  58563. import { Mesh } from "babylonjs/Meshes/mesh";
  58564. /**
  58565. * Class containing static functions to help procedurally build meshes
  58566. */
  58567. export class TiledBoxBuilder {
  58568. /**
  58569. * Creates a box mesh
  58570. * 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)
  58571. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58575. * @param name defines the name of the mesh
  58576. * @param options defines the options used to create the mesh
  58577. * @param scene defines the hosting scene
  58578. * @returns the box mesh
  58579. */
  58580. static CreateTiledBox(name: string, options: {
  58581. pattern?: number;
  58582. width?: number;
  58583. height?: number;
  58584. depth?: number;
  58585. tileSize?: number;
  58586. tileWidth?: number;
  58587. tileHeight?: number;
  58588. alignHorizontal?: number;
  58589. alignVertical?: number;
  58590. faceUV?: Vector4[];
  58591. faceColors?: Color4[];
  58592. sideOrientation?: number;
  58593. updatable?: boolean;
  58594. }, scene?: Nullable<Scene>): Mesh;
  58595. }
  58596. }
  58597. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58598. import { Vector4 } from "babylonjs/Maths/math.vector";
  58599. import { Mesh } from "babylonjs/Meshes/mesh";
  58600. /**
  58601. * Class containing static functions to help procedurally build meshes
  58602. */
  58603. export class TorusKnotBuilder {
  58604. /**
  58605. * Creates a torus knot mesh
  58606. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58607. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58608. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58609. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58613. * @param name defines the name of the mesh
  58614. * @param options defines the options used to create the mesh
  58615. * @param scene defines the hosting scene
  58616. * @returns the torus knot mesh
  58617. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58618. */
  58619. static CreateTorusKnot(name: string, options: {
  58620. radius?: number;
  58621. tube?: number;
  58622. radialSegments?: number;
  58623. tubularSegments?: number;
  58624. p?: number;
  58625. q?: number;
  58626. updatable?: boolean;
  58627. sideOrientation?: number;
  58628. frontUVs?: Vector4;
  58629. backUVs?: Vector4;
  58630. }, scene: any): Mesh;
  58631. }
  58632. }
  58633. declare module "babylonjs/Meshes/polygonMesh" {
  58634. import { Scene } from "babylonjs/scene";
  58635. import { Vector2 } from "babylonjs/Maths/math.vector";
  58636. import { Mesh } from "babylonjs/Meshes/mesh";
  58637. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58638. import { Path2 } from "babylonjs/Maths/math.path";
  58639. /**
  58640. * Polygon
  58641. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58642. */
  58643. export class Polygon {
  58644. /**
  58645. * Creates a rectangle
  58646. * @param xmin bottom X coord
  58647. * @param ymin bottom Y coord
  58648. * @param xmax top X coord
  58649. * @param ymax top Y coord
  58650. * @returns points that make the resulting rectation
  58651. */
  58652. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58653. /**
  58654. * Creates a circle
  58655. * @param radius radius of circle
  58656. * @param cx scale in x
  58657. * @param cy scale in y
  58658. * @param numberOfSides number of sides that make up the circle
  58659. * @returns points that make the resulting circle
  58660. */
  58661. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58662. /**
  58663. * Creates a polygon from input string
  58664. * @param input Input polygon data
  58665. * @returns the parsed points
  58666. */
  58667. static Parse(input: string): Vector2[];
  58668. /**
  58669. * Starts building a polygon from x and y coordinates
  58670. * @param x x coordinate
  58671. * @param y y coordinate
  58672. * @returns the started path2
  58673. */
  58674. static StartingAt(x: number, y: number): Path2;
  58675. }
  58676. /**
  58677. * Builds a polygon
  58678. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58679. */
  58680. export class PolygonMeshBuilder {
  58681. private _points;
  58682. private _outlinepoints;
  58683. private _holes;
  58684. private _name;
  58685. private _scene;
  58686. private _epoints;
  58687. private _eholes;
  58688. private _addToepoint;
  58689. /**
  58690. * Babylon reference to the earcut plugin.
  58691. */
  58692. bjsEarcut: any;
  58693. /**
  58694. * Creates a PolygonMeshBuilder
  58695. * @param name name of the builder
  58696. * @param contours Path of the polygon
  58697. * @param scene scene to add to when creating the mesh
  58698. * @param earcutInjection can be used to inject your own earcut reference
  58699. */
  58700. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58701. /**
  58702. * Adds a whole within the polygon
  58703. * @param hole Array of points defining the hole
  58704. * @returns this
  58705. */
  58706. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58707. /**
  58708. * Creates the polygon
  58709. * @param updatable If the mesh should be updatable
  58710. * @param depth The depth of the mesh created
  58711. * @returns the created mesh
  58712. */
  58713. build(updatable?: boolean, depth?: number): Mesh;
  58714. /**
  58715. * Creates the polygon
  58716. * @param depth The depth of the mesh created
  58717. * @returns the created VertexData
  58718. */
  58719. buildVertexData(depth?: number): VertexData;
  58720. /**
  58721. * Adds a side to the polygon
  58722. * @param positions points that make the polygon
  58723. * @param normals normals of the polygon
  58724. * @param uvs uvs of the polygon
  58725. * @param indices indices of the polygon
  58726. * @param bounds bounds of the polygon
  58727. * @param points points of the polygon
  58728. * @param depth depth of the polygon
  58729. * @param flip flip of the polygon
  58730. */
  58731. private addSide;
  58732. }
  58733. }
  58734. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58735. import { Scene } from "babylonjs/scene";
  58736. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58737. import { Color4 } from "babylonjs/Maths/math.color";
  58738. import { Mesh } from "babylonjs/Meshes/mesh";
  58739. import { Nullable } from "babylonjs/types";
  58740. /**
  58741. * Class containing static functions to help procedurally build meshes
  58742. */
  58743. export class PolygonBuilder {
  58744. /**
  58745. * Creates a polygon mesh
  58746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58747. * * 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
  58748. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58751. * * Remember you can only change the shape positions, not their number when updating a polygon
  58752. * @param name defines the name of the mesh
  58753. * @param options defines the options used to create the mesh
  58754. * @param scene defines the hosting scene
  58755. * @param earcutInjection can be used to inject your own earcut reference
  58756. * @returns the polygon mesh
  58757. */
  58758. static CreatePolygon(name: string, options: {
  58759. shape: Vector3[];
  58760. holes?: Vector3[][];
  58761. depth?: number;
  58762. faceUV?: Vector4[];
  58763. faceColors?: Color4[];
  58764. updatable?: boolean;
  58765. sideOrientation?: number;
  58766. frontUVs?: Vector4;
  58767. backUVs?: Vector4;
  58768. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58769. /**
  58770. * Creates an extruded polygon mesh, with depth in the Y direction.
  58771. * * 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)
  58772. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58773. * @param name defines the name of the mesh
  58774. * @param options defines the options used to create the mesh
  58775. * @param scene defines the hosting scene
  58776. * @param earcutInjection can be used to inject your own earcut reference
  58777. * @returns the polygon mesh
  58778. */
  58779. static ExtrudePolygon(name: string, options: {
  58780. shape: Vector3[];
  58781. holes?: Vector3[][];
  58782. depth?: number;
  58783. faceUV?: Vector4[];
  58784. faceColors?: Color4[];
  58785. updatable?: boolean;
  58786. sideOrientation?: number;
  58787. frontUVs?: Vector4;
  58788. backUVs?: Vector4;
  58789. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58790. }
  58791. }
  58792. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58793. import { Scene } from "babylonjs/scene";
  58794. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58795. import { Mesh } from "babylonjs/Meshes/mesh";
  58796. import { Nullable } from "babylonjs/types";
  58797. /**
  58798. * Class containing static functions to help procedurally build meshes
  58799. */
  58800. export class LatheBuilder {
  58801. /**
  58802. * Creates lathe mesh.
  58803. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58804. * * 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
  58805. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58806. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58807. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58808. * * 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
  58809. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58810. * * 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
  58811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58812. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58815. * @param name defines the name of the mesh
  58816. * @param options defines the options used to create the mesh
  58817. * @param scene defines the hosting scene
  58818. * @returns the lathe mesh
  58819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58820. */
  58821. static CreateLathe(name: string, options: {
  58822. shape: Vector3[];
  58823. radius?: number;
  58824. tessellation?: number;
  58825. clip?: number;
  58826. arc?: number;
  58827. closed?: boolean;
  58828. updatable?: boolean;
  58829. sideOrientation?: number;
  58830. frontUVs?: Vector4;
  58831. backUVs?: Vector4;
  58832. cap?: number;
  58833. invertUV?: boolean;
  58834. }, scene?: Nullable<Scene>): Mesh;
  58835. }
  58836. }
  58837. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58838. import { Nullable } from "babylonjs/types";
  58839. import { Scene } from "babylonjs/scene";
  58840. import { Vector4 } from "babylonjs/Maths/math.vector";
  58841. import { Mesh } from "babylonjs/Meshes/mesh";
  58842. /**
  58843. * Class containing static functions to help procedurally build meshes
  58844. */
  58845. export class TiledPlaneBuilder {
  58846. /**
  58847. * Creates a tiled plane mesh
  58848. * * The parameter `pattern` will, depending on value, do nothing or
  58849. * * * flip (reflect about central vertical) alternate tiles across and up
  58850. * * * flip every tile on alternate rows
  58851. * * * rotate (180 degs) alternate tiles across and up
  58852. * * * rotate every tile on alternate rows
  58853. * * * flip and rotate alternate tiles across and up
  58854. * * * flip and rotate every tile on alternate rows
  58855. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58856. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58858. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58859. * * 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)
  58860. * * 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)
  58861. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58862. * @param name defines the name of the mesh
  58863. * @param options defines the options used to create the mesh
  58864. * @param scene defines the hosting scene
  58865. * @returns the box mesh
  58866. */
  58867. static CreateTiledPlane(name: string, options: {
  58868. pattern?: number;
  58869. tileSize?: number;
  58870. tileWidth?: number;
  58871. tileHeight?: number;
  58872. size?: number;
  58873. width?: number;
  58874. height?: number;
  58875. alignHorizontal?: number;
  58876. alignVertical?: number;
  58877. sideOrientation?: number;
  58878. frontUVs?: Vector4;
  58879. backUVs?: Vector4;
  58880. updatable?: boolean;
  58881. }, scene?: Nullable<Scene>): Mesh;
  58882. }
  58883. }
  58884. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58885. import { Nullable } from "babylonjs/types";
  58886. import { Scene } from "babylonjs/scene";
  58887. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58888. import { Mesh } from "babylonjs/Meshes/mesh";
  58889. /**
  58890. * Class containing static functions to help procedurally build meshes
  58891. */
  58892. export class TubeBuilder {
  58893. /**
  58894. * Creates a tube mesh.
  58895. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58896. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58897. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58898. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58899. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58900. * * 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)
  58901. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58902. * * 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
  58903. * * 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
  58904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58905. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58906. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58908. * @param name defines the name of the mesh
  58909. * @param options defines the options used to create the mesh
  58910. * @param scene defines the hosting scene
  58911. * @returns the tube mesh
  58912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58913. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58914. */
  58915. static CreateTube(name: string, options: {
  58916. path: Vector3[];
  58917. radius?: number;
  58918. tessellation?: number;
  58919. radiusFunction?: {
  58920. (i: number, distance: number): number;
  58921. };
  58922. cap?: number;
  58923. arc?: number;
  58924. updatable?: boolean;
  58925. sideOrientation?: number;
  58926. frontUVs?: Vector4;
  58927. backUVs?: Vector4;
  58928. instance?: Mesh;
  58929. invertUV?: boolean;
  58930. }, scene?: Nullable<Scene>): Mesh;
  58931. }
  58932. }
  58933. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58934. import { Scene } from "babylonjs/scene";
  58935. import { Vector4 } from "babylonjs/Maths/math.vector";
  58936. import { Mesh } from "babylonjs/Meshes/mesh";
  58937. import { Nullable } from "babylonjs/types";
  58938. /**
  58939. * Class containing static functions to help procedurally build meshes
  58940. */
  58941. export class IcoSphereBuilder {
  58942. /**
  58943. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58944. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58945. * * 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`)
  58946. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58947. * * 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
  58948. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58949. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58951. * @param name defines the name of the mesh
  58952. * @param options defines the options used to create the mesh
  58953. * @param scene defines the hosting scene
  58954. * @returns the icosahedron mesh
  58955. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58956. */
  58957. static CreateIcoSphere(name: string, options: {
  58958. radius?: number;
  58959. radiusX?: number;
  58960. radiusY?: number;
  58961. radiusZ?: number;
  58962. flat?: boolean;
  58963. subdivisions?: number;
  58964. sideOrientation?: number;
  58965. frontUVs?: Vector4;
  58966. backUVs?: Vector4;
  58967. updatable?: boolean;
  58968. }, scene?: Nullable<Scene>): Mesh;
  58969. }
  58970. }
  58971. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58972. import { Vector3 } from "babylonjs/Maths/math.vector";
  58973. import { Mesh } from "babylonjs/Meshes/mesh";
  58974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58975. /**
  58976. * Class containing static functions to help procedurally build meshes
  58977. */
  58978. export class DecalBuilder {
  58979. /**
  58980. * Creates a decal mesh.
  58981. * 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
  58982. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58983. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58984. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58985. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58986. * @param name defines the name of the mesh
  58987. * @param sourceMesh defines the mesh where the decal must be applied
  58988. * @param options defines the options used to create the mesh
  58989. * @param scene defines the hosting scene
  58990. * @returns the decal mesh
  58991. * @see https://doc.babylonjs.com/how_to/decals
  58992. */
  58993. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58994. position?: Vector3;
  58995. normal?: Vector3;
  58996. size?: Vector3;
  58997. angle?: number;
  58998. }): Mesh;
  58999. }
  59000. }
  59001. declare module "babylonjs/Meshes/meshBuilder" {
  59002. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59003. import { Nullable } from "babylonjs/types";
  59004. import { Scene } from "babylonjs/scene";
  59005. import { Mesh } from "babylonjs/Meshes/mesh";
  59006. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59007. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59009. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59010. import { Plane } from "babylonjs/Maths/math.plane";
  59011. /**
  59012. * Class containing static functions to help procedurally build meshes
  59013. */
  59014. export class MeshBuilder {
  59015. /**
  59016. * Creates a box mesh
  59017. * * The parameter `size` sets the size (float) of each box side (default 1)
  59018. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59019. * * 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)
  59020. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59022. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59024. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59025. * @param name defines the name of the mesh
  59026. * @param options defines the options used to create the mesh
  59027. * @param scene defines the hosting scene
  59028. * @returns the box mesh
  59029. */
  59030. static CreateBox(name: string, options: {
  59031. size?: number;
  59032. width?: number;
  59033. height?: number;
  59034. depth?: number;
  59035. faceUV?: Vector4[];
  59036. faceColors?: Color4[];
  59037. sideOrientation?: number;
  59038. frontUVs?: Vector4;
  59039. backUVs?: Vector4;
  59040. updatable?: boolean;
  59041. }, scene?: Nullable<Scene>): Mesh;
  59042. /**
  59043. * Creates a tiled box mesh
  59044. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59046. * @param name defines the name of the mesh
  59047. * @param options defines the options used to create the mesh
  59048. * @param scene defines the hosting scene
  59049. * @returns the tiled box mesh
  59050. */
  59051. static CreateTiledBox(name: string, options: {
  59052. pattern?: number;
  59053. size?: number;
  59054. width?: number;
  59055. height?: number;
  59056. depth: number;
  59057. tileSize?: number;
  59058. tileWidth?: number;
  59059. tileHeight?: number;
  59060. faceUV?: Vector4[];
  59061. faceColors?: Color4[];
  59062. alignHorizontal?: number;
  59063. alignVertical?: number;
  59064. sideOrientation?: number;
  59065. updatable?: boolean;
  59066. }, scene?: Nullable<Scene>): Mesh;
  59067. /**
  59068. * Creates a sphere mesh
  59069. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59070. * * 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`)
  59071. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59072. * * 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
  59073. * * 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)
  59074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59077. * @param name defines the name of the mesh
  59078. * @param options defines the options used to create the mesh
  59079. * @param scene defines the hosting scene
  59080. * @returns the sphere mesh
  59081. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59082. */
  59083. static CreateSphere(name: string, options: {
  59084. segments?: number;
  59085. diameter?: number;
  59086. diameterX?: number;
  59087. diameterY?: number;
  59088. diameterZ?: number;
  59089. arc?: number;
  59090. slice?: number;
  59091. sideOrientation?: number;
  59092. frontUVs?: Vector4;
  59093. backUVs?: Vector4;
  59094. updatable?: boolean;
  59095. }, scene?: Nullable<Scene>): Mesh;
  59096. /**
  59097. * Creates a plane polygonal mesh. By default, this is a disc
  59098. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59099. * * 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
  59100. * * 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
  59101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59104. * @param name defines the name of the mesh
  59105. * @param options defines the options used to create the mesh
  59106. * @param scene defines the hosting scene
  59107. * @returns the plane polygonal mesh
  59108. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59109. */
  59110. static CreateDisc(name: string, options: {
  59111. radius?: number;
  59112. tessellation?: number;
  59113. arc?: number;
  59114. updatable?: boolean;
  59115. sideOrientation?: number;
  59116. frontUVs?: Vector4;
  59117. backUVs?: Vector4;
  59118. }, scene?: Nullable<Scene>): Mesh;
  59119. /**
  59120. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59121. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59122. * * 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`)
  59123. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59124. * * 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
  59125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59128. * @param name defines the name of the mesh
  59129. * @param options defines the options used to create the mesh
  59130. * @param scene defines the hosting scene
  59131. * @returns the icosahedron mesh
  59132. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59133. */
  59134. static CreateIcoSphere(name: string, options: {
  59135. radius?: number;
  59136. radiusX?: number;
  59137. radiusY?: number;
  59138. radiusZ?: number;
  59139. flat?: boolean;
  59140. subdivisions?: number;
  59141. sideOrientation?: number;
  59142. frontUVs?: Vector4;
  59143. backUVs?: Vector4;
  59144. updatable?: boolean;
  59145. }, scene?: Nullable<Scene>): Mesh;
  59146. /**
  59147. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59148. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59149. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59150. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59151. * * 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
  59152. * * 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
  59153. * * 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
  59154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59156. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59157. * * 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
  59158. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59159. * * 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
  59160. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59162. * @param name defines the name of the mesh
  59163. * @param options defines the options used to create the mesh
  59164. * @param scene defines the hosting scene
  59165. * @returns the ribbon mesh
  59166. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59167. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59168. */
  59169. static CreateRibbon(name: string, options: {
  59170. pathArray: Vector3[][];
  59171. closeArray?: boolean;
  59172. closePath?: boolean;
  59173. offset?: number;
  59174. updatable?: boolean;
  59175. sideOrientation?: number;
  59176. frontUVs?: Vector4;
  59177. backUVs?: Vector4;
  59178. instance?: Mesh;
  59179. invertUV?: boolean;
  59180. uvs?: Vector2[];
  59181. colors?: Color4[];
  59182. }, scene?: Nullable<Scene>): Mesh;
  59183. /**
  59184. * Creates a cylinder or a cone mesh
  59185. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59186. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59187. * * 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.
  59188. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59189. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59190. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59191. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59192. * * 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).
  59193. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59194. * * 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).
  59195. * * 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
  59196. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59197. * * 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
  59198. * * 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.
  59199. * * If `enclose` is false, a ring surface is one element.
  59200. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59201. * * 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
  59202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59205. * @param name defines the name of the mesh
  59206. * @param options defines the options used to create the mesh
  59207. * @param scene defines the hosting scene
  59208. * @returns the cylinder mesh
  59209. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59210. */
  59211. static CreateCylinder(name: string, options: {
  59212. height?: number;
  59213. diameterTop?: number;
  59214. diameterBottom?: number;
  59215. diameter?: number;
  59216. tessellation?: number;
  59217. subdivisions?: number;
  59218. arc?: number;
  59219. faceColors?: Color4[];
  59220. faceUV?: Vector4[];
  59221. updatable?: boolean;
  59222. hasRings?: boolean;
  59223. enclose?: boolean;
  59224. cap?: number;
  59225. sideOrientation?: number;
  59226. frontUVs?: Vector4;
  59227. backUVs?: Vector4;
  59228. }, scene?: Nullable<Scene>): Mesh;
  59229. /**
  59230. * Creates a torus mesh
  59231. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59232. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59233. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59237. * @param name defines the name of the mesh
  59238. * @param options defines the options used to create the mesh
  59239. * @param scene defines the hosting scene
  59240. * @returns the torus mesh
  59241. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59242. */
  59243. static CreateTorus(name: string, options: {
  59244. diameter?: number;
  59245. thickness?: number;
  59246. tessellation?: number;
  59247. updatable?: boolean;
  59248. sideOrientation?: number;
  59249. frontUVs?: Vector4;
  59250. backUVs?: Vector4;
  59251. }, scene?: Nullable<Scene>): Mesh;
  59252. /**
  59253. * Creates a torus knot mesh
  59254. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59255. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59256. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59257. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59261. * @param name defines the name of the mesh
  59262. * @param options defines the options used to create the mesh
  59263. * @param scene defines the hosting scene
  59264. * @returns the torus knot mesh
  59265. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59266. */
  59267. static CreateTorusKnot(name: string, options: {
  59268. radius?: number;
  59269. tube?: number;
  59270. radialSegments?: number;
  59271. tubularSegments?: number;
  59272. p?: number;
  59273. q?: number;
  59274. updatable?: boolean;
  59275. sideOrientation?: number;
  59276. frontUVs?: Vector4;
  59277. backUVs?: Vector4;
  59278. }, scene?: Nullable<Scene>): Mesh;
  59279. /**
  59280. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59281. * * 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
  59282. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59283. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59284. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59285. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59286. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59287. * * 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
  59288. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59290. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59291. * @param name defines the name of the new line system
  59292. * @param options defines the options used to create the line system
  59293. * @param scene defines the hosting scene
  59294. * @returns a new line system mesh
  59295. */
  59296. static CreateLineSystem(name: string, options: {
  59297. lines: Vector3[][];
  59298. updatable?: boolean;
  59299. instance?: Nullable<LinesMesh>;
  59300. colors?: Nullable<Color4[][]>;
  59301. useVertexAlpha?: boolean;
  59302. }, scene: Nullable<Scene>): LinesMesh;
  59303. /**
  59304. * Creates a line mesh
  59305. * 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
  59306. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59307. * * The parameter `points` is an array successive Vector3
  59308. * * 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
  59309. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59310. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59311. * * When updating an instance, remember that only point positions can change, not the number of points
  59312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59314. * @param name defines the name of the new line system
  59315. * @param options defines the options used to create the line system
  59316. * @param scene defines the hosting scene
  59317. * @returns a new line mesh
  59318. */
  59319. static CreateLines(name: string, options: {
  59320. points: Vector3[];
  59321. updatable?: boolean;
  59322. instance?: Nullable<LinesMesh>;
  59323. colors?: Color4[];
  59324. useVertexAlpha?: boolean;
  59325. }, scene?: Nullable<Scene>): LinesMesh;
  59326. /**
  59327. * Creates a dashed line mesh
  59328. * * 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
  59329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59330. * * The parameter `points` is an array successive Vector3
  59331. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59332. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59333. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59334. * * 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
  59335. * * When updating an instance, remember that only point positions can change, not the number of points
  59336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59337. * @param name defines the name of the mesh
  59338. * @param options defines the options used to create the mesh
  59339. * @param scene defines the hosting scene
  59340. * @returns the dashed line mesh
  59341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59342. */
  59343. static CreateDashedLines(name: string, options: {
  59344. points: Vector3[];
  59345. dashSize?: number;
  59346. gapSize?: number;
  59347. dashNb?: number;
  59348. updatable?: boolean;
  59349. instance?: LinesMesh;
  59350. }, scene?: Nullable<Scene>): LinesMesh;
  59351. /**
  59352. * 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.
  59353. * * 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.
  59354. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59355. * * 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.
  59356. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59357. * * 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
  59358. * * 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
  59359. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59364. * @param name defines the name of the mesh
  59365. * @param options defines the options used to create the mesh
  59366. * @param scene defines the hosting scene
  59367. * @returns the extruded shape mesh
  59368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59370. */
  59371. static ExtrudeShape(name: string, options: {
  59372. shape: Vector3[];
  59373. path: Vector3[];
  59374. scale?: number;
  59375. rotation?: number;
  59376. cap?: number;
  59377. updatable?: boolean;
  59378. sideOrientation?: number;
  59379. frontUVs?: Vector4;
  59380. backUVs?: Vector4;
  59381. instance?: Mesh;
  59382. invertUV?: boolean;
  59383. }, scene?: Nullable<Scene>): Mesh;
  59384. /**
  59385. * Creates an custom extruded shape mesh.
  59386. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59387. * * 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.
  59388. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59389. * * 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
  59390. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59391. * * 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
  59392. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59393. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59394. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59395. * * 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
  59396. * * 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
  59397. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59400. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59402. * @param name defines the name of the mesh
  59403. * @param options defines the options used to create the mesh
  59404. * @param scene defines the hosting scene
  59405. * @returns the custom extruded shape mesh
  59406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59409. */
  59410. static ExtrudeShapeCustom(name: string, options: {
  59411. shape: Vector3[];
  59412. path: Vector3[];
  59413. scaleFunction?: any;
  59414. rotationFunction?: any;
  59415. ribbonCloseArray?: boolean;
  59416. ribbonClosePath?: boolean;
  59417. cap?: number;
  59418. updatable?: boolean;
  59419. sideOrientation?: number;
  59420. frontUVs?: Vector4;
  59421. backUVs?: Vector4;
  59422. instance?: Mesh;
  59423. invertUV?: boolean;
  59424. }, scene?: Nullable<Scene>): Mesh;
  59425. /**
  59426. * Creates lathe mesh.
  59427. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59428. * * 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
  59429. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59430. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59431. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59432. * * 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
  59433. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59434. * * 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
  59435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59437. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59439. * @param name defines the name of the mesh
  59440. * @param options defines the options used to create the mesh
  59441. * @param scene defines the hosting scene
  59442. * @returns the lathe mesh
  59443. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59444. */
  59445. static CreateLathe(name: string, options: {
  59446. shape: Vector3[];
  59447. radius?: number;
  59448. tessellation?: number;
  59449. clip?: number;
  59450. arc?: number;
  59451. closed?: boolean;
  59452. updatable?: boolean;
  59453. sideOrientation?: number;
  59454. frontUVs?: Vector4;
  59455. backUVs?: Vector4;
  59456. cap?: number;
  59457. invertUV?: boolean;
  59458. }, scene?: Nullable<Scene>): Mesh;
  59459. /**
  59460. * Creates a tiled plane mesh
  59461. * * You can set a limited pattern arrangement with the tiles
  59462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59464. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59465. * @param name defines the name of the mesh
  59466. * @param options defines the options used to create the mesh
  59467. * @param scene defines the hosting scene
  59468. * @returns the plane mesh
  59469. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59470. */
  59471. static CreateTiledPlane(name: string, options: {
  59472. pattern?: number;
  59473. tileSize?: number;
  59474. tileWidth?: number;
  59475. tileHeight?: number;
  59476. size?: number;
  59477. width?: number;
  59478. height?: number;
  59479. alignHorizontal?: number;
  59480. alignVertical?: number;
  59481. sideOrientation?: number;
  59482. frontUVs?: Vector4;
  59483. backUVs?: Vector4;
  59484. updatable?: boolean;
  59485. }, scene?: Nullable<Scene>): Mesh;
  59486. /**
  59487. * Creates a plane mesh
  59488. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59489. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59490. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59494. * @param name defines the name of the mesh
  59495. * @param options defines the options used to create the mesh
  59496. * @param scene defines the hosting scene
  59497. * @returns the plane mesh
  59498. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59499. */
  59500. static CreatePlane(name: string, options: {
  59501. size?: number;
  59502. width?: number;
  59503. height?: number;
  59504. sideOrientation?: number;
  59505. frontUVs?: Vector4;
  59506. backUVs?: Vector4;
  59507. updatable?: boolean;
  59508. sourcePlane?: Plane;
  59509. }, scene?: Nullable<Scene>): Mesh;
  59510. /**
  59511. * Creates a ground mesh
  59512. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59513. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59515. * @param name defines the name of the mesh
  59516. * @param options defines the options used to create the mesh
  59517. * @param scene defines the hosting scene
  59518. * @returns the ground mesh
  59519. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59520. */
  59521. static CreateGround(name: string, options: {
  59522. width?: number;
  59523. height?: number;
  59524. subdivisions?: number;
  59525. subdivisionsX?: number;
  59526. subdivisionsY?: number;
  59527. updatable?: boolean;
  59528. }, scene?: Nullable<Scene>): Mesh;
  59529. /**
  59530. * Creates a tiled ground mesh
  59531. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59532. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59533. * * 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
  59534. * * 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
  59535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59536. * @param name defines the name of the mesh
  59537. * @param options defines the options used to create the mesh
  59538. * @param scene defines the hosting scene
  59539. * @returns the tiled ground mesh
  59540. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59541. */
  59542. static CreateTiledGround(name: string, options: {
  59543. xmin: number;
  59544. zmin: number;
  59545. xmax: number;
  59546. zmax: number;
  59547. subdivisions?: {
  59548. w: number;
  59549. h: number;
  59550. };
  59551. precision?: {
  59552. w: number;
  59553. h: number;
  59554. };
  59555. updatable?: boolean;
  59556. }, scene?: Nullable<Scene>): Mesh;
  59557. /**
  59558. * Creates a ground mesh from a height map
  59559. * * The parameter `url` sets the URL of the height map image resource.
  59560. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59561. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59562. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59563. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59564. * * 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.
  59565. * * 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).
  59566. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59568. * @param name defines the name of the mesh
  59569. * @param url defines the url to the height map
  59570. * @param options defines the options used to create the mesh
  59571. * @param scene defines the hosting scene
  59572. * @returns the ground mesh
  59573. * @see https://doc.babylonjs.com/babylon101/height_map
  59574. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59575. */
  59576. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59577. width?: number;
  59578. height?: number;
  59579. subdivisions?: number;
  59580. minHeight?: number;
  59581. maxHeight?: number;
  59582. colorFilter?: Color3;
  59583. alphaFilter?: number;
  59584. updatable?: boolean;
  59585. onReady?: (mesh: GroundMesh) => void;
  59586. }, scene?: Nullable<Scene>): GroundMesh;
  59587. /**
  59588. * Creates a polygon mesh
  59589. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59590. * * 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
  59591. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59594. * * Remember you can only change the shape positions, not their number when updating a polygon
  59595. * @param name defines the name of the mesh
  59596. * @param options defines the options used to create the mesh
  59597. * @param scene defines the hosting scene
  59598. * @param earcutInjection can be used to inject your own earcut reference
  59599. * @returns the polygon mesh
  59600. */
  59601. static CreatePolygon(name: string, options: {
  59602. shape: Vector3[];
  59603. holes?: Vector3[][];
  59604. depth?: number;
  59605. faceUV?: Vector4[];
  59606. faceColors?: Color4[];
  59607. updatable?: boolean;
  59608. sideOrientation?: number;
  59609. frontUVs?: Vector4;
  59610. backUVs?: Vector4;
  59611. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59612. /**
  59613. * Creates an extruded polygon mesh, with depth in the Y direction.
  59614. * * 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)
  59615. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59616. * @param name defines the name of the mesh
  59617. * @param options defines the options used to create the mesh
  59618. * @param scene defines the hosting scene
  59619. * @param earcutInjection can be used to inject your own earcut reference
  59620. * @returns the polygon mesh
  59621. */
  59622. static ExtrudePolygon(name: string, options: {
  59623. shape: Vector3[];
  59624. holes?: Vector3[][];
  59625. depth?: number;
  59626. faceUV?: Vector4[];
  59627. faceColors?: Color4[];
  59628. updatable?: boolean;
  59629. sideOrientation?: number;
  59630. frontUVs?: Vector4;
  59631. backUVs?: Vector4;
  59632. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59633. /**
  59634. * Creates a tube mesh.
  59635. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59636. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59637. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59638. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59639. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59640. * * 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)
  59641. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59642. * * 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
  59643. * * 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
  59644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59648. * @param name defines the name of the mesh
  59649. * @param options defines the options used to create the mesh
  59650. * @param scene defines the hosting scene
  59651. * @returns the tube mesh
  59652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59653. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59654. */
  59655. static CreateTube(name: string, options: {
  59656. path: Vector3[];
  59657. radius?: number;
  59658. tessellation?: number;
  59659. radiusFunction?: {
  59660. (i: number, distance: number): number;
  59661. };
  59662. cap?: number;
  59663. arc?: number;
  59664. updatable?: boolean;
  59665. sideOrientation?: number;
  59666. frontUVs?: Vector4;
  59667. backUVs?: Vector4;
  59668. instance?: Mesh;
  59669. invertUV?: boolean;
  59670. }, scene?: Nullable<Scene>): Mesh;
  59671. /**
  59672. * Creates a polyhedron mesh
  59673. * * 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
  59674. * * The parameter `size` (positive float, default 1) sets the polygon size
  59675. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59676. * * 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`
  59677. * * 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
  59678. * * 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)`)
  59679. * * 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
  59680. * * 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
  59681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59682. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59684. * @param name defines the name of the mesh
  59685. * @param options defines the options used to create the mesh
  59686. * @param scene defines the hosting scene
  59687. * @returns the polyhedron mesh
  59688. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59689. */
  59690. static CreatePolyhedron(name: string, options: {
  59691. type?: number;
  59692. size?: number;
  59693. sizeX?: number;
  59694. sizeY?: number;
  59695. sizeZ?: number;
  59696. custom?: any;
  59697. faceUV?: Vector4[];
  59698. faceColors?: Color4[];
  59699. flat?: boolean;
  59700. updatable?: boolean;
  59701. sideOrientation?: number;
  59702. frontUVs?: Vector4;
  59703. backUVs?: Vector4;
  59704. }, scene?: Nullable<Scene>): Mesh;
  59705. /**
  59706. * Creates a decal mesh.
  59707. * 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
  59708. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59709. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59710. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59711. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59712. * @param name defines the name of the mesh
  59713. * @param sourceMesh defines the mesh where the decal must be applied
  59714. * @param options defines the options used to create the mesh
  59715. * @param scene defines the hosting scene
  59716. * @returns the decal mesh
  59717. * @see https://doc.babylonjs.com/how_to/decals
  59718. */
  59719. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59720. position?: Vector3;
  59721. normal?: Vector3;
  59722. size?: Vector3;
  59723. angle?: number;
  59724. }): Mesh;
  59725. }
  59726. }
  59727. declare module "babylonjs/Meshes/meshSimplification" {
  59728. import { Mesh } from "babylonjs/Meshes/mesh";
  59729. /**
  59730. * A simplifier interface for future simplification implementations
  59731. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59732. */
  59733. export interface ISimplifier {
  59734. /**
  59735. * Simplification of a given mesh according to the given settings.
  59736. * Since this requires computation, it is assumed that the function runs async.
  59737. * @param settings The settings of the simplification, including quality and distance
  59738. * @param successCallback A callback that will be called after the mesh was simplified.
  59739. * @param errorCallback in case of an error, this callback will be called. optional.
  59740. */
  59741. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59742. }
  59743. /**
  59744. * Expected simplification settings.
  59745. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59746. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59747. */
  59748. export interface ISimplificationSettings {
  59749. /**
  59750. * Gets or sets the expected quality
  59751. */
  59752. quality: number;
  59753. /**
  59754. * Gets or sets the distance when this optimized version should be used
  59755. */
  59756. distance: number;
  59757. /**
  59758. * Gets an already optimized mesh
  59759. */
  59760. optimizeMesh?: boolean;
  59761. }
  59762. /**
  59763. * Class used to specify simplification options
  59764. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59765. */
  59766. export class SimplificationSettings implements ISimplificationSettings {
  59767. /** expected quality */
  59768. quality: number;
  59769. /** distance when this optimized version should be used */
  59770. distance: number;
  59771. /** already optimized mesh */
  59772. optimizeMesh?: boolean | undefined;
  59773. /**
  59774. * Creates a SimplificationSettings
  59775. * @param quality expected quality
  59776. * @param distance distance when this optimized version should be used
  59777. * @param optimizeMesh already optimized mesh
  59778. */
  59779. constructor(
  59780. /** expected quality */
  59781. quality: number,
  59782. /** distance when this optimized version should be used */
  59783. distance: number,
  59784. /** already optimized mesh */
  59785. optimizeMesh?: boolean | undefined);
  59786. }
  59787. /**
  59788. * Interface used to define a simplification task
  59789. */
  59790. export interface ISimplificationTask {
  59791. /**
  59792. * Array of settings
  59793. */
  59794. settings: Array<ISimplificationSettings>;
  59795. /**
  59796. * Simplification type
  59797. */
  59798. simplificationType: SimplificationType;
  59799. /**
  59800. * Mesh to simplify
  59801. */
  59802. mesh: Mesh;
  59803. /**
  59804. * Callback called on success
  59805. */
  59806. successCallback?: () => void;
  59807. /**
  59808. * Defines if parallel processing can be used
  59809. */
  59810. parallelProcessing: boolean;
  59811. }
  59812. /**
  59813. * Queue used to order the simplification tasks
  59814. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59815. */
  59816. export class SimplificationQueue {
  59817. private _simplificationArray;
  59818. /**
  59819. * Gets a boolean indicating that the process is still running
  59820. */
  59821. running: boolean;
  59822. /**
  59823. * Creates a new queue
  59824. */
  59825. constructor();
  59826. /**
  59827. * Adds a new simplification task
  59828. * @param task defines a task to add
  59829. */
  59830. addTask(task: ISimplificationTask): void;
  59831. /**
  59832. * Execute next task
  59833. */
  59834. executeNext(): void;
  59835. /**
  59836. * Execute a simplification task
  59837. * @param task defines the task to run
  59838. */
  59839. runSimplification(task: ISimplificationTask): void;
  59840. private getSimplifier;
  59841. }
  59842. /**
  59843. * The implemented types of simplification
  59844. * At the moment only Quadratic Error Decimation is implemented
  59845. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59846. */
  59847. export enum SimplificationType {
  59848. /** Quadratic error decimation */
  59849. QUADRATIC = 0
  59850. }
  59851. }
  59852. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59853. import { Scene } from "babylonjs/scene";
  59854. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59855. import { ISceneComponent } from "babylonjs/sceneComponent";
  59856. module "babylonjs/scene" {
  59857. interface Scene {
  59858. /** @hidden (Backing field) */
  59859. _simplificationQueue: SimplificationQueue;
  59860. /**
  59861. * Gets or sets the simplification queue attached to the scene
  59862. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59863. */
  59864. simplificationQueue: SimplificationQueue;
  59865. }
  59866. }
  59867. module "babylonjs/Meshes/mesh" {
  59868. interface Mesh {
  59869. /**
  59870. * Simplify the mesh according to the given array of settings.
  59871. * Function will return immediately and will simplify async
  59872. * @param settings a collection of simplification settings
  59873. * @param parallelProcessing should all levels calculate parallel or one after the other
  59874. * @param simplificationType the type of simplification to run
  59875. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59876. * @returns the current mesh
  59877. */
  59878. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59879. }
  59880. }
  59881. /**
  59882. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59883. * created in a scene
  59884. */
  59885. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59886. /**
  59887. * The component name helpfull to identify the component in the list of scene components.
  59888. */
  59889. readonly name: string;
  59890. /**
  59891. * The scene the component belongs to.
  59892. */
  59893. scene: Scene;
  59894. /**
  59895. * Creates a new instance of the component for the given scene
  59896. * @param scene Defines the scene to register the component in
  59897. */
  59898. constructor(scene: Scene);
  59899. /**
  59900. * Registers the component in a given scene
  59901. */
  59902. register(): void;
  59903. /**
  59904. * Rebuilds the elements related to this component in case of
  59905. * context lost for instance.
  59906. */
  59907. rebuild(): void;
  59908. /**
  59909. * Disposes the component and the associated ressources
  59910. */
  59911. dispose(): void;
  59912. private _beforeCameraUpdate;
  59913. }
  59914. }
  59915. declare module "babylonjs/Meshes/Builders/index" {
  59916. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59917. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59918. export * from "babylonjs/Meshes/Builders/discBuilder";
  59919. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59920. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59921. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59922. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59923. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59924. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59925. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59926. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59927. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59928. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59929. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59930. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59931. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59932. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59933. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59934. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59935. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59936. }
  59937. declare module "babylonjs/Meshes/index" {
  59938. export * from "babylonjs/Meshes/abstractMesh";
  59939. export * from "babylonjs/Meshes/buffer";
  59940. export * from "babylonjs/Meshes/Compression/index";
  59941. export * from "babylonjs/Meshes/csg";
  59942. export * from "babylonjs/Meshes/geometry";
  59943. export * from "babylonjs/Meshes/groundMesh";
  59944. export * from "babylonjs/Meshes/trailMesh";
  59945. export * from "babylonjs/Meshes/instancedMesh";
  59946. export * from "babylonjs/Meshes/linesMesh";
  59947. export * from "babylonjs/Meshes/mesh";
  59948. export * from "babylonjs/Meshes/mesh.vertexData";
  59949. export * from "babylonjs/Meshes/meshBuilder";
  59950. export * from "babylonjs/Meshes/meshSimplification";
  59951. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59952. export * from "babylonjs/Meshes/polygonMesh";
  59953. export * from "babylonjs/Meshes/subMesh";
  59954. export * from "babylonjs/Meshes/meshLODLevel";
  59955. export * from "babylonjs/Meshes/transformNode";
  59956. export * from "babylonjs/Meshes/Builders/index";
  59957. export * from "babylonjs/Meshes/dataBuffer";
  59958. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59959. }
  59960. declare module "babylonjs/Morph/index" {
  59961. export * from "babylonjs/Morph/morphTarget";
  59962. export * from "babylonjs/Morph/morphTargetManager";
  59963. }
  59964. declare module "babylonjs/Navigation/INavigationEngine" {
  59965. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59966. import { Vector3 } from "babylonjs/Maths/math";
  59967. import { Mesh } from "babylonjs/Meshes/mesh";
  59968. import { Scene } from "babylonjs/scene";
  59969. /**
  59970. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59971. */
  59972. export interface INavigationEnginePlugin {
  59973. /**
  59974. * plugin name
  59975. */
  59976. name: string;
  59977. /**
  59978. * Creates a navigation mesh
  59979. * @param meshes array of all the geometry used to compute the navigatio mesh
  59980. * @param parameters bunch of parameters used to filter geometry
  59981. */
  59982. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59983. /**
  59984. * Create a navigation mesh debug mesh
  59985. * @param scene is where the mesh will be added
  59986. * @returns debug display mesh
  59987. */
  59988. createDebugNavMesh(scene: Scene): Mesh;
  59989. /**
  59990. * Get a navigation mesh constrained position, closest to the parameter position
  59991. * @param position world position
  59992. * @returns the closest point to position constrained by the navigation mesh
  59993. */
  59994. getClosestPoint(position: Vector3): Vector3;
  59995. /**
  59996. * Get a navigation mesh constrained position, within a particular radius
  59997. * @param position world position
  59998. * @param maxRadius the maximum distance to the constrained world position
  59999. * @returns the closest point to position constrained by the navigation mesh
  60000. */
  60001. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60002. /**
  60003. * Compute the final position from a segment made of destination-position
  60004. * @param position world position
  60005. * @param destination world position
  60006. * @returns the resulting point along the navmesh
  60007. */
  60008. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60009. /**
  60010. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60011. * @param start world position
  60012. * @param end world position
  60013. * @returns array containing world position composing the path
  60014. */
  60015. computePath(start: Vector3, end: Vector3): Vector3[];
  60016. /**
  60017. * If this plugin is supported
  60018. * @returns true if plugin is supported
  60019. */
  60020. isSupported(): boolean;
  60021. /**
  60022. * Create a new Crowd so you can add agents
  60023. * @param maxAgents the maximum agent count in the crowd
  60024. * @param maxAgentRadius the maximum radius an agent can have
  60025. * @param scene to attach the crowd to
  60026. * @returns the crowd you can add agents to
  60027. */
  60028. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60029. /**
  60030. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60031. * The queries will try to find a solution within those bounds
  60032. * default is (1,1,1)
  60033. * @param extent x,y,z value that define the extent around the queries point of reference
  60034. */
  60035. setDefaultQueryExtent(extent: Vector3): void;
  60036. /**
  60037. * Get the Bounding box extent specified by setDefaultQueryExtent
  60038. * @returns the box extent values
  60039. */
  60040. getDefaultQueryExtent(): Vector3;
  60041. /**
  60042. * Release all resources
  60043. */
  60044. dispose(): void;
  60045. }
  60046. /**
  60047. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60048. */
  60049. export interface ICrowd {
  60050. /**
  60051. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60052. * You can attach anything to that node. The node position is updated in the scene update tick.
  60053. * @param pos world position that will be constrained by the navigation mesh
  60054. * @param parameters agent parameters
  60055. * @param transform hooked to the agent that will be update by the scene
  60056. * @returns agent index
  60057. */
  60058. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60059. /**
  60060. * Returns the agent position in world space
  60061. * @param index agent index returned by addAgent
  60062. * @returns world space position
  60063. */
  60064. getAgentPosition(index: number): Vector3;
  60065. /**
  60066. * Gets the agent velocity in world space
  60067. * @param index agent index returned by addAgent
  60068. * @returns world space velocity
  60069. */
  60070. getAgentVelocity(index: number): Vector3;
  60071. /**
  60072. * remove a particular agent previously created
  60073. * @param index agent index returned by addAgent
  60074. */
  60075. removeAgent(index: number): void;
  60076. /**
  60077. * get the list of all agents attached to this crowd
  60078. * @returns list of agent indices
  60079. */
  60080. getAgents(): number[];
  60081. /**
  60082. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60083. * @param deltaTime in seconds
  60084. */
  60085. update(deltaTime: number): void;
  60086. /**
  60087. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60088. * @param index agent index returned by addAgent
  60089. * @param destination targeted world position
  60090. */
  60091. agentGoto(index: number, destination: Vector3): void;
  60092. /**
  60093. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60094. * The queries will try to find a solution within those bounds
  60095. * default is (1,1,1)
  60096. * @param extent x,y,z value that define the extent around the queries point of reference
  60097. */
  60098. setDefaultQueryExtent(extent: Vector3): void;
  60099. /**
  60100. * Get the Bounding box extent specified by setDefaultQueryExtent
  60101. * @returns the box extent values
  60102. */
  60103. getDefaultQueryExtent(): Vector3;
  60104. /**
  60105. * Release all resources
  60106. */
  60107. dispose(): void;
  60108. }
  60109. /**
  60110. * Configures an agent
  60111. */
  60112. export interface IAgentParameters {
  60113. /**
  60114. * Agent radius. [Limit: >= 0]
  60115. */
  60116. radius: number;
  60117. /**
  60118. * Agent height. [Limit: > 0]
  60119. */
  60120. height: number;
  60121. /**
  60122. * Maximum allowed acceleration. [Limit: >= 0]
  60123. */
  60124. maxAcceleration: number;
  60125. /**
  60126. * Maximum allowed speed. [Limit: >= 0]
  60127. */
  60128. maxSpeed: number;
  60129. /**
  60130. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60131. */
  60132. collisionQueryRange: number;
  60133. /**
  60134. * The path visibility optimization range. [Limit: > 0]
  60135. */
  60136. pathOptimizationRange: number;
  60137. /**
  60138. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60139. */
  60140. separationWeight: number;
  60141. }
  60142. /**
  60143. * Configures the navigation mesh creation
  60144. */
  60145. export interface INavMeshParameters {
  60146. /**
  60147. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60148. */
  60149. cs: number;
  60150. /**
  60151. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60152. */
  60153. ch: number;
  60154. /**
  60155. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60156. */
  60157. walkableSlopeAngle: number;
  60158. /**
  60159. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60160. * be considered walkable. [Limit: >= 3] [Units: vx]
  60161. */
  60162. walkableHeight: number;
  60163. /**
  60164. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60165. */
  60166. walkableClimb: number;
  60167. /**
  60168. * The distance to erode/shrink the walkable area of the heightfield away from
  60169. * obstructions. [Limit: >=0] [Units: vx]
  60170. */
  60171. walkableRadius: number;
  60172. /**
  60173. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60174. */
  60175. maxEdgeLen: number;
  60176. /**
  60177. * The maximum distance a simplfied contour's border edges should deviate
  60178. * the original raw contour. [Limit: >=0] [Units: vx]
  60179. */
  60180. maxSimplificationError: number;
  60181. /**
  60182. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60183. */
  60184. minRegionArea: number;
  60185. /**
  60186. * Any regions with a span count smaller than this value will, if possible,
  60187. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60188. */
  60189. mergeRegionArea: number;
  60190. /**
  60191. * The maximum number of vertices allowed for polygons generated during the
  60192. * contour to polygon conversion process. [Limit: >= 3]
  60193. */
  60194. maxVertsPerPoly: number;
  60195. /**
  60196. * Sets the sampling distance to use when generating the detail mesh.
  60197. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60198. */
  60199. detailSampleDist: number;
  60200. /**
  60201. * The maximum distance the detail mesh surface should deviate from heightfield
  60202. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60203. */
  60204. detailSampleMaxError: number;
  60205. }
  60206. }
  60207. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60208. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60209. import { Mesh } from "babylonjs/Meshes/mesh";
  60210. import { Scene } from "babylonjs/scene";
  60211. import { Vector3 } from "babylonjs/Maths/math";
  60212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60213. /**
  60214. * RecastJS navigation plugin
  60215. */
  60216. export class RecastJSPlugin implements INavigationEnginePlugin {
  60217. /**
  60218. * Reference to the Recast library
  60219. */
  60220. bjsRECAST: any;
  60221. /**
  60222. * plugin name
  60223. */
  60224. name: string;
  60225. /**
  60226. * the first navmesh created. We might extend this to support multiple navmeshes
  60227. */
  60228. navMesh: any;
  60229. /**
  60230. * Initializes the recastJS plugin
  60231. * @param recastInjection can be used to inject your own recast reference
  60232. */
  60233. constructor(recastInjection?: any);
  60234. /**
  60235. * Creates a navigation mesh
  60236. * @param meshes array of all the geometry used to compute the navigatio mesh
  60237. * @param parameters bunch of parameters used to filter geometry
  60238. */
  60239. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60240. /**
  60241. * Create a navigation mesh debug mesh
  60242. * @param scene is where the mesh will be added
  60243. * @returns debug display mesh
  60244. */
  60245. createDebugNavMesh(scene: Scene): Mesh;
  60246. /**
  60247. * Get a navigation mesh constrained position, closest to the parameter position
  60248. * @param position world position
  60249. * @returns the closest point to position constrained by the navigation mesh
  60250. */
  60251. getClosestPoint(position: Vector3): Vector3;
  60252. /**
  60253. * Get a navigation mesh constrained position, within a particular radius
  60254. * @param position world position
  60255. * @param maxRadius the maximum distance to the constrained world position
  60256. * @returns the closest point to position constrained by the navigation mesh
  60257. */
  60258. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60259. /**
  60260. * Compute the final position from a segment made of destination-position
  60261. * @param position world position
  60262. * @param destination world position
  60263. * @returns the resulting point along the navmesh
  60264. */
  60265. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60266. /**
  60267. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60268. * @param start world position
  60269. * @param end world position
  60270. * @returns array containing world position composing the path
  60271. */
  60272. computePath(start: Vector3, end: Vector3): Vector3[];
  60273. /**
  60274. * Create a new Crowd so you can add agents
  60275. * @param maxAgents the maximum agent count in the crowd
  60276. * @param maxAgentRadius the maximum radius an agent can have
  60277. * @param scene to attach the crowd to
  60278. * @returns the crowd you can add agents to
  60279. */
  60280. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60281. /**
  60282. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60283. * The queries will try to find a solution within those bounds
  60284. * default is (1,1,1)
  60285. * @param extent x,y,z value that define the extent around the queries point of reference
  60286. */
  60287. setDefaultQueryExtent(extent: Vector3): void;
  60288. /**
  60289. * Get the Bounding box extent specified by setDefaultQueryExtent
  60290. * @returns the box extent values
  60291. */
  60292. getDefaultQueryExtent(): Vector3;
  60293. /**
  60294. * Disposes
  60295. */
  60296. dispose(): void;
  60297. /**
  60298. * If this plugin is supported
  60299. * @returns true if plugin is supported
  60300. */
  60301. isSupported(): boolean;
  60302. }
  60303. /**
  60304. * Recast detour crowd implementation
  60305. */
  60306. export class RecastJSCrowd implements ICrowd {
  60307. /**
  60308. * Recast/detour plugin
  60309. */
  60310. bjsRECASTPlugin: RecastJSPlugin;
  60311. /**
  60312. * Link to the detour crowd
  60313. */
  60314. recastCrowd: any;
  60315. /**
  60316. * One transform per agent
  60317. */
  60318. transforms: TransformNode[];
  60319. /**
  60320. * All agents created
  60321. */
  60322. agents: number[];
  60323. /**
  60324. * Link to the scene is kept to unregister the crowd from the scene
  60325. */
  60326. private _scene;
  60327. /**
  60328. * Observer for crowd updates
  60329. */
  60330. private _onBeforeAnimationsObserver;
  60331. /**
  60332. * Constructor
  60333. * @param plugin recastJS plugin
  60334. * @param maxAgents the maximum agent count in the crowd
  60335. * @param maxAgentRadius the maximum radius an agent can have
  60336. * @param scene to attach the crowd to
  60337. * @returns the crowd you can add agents to
  60338. */
  60339. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60340. /**
  60341. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60342. * You can attach anything to that node. The node position is updated in the scene update tick.
  60343. * @param pos world position that will be constrained by the navigation mesh
  60344. * @param parameters agent parameters
  60345. * @param transform hooked to the agent that will be update by the scene
  60346. * @returns agent index
  60347. */
  60348. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60349. /**
  60350. * Returns the agent position in world space
  60351. * @param index agent index returned by addAgent
  60352. * @returns world space position
  60353. */
  60354. getAgentPosition(index: number): Vector3;
  60355. /**
  60356. * Returns the agent velocity in world space
  60357. * @param index agent index returned by addAgent
  60358. * @returns world space velocity
  60359. */
  60360. getAgentVelocity(index: number): Vector3;
  60361. /**
  60362. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60363. * @param index agent index returned by addAgent
  60364. * @param destination targeted world position
  60365. */
  60366. agentGoto(index: number, destination: Vector3): void;
  60367. /**
  60368. * remove a particular agent previously created
  60369. * @param index agent index returned by addAgent
  60370. */
  60371. removeAgent(index: number): void;
  60372. /**
  60373. * get the list of all agents attached to this crowd
  60374. * @returns list of agent indices
  60375. */
  60376. getAgents(): number[];
  60377. /**
  60378. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60379. * @param deltaTime in seconds
  60380. */
  60381. update(deltaTime: number): void;
  60382. /**
  60383. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60384. * The queries will try to find a solution within those bounds
  60385. * default is (1,1,1)
  60386. * @param extent x,y,z value that define the extent around the queries point of reference
  60387. */
  60388. setDefaultQueryExtent(extent: Vector3): void;
  60389. /**
  60390. * Get the Bounding box extent specified by setDefaultQueryExtent
  60391. * @returns the box extent values
  60392. */
  60393. getDefaultQueryExtent(): Vector3;
  60394. /**
  60395. * Release all resources
  60396. */
  60397. dispose(): void;
  60398. }
  60399. }
  60400. declare module "babylonjs/Navigation/Plugins/index" {
  60401. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60402. }
  60403. declare module "babylonjs/Navigation/index" {
  60404. export * from "babylonjs/Navigation/INavigationEngine";
  60405. export * from "babylonjs/Navigation/Plugins/index";
  60406. }
  60407. declare module "babylonjs/Offline/database" {
  60408. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60409. /**
  60410. * Class used to enable access to IndexedDB
  60411. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60412. */
  60413. export class Database implements IOfflineProvider {
  60414. private _callbackManifestChecked;
  60415. private _currentSceneUrl;
  60416. private _db;
  60417. private _enableSceneOffline;
  60418. private _enableTexturesOffline;
  60419. private _manifestVersionFound;
  60420. private _mustUpdateRessources;
  60421. private _hasReachedQuota;
  60422. private _isSupported;
  60423. private _idbFactory;
  60424. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60425. private static IsUASupportingBlobStorage;
  60426. /**
  60427. * Gets a boolean indicating if Database storate is enabled (off by default)
  60428. */
  60429. static IDBStorageEnabled: boolean;
  60430. /**
  60431. * Gets a boolean indicating if scene must be saved in the database
  60432. */
  60433. readonly enableSceneOffline: boolean;
  60434. /**
  60435. * Gets a boolean indicating if textures must be saved in the database
  60436. */
  60437. readonly enableTexturesOffline: boolean;
  60438. /**
  60439. * Creates a new Database
  60440. * @param urlToScene defines the url to load the scene
  60441. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60442. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60443. */
  60444. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60445. private static _ParseURL;
  60446. private static _ReturnFullUrlLocation;
  60447. private _checkManifestFile;
  60448. /**
  60449. * Open the database and make it available
  60450. * @param successCallback defines the callback to call on success
  60451. * @param errorCallback defines the callback to call on error
  60452. */
  60453. open(successCallback: () => void, errorCallback: () => void): void;
  60454. /**
  60455. * Loads an image from the database
  60456. * @param url defines the url to load from
  60457. * @param image defines the target DOM image
  60458. */
  60459. loadImage(url: string, image: HTMLImageElement): void;
  60460. private _loadImageFromDBAsync;
  60461. private _saveImageIntoDBAsync;
  60462. private _checkVersionFromDB;
  60463. private _loadVersionFromDBAsync;
  60464. private _saveVersionIntoDBAsync;
  60465. /**
  60466. * Loads a file from database
  60467. * @param url defines the URL to load from
  60468. * @param sceneLoaded defines a callback to call on success
  60469. * @param progressCallBack defines a callback to call when progress changed
  60470. * @param errorCallback defines a callback to call on error
  60471. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60472. */
  60473. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60474. private _loadFileAsync;
  60475. private _saveFileAsync;
  60476. /**
  60477. * Validates if xhr data is correct
  60478. * @param xhr defines the request to validate
  60479. * @param dataType defines the expected data type
  60480. * @returns true if data is correct
  60481. */
  60482. private static _ValidateXHRData;
  60483. }
  60484. }
  60485. declare module "babylonjs/Offline/index" {
  60486. export * from "babylonjs/Offline/database";
  60487. export * from "babylonjs/Offline/IOfflineProvider";
  60488. }
  60489. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60490. /** @hidden */
  60491. export var gpuUpdateParticlesPixelShader: {
  60492. name: string;
  60493. shader: string;
  60494. };
  60495. }
  60496. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60497. /** @hidden */
  60498. export var gpuUpdateParticlesVertexShader: {
  60499. name: string;
  60500. shader: string;
  60501. };
  60502. }
  60503. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60504. /** @hidden */
  60505. export var clipPlaneFragmentDeclaration2: {
  60506. name: string;
  60507. shader: string;
  60508. };
  60509. }
  60510. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60511. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60512. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60513. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60514. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60515. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60516. /** @hidden */
  60517. export var gpuRenderParticlesPixelShader: {
  60518. name: string;
  60519. shader: string;
  60520. };
  60521. }
  60522. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60523. /** @hidden */
  60524. export var clipPlaneVertexDeclaration2: {
  60525. name: string;
  60526. shader: string;
  60527. };
  60528. }
  60529. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60531. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60532. /** @hidden */
  60533. export var gpuRenderParticlesVertexShader: {
  60534. name: string;
  60535. shader: string;
  60536. };
  60537. }
  60538. declare module "babylonjs/Particles/gpuParticleSystem" {
  60539. import { Nullable } from "babylonjs/types";
  60540. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60541. import { Observable } from "babylonjs/Misc/observable";
  60542. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60543. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60544. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60545. import { Scene, IDisposable } from "babylonjs/scene";
  60546. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60548. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60549. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60550. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60551. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60552. /**
  60553. * This represents a GPU particle system in Babylon
  60554. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60555. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60556. */
  60557. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60558. /**
  60559. * The layer mask we are rendering the particles through.
  60560. */
  60561. layerMask: number;
  60562. private _capacity;
  60563. private _activeCount;
  60564. private _currentActiveCount;
  60565. private _accumulatedCount;
  60566. private _renderEffect;
  60567. private _updateEffect;
  60568. private _buffer0;
  60569. private _buffer1;
  60570. private _spriteBuffer;
  60571. private _updateVAO;
  60572. private _renderVAO;
  60573. private _targetIndex;
  60574. private _sourceBuffer;
  60575. private _targetBuffer;
  60576. private _engine;
  60577. private _currentRenderId;
  60578. private _started;
  60579. private _stopped;
  60580. private _timeDelta;
  60581. private _randomTexture;
  60582. private _randomTexture2;
  60583. private _attributesStrideSize;
  60584. private _updateEffectOptions;
  60585. private _randomTextureSize;
  60586. private _actualFrame;
  60587. private readonly _rawTextureWidth;
  60588. /**
  60589. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60590. */
  60591. static readonly IsSupported: boolean;
  60592. /**
  60593. * An event triggered when the system is disposed.
  60594. */
  60595. onDisposeObservable: Observable<GPUParticleSystem>;
  60596. /**
  60597. * Gets the maximum number of particles active at the same time.
  60598. * @returns The max number of active particles.
  60599. */
  60600. getCapacity(): number;
  60601. /**
  60602. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60603. * to override the particles.
  60604. */
  60605. forceDepthWrite: boolean;
  60606. /**
  60607. * Gets or set the number of active particles
  60608. */
  60609. activeParticleCount: number;
  60610. private _preWarmDone;
  60611. /**
  60612. * Is this system ready to be used/rendered
  60613. * @return true if the system is ready
  60614. */
  60615. isReady(): boolean;
  60616. /**
  60617. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60618. * @returns True if it has been started, otherwise false.
  60619. */
  60620. isStarted(): boolean;
  60621. /**
  60622. * Starts the particle system and begins to emit
  60623. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60624. */
  60625. start(delay?: number): void;
  60626. /**
  60627. * Stops the particle system.
  60628. */
  60629. stop(): void;
  60630. /**
  60631. * Remove all active particles
  60632. */
  60633. reset(): void;
  60634. /**
  60635. * Returns the string "GPUParticleSystem"
  60636. * @returns a string containing the class name
  60637. */
  60638. getClassName(): string;
  60639. private _colorGradientsTexture;
  60640. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60641. /**
  60642. * Adds a new color gradient
  60643. * @param gradient defines the gradient to use (between 0 and 1)
  60644. * @param color1 defines the color to affect to the specified gradient
  60645. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60646. * @returns the current particle system
  60647. */
  60648. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60649. /**
  60650. * Remove a specific color gradient
  60651. * @param gradient defines the gradient to remove
  60652. * @returns the current particle system
  60653. */
  60654. removeColorGradient(gradient: number): GPUParticleSystem;
  60655. private _angularSpeedGradientsTexture;
  60656. private _sizeGradientsTexture;
  60657. private _velocityGradientsTexture;
  60658. private _limitVelocityGradientsTexture;
  60659. private _dragGradientsTexture;
  60660. private _addFactorGradient;
  60661. /**
  60662. * Adds a new size gradient
  60663. * @param gradient defines the gradient to use (between 0 and 1)
  60664. * @param factor defines the size factor to affect to the specified gradient
  60665. * @returns the current particle system
  60666. */
  60667. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60668. /**
  60669. * Remove a specific size gradient
  60670. * @param gradient defines the gradient to remove
  60671. * @returns the current particle system
  60672. */
  60673. removeSizeGradient(gradient: number): GPUParticleSystem;
  60674. /**
  60675. * Adds a new angular speed gradient
  60676. * @param gradient defines the gradient to use (between 0 and 1)
  60677. * @param factor defines the angular speed to affect to the specified gradient
  60678. * @returns the current particle system
  60679. */
  60680. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60681. /**
  60682. * Remove a specific angular speed gradient
  60683. * @param gradient defines the gradient to remove
  60684. * @returns the current particle system
  60685. */
  60686. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60687. /**
  60688. * Adds a new velocity gradient
  60689. * @param gradient defines the gradient to use (between 0 and 1)
  60690. * @param factor defines the velocity to affect to the specified gradient
  60691. * @returns the current particle system
  60692. */
  60693. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60694. /**
  60695. * Remove a specific velocity gradient
  60696. * @param gradient defines the gradient to remove
  60697. * @returns the current particle system
  60698. */
  60699. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60700. /**
  60701. * Adds a new limit velocity gradient
  60702. * @param gradient defines the gradient to use (between 0 and 1)
  60703. * @param factor defines the limit velocity value to affect to the specified gradient
  60704. * @returns the current particle system
  60705. */
  60706. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60707. /**
  60708. * Remove a specific limit velocity gradient
  60709. * @param gradient defines the gradient to remove
  60710. * @returns the current particle system
  60711. */
  60712. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60713. /**
  60714. * Adds a new drag gradient
  60715. * @param gradient defines the gradient to use (between 0 and 1)
  60716. * @param factor defines the drag value to affect to the specified gradient
  60717. * @returns the current particle system
  60718. */
  60719. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60720. /**
  60721. * Remove a specific drag gradient
  60722. * @param gradient defines the gradient to remove
  60723. * @returns the current particle system
  60724. */
  60725. removeDragGradient(gradient: number): GPUParticleSystem;
  60726. /**
  60727. * Not supported by GPUParticleSystem
  60728. * @param gradient defines the gradient to use (between 0 and 1)
  60729. * @param factor defines the emit rate value to affect to the specified gradient
  60730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60731. * @returns the current particle system
  60732. */
  60733. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60734. /**
  60735. * Not supported by GPUParticleSystem
  60736. * @param gradient defines the gradient to remove
  60737. * @returns the current particle system
  60738. */
  60739. removeEmitRateGradient(gradient: number): IParticleSystem;
  60740. /**
  60741. * Not supported by GPUParticleSystem
  60742. * @param gradient defines the gradient to use (between 0 and 1)
  60743. * @param factor defines the start size value to affect to the specified gradient
  60744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60745. * @returns the current particle system
  60746. */
  60747. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60748. /**
  60749. * Not supported by GPUParticleSystem
  60750. * @param gradient defines the gradient to remove
  60751. * @returns the current particle system
  60752. */
  60753. removeStartSizeGradient(gradient: number): IParticleSystem;
  60754. /**
  60755. * Not supported by GPUParticleSystem
  60756. * @param gradient defines the gradient to use (between 0 and 1)
  60757. * @param min defines the color remap minimal range
  60758. * @param max defines the color remap maximal range
  60759. * @returns the current particle system
  60760. */
  60761. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60762. /**
  60763. * Not supported by GPUParticleSystem
  60764. * @param gradient defines the gradient to remove
  60765. * @returns the current particle system
  60766. */
  60767. removeColorRemapGradient(): IParticleSystem;
  60768. /**
  60769. * Not supported by GPUParticleSystem
  60770. * @param gradient defines the gradient to use (between 0 and 1)
  60771. * @param min defines the alpha remap minimal range
  60772. * @param max defines the alpha remap maximal range
  60773. * @returns the current particle system
  60774. */
  60775. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60776. /**
  60777. * Not supported by GPUParticleSystem
  60778. * @param gradient defines the gradient to remove
  60779. * @returns the current particle system
  60780. */
  60781. removeAlphaRemapGradient(): IParticleSystem;
  60782. /**
  60783. * Not supported by GPUParticleSystem
  60784. * @param gradient defines the gradient to use (between 0 and 1)
  60785. * @param color defines the color to affect to the specified gradient
  60786. * @returns the current particle system
  60787. */
  60788. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60789. /**
  60790. * Not supported by GPUParticleSystem
  60791. * @param gradient defines the gradient to remove
  60792. * @returns the current particle system
  60793. */
  60794. removeRampGradient(): IParticleSystem;
  60795. /**
  60796. * Not supported by GPUParticleSystem
  60797. * @returns the list of ramp gradients
  60798. */
  60799. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60800. /**
  60801. * Not supported by GPUParticleSystem
  60802. * Gets or sets a boolean indicating that ramp gradients must be used
  60803. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60804. */
  60805. useRampGradients: boolean;
  60806. /**
  60807. * Not supported by GPUParticleSystem
  60808. * @param gradient defines the gradient to use (between 0 and 1)
  60809. * @param factor defines the life time factor to affect to the specified gradient
  60810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60811. * @returns the current particle system
  60812. */
  60813. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60814. /**
  60815. * Not supported by GPUParticleSystem
  60816. * @param gradient defines the gradient to remove
  60817. * @returns the current particle system
  60818. */
  60819. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60820. /**
  60821. * Instantiates a GPU particle system.
  60822. * 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.
  60823. * @param name The name of the particle system
  60824. * @param options The options used to create the system
  60825. * @param scene The scene the particle system belongs to
  60826. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60827. */
  60828. constructor(name: string, options: Partial<{
  60829. capacity: number;
  60830. randomTextureSize: number;
  60831. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60832. protected _reset(): void;
  60833. private _createUpdateVAO;
  60834. private _createRenderVAO;
  60835. private _initialize;
  60836. /** @hidden */
  60837. _recreateUpdateEffect(): void;
  60838. /** @hidden */
  60839. _recreateRenderEffect(): void;
  60840. /**
  60841. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60842. * @param preWarm defines if we are in the pre-warmimg phase
  60843. */
  60844. animate(preWarm?: boolean): void;
  60845. private _createFactorGradientTexture;
  60846. private _createSizeGradientTexture;
  60847. private _createAngularSpeedGradientTexture;
  60848. private _createVelocityGradientTexture;
  60849. private _createLimitVelocityGradientTexture;
  60850. private _createDragGradientTexture;
  60851. private _createColorGradientTexture;
  60852. /**
  60853. * Renders the particle system in its current state
  60854. * @param preWarm defines if the system should only update the particles but not render them
  60855. * @returns the current number of particles
  60856. */
  60857. render(preWarm?: boolean): number;
  60858. /**
  60859. * Rebuilds the particle system
  60860. */
  60861. rebuild(): void;
  60862. private _releaseBuffers;
  60863. private _releaseVAOs;
  60864. /**
  60865. * Disposes the particle system and free the associated resources
  60866. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60867. */
  60868. dispose(disposeTexture?: boolean): void;
  60869. /**
  60870. * Clones the particle system.
  60871. * @param name The name of the cloned object
  60872. * @param newEmitter The new emitter to use
  60873. * @returns the cloned particle system
  60874. */
  60875. clone(name: string, newEmitter: any): GPUParticleSystem;
  60876. /**
  60877. * Serializes the particle system to a JSON object.
  60878. * @returns the JSON object
  60879. */
  60880. serialize(): any;
  60881. /**
  60882. * Parses a JSON object to create a GPU particle system.
  60883. * @param parsedParticleSystem The JSON object to parse
  60884. * @param scene The scene to create the particle system in
  60885. * @param rootUrl The root url to use to load external dependencies like texture
  60886. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60887. * @returns the parsed GPU particle system
  60888. */
  60889. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60890. }
  60891. }
  60892. declare module "babylonjs/Particles/particleSystemSet" {
  60893. import { Nullable } from "babylonjs/types";
  60894. import { Color3 } from "babylonjs/Maths/math.color";
  60895. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60897. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60898. import { Scene, IDisposable } from "babylonjs/scene";
  60899. /**
  60900. * Represents a set of particle systems working together to create a specific effect
  60901. */
  60902. export class ParticleSystemSet implements IDisposable {
  60903. private _emitterCreationOptions;
  60904. private _emitterNode;
  60905. /**
  60906. * Gets the particle system list
  60907. */
  60908. systems: IParticleSystem[];
  60909. /**
  60910. * Gets the emitter node used with this set
  60911. */
  60912. readonly emitterNode: Nullable<TransformNode>;
  60913. /**
  60914. * Creates a new emitter mesh as a sphere
  60915. * @param options defines the options used to create the sphere
  60916. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60917. * @param scene defines the hosting scene
  60918. */
  60919. setEmitterAsSphere(options: {
  60920. diameter: number;
  60921. segments: number;
  60922. color: Color3;
  60923. }, renderingGroupId: number, scene: Scene): void;
  60924. /**
  60925. * Starts all particle systems of the set
  60926. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60927. */
  60928. start(emitter?: AbstractMesh): void;
  60929. /**
  60930. * Release all associated resources
  60931. */
  60932. dispose(): void;
  60933. /**
  60934. * Serialize the set into a JSON compatible object
  60935. * @returns a JSON compatible representation of the set
  60936. */
  60937. serialize(): any;
  60938. /**
  60939. * Parse a new ParticleSystemSet from a serialized source
  60940. * @param data defines a JSON compatible representation of the set
  60941. * @param scene defines the hosting scene
  60942. * @param gpu defines if we want GPU particles or CPU particles
  60943. * @returns a new ParticleSystemSet
  60944. */
  60945. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60946. }
  60947. }
  60948. declare module "babylonjs/Particles/particleHelper" {
  60949. import { Nullable } from "babylonjs/types";
  60950. import { Scene } from "babylonjs/scene";
  60951. import { Vector3 } from "babylonjs/Maths/math.vector";
  60952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60953. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60954. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60955. /**
  60956. * This class is made for on one-liner static method to help creating particle system set.
  60957. */
  60958. export class ParticleHelper {
  60959. /**
  60960. * Gets or sets base Assets URL
  60961. */
  60962. static BaseAssetsUrl: string;
  60963. /**
  60964. * Create a default particle system that you can tweak
  60965. * @param emitter defines the emitter to use
  60966. * @param capacity defines the system capacity (default is 500 particles)
  60967. * @param scene defines the hosting scene
  60968. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60969. * @returns the new Particle system
  60970. */
  60971. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60972. /**
  60973. * This is the main static method (one-liner) of this helper to create different particle systems
  60974. * @param type This string represents the type to the particle system to create
  60975. * @param scene The scene where the particle system should live
  60976. * @param gpu If the system will use gpu
  60977. * @returns the ParticleSystemSet created
  60978. */
  60979. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60980. /**
  60981. * Static function used to export a particle system to a ParticleSystemSet variable.
  60982. * Please note that the emitter shape is not exported
  60983. * @param systems defines the particle systems to export
  60984. * @returns the created particle system set
  60985. */
  60986. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60987. }
  60988. }
  60989. declare module "babylonjs/Particles/particleSystemComponent" {
  60990. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60991. import { Effect } from "babylonjs/Materials/effect";
  60992. import "babylonjs/Shaders/particles.vertex";
  60993. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60994. module "babylonjs/Engines/engine" {
  60995. interface Engine {
  60996. /**
  60997. * Create an effect to use with particle systems.
  60998. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60999. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61000. * @param uniformsNames defines a list of attribute names
  61001. * @param samplers defines an array of string used to represent textures
  61002. * @param defines defines the string containing the defines to use to compile the shaders
  61003. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61004. * @param onCompiled defines a function to call when the effect creation is successful
  61005. * @param onError defines a function to call when the effect creation has failed
  61006. * @returns the new Effect
  61007. */
  61008. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61009. }
  61010. }
  61011. module "babylonjs/Meshes/mesh" {
  61012. interface Mesh {
  61013. /**
  61014. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61015. * @returns an array of IParticleSystem
  61016. */
  61017. getEmittedParticleSystems(): IParticleSystem[];
  61018. /**
  61019. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61020. * @returns an array of IParticleSystem
  61021. */
  61022. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61023. }
  61024. }
  61025. /**
  61026. * @hidden
  61027. */
  61028. export var _IDoNeedToBeInTheBuild: number;
  61029. }
  61030. declare module "babylonjs/Particles/index" {
  61031. export * from "babylonjs/Particles/baseParticleSystem";
  61032. export * from "babylonjs/Particles/EmitterTypes/index";
  61033. export * from "babylonjs/Particles/gpuParticleSystem";
  61034. export * from "babylonjs/Particles/IParticleSystem";
  61035. export * from "babylonjs/Particles/particle";
  61036. export * from "babylonjs/Particles/particleHelper";
  61037. export * from "babylonjs/Particles/particleSystem";
  61038. export * from "babylonjs/Particles/particleSystemComponent";
  61039. export * from "babylonjs/Particles/particleSystemSet";
  61040. export * from "babylonjs/Particles/solidParticle";
  61041. export * from "babylonjs/Particles/solidParticleSystem";
  61042. export * from "babylonjs/Particles/subEmitter";
  61043. }
  61044. declare module "babylonjs/Physics/physicsEngineComponent" {
  61045. import { Nullable } from "babylonjs/types";
  61046. import { Observable, Observer } from "babylonjs/Misc/observable";
  61047. import { Vector3 } from "babylonjs/Maths/math.vector";
  61048. import { Mesh } from "babylonjs/Meshes/mesh";
  61049. import { ISceneComponent } from "babylonjs/sceneComponent";
  61050. import { Scene } from "babylonjs/scene";
  61051. import { Node } from "babylonjs/node";
  61052. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61053. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61054. module "babylonjs/scene" {
  61055. interface Scene {
  61056. /** @hidden (Backing field) */
  61057. _physicsEngine: Nullable<IPhysicsEngine>;
  61058. /**
  61059. * Gets the current physics engine
  61060. * @returns a IPhysicsEngine or null if none attached
  61061. */
  61062. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61063. /**
  61064. * Enables physics to the current scene
  61065. * @param gravity defines the scene's gravity for the physics engine
  61066. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61067. * @return a boolean indicating if the physics engine was initialized
  61068. */
  61069. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61070. /**
  61071. * Disables and disposes the physics engine associated with the scene
  61072. */
  61073. disablePhysicsEngine(): void;
  61074. /**
  61075. * Gets a boolean indicating if there is an active physics engine
  61076. * @returns a boolean indicating if there is an active physics engine
  61077. */
  61078. isPhysicsEnabled(): boolean;
  61079. /**
  61080. * Deletes a physics compound impostor
  61081. * @param compound defines the compound to delete
  61082. */
  61083. deleteCompoundImpostor(compound: any): void;
  61084. /**
  61085. * An event triggered when physic simulation is about to be run
  61086. */
  61087. onBeforePhysicsObservable: Observable<Scene>;
  61088. /**
  61089. * An event triggered when physic simulation has been done
  61090. */
  61091. onAfterPhysicsObservable: Observable<Scene>;
  61092. }
  61093. }
  61094. module "babylonjs/Meshes/abstractMesh" {
  61095. interface AbstractMesh {
  61096. /** @hidden */
  61097. _physicsImpostor: Nullable<PhysicsImpostor>;
  61098. /**
  61099. * Gets or sets impostor used for physic simulation
  61100. * @see http://doc.babylonjs.com/features/physics_engine
  61101. */
  61102. physicsImpostor: Nullable<PhysicsImpostor>;
  61103. /**
  61104. * Gets the current physics impostor
  61105. * @see http://doc.babylonjs.com/features/physics_engine
  61106. * @returns a physics impostor or null
  61107. */
  61108. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61109. /** Apply a physic impulse to the mesh
  61110. * @param force defines the force to apply
  61111. * @param contactPoint defines where to apply the force
  61112. * @returns the current mesh
  61113. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61114. */
  61115. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61116. /**
  61117. * Creates a physic joint between two meshes
  61118. * @param otherMesh defines the other mesh to use
  61119. * @param pivot1 defines the pivot to use on this mesh
  61120. * @param pivot2 defines the pivot to use on the other mesh
  61121. * @param options defines additional options (can be plugin dependent)
  61122. * @returns the current mesh
  61123. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61124. */
  61125. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61126. /** @hidden */
  61127. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61128. }
  61129. }
  61130. /**
  61131. * Defines the physics engine scene component responsible to manage a physics engine
  61132. */
  61133. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61134. /**
  61135. * The component name helpful to identify the component in the list of scene components.
  61136. */
  61137. readonly name: string;
  61138. /**
  61139. * The scene the component belongs to.
  61140. */
  61141. scene: Scene;
  61142. /**
  61143. * Creates a new instance of the component for the given scene
  61144. * @param scene Defines the scene to register the component in
  61145. */
  61146. constructor(scene: Scene);
  61147. /**
  61148. * Registers the component in a given scene
  61149. */
  61150. register(): void;
  61151. /**
  61152. * Rebuilds the elements related to this component in case of
  61153. * context lost for instance.
  61154. */
  61155. rebuild(): void;
  61156. /**
  61157. * Disposes the component and the associated ressources
  61158. */
  61159. dispose(): void;
  61160. }
  61161. }
  61162. declare module "babylonjs/Physics/physicsHelper" {
  61163. import { Nullable } from "babylonjs/types";
  61164. import { Vector3 } from "babylonjs/Maths/math.vector";
  61165. import { Mesh } from "babylonjs/Meshes/mesh";
  61166. import { Scene } from "babylonjs/scene";
  61167. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61168. /**
  61169. * A helper for physics simulations
  61170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61171. */
  61172. export class PhysicsHelper {
  61173. private _scene;
  61174. private _physicsEngine;
  61175. /**
  61176. * Initializes the Physics helper
  61177. * @param scene Babylon.js scene
  61178. */
  61179. constructor(scene: Scene);
  61180. /**
  61181. * Applies a radial explosion impulse
  61182. * @param origin the origin of the explosion
  61183. * @param radiusOrEventOptions the radius or the options of radial explosion
  61184. * @param strength the explosion strength
  61185. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61186. * @returns A physics radial explosion event, or null
  61187. */
  61188. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61189. /**
  61190. * Applies a radial explosion force
  61191. * @param origin the origin of the explosion
  61192. * @param radiusOrEventOptions the radius or the options of radial explosion
  61193. * @param strength the explosion strength
  61194. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61195. * @returns A physics radial explosion event, or null
  61196. */
  61197. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61198. /**
  61199. * Creates a gravitational field
  61200. * @param origin the origin of the explosion
  61201. * @param radiusOrEventOptions the radius or the options of radial explosion
  61202. * @param strength the explosion strength
  61203. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61204. * @returns A physics gravitational field event, or null
  61205. */
  61206. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61207. /**
  61208. * Creates a physics updraft event
  61209. * @param origin the origin of the updraft
  61210. * @param radiusOrEventOptions the radius or the options of the updraft
  61211. * @param strength the strength of the updraft
  61212. * @param height the height of the updraft
  61213. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61214. * @returns A physics updraft event, or null
  61215. */
  61216. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61217. /**
  61218. * Creates a physics vortex event
  61219. * @param origin the of the vortex
  61220. * @param radiusOrEventOptions the radius or the options of the vortex
  61221. * @param strength the strength of the vortex
  61222. * @param height the height of the vortex
  61223. * @returns a Physics vortex event, or null
  61224. * A physics vortex event or null
  61225. */
  61226. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61227. }
  61228. /**
  61229. * Represents a physics radial explosion event
  61230. */
  61231. class PhysicsRadialExplosionEvent {
  61232. private _scene;
  61233. private _options;
  61234. private _sphere;
  61235. private _dataFetched;
  61236. /**
  61237. * Initializes a radial explosioin event
  61238. * @param _scene BabylonJS scene
  61239. * @param _options The options for the vortex event
  61240. */
  61241. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61242. /**
  61243. * Returns the data related to the radial explosion event (sphere).
  61244. * @returns The radial explosion event data
  61245. */
  61246. getData(): PhysicsRadialExplosionEventData;
  61247. /**
  61248. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61249. * @param impostor A physics imposter
  61250. * @param origin the origin of the explosion
  61251. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61252. */
  61253. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61254. /**
  61255. * Triggers affecterd impostors callbacks
  61256. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61257. */
  61258. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61259. /**
  61260. * Disposes the sphere.
  61261. * @param force Specifies if the sphere should be disposed by force
  61262. */
  61263. dispose(force?: boolean): void;
  61264. /*** Helpers ***/
  61265. private _prepareSphere;
  61266. private _intersectsWithSphere;
  61267. }
  61268. /**
  61269. * Represents a gravitational field event
  61270. */
  61271. class PhysicsGravitationalFieldEvent {
  61272. private _physicsHelper;
  61273. private _scene;
  61274. private _origin;
  61275. private _options;
  61276. private _tickCallback;
  61277. private _sphere;
  61278. private _dataFetched;
  61279. /**
  61280. * Initializes the physics gravitational field event
  61281. * @param _physicsHelper A physics helper
  61282. * @param _scene BabylonJS scene
  61283. * @param _origin The origin position of the gravitational field event
  61284. * @param _options The options for the vortex event
  61285. */
  61286. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61287. /**
  61288. * Returns the data related to the gravitational field event (sphere).
  61289. * @returns A gravitational field event
  61290. */
  61291. getData(): PhysicsGravitationalFieldEventData;
  61292. /**
  61293. * Enables the gravitational field.
  61294. */
  61295. enable(): void;
  61296. /**
  61297. * Disables the gravitational field.
  61298. */
  61299. disable(): void;
  61300. /**
  61301. * Disposes the sphere.
  61302. * @param force The force to dispose from the gravitational field event
  61303. */
  61304. dispose(force?: boolean): void;
  61305. private _tick;
  61306. }
  61307. /**
  61308. * Represents a physics updraft event
  61309. */
  61310. class PhysicsUpdraftEvent {
  61311. private _scene;
  61312. private _origin;
  61313. private _options;
  61314. private _physicsEngine;
  61315. private _originTop;
  61316. private _originDirection;
  61317. private _tickCallback;
  61318. private _cylinder;
  61319. private _cylinderPosition;
  61320. private _dataFetched;
  61321. /**
  61322. * Initializes the physics updraft event
  61323. * @param _scene BabylonJS scene
  61324. * @param _origin The origin position of the updraft
  61325. * @param _options The options for the updraft event
  61326. */
  61327. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61328. /**
  61329. * Returns the data related to the updraft event (cylinder).
  61330. * @returns A physics updraft event
  61331. */
  61332. getData(): PhysicsUpdraftEventData;
  61333. /**
  61334. * Enables the updraft.
  61335. */
  61336. enable(): void;
  61337. /**
  61338. * Disables the updraft.
  61339. */
  61340. disable(): void;
  61341. /**
  61342. * Disposes the cylinder.
  61343. * @param force Specifies if the updraft should be disposed by force
  61344. */
  61345. dispose(force?: boolean): void;
  61346. private getImpostorHitData;
  61347. private _tick;
  61348. /*** Helpers ***/
  61349. private _prepareCylinder;
  61350. private _intersectsWithCylinder;
  61351. }
  61352. /**
  61353. * Represents a physics vortex event
  61354. */
  61355. class PhysicsVortexEvent {
  61356. private _scene;
  61357. private _origin;
  61358. private _options;
  61359. private _physicsEngine;
  61360. private _originTop;
  61361. private _tickCallback;
  61362. private _cylinder;
  61363. private _cylinderPosition;
  61364. private _dataFetched;
  61365. /**
  61366. * Initializes the physics vortex event
  61367. * @param _scene The BabylonJS scene
  61368. * @param _origin The origin position of the vortex
  61369. * @param _options The options for the vortex event
  61370. */
  61371. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61372. /**
  61373. * Returns the data related to the vortex event (cylinder).
  61374. * @returns The physics vortex event data
  61375. */
  61376. getData(): PhysicsVortexEventData;
  61377. /**
  61378. * Enables the vortex.
  61379. */
  61380. enable(): void;
  61381. /**
  61382. * Disables the cortex.
  61383. */
  61384. disable(): void;
  61385. /**
  61386. * Disposes the sphere.
  61387. * @param force
  61388. */
  61389. dispose(force?: boolean): void;
  61390. private getImpostorHitData;
  61391. private _tick;
  61392. /*** Helpers ***/
  61393. private _prepareCylinder;
  61394. private _intersectsWithCylinder;
  61395. }
  61396. /**
  61397. * Options fot the radial explosion event
  61398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61399. */
  61400. export class PhysicsRadialExplosionEventOptions {
  61401. /**
  61402. * The radius of the sphere for the radial explosion.
  61403. */
  61404. radius: number;
  61405. /**
  61406. * The strenth of the explosion.
  61407. */
  61408. strength: number;
  61409. /**
  61410. * The strenght of the force in correspondence to the distance of the affected object
  61411. */
  61412. falloff: PhysicsRadialImpulseFalloff;
  61413. /**
  61414. * Sphere options for the radial explosion.
  61415. */
  61416. sphere: {
  61417. segments: number;
  61418. diameter: number;
  61419. };
  61420. /**
  61421. * Sphere options for the radial explosion.
  61422. */
  61423. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61424. }
  61425. /**
  61426. * Options fot the updraft event
  61427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61428. */
  61429. export class PhysicsUpdraftEventOptions {
  61430. /**
  61431. * The radius of the cylinder for the vortex
  61432. */
  61433. radius: number;
  61434. /**
  61435. * The strenth of the updraft.
  61436. */
  61437. strength: number;
  61438. /**
  61439. * The height of the cylinder for the updraft.
  61440. */
  61441. height: number;
  61442. /**
  61443. * The mode for the the updraft.
  61444. */
  61445. updraftMode: PhysicsUpdraftMode;
  61446. }
  61447. /**
  61448. * Options fot the vortex event
  61449. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61450. */
  61451. export class PhysicsVortexEventOptions {
  61452. /**
  61453. * The radius of the cylinder for the vortex
  61454. */
  61455. radius: number;
  61456. /**
  61457. * The strenth of the vortex.
  61458. */
  61459. strength: number;
  61460. /**
  61461. * The height of the cylinder for the vortex.
  61462. */
  61463. height: number;
  61464. /**
  61465. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61466. */
  61467. centripetalForceThreshold: number;
  61468. /**
  61469. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61470. */
  61471. centripetalForceMultiplier: number;
  61472. /**
  61473. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61474. */
  61475. centrifugalForceMultiplier: number;
  61476. /**
  61477. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61478. */
  61479. updraftForceMultiplier: number;
  61480. }
  61481. /**
  61482. * The strenght of the force in correspondence to the distance of the affected object
  61483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61484. */
  61485. export enum PhysicsRadialImpulseFalloff {
  61486. /** Defines that impulse is constant in strength across it's whole radius */
  61487. Constant = 0,
  61488. /** Defines that impulse gets weaker if it's further from the origin */
  61489. Linear = 1
  61490. }
  61491. /**
  61492. * The strength of the force in correspondence to the distance of the affected object
  61493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61494. */
  61495. export enum PhysicsUpdraftMode {
  61496. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61497. Center = 0,
  61498. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61499. Perpendicular = 1
  61500. }
  61501. /**
  61502. * Interface for a physics hit data
  61503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61504. */
  61505. export interface PhysicsHitData {
  61506. /**
  61507. * The force applied at the contact point
  61508. */
  61509. force: Vector3;
  61510. /**
  61511. * The contact point
  61512. */
  61513. contactPoint: Vector3;
  61514. /**
  61515. * The distance from the origin to the contact point
  61516. */
  61517. distanceFromOrigin: number;
  61518. }
  61519. /**
  61520. * Interface for radial explosion event data
  61521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61522. */
  61523. export interface PhysicsRadialExplosionEventData {
  61524. /**
  61525. * A sphere used for the radial explosion event
  61526. */
  61527. sphere: Mesh;
  61528. }
  61529. /**
  61530. * Interface for gravitational field event data
  61531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61532. */
  61533. export interface PhysicsGravitationalFieldEventData {
  61534. /**
  61535. * A sphere mesh used for the gravitational field event
  61536. */
  61537. sphere: Mesh;
  61538. }
  61539. /**
  61540. * Interface for updraft event data
  61541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61542. */
  61543. export interface PhysicsUpdraftEventData {
  61544. /**
  61545. * A cylinder used for the updraft event
  61546. */
  61547. cylinder: Mesh;
  61548. }
  61549. /**
  61550. * Interface for vortex event data
  61551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61552. */
  61553. export interface PhysicsVortexEventData {
  61554. /**
  61555. * A cylinder used for the vortex event
  61556. */
  61557. cylinder: Mesh;
  61558. }
  61559. /**
  61560. * Interface for an affected physics impostor
  61561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61562. */
  61563. export interface PhysicsAffectedImpostorWithData {
  61564. /**
  61565. * The impostor affected by the effect
  61566. */
  61567. impostor: PhysicsImpostor;
  61568. /**
  61569. * The data about the hit/horce from the explosion
  61570. */
  61571. hitData: PhysicsHitData;
  61572. }
  61573. }
  61574. declare module "babylonjs/Physics/Plugins/index" {
  61575. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61576. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61577. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61578. }
  61579. declare module "babylonjs/Physics/index" {
  61580. export * from "babylonjs/Physics/IPhysicsEngine";
  61581. export * from "babylonjs/Physics/physicsEngine";
  61582. export * from "babylonjs/Physics/physicsEngineComponent";
  61583. export * from "babylonjs/Physics/physicsHelper";
  61584. export * from "babylonjs/Physics/physicsImpostor";
  61585. export * from "babylonjs/Physics/physicsJoint";
  61586. export * from "babylonjs/Physics/Plugins/index";
  61587. }
  61588. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61589. /** @hidden */
  61590. export var blackAndWhitePixelShader: {
  61591. name: string;
  61592. shader: string;
  61593. };
  61594. }
  61595. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61596. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61597. import { Camera } from "babylonjs/Cameras/camera";
  61598. import { Engine } from "babylonjs/Engines/engine";
  61599. import "babylonjs/Shaders/blackAndWhite.fragment";
  61600. /**
  61601. * Post process used to render in black and white
  61602. */
  61603. export class BlackAndWhitePostProcess extends PostProcess {
  61604. /**
  61605. * Linear about to convert he result to black and white (default: 1)
  61606. */
  61607. degree: number;
  61608. /**
  61609. * Creates a black and white post process
  61610. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61611. * @param name The name of the effect.
  61612. * @param options The required width/height ratio to downsize to before computing the render pass.
  61613. * @param camera The camera to apply the render pass to.
  61614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61615. * @param engine The engine which the post process will be applied. (default: current engine)
  61616. * @param reusable If the post process can be reused on the same frame. (default: false)
  61617. */
  61618. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61619. }
  61620. }
  61621. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61622. import { Nullable } from "babylonjs/types";
  61623. import { Camera } from "babylonjs/Cameras/camera";
  61624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61625. import { Engine } from "babylonjs/Engines/engine";
  61626. /**
  61627. * This represents a set of one or more post processes in Babylon.
  61628. * A post process can be used to apply a shader to a texture after it is rendered.
  61629. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61630. */
  61631. export class PostProcessRenderEffect {
  61632. private _postProcesses;
  61633. private _getPostProcesses;
  61634. private _singleInstance;
  61635. private _cameras;
  61636. private _indicesForCamera;
  61637. /**
  61638. * Name of the effect
  61639. * @hidden
  61640. */
  61641. _name: string;
  61642. /**
  61643. * Instantiates a post process render effect.
  61644. * A post process can be used to apply a shader to a texture after it is rendered.
  61645. * @param engine The engine the effect is tied to
  61646. * @param name The name of the effect
  61647. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61648. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61649. */
  61650. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61651. /**
  61652. * Checks if all the post processes in the effect are supported.
  61653. */
  61654. readonly isSupported: boolean;
  61655. /**
  61656. * Updates the current state of the effect
  61657. * @hidden
  61658. */
  61659. _update(): void;
  61660. /**
  61661. * Attaches the effect on cameras
  61662. * @param cameras The camera to attach to.
  61663. * @hidden
  61664. */
  61665. _attachCameras(cameras: Camera): void;
  61666. /**
  61667. * Attaches the effect on cameras
  61668. * @param cameras The camera to attach to.
  61669. * @hidden
  61670. */
  61671. _attachCameras(cameras: Camera[]): void;
  61672. /**
  61673. * Detaches the effect on cameras
  61674. * @param cameras The camera to detatch from.
  61675. * @hidden
  61676. */
  61677. _detachCameras(cameras: Camera): void;
  61678. /**
  61679. * Detatches the effect on cameras
  61680. * @param cameras The camera to detatch from.
  61681. * @hidden
  61682. */
  61683. _detachCameras(cameras: Camera[]): void;
  61684. /**
  61685. * Enables the effect on given cameras
  61686. * @param cameras The camera to enable.
  61687. * @hidden
  61688. */
  61689. _enable(cameras: Camera): void;
  61690. /**
  61691. * Enables the effect on given cameras
  61692. * @param cameras The camera to enable.
  61693. * @hidden
  61694. */
  61695. _enable(cameras: Nullable<Camera[]>): void;
  61696. /**
  61697. * Disables the effect on the given cameras
  61698. * @param cameras The camera to disable.
  61699. * @hidden
  61700. */
  61701. _disable(cameras: Camera): void;
  61702. /**
  61703. * Disables the effect on the given cameras
  61704. * @param cameras The camera to disable.
  61705. * @hidden
  61706. */
  61707. _disable(cameras: Nullable<Camera[]>): void;
  61708. /**
  61709. * Gets a list of the post processes contained in the effect.
  61710. * @param camera The camera to get the post processes on.
  61711. * @returns The list of the post processes in the effect.
  61712. */
  61713. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61714. }
  61715. }
  61716. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61717. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61718. /** @hidden */
  61719. export var extractHighlightsPixelShader: {
  61720. name: string;
  61721. shader: string;
  61722. };
  61723. }
  61724. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61725. import { Nullable } from "babylonjs/types";
  61726. import { Camera } from "babylonjs/Cameras/camera";
  61727. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61728. import { Engine } from "babylonjs/Engines/engine";
  61729. import "babylonjs/Shaders/extractHighlights.fragment";
  61730. /**
  61731. * 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.
  61732. */
  61733. export class ExtractHighlightsPostProcess extends PostProcess {
  61734. /**
  61735. * The luminance threshold, pixels below this value will be set to black.
  61736. */
  61737. threshold: number;
  61738. /** @hidden */
  61739. _exposure: number;
  61740. /**
  61741. * Post process which has the input texture to be used when performing highlight extraction
  61742. * @hidden
  61743. */
  61744. _inputPostProcess: Nullable<PostProcess>;
  61745. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61746. }
  61747. }
  61748. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61749. /** @hidden */
  61750. export var bloomMergePixelShader: {
  61751. name: string;
  61752. shader: string;
  61753. };
  61754. }
  61755. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61756. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61757. import { Nullable } from "babylonjs/types";
  61758. import { Engine } from "babylonjs/Engines/engine";
  61759. import { Camera } from "babylonjs/Cameras/camera";
  61760. import "babylonjs/Shaders/bloomMerge.fragment";
  61761. /**
  61762. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61763. */
  61764. export class BloomMergePostProcess extends PostProcess {
  61765. /** Weight of the bloom to be added to the original input. */
  61766. weight: number;
  61767. /**
  61768. * Creates a new instance of @see BloomMergePostProcess
  61769. * @param name The name of the effect.
  61770. * @param originalFromInput Post process which's input will be used for the merge.
  61771. * @param blurred Blurred highlights post process which's output will be used.
  61772. * @param weight Weight of the bloom to be added to the original input.
  61773. * @param options The required width/height ratio to downsize to before computing the render pass.
  61774. * @param camera The camera to apply the render pass to.
  61775. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61776. * @param engine The engine which the post process will be applied. (default: current engine)
  61777. * @param reusable If the post process can be reused on the same frame. (default: false)
  61778. * @param textureType Type of textures used when performing the post process. (default: 0)
  61779. * @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)
  61780. */
  61781. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61782. /** Weight of the bloom to be added to the original input. */
  61783. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61784. }
  61785. }
  61786. declare module "babylonjs/PostProcesses/bloomEffect" {
  61787. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61788. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61789. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61790. import { Camera } from "babylonjs/Cameras/camera";
  61791. import { Scene } from "babylonjs/scene";
  61792. /**
  61793. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61794. */
  61795. export class BloomEffect extends PostProcessRenderEffect {
  61796. private bloomScale;
  61797. /**
  61798. * @hidden Internal
  61799. */
  61800. _effects: Array<PostProcess>;
  61801. /**
  61802. * @hidden Internal
  61803. */
  61804. _downscale: ExtractHighlightsPostProcess;
  61805. private _blurX;
  61806. private _blurY;
  61807. private _merge;
  61808. /**
  61809. * The luminance threshold to find bright areas of the image to bloom.
  61810. */
  61811. threshold: number;
  61812. /**
  61813. * The strength of the bloom.
  61814. */
  61815. weight: number;
  61816. /**
  61817. * Specifies the size of the bloom blur kernel, relative to the final output size
  61818. */
  61819. kernel: number;
  61820. /**
  61821. * Creates a new instance of @see BloomEffect
  61822. * @param scene The scene the effect belongs to.
  61823. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61824. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61825. * @param bloomWeight The the strength of bloom.
  61826. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61827. * @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)
  61828. */
  61829. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61830. /**
  61831. * Disposes each of the internal effects for a given camera.
  61832. * @param camera The camera to dispose the effect on.
  61833. */
  61834. disposeEffects(camera: Camera): void;
  61835. /**
  61836. * @hidden Internal
  61837. */
  61838. _updateEffects(): void;
  61839. /**
  61840. * Internal
  61841. * @returns if all the contained post processes are ready.
  61842. * @hidden
  61843. */
  61844. _isReady(): boolean;
  61845. }
  61846. }
  61847. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61848. /** @hidden */
  61849. export var chromaticAberrationPixelShader: {
  61850. name: string;
  61851. shader: string;
  61852. };
  61853. }
  61854. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61855. import { Vector2 } from "babylonjs/Maths/math.vector";
  61856. import { Nullable } from "babylonjs/types";
  61857. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61858. import { Camera } from "babylonjs/Cameras/camera";
  61859. import { Engine } from "babylonjs/Engines/engine";
  61860. import "babylonjs/Shaders/chromaticAberration.fragment";
  61861. /**
  61862. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61863. */
  61864. export class ChromaticAberrationPostProcess extends PostProcess {
  61865. /**
  61866. * The amount of seperation of rgb channels (default: 30)
  61867. */
  61868. aberrationAmount: number;
  61869. /**
  61870. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61871. */
  61872. radialIntensity: number;
  61873. /**
  61874. * 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))
  61875. */
  61876. direction: Vector2;
  61877. /**
  61878. * 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))
  61879. */
  61880. centerPosition: Vector2;
  61881. /**
  61882. * Creates a new instance ChromaticAberrationPostProcess
  61883. * @param name The name of the effect.
  61884. * @param screenWidth The width of the screen to apply the effect on.
  61885. * @param screenHeight The height of the screen to apply the effect on.
  61886. * @param options The required width/height ratio to downsize to before computing the render pass.
  61887. * @param camera The camera to apply the render pass to.
  61888. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61889. * @param engine The engine which the post process will be applied. (default: current engine)
  61890. * @param reusable If the post process can be reused on the same frame. (default: false)
  61891. * @param textureType Type of textures used when performing the post process. (default: 0)
  61892. * @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)
  61893. */
  61894. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61895. }
  61896. }
  61897. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61898. /** @hidden */
  61899. export var circleOfConfusionPixelShader: {
  61900. name: string;
  61901. shader: string;
  61902. };
  61903. }
  61904. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61905. import { Nullable } from "babylonjs/types";
  61906. import { Engine } from "babylonjs/Engines/engine";
  61907. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61908. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61909. import { Camera } from "babylonjs/Cameras/camera";
  61910. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61911. /**
  61912. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61913. */
  61914. export class CircleOfConfusionPostProcess extends PostProcess {
  61915. /**
  61916. * 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.
  61917. */
  61918. lensSize: number;
  61919. /**
  61920. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61921. */
  61922. fStop: number;
  61923. /**
  61924. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61925. */
  61926. focusDistance: number;
  61927. /**
  61928. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61929. */
  61930. focalLength: number;
  61931. private _depthTexture;
  61932. /**
  61933. * Creates a new instance CircleOfConfusionPostProcess
  61934. * @param name The name of the effect.
  61935. * @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.
  61936. * @param options The required width/height ratio to downsize to before computing the render pass.
  61937. * @param camera The camera to apply the render pass to.
  61938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61939. * @param engine The engine which the post process will be applied. (default: current engine)
  61940. * @param reusable If the post process can be reused on the same frame. (default: false)
  61941. * @param textureType Type of textures used when performing the post process. (default: 0)
  61942. * @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)
  61943. */
  61944. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61945. /**
  61946. * 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.
  61947. */
  61948. depthTexture: RenderTargetTexture;
  61949. }
  61950. }
  61951. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61952. /** @hidden */
  61953. export var colorCorrectionPixelShader: {
  61954. name: string;
  61955. shader: string;
  61956. };
  61957. }
  61958. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61959. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61960. import { Engine } from "babylonjs/Engines/engine";
  61961. import { Camera } from "babylonjs/Cameras/camera";
  61962. import "babylonjs/Shaders/colorCorrection.fragment";
  61963. /**
  61964. *
  61965. * This post-process allows the modification of rendered colors by using
  61966. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61967. *
  61968. * The object needs to be provided an url to a texture containing the color
  61969. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61970. * Use an image editing software to tweak the LUT to match your needs.
  61971. *
  61972. * For an example of a color LUT, see here:
  61973. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61974. * For explanations on color grading, see here:
  61975. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61976. *
  61977. */
  61978. export class ColorCorrectionPostProcess extends PostProcess {
  61979. private _colorTableTexture;
  61980. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61981. }
  61982. }
  61983. declare module "babylonjs/Shaders/convolution.fragment" {
  61984. /** @hidden */
  61985. export var convolutionPixelShader: {
  61986. name: string;
  61987. shader: string;
  61988. };
  61989. }
  61990. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61991. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61992. import { Nullable } from "babylonjs/types";
  61993. import { Camera } from "babylonjs/Cameras/camera";
  61994. import { Engine } from "babylonjs/Engines/engine";
  61995. import "babylonjs/Shaders/convolution.fragment";
  61996. /**
  61997. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61998. * input texture to perform effects such as edge detection or sharpening
  61999. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62000. */
  62001. export class ConvolutionPostProcess extends PostProcess {
  62002. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62003. kernel: number[];
  62004. /**
  62005. * Creates a new instance ConvolutionPostProcess
  62006. * @param name The name of the effect.
  62007. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62008. * @param options The required width/height ratio to downsize to before computing the render pass.
  62009. * @param camera The camera to apply the render pass to.
  62010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62011. * @param engine The engine which the post process will be applied. (default: current engine)
  62012. * @param reusable If the post process can be reused on the same frame. (default: false)
  62013. * @param textureType Type of textures used when performing the post process. (default: 0)
  62014. */
  62015. constructor(name: string,
  62016. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62017. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62018. /**
  62019. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62020. */
  62021. static EdgeDetect0Kernel: number[];
  62022. /**
  62023. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62024. */
  62025. static EdgeDetect1Kernel: number[];
  62026. /**
  62027. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62028. */
  62029. static EdgeDetect2Kernel: number[];
  62030. /**
  62031. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62032. */
  62033. static SharpenKernel: number[];
  62034. /**
  62035. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62036. */
  62037. static EmbossKernel: number[];
  62038. /**
  62039. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62040. */
  62041. static GaussianKernel: number[];
  62042. }
  62043. }
  62044. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62045. import { Nullable } from "babylonjs/types";
  62046. import { Vector2 } from "babylonjs/Maths/math.vector";
  62047. import { Camera } from "babylonjs/Cameras/camera";
  62048. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62049. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62050. import { Engine } from "babylonjs/Engines/engine";
  62051. import { Scene } from "babylonjs/scene";
  62052. /**
  62053. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62054. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62055. * based on samples that have a large difference in distance than the center pixel.
  62056. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62057. */
  62058. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62059. direction: Vector2;
  62060. /**
  62061. * Creates a new instance CircleOfConfusionPostProcess
  62062. * @param name The name of the effect.
  62063. * @param scene The scene the effect belongs to.
  62064. * @param direction The direction the blur should be applied.
  62065. * @param kernel The size of the kernel used to blur.
  62066. * @param options The required width/height ratio to downsize to before computing the render pass.
  62067. * @param camera The camera to apply the render pass to.
  62068. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62069. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62071. * @param engine The engine which the post process will be applied. (default: current engine)
  62072. * @param reusable If the post process can be reused on the same frame. (default: false)
  62073. * @param textureType Type of textures used when performing the post process. (default: 0)
  62074. * @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)
  62075. */
  62076. 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);
  62077. }
  62078. }
  62079. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62080. /** @hidden */
  62081. export var depthOfFieldMergePixelShader: {
  62082. name: string;
  62083. shader: string;
  62084. };
  62085. }
  62086. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62087. import { Nullable } from "babylonjs/types";
  62088. import { Camera } from "babylonjs/Cameras/camera";
  62089. import { Effect } from "babylonjs/Materials/effect";
  62090. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62091. import { Engine } from "babylonjs/Engines/engine";
  62092. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62093. /**
  62094. * Options to be set when merging outputs from the default pipeline.
  62095. */
  62096. export class DepthOfFieldMergePostProcessOptions {
  62097. /**
  62098. * The original image to merge on top of
  62099. */
  62100. originalFromInput: PostProcess;
  62101. /**
  62102. * Parameters to perform the merge of the depth of field effect
  62103. */
  62104. depthOfField?: {
  62105. circleOfConfusion: PostProcess;
  62106. blurSteps: Array<PostProcess>;
  62107. };
  62108. /**
  62109. * Parameters to perform the merge of bloom effect
  62110. */
  62111. bloom?: {
  62112. blurred: PostProcess;
  62113. weight: number;
  62114. };
  62115. }
  62116. /**
  62117. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62118. */
  62119. export class DepthOfFieldMergePostProcess extends PostProcess {
  62120. private blurSteps;
  62121. /**
  62122. * Creates a new instance of DepthOfFieldMergePostProcess
  62123. * @param name The name of the effect.
  62124. * @param originalFromInput Post process which's input will be used for the merge.
  62125. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62126. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62127. * @param options The required width/height ratio to downsize to before computing the render pass.
  62128. * @param camera The camera to apply the render pass to.
  62129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62130. * @param engine The engine which the post process will be applied. (default: current engine)
  62131. * @param reusable If the post process can be reused on the same frame. (default: false)
  62132. * @param textureType Type of textures used when performing the post process. (default: 0)
  62133. * @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)
  62134. */
  62135. 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);
  62136. /**
  62137. * Updates the effect with the current post process compile time values and recompiles the shader.
  62138. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62139. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62140. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62141. * @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
  62142. * @param onCompiled Called when the shader has been compiled.
  62143. * @param onError Called if there is an error when compiling a shader.
  62144. */
  62145. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62146. }
  62147. }
  62148. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62149. import { Nullable } from "babylonjs/types";
  62150. import { Camera } from "babylonjs/Cameras/camera";
  62151. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62152. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62153. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62154. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62155. import { Scene } from "babylonjs/scene";
  62156. /**
  62157. * Specifies the level of max blur that should be applied when using the depth of field effect
  62158. */
  62159. export enum DepthOfFieldEffectBlurLevel {
  62160. /**
  62161. * Subtle blur
  62162. */
  62163. Low = 0,
  62164. /**
  62165. * Medium blur
  62166. */
  62167. Medium = 1,
  62168. /**
  62169. * Large blur
  62170. */
  62171. High = 2
  62172. }
  62173. /**
  62174. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62175. */
  62176. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62177. private _circleOfConfusion;
  62178. /**
  62179. * @hidden Internal, blurs from high to low
  62180. */
  62181. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62182. private _depthOfFieldBlurY;
  62183. private _dofMerge;
  62184. /**
  62185. * @hidden Internal post processes in depth of field effect
  62186. */
  62187. _effects: Array<PostProcess>;
  62188. /**
  62189. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62190. */
  62191. focalLength: number;
  62192. /**
  62193. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62194. */
  62195. fStop: number;
  62196. /**
  62197. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62198. */
  62199. focusDistance: number;
  62200. /**
  62201. * 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.
  62202. */
  62203. lensSize: number;
  62204. /**
  62205. * Creates a new instance DepthOfFieldEffect
  62206. * @param scene The scene the effect belongs to.
  62207. * @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.
  62208. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62209. * @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)
  62210. */
  62211. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62212. /**
  62213. * Get the current class name of the current effet
  62214. * @returns "DepthOfFieldEffect"
  62215. */
  62216. getClassName(): string;
  62217. /**
  62218. * 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.
  62219. */
  62220. depthTexture: RenderTargetTexture;
  62221. /**
  62222. * Disposes each of the internal effects for a given camera.
  62223. * @param camera The camera to dispose the effect on.
  62224. */
  62225. disposeEffects(camera: Camera): void;
  62226. /**
  62227. * @hidden Internal
  62228. */
  62229. _updateEffects(): void;
  62230. /**
  62231. * Internal
  62232. * @returns if all the contained post processes are ready.
  62233. * @hidden
  62234. */
  62235. _isReady(): boolean;
  62236. }
  62237. }
  62238. declare module "babylonjs/Shaders/displayPass.fragment" {
  62239. /** @hidden */
  62240. export var displayPassPixelShader: {
  62241. name: string;
  62242. shader: string;
  62243. };
  62244. }
  62245. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62246. import { Nullable } from "babylonjs/types";
  62247. import { Camera } from "babylonjs/Cameras/camera";
  62248. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62249. import { Engine } from "babylonjs/Engines/engine";
  62250. import "babylonjs/Shaders/displayPass.fragment";
  62251. /**
  62252. * DisplayPassPostProcess which produces an output the same as it's input
  62253. */
  62254. export class DisplayPassPostProcess extends PostProcess {
  62255. /**
  62256. * Creates the DisplayPassPostProcess
  62257. * @param name The name of the effect.
  62258. * @param options The required width/height ratio to downsize to before computing the render pass.
  62259. * @param camera The camera to apply the render pass to.
  62260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62261. * @param engine The engine which the post process will be applied. (default: current engine)
  62262. * @param reusable If the post process can be reused on the same frame. (default: false)
  62263. */
  62264. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62265. }
  62266. }
  62267. declare module "babylonjs/Shaders/filter.fragment" {
  62268. /** @hidden */
  62269. export var filterPixelShader: {
  62270. name: string;
  62271. shader: string;
  62272. };
  62273. }
  62274. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62275. import { Nullable } from "babylonjs/types";
  62276. import { Matrix } from "babylonjs/Maths/math.vector";
  62277. import { Camera } from "babylonjs/Cameras/camera";
  62278. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62279. import { Engine } from "babylonjs/Engines/engine";
  62280. import "babylonjs/Shaders/filter.fragment";
  62281. /**
  62282. * Applies a kernel filter to the image
  62283. */
  62284. export class FilterPostProcess extends PostProcess {
  62285. /** The matrix to be applied to the image */
  62286. kernelMatrix: Matrix;
  62287. /**
  62288. *
  62289. * @param name The name of the effect.
  62290. * @param kernelMatrix The matrix to be applied to the image
  62291. * @param options The required width/height ratio to downsize to before computing the render pass.
  62292. * @param camera The camera to apply the render pass to.
  62293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62294. * @param engine The engine which the post process will be applied. (default: current engine)
  62295. * @param reusable If the post process can be reused on the same frame. (default: false)
  62296. */
  62297. constructor(name: string,
  62298. /** The matrix to be applied to the image */
  62299. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62300. }
  62301. }
  62302. declare module "babylonjs/Shaders/fxaa.fragment" {
  62303. /** @hidden */
  62304. export var fxaaPixelShader: {
  62305. name: string;
  62306. shader: string;
  62307. };
  62308. }
  62309. declare module "babylonjs/Shaders/fxaa.vertex" {
  62310. /** @hidden */
  62311. export var fxaaVertexShader: {
  62312. name: string;
  62313. shader: string;
  62314. };
  62315. }
  62316. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62317. import { Nullable } from "babylonjs/types";
  62318. import { Camera } from "babylonjs/Cameras/camera";
  62319. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62320. import { Engine } from "babylonjs/Engines/engine";
  62321. import "babylonjs/Shaders/fxaa.fragment";
  62322. import "babylonjs/Shaders/fxaa.vertex";
  62323. /**
  62324. * Fxaa post process
  62325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62326. */
  62327. export class FxaaPostProcess extends PostProcess {
  62328. /** @hidden */
  62329. texelWidth: number;
  62330. /** @hidden */
  62331. texelHeight: number;
  62332. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62333. private _getDefines;
  62334. }
  62335. }
  62336. declare module "babylonjs/Shaders/grain.fragment" {
  62337. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62338. /** @hidden */
  62339. export var grainPixelShader: {
  62340. name: string;
  62341. shader: string;
  62342. };
  62343. }
  62344. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62345. import { Nullable } from "babylonjs/types";
  62346. import { Camera } from "babylonjs/Cameras/camera";
  62347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62348. import { Engine } from "babylonjs/Engines/engine";
  62349. import "babylonjs/Shaders/grain.fragment";
  62350. /**
  62351. * The GrainPostProcess adds noise to the image at mid luminance levels
  62352. */
  62353. export class GrainPostProcess extends PostProcess {
  62354. /**
  62355. * The intensity of the grain added (default: 30)
  62356. */
  62357. intensity: number;
  62358. /**
  62359. * If the grain should be randomized on every frame
  62360. */
  62361. animated: boolean;
  62362. /**
  62363. * Creates a new instance of @see GrainPostProcess
  62364. * @param name The name of the effect.
  62365. * @param options The required width/height ratio to downsize to before computing the render pass.
  62366. * @param camera The camera to apply the render pass to.
  62367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62368. * @param engine The engine which the post process will be applied. (default: current engine)
  62369. * @param reusable If the post process can be reused on the same frame. (default: false)
  62370. * @param textureType Type of textures used when performing the post process. (default: 0)
  62371. * @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)
  62372. */
  62373. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62374. }
  62375. }
  62376. declare module "babylonjs/Shaders/highlights.fragment" {
  62377. /** @hidden */
  62378. export var highlightsPixelShader: {
  62379. name: string;
  62380. shader: string;
  62381. };
  62382. }
  62383. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62384. import { Nullable } from "babylonjs/types";
  62385. import { Camera } from "babylonjs/Cameras/camera";
  62386. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62387. import { Engine } from "babylonjs/Engines/engine";
  62388. import "babylonjs/Shaders/highlights.fragment";
  62389. /**
  62390. * Extracts highlights from the image
  62391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62392. */
  62393. export class HighlightsPostProcess extends PostProcess {
  62394. /**
  62395. * Extracts highlights from the image
  62396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62397. * @param name The name of the effect.
  62398. * @param options The required width/height ratio to downsize to before computing the render pass.
  62399. * @param camera The camera to apply the render pass to.
  62400. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62401. * @param engine The engine which the post process will be applied. (default: current engine)
  62402. * @param reusable If the post process can be reused on the same frame. (default: false)
  62403. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62404. */
  62405. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62406. }
  62407. }
  62408. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62409. /** @hidden */
  62410. export var mrtFragmentDeclaration: {
  62411. name: string;
  62412. shader: string;
  62413. };
  62414. }
  62415. declare module "babylonjs/Shaders/geometry.fragment" {
  62416. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62417. /** @hidden */
  62418. export var geometryPixelShader: {
  62419. name: string;
  62420. shader: string;
  62421. };
  62422. }
  62423. declare module "babylonjs/Shaders/geometry.vertex" {
  62424. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62427. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62431. /** @hidden */
  62432. export var geometryVertexShader: {
  62433. name: string;
  62434. shader: string;
  62435. };
  62436. }
  62437. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62438. import { Matrix } from "babylonjs/Maths/math.vector";
  62439. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62440. import { Mesh } from "babylonjs/Meshes/mesh";
  62441. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62442. import { Effect } from "babylonjs/Materials/effect";
  62443. import { Scene } from "babylonjs/scene";
  62444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62445. import "babylonjs/Shaders/geometry.fragment";
  62446. import "babylonjs/Shaders/geometry.vertex";
  62447. /** @hidden */
  62448. interface ISavedTransformationMatrix {
  62449. world: Matrix;
  62450. viewProjection: Matrix;
  62451. }
  62452. /**
  62453. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62454. */
  62455. export class GeometryBufferRenderer {
  62456. /**
  62457. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62458. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62459. */
  62460. static readonly POSITION_TEXTURE_TYPE: number;
  62461. /**
  62462. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62463. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62464. */
  62465. static readonly VELOCITY_TEXTURE_TYPE: number;
  62466. /**
  62467. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62468. * in order to compute objects velocities when enableVelocity is set to "true"
  62469. * @hidden
  62470. */
  62471. _previousTransformationMatrices: {
  62472. [index: number]: ISavedTransformationMatrix;
  62473. };
  62474. /**
  62475. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62476. * in order to compute objects velocities when enableVelocity is set to "true"
  62477. * @hidden
  62478. */
  62479. _previousBonesTransformationMatrices: {
  62480. [index: number]: Float32Array;
  62481. };
  62482. /**
  62483. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62484. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62485. */
  62486. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62487. private _scene;
  62488. private _multiRenderTarget;
  62489. private _ratio;
  62490. private _enablePosition;
  62491. private _enableVelocity;
  62492. private _positionIndex;
  62493. private _velocityIndex;
  62494. protected _effect: Effect;
  62495. protected _cachedDefines: string;
  62496. /**
  62497. * Set the render list (meshes to be rendered) used in the G buffer.
  62498. */
  62499. renderList: Mesh[];
  62500. /**
  62501. * Gets wether or not G buffer are supported by the running hardware.
  62502. * This requires draw buffer supports
  62503. */
  62504. readonly isSupported: boolean;
  62505. /**
  62506. * Returns the index of the given texture type in the G-Buffer textures array
  62507. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62508. * @returns the index of the given texture type in the G-Buffer textures array
  62509. */
  62510. getTextureIndex(textureType: number): number;
  62511. /**
  62512. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62513. */
  62514. /**
  62515. * Sets whether or not objects positions are enabled for the G buffer.
  62516. */
  62517. enablePosition: boolean;
  62518. /**
  62519. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62520. */
  62521. /**
  62522. * Sets wether or not objects velocities are enabled for the G buffer.
  62523. */
  62524. enableVelocity: boolean;
  62525. /**
  62526. * Gets the scene associated with the buffer.
  62527. */
  62528. readonly scene: Scene;
  62529. /**
  62530. * Gets the ratio used by the buffer during its creation.
  62531. * How big is the buffer related to the main canvas.
  62532. */
  62533. readonly ratio: number;
  62534. /** @hidden */
  62535. static _SceneComponentInitialization: (scene: Scene) => void;
  62536. /**
  62537. * Creates a new G Buffer for the scene
  62538. * @param scene The scene the buffer belongs to
  62539. * @param ratio How big is the buffer related to the main canvas.
  62540. */
  62541. constructor(scene: Scene, ratio?: number);
  62542. /**
  62543. * Checks wether everything is ready to render a submesh to the G buffer.
  62544. * @param subMesh the submesh to check readiness for
  62545. * @param useInstances is the mesh drawn using instance or not
  62546. * @returns true if ready otherwise false
  62547. */
  62548. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62549. /**
  62550. * Gets the current underlying G Buffer.
  62551. * @returns the buffer
  62552. */
  62553. getGBuffer(): MultiRenderTarget;
  62554. /**
  62555. * Gets the number of samples used to render the buffer (anti aliasing).
  62556. */
  62557. /**
  62558. * Sets the number of samples used to render the buffer (anti aliasing).
  62559. */
  62560. samples: number;
  62561. /**
  62562. * Disposes the renderer and frees up associated resources.
  62563. */
  62564. dispose(): void;
  62565. protected _createRenderTargets(): void;
  62566. private _copyBonesTransformationMatrices;
  62567. }
  62568. }
  62569. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62570. import { Nullable } from "babylonjs/types";
  62571. import { Scene } from "babylonjs/scene";
  62572. import { ISceneComponent } from "babylonjs/sceneComponent";
  62573. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62574. module "babylonjs/scene" {
  62575. interface Scene {
  62576. /** @hidden (Backing field) */
  62577. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62578. /**
  62579. * Gets or Sets the current geometry buffer associated to the scene.
  62580. */
  62581. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62582. /**
  62583. * Enables a GeometryBufferRender and associates it with the scene
  62584. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62585. * @returns the GeometryBufferRenderer
  62586. */
  62587. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62588. /**
  62589. * Disables the GeometryBufferRender associated with the scene
  62590. */
  62591. disableGeometryBufferRenderer(): void;
  62592. }
  62593. }
  62594. /**
  62595. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62596. * in several rendering techniques.
  62597. */
  62598. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62599. /**
  62600. * The component name helpful to identify the component in the list of scene components.
  62601. */
  62602. readonly name: string;
  62603. /**
  62604. * The scene the component belongs to.
  62605. */
  62606. scene: Scene;
  62607. /**
  62608. * Creates a new instance of the component for the given scene
  62609. * @param scene Defines the scene to register the component in
  62610. */
  62611. constructor(scene: Scene);
  62612. /**
  62613. * Registers the component in a given scene
  62614. */
  62615. register(): void;
  62616. /**
  62617. * Rebuilds the elements related to this component in case of
  62618. * context lost for instance.
  62619. */
  62620. rebuild(): void;
  62621. /**
  62622. * Disposes the component and the associated ressources
  62623. */
  62624. dispose(): void;
  62625. private _gatherRenderTargets;
  62626. }
  62627. }
  62628. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62629. /** @hidden */
  62630. export var motionBlurPixelShader: {
  62631. name: string;
  62632. shader: string;
  62633. };
  62634. }
  62635. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62636. import { Nullable } from "babylonjs/types";
  62637. import { Camera } from "babylonjs/Cameras/camera";
  62638. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62639. import { Scene } from "babylonjs/scene";
  62640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62641. import "babylonjs/Animations/animatable";
  62642. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62643. import "babylonjs/Shaders/motionBlur.fragment";
  62644. import { Engine } from "babylonjs/Engines/engine";
  62645. /**
  62646. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62647. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62648. * As an example, all you have to do is to create the post-process:
  62649. * var mb = new BABYLON.MotionBlurPostProcess(
  62650. * 'mb', // The name of the effect.
  62651. * scene, // The scene containing the objects to blur according to their velocity.
  62652. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62653. * camera // The camera to apply the render pass to.
  62654. * );
  62655. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62656. */
  62657. export class MotionBlurPostProcess extends PostProcess {
  62658. /**
  62659. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62660. */
  62661. motionStrength: number;
  62662. /**
  62663. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62664. */
  62665. /**
  62666. * Sets the number of iterations to be used for motion blur quality
  62667. */
  62668. motionBlurSamples: number;
  62669. private _motionBlurSamples;
  62670. private _geometryBufferRenderer;
  62671. /**
  62672. * Creates a new instance MotionBlurPostProcess
  62673. * @param name The name of the effect.
  62674. * @param scene The scene containing the objects to blur according to their velocity.
  62675. * @param options The required width/height ratio to downsize to before computing the render pass.
  62676. * @param camera The camera to apply the render pass to.
  62677. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62678. * @param engine The engine which the post process will be applied. (default: current engine)
  62679. * @param reusable If the post process can be reused on the same frame. (default: false)
  62680. * @param textureType Type of textures used when performing the post process. (default: 0)
  62681. * @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)
  62682. */
  62683. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62684. /**
  62685. * Excludes the given skinned mesh from computing bones velocities.
  62686. * 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.
  62687. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62688. */
  62689. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62690. /**
  62691. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62692. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62693. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62694. */
  62695. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62696. /**
  62697. * Disposes the post process.
  62698. * @param camera The camera to dispose the post process on.
  62699. */
  62700. dispose(camera?: Camera): void;
  62701. }
  62702. }
  62703. declare module "babylonjs/Shaders/refraction.fragment" {
  62704. /** @hidden */
  62705. export var refractionPixelShader: {
  62706. name: string;
  62707. shader: string;
  62708. };
  62709. }
  62710. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62711. import { Color3 } from "babylonjs/Maths/math.color";
  62712. import { Camera } from "babylonjs/Cameras/camera";
  62713. import { Texture } from "babylonjs/Materials/Textures/texture";
  62714. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62715. import { Engine } from "babylonjs/Engines/engine";
  62716. import "babylonjs/Shaders/refraction.fragment";
  62717. /**
  62718. * Post process which applies a refractin texture
  62719. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62720. */
  62721. export class RefractionPostProcess extends PostProcess {
  62722. /** the base color of the refraction (used to taint the rendering) */
  62723. color: Color3;
  62724. /** simulated refraction depth */
  62725. depth: number;
  62726. /** the coefficient of the base color (0 to remove base color tainting) */
  62727. colorLevel: number;
  62728. private _refTexture;
  62729. private _ownRefractionTexture;
  62730. /**
  62731. * Gets or sets the refraction texture
  62732. * Please note that you are responsible for disposing the texture if you set it manually
  62733. */
  62734. refractionTexture: Texture;
  62735. /**
  62736. * Initializes the RefractionPostProcess
  62737. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62738. * @param name The name of the effect.
  62739. * @param refractionTextureUrl Url of the refraction texture to use
  62740. * @param color the base color of the refraction (used to taint the rendering)
  62741. * @param depth simulated refraction depth
  62742. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62743. * @param camera The camera to apply the render pass to.
  62744. * @param options The required width/height ratio to downsize to before computing the render pass.
  62745. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62746. * @param engine The engine which the post process will be applied. (default: current engine)
  62747. * @param reusable If the post process can be reused on the same frame. (default: false)
  62748. */
  62749. constructor(name: string, refractionTextureUrl: string,
  62750. /** the base color of the refraction (used to taint the rendering) */
  62751. color: Color3,
  62752. /** simulated refraction depth */
  62753. depth: number,
  62754. /** the coefficient of the base color (0 to remove base color tainting) */
  62755. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62756. /**
  62757. * Disposes of the post process
  62758. * @param camera Camera to dispose post process on
  62759. */
  62760. dispose(camera: Camera): void;
  62761. }
  62762. }
  62763. declare module "babylonjs/Shaders/sharpen.fragment" {
  62764. /** @hidden */
  62765. export var sharpenPixelShader: {
  62766. name: string;
  62767. shader: string;
  62768. };
  62769. }
  62770. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62771. import { Nullable } from "babylonjs/types";
  62772. import { Camera } from "babylonjs/Cameras/camera";
  62773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62774. import "babylonjs/Shaders/sharpen.fragment";
  62775. import { Engine } from "babylonjs/Engines/engine";
  62776. /**
  62777. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62778. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62779. */
  62780. export class SharpenPostProcess extends PostProcess {
  62781. /**
  62782. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62783. */
  62784. colorAmount: number;
  62785. /**
  62786. * How much sharpness should be applied (default: 0.3)
  62787. */
  62788. edgeAmount: number;
  62789. /**
  62790. * Creates a new instance ConvolutionPostProcess
  62791. * @param name The name of the effect.
  62792. * @param options The required width/height ratio to downsize to before computing the render pass.
  62793. * @param camera The camera to apply the render pass to.
  62794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62795. * @param engine The engine which the post process will be applied. (default: current engine)
  62796. * @param reusable If the post process can be reused on the same frame. (default: false)
  62797. * @param textureType Type of textures used when performing the post process. (default: 0)
  62798. * @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)
  62799. */
  62800. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62801. }
  62802. }
  62803. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62804. import { Nullable } from "babylonjs/types";
  62805. import { Camera } from "babylonjs/Cameras/camera";
  62806. import { Engine } from "babylonjs/Engines/engine";
  62807. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62808. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62809. /**
  62810. * PostProcessRenderPipeline
  62811. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62812. */
  62813. export class PostProcessRenderPipeline {
  62814. private engine;
  62815. private _renderEffects;
  62816. private _renderEffectsForIsolatedPass;
  62817. /**
  62818. * List of inspectable custom properties (used by the Inspector)
  62819. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62820. */
  62821. inspectableCustomProperties: IInspectable[];
  62822. /**
  62823. * @hidden
  62824. */
  62825. protected _cameras: Camera[];
  62826. /** @hidden */
  62827. _name: string;
  62828. /**
  62829. * Gets pipeline name
  62830. */
  62831. readonly name: string;
  62832. /**
  62833. * Initializes a PostProcessRenderPipeline
  62834. * @param engine engine to add the pipeline to
  62835. * @param name name of the pipeline
  62836. */
  62837. constructor(engine: Engine, name: string);
  62838. /**
  62839. * Gets the class name
  62840. * @returns "PostProcessRenderPipeline"
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * If all the render effects in the pipeline are supported
  62845. */
  62846. readonly isSupported: boolean;
  62847. /**
  62848. * Adds an effect to the pipeline
  62849. * @param renderEffect the effect to add
  62850. */
  62851. addEffect(renderEffect: PostProcessRenderEffect): void;
  62852. /** @hidden */
  62853. _rebuild(): void;
  62854. /** @hidden */
  62855. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62856. /** @hidden */
  62857. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62858. /** @hidden */
  62859. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62860. /** @hidden */
  62861. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62862. /** @hidden */
  62863. _attachCameras(cameras: Camera, unique: boolean): void;
  62864. /** @hidden */
  62865. _attachCameras(cameras: Camera[], unique: boolean): void;
  62866. /** @hidden */
  62867. _detachCameras(cameras: Camera): void;
  62868. /** @hidden */
  62869. _detachCameras(cameras: Nullable<Camera[]>): void;
  62870. /** @hidden */
  62871. _update(): void;
  62872. /** @hidden */
  62873. _reset(): void;
  62874. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62875. /**
  62876. * Disposes of the pipeline
  62877. */
  62878. dispose(): void;
  62879. }
  62880. }
  62881. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62882. import { Camera } from "babylonjs/Cameras/camera";
  62883. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62884. /**
  62885. * PostProcessRenderPipelineManager class
  62886. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62887. */
  62888. export class PostProcessRenderPipelineManager {
  62889. private _renderPipelines;
  62890. /**
  62891. * Initializes a PostProcessRenderPipelineManager
  62892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62893. */
  62894. constructor();
  62895. /**
  62896. * Gets the list of supported render pipelines
  62897. */
  62898. readonly supportedPipelines: PostProcessRenderPipeline[];
  62899. /**
  62900. * Adds a pipeline to the manager
  62901. * @param renderPipeline The pipeline to add
  62902. */
  62903. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62904. /**
  62905. * Attaches a camera to the pipeline
  62906. * @param renderPipelineName The name of the pipeline to attach to
  62907. * @param cameras the camera to attach
  62908. * @param unique if the camera can be attached multiple times to the pipeline
  62909. */
  62910. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62911. /**
  62912. * Detaches a camera from the pipeline
  62913. * @param renderPipelineName The name of the pipeline to detach from
  62914. * @param cameras the camera to detach
  62915. */
  62916. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62917. /**
  62918. * Enables an effect by name on a pipeline
  62919. * @param renderPipelineName the name of the pipeline to enable the effect in
  62920. * @param renderEffectName the name of the effect to enable
  62921. * @param cameras the cameras that the effect should be enabled on
  62922. */
  62923. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62924. /**
  62925. * Disables an effect by name on a pipeline
  62926. * @param renderPipelineName the name of the pipeline to disable the effect in
  62927. * @param renderEffectName the name of the effect to disable
  62928. * @param cameras the cameras that the effect should be disabled on
  62929. */
  62930. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62931. /**
  62932. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62933. */
  62934. update(): void;
  62935. /** @hidden */
  62936. _rebuild(): void;
  62937. /**
  62938. * Disposes of the manager and pipelines
  62939. */
  62940. dispose(): void;
  62941. }
  62942. }
  62943. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62944. import { ISceneComponent } from "babylonjs/sceneComponent";
  62945. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62946. import { Scene } from "babylonjs/scene";
  62947. module "babylonjs/scene" {
  62948. interface Scene {
  62949. /** @hidden (Backing field) */
  62950. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62951. /**
  62952. * Gets the postprocess render pipeline manager
  62953. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62954. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62955. */
  62956. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62957. }
  62958. }
  62959. /**
  62960. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62961. */
  62962. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62963. /**
  62964. * The component name helpfull to identify the component in the list of scene components.
  62965. */
  62966. readonly name: string;
  62967. /**
  62968. * The scene the component belongs to.
  62969. */
  62970. scene: Scene;
  62971. /**
  62972. * Creates a new instance of the component for the given scene
  62973. * @param scene Defines the scene to register the component in
  62974. */
  62975. constructor(scene: Scene);
  62976. /**
  62977. * Registers the component in a given scene
  62978. */
  62979. register(): void;
  62980. /**
  62981. * Rebuilds the elements related to this component in case of
  62982. * context lost for instance.
  62983. */
  62984. rebuild(): void;
  62985. /**
  62986. * Disposes the component and the associated ressources
  62987. */
  62988. dispose(): void;
  62989. private _gatherRenderTargets;
  62990. }
  62991. }
  62992. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62993. import { Nullable } from "babylonjs/types";
  62994. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62995. import { Camera } from "babylonjs/Cameras/camera";
  62996. import { IDisposable } from "babylonjs/scene";
  62997. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62998. import { Scene } from "babylonjs/scene";
  62999. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63000. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63001. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63002. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63003. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63004. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63005. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63006. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63007. import { Animation } from "babylonjs/Animations/animation";
  63008. /**
  63009. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63010. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63011. */
  63012. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63013. private _scene;
  63014. private _camerasToBeAttached;
  63015. /**
  63016. * ID of the sharpen post process,
  63017. */
  63018. private readonly SharpenPostProcessId;
  63019. /**
  63020. * @ignore
  63021. * ID of the image processing post process;
  63022. */
  63023. readonly ImageProcessingPostProcessId: string;
  63024. /**
  63025. * @ignore
  63026. * ID of the Fast Approximate Anti-Aliasing post process;
  63027. */
  63028. readonly FxaaPostProcessId: string;
  63029. /**
  63030. * ID of the chromatic aberration post process,
  63031. */
  63032. private readonly ChromaticAberrationPostProcessId;
  63033. /**
  63034. * ID of the grain post process
  63035. */
  63036. private readonly GrainPostProcessId;
  63037. /**
  63038. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63039. */
  63040. sharpen: SharpenPostProcess;
  63041. private _sharpenEffect;
  63042. private bloom;
  63043. /**
  63044. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63045. */
  63046. depthOfField: DepthOfFieldEffect;
  63047. /**
  63048. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63049. */
  63050. fxaa: FxaaPostProcess;
  63051. /**
  63052. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63053. */
  63054. imageProcessing: ImageProcessingPostProcess;
  63055. /**
  63056. * Chromatic aberration post process which will shift rgb colors in the image
  63057. */
  63058. chromaticAberration: ChromaticAberrationPostProcess;
  63059. private _chromaticAberrationEffect;
  63060. /**
  63061. * Grain post process which add noise to the image
  63062. */
  63063. grain: GrainPostProcess;
  63064. private _grainEffect;
  63065. /**
  63066. * Glow post process which adds a glow to emissive areas of the image
  63067. */
  63068. private _glowLayer;
  63069. /**
  63070. * Animations which can be used to tweak settings over a period of time
  63071. */
  63072. animations: Animation[];
  63073. private _imageProcessingConfigurationObserver;
  63074. private _sharpenEnabled;
  63075. private _bloomEnabled;
  63076. private _depthOfFieldEnabled;
  63077. private _depthOfFieldBlurLevel;
  63078. private _fxaaEnabled;
  63079. private _imageProcessingEnabled;
  63080. private _defaultPipelineTextureType;
  63081. private _bloomScale;
  63082. private _chromaticAberrationEnabled;
  63083. private _grainEnabled;
  63084. private _buildAllowed;
  63085. /**
  63086. * Gets active scene
  63087. */
  63088. readonly scene: Scene;
  63089. /**
  63090. * Enable or disable the sharpen process from the pipeline
  63091. */
  63092. sharpenEnabled: boolean;
  63093. private _resizeObserver;
  63094. private _hardwareScaleLevel;
  63095. private _bloomKernel;
  63096. /**
  63097. * Specifies the size of the bloom blur kernel, relative to the final output size
  63098. */
  63099. bloomKernel: number;
  63100. /**
  63101. * Specifies the weight of the bloom in the final rendering
  63102. */
  63103. private _bloomWeight;
  63104. /**
  63105. * Specifies the luma threshold for the area that will be blurred by the bloom
  63106. */
  63107. private _bloomThreshold;
  63108. private _hdr;
  63109. /**
  63110. * The strength of the bloom.
  63111. */
  63112. bloomWeight: number;
  63113. /**
  63114. * The strength of the bloom.
  63115. */
  63116. bloomThreshold: number;
  63117. /**
  63118. * The scale of the bloom, lower value will provide better performance.
  63119. */
  63120. bloomScale: number;
  63121. /**
  63122. * Enable or disable the bloom from the pipeline
  63123. */
  63124. bloomEnabled: boolean;
  63125. private _rebuildBloom;
  63126. /**
  63127. * If the depth of field is enabled.
  63128. */
  63129. depthOfFieldEnabled: boolean;
  63130. /**
  63131. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63132. */
  63133. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63134. /**
  63135. * If the anti aliasing is enabled.
  63136. */
  63137. fxaaEnabled: boolean;
  63138. private _samples;
  63139. /**
  63140. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63141. */
  63142. samples: number;
  63143. /**
  63144. * If image processing is enabled.
  63145. */
  63146. imageProcessingEnabled: boolean;
  63147. /**
  63148. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63149. */
  63150. glowLayerEnabled: boolean;
  63151. /**
  63152. * Gets the glow layer (or null if not defined)
  63153. */
  63154. readonly glowLayer: Nullable<GlowLayer>;
  63155. /**
  63156. * Enable or disable the chromaticAberration process from the pipeline
  63157. */
  63158. chromaticAberrationEnabled: boolean;
  63159. /**
  63160. * Enable or disable the grain process from the pipeline
  63161. */
  63162. grainEnabled: boolean;
  63163. /**
  63164. * @constructor
  63165. * @param name - The rendering pipeline name (default: "")
  63166. * @param hdr - If high dynamic range textures should be used (default: true)
  63167. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63168. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63169. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63170. */
  63171. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63172. /**
  63173. * Get the class name
  63174. * @returns "DefaultRenderingPipeline"
  63175. */
  63176. getClassName(): string;
  63177. /**
  63178. * Force the compilation of the entire pipeline.
  63179. */
  63180. prepare(): void;
  63181. private _hasCleared;
  63182. private _prevPostProcess;
  63183. private _prevPrevPostProcess;
  63184. private _setAutoClearAndTextureSharing;
  63185. private _depthOfFieldSceneObserver;
  63186. private _buildPipeline;
  63187. private _disposePostProcesses;
  63188. /**
  63189. * Adds a camera to the pipeline
  63190. * @param camera the camera to be added
  63191. */
  63192. addCamera(camera: Camera): void;
  63193. /**
  63194. * Removes a camera from the pipeline
  63195. * @param camera the camera to remove
  63196. */
  63197. removeCamera(camera: Camera): void;
  63198. /**
  63199. * Dispose of the pipeline and stop all post processes
  63200. */
  63201. dispose(): void;
  63202. /**
  63203. * Serialize the rendering pipeline (Used when exporting)
  63204. * @returns the serialized object
  63205. */
  63206. serialize(): any;
  63207. /**
  63208. * Parse the serialized pipeline
  63209. * @param source Source pipeline.
  63210. * @param scene The scene to load the pipeline to.
  63211. * @param rootUrl The URL of the serialized pipeline.
  63212. * @returns An instantiated pipeline from the serialized object.
  63213. */
  63214. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63215. }
  63216. }
  63217. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63218. /** @hidden */
  63219. export var lensHighlightsPixelShader: {
  63220. name: string;
  63221. shader: string;
  63222. };
  63223. }
  63224. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63225. /** @hidden */
  63226. export var depthOfFieldPixelShader: {
  63227. name: string;
  63228. shader: string;
  63229. };
  63230. }
  63231. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63232. import { Camera } from "babylonjs/Cameras/camera";
  63233. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63234. import { Scene } from "babylonjs/scene";
  63235. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63236. import "babylonjs/Shaders/chromaticAberration.fragment";
  63237. import "babylonjs/Shaders/lensHighlights.fragment";
  63238. import "babylonjs/Shaders/depthOfField.fragment";
  63239. /**
  63240. * BABYLON.JS Chromatic Aberration GLSL Shader
  63241. * Author: Olivier Guyot
  63242. * Separates very slightly R, G and B colors on the edges of the screen
  63243. * Inspired by Francois Tarlier & Martins Upitis
  63244. */
  63245. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63246. /**
  63247. * @ignore
  63248. * The chromatic aberration PostProcess id in the pipeline
  63249. */
  63250. LensChromaticAberrationEffect: string;
  63251. /**
  63252. * @ignore
  63253. * The highlights enhancing PostProcess id in the pipeline
  63254. */
  63255. HighlightsEnhancingEffect: string;
  63256. /**
  63257. * @ignore
  63258. * The depth-of-field PostProcess id in the pipeline
  63259. */
  63260. LensDepthOfFieldEffect: string;
  63261. private _scene;
  63262. private _depthTexture;
  63263. private _grainTexture;
  63264. private _chromaticAberrationPostProcess;
  63265. private _highlightsPostProcess;
  63266. private _depthOfFieldPostProcess;
  63267. private _edgeBlur;
  63268. private _grainAmount;
  63269. private _chromaticAberration;
  63270. private _distortion;
  63271. private _highlightsGain;
  63272. private _highlightsThreshold;
  63273. private _dofDistance;
  63274. private _dofAperture;
  63275. private _dofDarken;
  63276. private _dofPentagon;
  63277. private _blurNoise;
  63278. /**
  63279. * @constructor
  63280. *
  63281. * Effect parameters are as follow:
  63282. * {
  63283. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63284. * edge_blur: number; // from 0 to x (1 for realism)
  63285. * distortion: number; // from 0 to x (1 for realism)
  63286. * grain_amount: number; // from 0 to 1
  63287. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63288. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63289. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63290. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63291. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63292. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63293. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63294. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63295. * }
  63296. * Note: if an effect parameter is unset, effect is disabled
  63297. *
  63298. * @param name The rendering pipeline name
  63299. * @param parameters - An object containing all parameters (see above)
  63300. * @param scene The scene linked to this pipeline
  63301. * @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)
  63302. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63303. */
  63304. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63305. /**
  63306. * Get the class name
  63307. * @returns "LensRenderingPipeline"
  63308. */
  63309. getClassName(): string;
  63310. /**
  63311. * Gets associated scene
  63312. */
  63313. readonly scene: Scene;
  63314. /**
  63315. * Gets or sets the edge blur
  63316. */
  63317. edgeBlur: number;
  63318. /**
  63319. * Gets or sets the grain amount
  63320. */
  63321. grainAmount: number;
  63322. /**
  63323. * Gets or sets the chromatic aberration amount
  63324. */
  63325. chromaticAberration: number;
  63326. /**
  63327. * Gets or sets the depth of field aperture
  63328. */
  63329. dofAperture: number;
  63330. /**
  63331. * Gets or sets the edge distortion
  63332. */
  63333. edgeDistortion: number;
  63334. /**
  63335. * Gets or sets the depth of field distortion
  63336. */
  63337. dofDistortion: number;
  63338. /**
  63339. * Gets or sets the darken out of focus amount
  63340. */
  63341. darkenOutOfFocus: number;
  63342. /**
  63343. * Gets or sets a boolean indicating if blur noise is enabled
  63344. */
  63345. blurNoise: boolean;
  63346. /**
  63347. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63348. */
  63349. pentagonBokeh: boolean;
  63350. /**
  63351. * Gets or sets the highlight grain amount
  63352. */
  63353. highlightsGain: number;
  63354. /**
  63355. * Gets or sets the highlight threshold
  63356. */
  63357. highlightsThreshold: number;
  63358. /**
  63359. * Sets the amount of blur at the edges
  63360. * @param amount blur amount
  63361. */
  63362. setEdgeBlur(amount: number): void;
  63363. /**
  63364. * Sets edge blur to 0
  63365. */
  63366. disableEdgeBlur(): void;
  63367. /**
  63368. * Sets the amout of grain
  63369. * @param amount Amount of grain
  63370. */
  63371. setGrainAmount(amount: number): void;
  63372. /**
  63373. * Set grain amount to 0
  63374. */
  63375. disableGrain(): void;
  63376. /**
  63377. * Sets the chromatic aberration amount
  63378. * @param amount amount of chromatic aberration
  63379. */
  63380. setChromaticAberration(amount: number): void;
  63381. /**
  63382. * Sets chromatic aberration amount to 0
  63383. */
  63384. disableChromaticAberration(): void;
  63385. /**
  63386. * Sets the EdgeDistortion amount
  63387. * @param amount amount of EdgeDistortion
  63388. */
  63389. setEdgeDistortion(amount: number): void;
  63390. /**
  63391. * Sets edge distortion to 0
  63392. */
  63393. disableEdgeDistortion(): void;
  63394. /**
  63395. * Sets the FocusDistance amount
  63396. * @param amount amount of FocusDistance
  63397. */
  63398. setFocusDistance(amount: number): void;
  63399. /**
  63400. * Disables depth of field
  63401. */
  63402. disableDepthOfField(): void;
  63403. /**
  63404. * Sets the Aperture amount
  63405. * @param amount amount of Aperture
  63406. */
  63407. setAperture(amount: number): void;
  63408. /**
  63409. * Sets the DarkenOutOfFocus amount
  63410. * @param amount amount of DarkenOutOfFocus
  63411. */
  63412. setDarkenOutOfFocus(amount: number): void;
  63413. private _pentagonBokehIsEnabled;
  63414. /**
  63415. * Creates a pentagon bokeh effect
  63416. */
  63417. enablePentagonBokeh(): void;
  63418. /**
  63419. * Disables the pentagon bokeh effect
  63420. */
  63421. disablePentagonBokeh(): void;
  63422. /**
  63423. * Enables noise blur
  63424. */
  63425. enableNoiseBlur(): void;
  63426. /**
  63427. * Disables noise blur
  63428. */
  63429. disableNoiseBlur(): void;
  63430. /**
  63431. * Sets the HighlightsGain amount
  63432. * @param amount amount of HighlightsGain
  63433. */
  63434. setHighlightsGain(amount: number): void;
  63435. /**
  63436. * Sets the HighlightsThreshold amount
  63437. * @param amount amount of HighlightsThreshold
  63438. */
  63439. setHighlightsThreshold(amount: number): void;
  63440. /**
  63441. * Disables highlights
  63442. */
  63443. disableHighlights(): void;
  63444. /**
  63445. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63446. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63447. */
  63448. dispose(disableDepthRender?: boolean): void;
  63449. private _createChromaticAberrationPostProcess;
  63450. private _createHighlightsPostProcess;
  63451. private _createDepthOfFieldPostProcess;
  63452. private _createGrainTexture;
  63453. }
  63454. }
  63455. declare module "babylonjs/Shaders/ssao2.fragment" {
  63456. /** @hidden */
  63457. export var ssao2PixelShader: {
  63458. name: string;
  63459. shader: string;
  63460. };
  63461. }
  63462. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63463. /** @hidden */
  63464. export var ssaoCombinePixelShader: {
  63465. name: string;
  63466. shader: string;
  63467. };
  63468. }
  63469. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63470. import { Camera } from "babylonjs/Cameras/camera";
  63471. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63472. import { Scene } from "babylonjs/scene";
  63473. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63474. import "babylonjs/Shaders/ssao2.fragment";
  63475. import "babylonjs/Shaders/ssaoCombine.fragment";
  63476. /**
  63477. * Render pipeline to produce ssao effect
  63478. */
  63479. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63480. /**
  63481. * @ignore
  63482. * The PassPostProcess id in the pipeline that contains the original scene color
  63483. */
  63484. SSAOOriginalSceneColorEffect: string;
  63485. /**
  63486. * @ignore
  63487. * The SSAO PostProcess id in the pipeline
  63488. */
  63489. SSAORenderEffect: string;
  63490. /**
  63491. * @ignore
  63492. * The horizontal blur PostProcess id in the pipeline
  63493. */
  63494. SSAOBlurHRenderEffect: string;
  63495. /**
  63496. * @ignore
  63497. * The vertical blur PostProcess id in the pipeline
  63498. */
  63499. SSAOBlurVRenderEffect: string;
  63500. /**
  63501. * @ignore
  63502. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63503. */
  63504. SSAOCombineRenderEffect: string;
  63505. /**
  63506. * The output strength of the SSAO post-process. Default value is 1.0.
  63507. */
  63508. totalStrength: number;
  63509. /**
  63510. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63511. */
  63512. maxZ: number;
  63513. /**
  63514. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63515. */
  63516. minZAspect: number;
  63517. private _samples;
  63518. /**
  63519. * Number of samples used for the SSAO calculations. Default value is 8
  63520. */
  63521. samples: number;
  63522. private _textureSamples;
  63523. /**
  63524. * Number of samples to use for antialiasing
  63525. */
  63526. textureSamples: number;
  63527. /**
  63528. * Ratio object used for SSAO ratio and blur ratio
  63529. */
  63530. private _ratio;
  63531. /**
  63532. * Dynamically generated sphere sampler.
  63533. */
  63534. private _sampleSphere;
  63535. /**
  63536. * Blur filter offsets
  63537. */
  63538. private _samplerOffsets;
  63539. private _expensiveBlur;
  63540. /**
  63541. * If bilateral blur should be used
  63542. */
  63543. expensiveBlur: boolean;
  63544. /**
  63545. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63546. */
  63547. radius: number;
  63548. /**
  63549. * The base color of the SSAO post-process
  63550. * The final result is "base + ssao" between [0, 1]
  63551. */
  63552. base: number;
  63553. /**
  63554. * Support test.
  63555. */
  63556. static readonly IsSupported: boolean;
  63557. private _scene;
  63558. private _depthTexture;
  63559. private _normalTexture;
  63560. private _randomTexture;
  63561. private _originalColorPostProcess;
  63562. private _ssaoPostProcess;
  63563. private _blurHPostProcess;
  63564. private _blurVPostProcess;
  63565. private _ssaoCombinePostProcess;
  63566. private _firstUpdate;
  63567. /**
  63568. * Gets active scene
  63569. */
  63570. readonly scene: Scene;
  63571. /**
  63572. * @constructor
  63573. * @param name The rendering pipeline name
  63574. * @param scene The scene linked to this pipeline
  63575. * @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 }
  63576. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63577. */
  63578. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63579. /**
  63580. * Get the class name
  63581. * @returns "SSAO2RenderingPipeline"
  63582. */
  63583. getClassName(): string;
  63584. /**
  63585. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63586. */
  63587. dispose(disableGeometryBufferRenderer?: boolean): void;
  63588. private _createBlurPostProcess;
  63589. /** @hidden */
  63590. _rebuild(): void;
  63591. private _bits;
  63592. private _radicalInverse_VdC;
  63593. private _hammersley;
  63594. private _hemisphereSample_uniform;
  63595. private _generateHemisphere;
  63596. private _createSSAOPostProcess;
  63597. private _createSSAOCombinePostProcess;
  63598. private _createRandomTexture;
  63599. /**
  63600. * Serialize the rendering pipeline (Used when exporting)
  63601. * @returns the serialized object
  63602. */
  63603. serialize(): any;
  63604. /**
  63605. * Parse the serialized pipeline
  63606. * @param source Source pipeline.
  63607. * @param scene The scene to load the pipeline to.
  63608. * @param rootUrl The URL of the serialized pipeline.
  63609. * @returns An instantiated pipeline from the serialized object.
  63610. */
  63611. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63612. }
  63613. }
  63614. declare module "babylonjs/Shaders/ssao.fragment" {
  63615. /** @hidden */
  63616. export var ssaoPixelShader: {
  63617. name: string;
  63618. shader: string;
  63619. };
  63620. }
  63621. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63622. import { Camera } from "babylonjs/Cameras/camera";
  63623. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63624. import { Scene } from "babylonjs/scene";
  63625. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63626. import "babylonjs/Shaders/ssao.fragment";
  63627. import "babylonjs/Shaders/ssaoCombine.fragment";
  63628. /**
  63629. * Render pipeline to produce ssao effect
  63630. */
  63631. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63632. /**
  63633. * @ignore
  63634. * The PassPostProcess id in the pipeline that contains the original scene color
  63635. */
  63636. SSAOOriginalSceneColorEffect: string;
  63637. /**
  63638. * @ignore
  63639. * The SSAO PostProcess id in the pipeline
  63640. */
  63641. SSAORenderEffect: string;
  63642. /**
  63643. * @ignore
  63644. * The horizontal blur PostProcess id in the pipeline
  63645. */
  63646. SSAOBlurHRenderEffect: string;
  63647. /**
  63648. * @ignore
  63649. * The vertical blur PostProcess id in the pipeline
  63650. */
  63651. SSAOBlurVRenderEffect: string;
  63652. /**
  63653. * @ignore
  63654. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63655. */
  63656. SSAOCombineRenderEffect: string;
  63657. /**
  63658. * The output strength of the SSAO post-process. Default value is 1.0.
  63659. */
  63660. totalStrength: number;
  63661. /**
  63662. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63663. */
  63664. radius: number;
  63665. /**
  63666. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63667. * Must not be equal to fallOff and superior to fallOff.
  63668. * Default value is 0.0075
  63669. */
  63670. area: number;
  63671. /**
  63672. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63673. * Must not be equal to area and inferior to area.
  63674. * Default value is 0.000001
  63675. */
  63676. fallOff: number;
  63677. /**
  63678. * The base color of the SSAO post-process
  63679. * The final result is "base + ssao" between [0, 1]
  63680. */
  63681. base: number;
  63682. private _scene;
  63683. private _depthTexture;
  63684. private _randomTexture;
  63685. private _originalColorPostProcess;
  63686. private _ssaoPostProcess;
  63687. private _blurHPostProcess;
  63688. private _blurVPostProcess;
  63689. private _ssaoCombinePostProcess;
  63690. private _firstUpdate;
  63691. /**
  63692. * Gets active scene
  63693. */
  63694. readonly scene: Scene;
  63695. /**
  63696. * @constructor
  63697. * @param name - The rendering pipeline name
  63698. * @param scene - The scene linked to this pipeline
  63699. * @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 }
  63700. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63701. */
  63702. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63703. /**
  63704. * Get the class name
  63705. * @returns "SSAORenderingPipeline"
  63706. */
  63707. getClassName(): string;
  63708. /**
  63709. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63710. */
  63711. dispose(disableDepthRender?: boolean): void;
  63712. private _createBlurPostProcess;
  63713. /** @hidden */
  63714. _rebuild(): void;
  63715. private _createSSAOPostProcess;
  63716. private _createSSAOCombinePostProcess;
  63717. private _createRandomTexture;
  63718. }
  63719. }
  63720. declare module "babylonjs/Shaders/standard.fragment" {
  63721. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63722. /** @hidden */
  63723. export var standardPixelShader: {
  63724. name: string;
  63725. shader: string;
  63726. };
  63727. }
  63728. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63729. import { Nullable } from "babylonjs/types";
  63730. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63731. import { Camera } from "babylonjs/Cameras/camera";
  63732. import { Texture } from "babylonjs/Materials/Textures/texture";
  63733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63734. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63735. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63736. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63737. import { IDisposable } from "babylonjs/scene";
  63738. import { SpotLight } from "babylonjs/Lights/spotLight";
  63739. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63740. import { Scene } from "babylonjs/scene";
  63741. import { Animation } from "babylonjs/Animations/animation";
  63742. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63743. import "babylonjs/Shaders/standard.fragment";
  63744. /**
  63745. * Standard rendering pipeline
  63746. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63747. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63748. */
  63749. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63750. /**
  63751. * Public members
  63752. */
  63753. /**
  63754. * Post-process which contains the original scene color before the pipeline applies all the effects
  63755. */
  63756. originalPostProcess: Nullable<PostProcess>;
  63757. /**
  63758. * Post-process used to down scale an image x4
  63759. */
  63760. downSampleX4PostProcess: Nullable<PostProcess>;
  63761. /**
  63762. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63763. */
  63764. brightPassPostProcess: Nullable<PostProcess>;
  63765. /**
  63766. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63767. */
  63768. blurHPostProcesses: PostProcess[];
  63769. /**
  63770. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63771. */
  63772. blurVPostProcesses: PostProcess[];
  63773. /**
  63774. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63775. */
  63776. textureAdderPostProcess: Nullable<PostProcess>;
  63777. /**
  63778. * Post-process used to create volumetric lighting effect
  63779. */
  63780. volumetricLightPostProcess: Nullable<PostProcess>;
  63781. /**
  63782. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63783. */
  63784. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63785. /**
  63786. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63787. */
  63788. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63789. /**
  63790. * Post-process used to merge the volumetric light effect and the real scene color
  63791. */
  63792. volumetricLightMergePostProces: Nullable<PostProcess>;
  63793. /**
  63794. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63795. */
  63796. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63797. /**
  63798. * Base post-process used to calculate the average luminance of the final image for HDR
  63799. */
  63800. luminancePostProcess: Nullable<PostProcess>;
  63801. /**
  63802. * Post-processes used to create down sample post-processes in order to get
  63803. * the average luminance of the final image for HDR
  63804. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63805. */
  63806. luminanceDownSamplePostProcesses: PostProcess[];
  63807. /**
  63808. * Post-process used to create a HDR effect (light adaptation)
  63809. */
  63810. hdrPostProcess: Nullable<PostProcess>;
  63811. /**
  63812. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63813. */
  63814. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63815. /**
  63816. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63817. */
  63818. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63819. /**
  63820. * Post-process used to merge the final HDR post-process and the real scene color
  63821. */
  63822. hdrFinalPostProcess: Nullable<PostProcess>;
  63823. /**
  63824. * Post-process used to create a lens flare effect
  63825. */
  63826. lensFlarePostProcess: Nullable<PostProcess>;
  63827. /**
  63828. * Post-process that merges the result of the lens flare post-process and the real scene color
  63829. */
  63830. lensFlareComposePostProcess: Nullable<PostProcess>;
  63831. /**
  63832. * Post-process used to create a motion blur effect
  63833. */
  63834. motionBlurPostProcess: Nullable<PostProcess>;
  63835. /**
  63836. * Post-process used to create a depth of field effect
  63837. */
  63838. depthOfFieldPostProcess: Nullable<PostProcess>;
  63839. /**
  63840. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63841. */
  63842. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63843. /**
  63844. * Represents the brightness threshold in order to configure the illuminated surfaces
  63845. */
  63846. brightThreshold: number;
  63847. /**
  63848. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63849. */
  63850. blurWidth: number;
  63851. /**
  63852. * Sets if the blur for highlighted surfaces must be only horizontal
  63853. */
  63854. horizontalBlur: boolean;
  63855. /**
  63856. * Gets the overall exposure used by the pipeline
  63857. */
  63858. /**
  63859. * Sets the overall exposure used by the pipeline
  63860. */
  63861. exposure: number;
  63862. /**
  63863. * Texture used typically to simulate "dirty" on camera lens
  63864. */
  63865. lensTexture: Nullable<Texture>;
  63866. /**
  63867. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63868. */
  63869. volumetricLightCoefficient: number;
  63870. /**
  63871. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63872. */
  63873. volumetricLightPower: number;
  63874. /**
  63875. * Used the set the blur intensity to smooth the volumetric lights
  63876. */
  63877. volumetricLightBlurScale: number;
  63878. /**
  63879. * Light (spot or directional) used to generate the volumetric lights rays
  63880. * The source light must have a shadow generate so the pipeline can get its
  63881. * depth map
  63882. */
  63883. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63884. /**
  63885. * For eye adaptation, represents the minimum luminance the eye can see
  63886. */
  63887. hdrMinimumLuminance: number;
  63888. /**
  63889. * For eye adaptation, represents the decrease luminance speed
  63890. */
  63891. hdrDecreaseRate: number;
  63892. /**
  63893. * For eye adaptation, represents the increase luminance speed
  63894. */
  63895. hdrIncreaseRate: number;
  63896. /**
  63897. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63898. */
  63899. /**
  63900. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63901. */
  63902. hdrAutoExposure: boolean;
  63903. /**
  63904. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63905. */
  63906. lensColorTexture: Nullable<Texture>;
  63907. /**
  63908. * The overall strengh for the lens flare effect
  63909. */
  63910. lensFlareStrength: number;
  63911. /**
  63912. * Dispersion coefficient for lens flare ghosts
  63913. */
  63914. lensFlareGhostDispersal: number;
  63915. /**
  63916. * Main lens flare halo width
  63917. */
  63918. lensFlareHaloWidth: number;
  63919. /**
  63920. * Based on the lens distortion effect, defines how much the lens flare result
  63921. * is distorted
  63922. */
  63923. lensFlareDistortionStrength: number;
  63924. /**
  63925. * Configures the blur intensity used for for lens flare (halo)
  63926. */
  63927. lensFlareBlurWidth: number;
  63928. /**
  63929. * Lens star texture must be used to simulate rays on the flares and is available
  63930. * in the documentation
  63931. */
  63932. lensStarTexture: Nullable<Texture>;
  63933. /**
  63934. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63935. * flare effect by taking account of the dirt texture
  63936. */
  63937. lensFlareDirtTexture: Nullable<Texture>;
  63938. /**
  63939. * Represents the focal length for the depth of field effect
  63940. */
  63941. depthOfFieldDistance: number;
  63942. /**
  63943. * Represents the blur intensity for the blurred part of the depth of field effect
  63944. */
  63945. depthOfFieldBlurWidth: number;
  63946. /**
  63947. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63948. */
  63949. /**
  63950. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63951. */
  63952. motionStrength: number;
  63953. /**
  63954. * Gets wether or not the motion blur post-process is object based or screen based.
  63955. */
  63956. /**
  63957. * Sets wether or not the motion blur post-process should be object based or screen based
  63958. */
  63959. objectBasedMotionBlur: boolean;
  63960. /**
  63961. * List of animations for the pipeline (IAnimatable implementation)
  63962. */
  63963. animations: Animation[];
  63964. /**
  63965. * Private members
  63966. */
  63967. private _scene;
  63968. private _currentDepthOfFieldSource;
  63969. private _basePostProcess;
  63970. private _fixedExposure;
  63971. private _currentExposure;
  63972. private _hdrAutoExposure;
  63973. private _hdrCurrentLuminance;
  63974. private _motionStrength;
  63975. private _isObjectBasedMotionBlur;
  63976. private _floatTextureType;
  63977. private _camerasToBeAttached;
  63978. private _ratio;
  63979. private _bloomEnabled;
  63980. private _depthOfFieldEnabled;
  63981. private _vlsEnabled;
  63982. private _lensFlareEnabled;
  63983. private _hdrEnabled;
  63984. private _motionBlurEnabled;
  63985. private _fxaaEnabled;
  63986. private _motionBlurSamples;
  63987. private _volumetricLightStepsCount;
  63988. private _samples;
  63989. /**
  63990. * @ignore
  63991. * Specifies if the bloom pipeline is enabled
  63992. */
  63993. BloomEnabled: boolean;
  63994. /**
  63995. * @ignore
  63996. * Specifies if the depth of field pipeline is enabed
  63997. */
  63998. DepthOfFieldEnabled: boolean;
  63999. /**
  64000. * @ignore
  64001. * Specifies if the lens flare pipeline is enabed
  64002. */
  64003. LensFlareEnabled: boolean;
  64004. /**
  64005. * @ignore
  64006. * Specifies if the HDR pipeline is enabled
  64007. */
  64008. HDREnabled: boolean;
  64009. /**
  64010. * @ignore
  64011. * Specifies if the volumetric lights scattering effect is enabled
  64012. */
  64013. VLSEnabled: boolean;
  64014. /**
  64015. * @ignore
  64016. * Specifies if the motion blur effect is enabled
  64017. */
  64018. MotionBlurEnabled: boolean;
  64019. /**
  64020. * Specifies if anti-aliasing is enabled
  64021. */
  64022. fxaaEnabled: boolean;
  64023. /**
  64024. * Specifies the number of steps used to calculate the volumetric lights
  64025. * Typically in interval [50, 200]
  64026. */
  64027. volumetricLightStepsCount: number;
  64028. /**
  64029. * Specifies the number of samples used for the motion blur effect
  64030. * Typically in interval [16, 64]
  64031. */
  64032. motionBlurSamples: number;
  64033. /**
  64034. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64035. */
  64036. samples: number;
  64037. /**
  64038. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64039. * @constructor
  64040. * @param name The rendering pipeline name
  64041. * @param scene The scene linked to this pipeline
  64042. * @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)
  64043. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64044. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64045. */
  64046. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64047. private _buildPipeline;
  64048. private _createDownSampleX4PostProcess;
  64049. private _createBrightPassPostProcess;
  64050. private _createBlurPostProcesses;
  64051. private _createTextureAdderPostProcess;
  64052. private _createVolumetricLightPostProcess;
  64053. private _createLuminancePostProcesses;
  64054. private _createHdrPostProcess;
  64055. private _createLensFlarePostProcess;
  64056. private _createDepthOfFieldPostProcess;
  64057. private _createMotionBlurPostProcess;
  64058. private _getDepthTexture;
  64059. private _disposePostProcesses;
  64060. /**
  64061. * Dispose of the pipeline and stop all post processes
  64062. */
  64063. dispose(): void;
  64064. /**
  64065. * Serialize the rendering pipeline (Used when exporting)
  64066. * @returns the serialized object
  64067. */
  64068. serialize(): any;
  64069. /**
  64070. * Parse the serialized pipeline
  64071. * @param source Source pipeline.
  64072. * @param scene The scene to load the pipeline to.
  64073. * @param rootUrl The URL of the serialized pipeline.
  64074. * @returns An instantiated pipeline from the serialized object.
  64075. */
  64076. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64077. /**
  64078. * Luminance steps
  64079. */
  64080. static LuminanceSteps: number;
  64081. }
  64082. }
  64083. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64084. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64085. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64086. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64087. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64088. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64089. }
  64090. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64091. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64092. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64093. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64094. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64095. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64096. }
  64097. declare module "babylonjs/Shaders/tonemap.fragment" {
  64098. /** @hidden */
  64099. export var tonemapPixelShader: {
  64100. name: string;
  64101. shader: string;
  64102. };
  64103. }
  64104. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64105. import { Camera } from "babylonjs/Cameras/camera";
  64106. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64107. import "babylonjs/Shaders/tonemap.fragment";
  64108. import { Engine } from "babylonjs/Engines/engine";
  64109. /** Defines operator used for tonemapping */
  64110. export enum TonemappingOperator {
  64111. /** Hable */
  64112. Hable = 0,
  64113. /** Reinhard */
  64114. Reinhard = 1,
  64115. /** HejiDawson */
  64116. HejiDawson = 2,
  64117. /** Photographic */
  64118. Photographic = 3
  64119. }
  64120. /**
  64121. * Defines a post process to apply tone mapping
  64122. */
  64123. export class TonemapPostProcess extends PostProcess {
  64124. private _operator;
  64125. /** Defines the required exposure adjustement */
  64126. exposureAdjustment: number;
  64127. /**
  64128. * Creates a new TonemapPostProcess
  64129. * @param name defines the name of the postprocess
  64130. * @param _operator defines the operator to use
  64131. * @param exposureAdjustment defines the required exposure adjustement
  64132. * @param camera defines the camera to use (can be null)
  64133. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64134. * @param engine defines the hosting engine (can be ignore if camera is set)
  64135. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64136. */
  64137. constructor(name: string, _operator: TonemappingOperator,
  64138. /** Defines the required exposure adjustement */
  64139. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64140. }
  64141. }
  64142. declare module "babylonjs/Shaders/depth.vertex" {
  64143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64144. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64145. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64146. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64147. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64148. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64149. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64150. /** @hidden */
  64151. export var depthVertexShader: {
  64152. name: string;
  64153. shader: string;
  64154. };
  64155. }
  64156. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64157. /** @hidden */
  64158. export var volumetricLightScatteringPixelShader: {
  64159. name: string;
  64160. shader: string;
  64161. };
  64162. }
  64163. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64164. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64165. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64166. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64167. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64168. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64169. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64170. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64171. /** @hidden */
  64172. export var volumetricLightScatteringPassVertexShader: {
  64173. name: string;
  64174. shader: string;
  64175. };
  64176. }
  64177. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64178. /** @hidden */
  64179. export var volumetricLightScatteringPassPixelShader: {
  64180. name: string;
  64181. shader: string;
  64182. };
  64183. }
  64184. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64185. import { Vector3 } from "babylonjs/Maths/math.vector";
  64186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64187. import { Mesh } from "babylonjs/Meshes/mesh";
  64188. import { Camera } from "babylonjs/Cameras/camera";
  64189. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64190. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64191. import { Scene } from "babylonjs/scene";
  64192. import "babylonjs/Meshes/Builders/planeBuilder";
  64193. import "babylonjs/Shaders/depth.vertex";
  64194. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64195. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64196. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64197. import { Engine } from "babylonjs/Engines/engine";
  64198. /**
  64199. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64200. */
  64201. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64202. private _volumetricLightScatteringPass;
  64203. private _volumetricLightScatteringRTT;
  64204. private _viewPort;
  64205. private _screenCoordinates;
  64206. private _cachedDefines;
  64207. /**
  64208. * If not undefined, the mesh position is computed from the attached node position
  64209. */
  64210. attachedNode: {
  64211. position: Vector3;
  64212. };
  64213. /**
  64214. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64215. */
  64216. customMeshPosition: Vector3;
  64217. /**
  64218. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64219. */
  64220. useCustomMeshPosition: boolean;
  64221. /**
  64222. * If the post-process should inverse the light scattering direction
  64223. */
  64224. invert: boolean;
  64225. /**
  64226. * The internal mesh used by the post-process
  64227. */
  64228. mesh: Mesh;
  64229. /**
  64230. * @hidden
  64231. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64232. */
  64233. useDiffuseColor: boolean;
  64234. /**
  64235. * Array containing the excluded meshes not rendered in the internal pass
  64236. */
  64237. excludedMeshes: AbstractMesh[];
  64238. /**
  64239. * Controls the overall intensity of the post-process
  64240. */
  64241. exposure: number;
  64242. /**
  64243. * Dissipates each sample's contribution in range [0, 1]
  64244. */
  64245. decay: number;
  64246. /**
  64247. * Controls the overall intensity of each sample
  64248. */
  64249. weight: number;
  64250. /**
  64251. * Controls the density of each sample
  64252. */
  64253. density: number;
  64254. /**
  64255. * @constructor
  64256. * @param name The post-process name
  64257. * @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)
  64258. * @param camera The camera that the post-process will be attached to
  64259. * @param mesh The mesh used to create the light scattering
  64260. * @param samples The post-process quality, default 100
  64261. * @param samplingModeThe post-process filtering mode
  64262. * @param engine The babylon engine
  64263. * @param reusable If the post-process is reusable
  64264. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64265. */
  64266. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64267. /**
  64268. * Returns the string "VolumetricLightScatteringPostProcess"
  64269. * @returns "VolumetricLightScatteringPostProcess"
  64270. */
  64271. getClassName(): string;
  64272. private _isReady;
  64273. /**
  64274. * Sets the new light position for light scattering effect
  64275. * @param position The new custom light position
  64276. */
  64277. setCustomMeshPosition(position: Vector3): void;
  64278. /**
  64279. * Returns the light position for light scattering effect
  64280. * @return Vector3 The custom light position
  64281. */
  64282. getCustomMeshPosition(): Vector3;
  64283. /**
  64284. * Disposes the internal assets and detaches the post-process from the camera
  64285. */
  64286. dispose(camera: Camera): void;
  64287. /**
  64288. * Returns the render target texture used by the post-process
  64289. * @return the render target texture used by the post-process
  64290. */
  64291. getPass(): RenderTargetTexture;
  64292. private _meshExcluded;
  64293. private _createPass;
  64294. private _updateMeshScreenCoordinates;
  64295. /**
  64296. * Creates a default mesh for the Volumeric Light Scattering post-process
  64297. * @param name The mesh name
  64298. * @param scene The scene where to create the mesh
  64299. * @return the default mesh
  64300. */
  64301. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64302. }
  64303. }
  64304. declare module "babylonjs/PostProcesses/index" {
  64305. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64306. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64307. export * from "babylonjs/PostProcesses/bloomEffect";
  64308. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64309. export * from "babylonjs/PostProcesses/blurPostProcess";
  64310. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64311. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64312. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64313. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64314. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64315. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64316. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64317. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64318. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64319. export * from "babylonjs/PostProcesses/filterPostProcess";
  64320. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64321. export * from "babylonjs/PostProcesses/grainPostProcess";
  64322. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64323. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64324. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64325. export * from "babylonjs/PostProcesses/passPostProcess";
  64326. export * from "babylonjs/PostProcesses/postProcess";
  64327. export * from "babylonjs/PostProcesses/postProcessManager";
  64328. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64329. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64330. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64331. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64332. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64333. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64334. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64335. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64336. }
  64337. declare module "babylonjs/Probes/index" {
  64338. export * from "babylonjs/Probes/reflectionProbe";
  64339. }
  64340. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64341. import { Scene } from "babylonjs/scene";
  64342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64343. import { SmartArray } from "babylonjs/Misc/smartArray";
  64344. import { ISceneComponent } from "babylonjs/sceneComponent";
  64345. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64346. import "babylonjs/Meshes/Builders/boxBuilder";
  64347. import "babylonjs/Shaders/color.fragment";
  64348. import "babylonjs/Shaders/color.vertex";
  64349. import { Color3 } from "babylonjs/Maths/math.color";
  64350. module "babylonjs/scene" {
  64351. interface Scene {
  64352. /** @hidden (Backing field) */
  64353. _boundingBoxRenderer: BoundingBoxRenderer;
  64354. /** @hidden (Backing field) */
  64355. _forceShowBoundingBoxes: boolean;
  64356. /**
  64357. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64358. */
  64359. forceShowBoundingBoxes: boolean;
  64360. /**
  64361. * Gets the bounding box renderer associated with the scene
  64362. * @returns a BoundingBoxRenderer
  64363. */
  64364. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64365. }
  64366. }
  64367. module "babylonjs/Meshes/abstractMesh" {
  64368. interface AbstractMesh {
  64369. /** @hidden (Backing field) */
  64370. _showBoundingBox: boolean;
  64371. /**
  64372. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64373. */
  64374. showBoundingBox: boolean;
  64375. }
  64376. }
  64377. /**
  64378. * Component responsible of rendering the bounding box of the meshes in a scene.
  64379. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64380. */
  64381. export class BoundingBoxRenderer implements ISceneComponent {
  64382. /**
  64383. * The component name helpfull to identify the component in the list of scene components.
  64384. */
  64385. readonly name: string;
  64386. /**
  64387. * The scene the component belongs to.
  64388. */
  64389. scene: Scene;
  64390. /**
  64391. * Color of the bounding box lines placed in front of an object
  64392. */
  64393. frontColor: Color3;
  64394. /**
  64395. * Color of the bounding box lines placed behind an object
  64396. */
  64397. backColor: Color3;
  64398. /**
  64399. * Defines if the renderer should show the back lines or not
  64400. */
  64401. showBackLines: boolean;
  64402. /**
  64403. * @hidden
  64404. */
  64405. renderList: SmartArray<BoundingBox>;
  64406. private _colorShader;
  64407. private _vertexBuffers;
  64408. private _indexBuffer;
  64409. private _fillIndexBuffer;
  64410. private _fillIndexData;
  64411. /**
  64412. * Instantiates a new bounding box renderer in a scene.
  64413. * @param scene the scene the renderer renders in
  64414. */
  64415. constructor(scene: Scene);
  64416. /**
  64417. * Registers the component in a given scene
  64418. */
  64419. register(): void;
  64420. private _evaluateSubMesh;
  64421. private _activeMesh;
  64422. private _prepareRessources;
  64423. private _createIndexBuffer;
  64424. /**
  64425. * Rebuilds the elements related to this component in case of
  64426. * context lost for instance.
  64427. */
  64428. rebuild(): void;
  64429. /**
  64430. * @hidden
  64431. */
  64432. reset(): void;
  64433. /**
  64434. * Render the bounding boxes of a specific rendering group
  64435. * @param renderingGroupId defines the rendering group to render
  64436. */
  64437. render(renderingGroupId: number): void;
  64438. /**
  64439. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64440. * @param mesh Define the mesh to render the occlusion bounding box for
  64441. */
  64442. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64443. /**
  64444. * Dispose and release the resources attached to this renderer.
  64445. */
  64446. dispose(): void;
  64447. }
  64448. }
  64449. declare module "babylonjs/Shaders/depth.fragment" {
  64450. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64451. /** @hidden */
  64452. export var depthPixelShader: {
  64453. name: string;
  64454. shader: string;
  64455. };
  64456. }
  64457. declare module "babylonjs/Rendering/depthRenderer" {
  64458. import { Nullable } from "babylonjs/types";
  64459. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64460. import { Scene } from "babylonjs/scene";
  64461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64462. import { Camera } from "babylonjs/Cameras/camera";
  64463. import "babylonjs/Shaders/depth.fragment";
  64464. import "babylonjs/Shaders/depth.vertex";
  64465. /**
  64466. * This represents a depth renderer in Babylon.
  64467. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64468. */
  64469. export class DepthRenderer {
  64470. private _scene;
  64471. private _depthMap;
  64472. private _effect;
  64473. private readonly _storeNonLinearDepth;
  64474. private readonly _clearColor;
  64475. /** Get if the depth renderer is using packed depth or not */
  64476. readonly isPacked: boolean;
  64477. private _cachedDefines;
  64478. private _camera;
  64479. /**
  64480. * Specifiess that the depth renderer will only be used within
  64481. * the camera it is created for.
  64482. * This can help forcing its rendering during the camera processing.
  64483. */
  64484. useOnlyInActiveCamera: boolean;
  64485. /** @hidden */
  64486. static _SceneComponentInitialization: (scene: Scene) => void;
  64487. /**
  64488. * Instantiates a depth renderer
  64489. * @param scene The scene the renderer belongs to
  64490. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64491. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64492. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64493. */
  64494. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64495. /**
  64496. * Creates the depth rendering effect and checks if the effect is ready.
  64497. * @param subMesh The submesh to be used to render the depth map of
  64498. * @param useInstances If multiple world instances should be used
  64499. * @returns if the depth renderer is ready to render the depth map
  64500. */
  64501. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64502. /**
  64503. * Gets the texture which the depth map will be written to.
  64504. * @returns The depth map texture
  64505. */
  64506. getDepthMap(): RenderTargetTexture;
  64507. /**
  64508. * Disposes of the depth renderer.
  64509. */
  64510. dispose(): void;
  64511. }
  64512. }
  64513. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64514. import { Nullable } from "babylonjs/types";
  64515. import { Scene } from "babylonjs/scene";
  64516. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64517. import { Camera } from "babylonjs/Cameras/camera";
  64518. import { ISceneComponent } from "babylonjs/sceneComponent";
  64519. module "babylonjs/scene" {
  64520. interface Scene {
  64521. /** @hidden (Backing field) */
  64522. _depthRenderer: {
  64523. [id: string]: DepthRenderer;
  64524. };
  64525. /**
  64526. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64527. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64528. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64529. * @returns the created depth renderer
  64530. */
  64531. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64532. /**
  64533. * Disables a depth renderer for a given camera
  64534. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64535. */
  64536. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64537. }
  64538. }
  64539. /**
  64540. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64541. * in several rendering techniques.
  64542. */
  64543. export class DepthRendererSceneComponent implements ISceneComponent {
  64544. /**
  64545. * The component name helpfull to identify the component in the list of scene components.
  64546. */
  64547. readonly name: string;
  64548. /**
  64549. * The scene the component belongs to.
  64550. */
  64551. scene: Scene;
  64552. /**
  64553. * Creates a new instance of the component for the given scene
  64554. * @param scene Defines the scene to register the component in
  64555. */
  64556. constructor(scene: Scene);
  64557. /**
  64558. * Registers the component in a given scene
  64559. */
  64560. register(): void;
  64561. /**
  64562. * Rebuilds the elements related to this component in case of
  64563. * context lost for instance.
  64564. */
  64565. rebuild(): void;
  64566. /**
  64567. * Disposes the component and the associated ressources
  64568. */
  64569. dispose(): void;
  64570. private _gatherRenderTargets;
  64571. private _gatherActiveCameraRenderTargets;
  64572. }
  64573. }
  64574. declare module "babylonjs/Shaders/outline.fragment" {
  64575. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64576. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64577. /** @hidden */
  64578. export var outlinePixelShader: {
  64579. name: string;
  64580. shader: string;
  64581. };
  64582. }
  64583. declare module "babylonjs/Shaders/outline.vertex" {
  64584. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64585. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64586. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64587. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64588. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64589. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64590. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64591. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64592. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64593. /** @hidden */
  64594. export var outlineVertexShader: {
  64595. name: string;
  64596. shader: string;
  64597. };
  64598. }
  64599. declare module "babylonjs/Rendering/outlineRenderer" {
  64600. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64601. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64602. import { Scene } from "babylonjs/scene";
  64603. import { ISceneComponent } from "babylonjs/sceneComponent";
  64604. import "babylonjs/Shaders/outline.fragment";
  64605. import "babylonjs/Shaders/outline.vertex";
  64606. module "babylonjs/scene" {
  64607. interface Scene {
  64608. /** @hidden */
  64609. _outlineRenderer: OutlineRenderer;
  64610. /**
  64611. * Gets the outline renderer associated with the scene
  64612. * @returns a OutlineRenderer
  64613. */
  64614. getOutlineRenderer(): OutlineRenderer;
  64615. }
  64616. }
  64617. module "babylonjs/Meshes/abstractMesh" {
  64618. interface AbstractMesh {
  64619. /** @hidden (Backing field) */
  64620. _renderOutline: boolean;
  64621. /**
  64622. * Gets or sets a boolean indicating if the outline must be rendered as well
  64623. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64624. */
  64625. renderOutline: boolean;
  64626. /** @hidden (Backing field) */
  64627. _renderOverlay: boolean;
  64628. /**
  64629. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64630. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64631. */
  64632. renderOverlay: boolean;
  64633. }
  64634. }
  64635. /**
  64636. * This class is responsible to draw bothe outline/overlay of meshes.
  64637. * It should not be used directly but through the available method on mesh.
  64638. */
  64639. export class OutlineRenderer implements ISceneComponent {
  64640. /**
  64641. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64642. */
  64643. private static _StencilReference;
  64644. /**
  64645. * The name of the component. Each component must have a unique name.
  64646. */
  64647. name: string;
  64648. /**
  64649. * The scene the component belongs to.
  64650. */
  64651. scene: Scene;
  64652. /**
  64653. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64654. */
  64655. zOffset: number;
  64656. private _engine;
  64657. private _effect;
  64658. private _cachedDefines;
  64659. private _savedDepthWrite;
  64660. /**
  64661. * Instantiates a new outline renderer. (There could be only one per scene).
  64662. * @param scene Defines the scene it belongs to
  64663. */
  64664. constructor(scene: Scene);
  64665. /**
  64666. * Register the component to one instance of a scene.
  64667. */
  64668. register(): void;
  64669. /**
  64670. * Rebuilds the elements related to this component in case of
  64671. * context lost for instance.
  64672. */
  64673. rebuild(): void;
  64674. /**
  64675. * Disposes the component and the associated ressources.
  64676. */
  64677. dispose(): void;
  64678. /**
  64679. * Renders the outline in the canvas.
  64680. * @param subMesh Defines the sumesh to render
  64681. * @param batch Defines the batch of meshes in case of instances
  64682. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64683. */
  64684. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64685. /**
  64686. * Returns whether or not the outline renderer is ready for a given submesh.
  64687. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64688. * @param subMesh Defines the submesh to check readyness for
  64689. * @param useInstances Defines wheter wee are trying to render instances or not
  64690. * @returns true if ready otherwise false
  64691. */
  64692. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64693. private _beforeRenderingMesh;
  64694. private _afterRenderingMesh;
  64695. }
  64696. }
  64697. declare module "babylonjs/Rendering/index" {
  64698. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64699. export * from "babylonjs/Rendering/depthRenderer";
  64700. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64701. export * from "babylonjs/Rendering/edgesRenderer";
  64702. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64703. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64704. export * from "babylonjs/Rendering/outlineRenderer";
  64705. export * from "babylonjs/Rendering/renderingGroup";
  64706. export * from "babylonjs/Rendering/renderingManager";
  64707. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64708. }
  64709. declare module "babylonjs/Sprites/spritePackedManager" {
  64710. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64711. import { Scene } from "babylonjs/scene";
  64712. /**
  64713. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64714. * @see http://doc.babylonjs.com/babylon101/sprites
  64715. */
  64716. export class SpritePackedManager extends SpriteManager {
  64717. /** defines the packed manager's name */
  64718. name: string;
  64719. /**
  64720. * Creates a new sprite manager from a packed sprite sheet
  64721. * @param name defines the manager's name
  64722. * @param imgUrl defines the sprite sheet url
  64723. * @param capacity defines the maximum allowed number of sprites
  64724. * @param scene defines the hosting scene
  64725. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64726. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64727. * @param samplingMode defines the smapling mode to use with spritesheet
  64728. * @param fromPacked set to true; do not alter
  64729. */
  64730. constructor(
  64731. /** defines the packed manager's name */
  64732. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64733. }
  64734. }
  64735. declare module "babylonjs/Sprites/index" {
  64736. export * from "babylonjs/Sprites/sprite";
  64737. export * from "babylonjs/Sprites/spriteManager";
  64738. export * from "babylonjs/Sprites/spritePackedManager";
  64739. export * from "babylonjs/Sprites/spriteSceneComponent";
  64740. }
  64741. declare module "babylonjs/States/index" {
  64742. export * from "babylonjs/States/alphaCullingState";
  64743. export * from "babylonjs/States/depthCullingState";
  64744. export * from "babylonjs/States/stencilState";
  64745. }
  64746. declare module "babylonjs/Misc/assetsManager" {
  64747. import { Scene } from "babylonjs/scene";
  64748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64749. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64750. import { Skeleton } from "babylonjs/Bones/skeleton";
  64751. import { Observable } from "babylonjs/Misc/observable";
  64752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64753. import { Texture } from "babylonjs/Materials/Textures/texture";
  64754. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64755. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64756. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64757. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64758. /**
  64759. * Defines the list of states available for a task inside a AssetsManager
  64760. */
  64761. export enum AssetTaskState {
  64762. /**
  64763. * Initialization
  64764. */
  64765. INIT = 0,
  64766. /**
  64767. * Running
  64768. */
  64769. RUNNING = 1,
  64770. /**
  64771. * Done
  64772. */
  64773. DONE = 2,
  64774. /**
  64775. * Error
  64776. */
  64777. ERROR = 3
  64778. }
  64779. /**
  64780. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64781. */
  64782. export abstract class AbstractAssetTask {
  64783. /**
  64784. * Task name
  64785. */ name: string;
  64786. /**
  64787. * Callback called when the task is successful
  64788. */
  64789. onSuccess: (task: any) => void;
  64790. /**
  64791. * Callback called when the task is not successful
  64792. */
  64793. onError: (task: any, message?: string, exception?: any) => void;
  64794. /**
  64795. * Creates a new AssetsManager
  64796. * @param name defines the name of the task
  64797. */
  64798. constructor(
  64799. /**
  64800. * Task name
  64801. */ name: string);
  64802. private _isCompleted;
  64803. private _taskState;
  64804. private _errorObject;
  64805. /**
  64806. * Get if the task is completed
  64807. */
  64808. readonly isCompleted: boolean;
  64809. /**
  64810. * Gets the current state of the task
  64811. */
  64812. readonly taskState: AssetTaskState;
  64813. /**
  64814. * Gets the current error object (if task is in error)
  64815. */
  64816. readonly errorObject: {
  64817. message?: string;
  64818. exception?: any;
  64819. };
  64820. /**
  64821. * Internal only
  64822. * @hidden
  64823. */
  64824. _setErrorObject(message?: string, exception?: any): void;
  64825. /**
  64826. * Execute the current task
  64827. * @param scene defines the scene where you want your assets to be loaded
  64828. * @param onSuccess is a callback called when the task is successfully executed
  64829. * @param onError is a callback called if an error occurs
  64830. */
  64831. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64832. /**
  64833. * Execute the current task
  64834. * @param scene defines the scene where you want your assets to be loaded
  64835. * @param onSuccess is a callback called when the task is successfully executed
  64836. * @param onError is a callback called if an error occurs
  64837. */
  64838. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64839. /**
  64840. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64841. * This can be used with failed tasks that have the reason for failure fixed.
  64842. */
  64843. reset(): void;
  64844. private onErrorCallback;
  64845. private onDoneCallback;
  64846. }
  64847. /**
  64848. * Define the interface used by progress events raised during assets loading
  64849. */
  64850. export interface IAssetsProgressEvent {
  64851. /**
  64852. * Defines the number of remaining tasks to process
  64853. */
  64854. remainingCount: number;
  64855. /**
  64856. * Defines the total number of tasks
  64857. */
  64858. totalCount: number;
  64859. /**
  64860. * Defines the task that was just processed
  64861. */
  64862. task: AbstractAssetTask;
  64863. }
  64864. /**
  64865. * Class used to share progress information about assets loading
  64866. */
  64867. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64868. /**
  64869. * Defines the number of remaining tasks to process
  64870. */
  64871. remainingCount: number;
  64872. /**
  64873. * Defines the total number of tasks
  64874. */
  64875. totalCount: number;
  64876. /**
  64877. * Defines the task that was just processed
  64878. */
  64879. task: AbstractAssetTask;
  64880. /**
  64881. * Creates a AssetsProgressEvent
  64882. * @param remainingCount defines the number of remaining tasks to process
  64883. * @param totalCount defines the total number of tasks
  64884. * @param task defines the task that was just processed
  64885. */
  64886. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64887. }
  64888. /**
  64889. * Define a task used by AssetsManager to load meshes
  64890. */
  64891. export class MeshAssetTask extends AbstractAssetTask {
  64892. /**
  64893. * Defines the name of the task
  64894. */
  64895. name: string;
  64896. /**
  64897. * Defines the list of mesh's names you want to load
  64898. */
  64899. meshesNames: any;
  64900. /**
  64901. * Defines the root url to use as a base to load your meshes and associated resources
  64902. */
  64903. rootUrl: string;
  64904. /**
  64905. * Defines the filename of the scene to load from
  64906. */
  64907. sceneFilename: string;
  64908. /**
  64909. * Gets the list of loaded meshes
  64910. */
  64911. loadedMeshes: Array<AbstractMesh>;
  64912. /**
  64913. * Gets the list of loaded particle systems
  64914. */
  64915. loadedParticleSystems: Array<IParticleSystem>;
  64916. /**
  64917. * Gets the list of loaded skeletons
  64918. */
  64919. loadedSkeletons: Array<Skeleton>;
  64920. /**
  64921. * Gets the list of loaded animation groups
  64922. */
  64923. loadedAnimationGroups: Array<AnimationGroup>;
  64924. /**
  64925. * Callback called when the task is successful
  64926. */
  64927. onSuccess: (task: MeshAssetTask) => void;
  64928. /**
  64929. * Callback called when the task is successful
  64930. */
  64931. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64932. /**
  64933. * Creates a new MeshAssetTask
  64934. * @param name defines the name of the task
  64935. * @param meshesNames defines the list of mesh's names you want to load
  64936. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64937. * @param sceneFilename defines the filename of the scene to load from
  64938. */
  64939. constructor(
  64940. /**
  64941. * Defines the name of the task
  64942. */
  64943. name: string,
  64944. /**
  64945. * Defines the list of mesh's names you want to load
  64946. */
  64947. meshesNames: any,
  64948. /**
  64949. * Defines the root url to use as a base to load your meshes and associated resources
  64950. */
  64951. rootUrl: string,
  64952. /**
  64953. * Defines the filename of the scene to load from
  64954. */
  64955. sceneFilename: string);
  64956. /**
  64957. * Execute the current task
  64958. * @param scene defines the scene where you want your assets to be loaded
  64959. * @param onSuccess is a callback called when the task is successfully executed
  64960. * @param onError is a callback called if an error occurs
  64961. */
  64962. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64963. }
  64964. /**
  64965. * Define a task used by AssetsManager to load text content
  64966. */
  64967. export class TextFileAssetTask extends AbstractAssetTask {
  64968. /**
  64969. * Defines the name of the task
  64970. */
  64971. name: string;
  64972. /**
  64973. * Defines the location of the file to load
  64974. */
  64975. url: string;
  64976. /**
  64977. * Gets the loaded text string
  64978. */
  64979. text: string;
  64980. /**
  64981. * Callback called when the task is successful
  64982. */
  64983. onSuccess: (task: TextFileAssetTask) => void;
  64984. /**
  64985. * Callback called when the task is successful
  64986. */
  64987. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64988. /**
  64989. * Creates a new TextFileAssetTask object
  64990. * @param name defines the name of the task
  64991. * @param url defines the location of the file to load
  64992. */
  64993. constructor(
  64994. /**
  64995. * Defines the name of the task
  64996. */
  64997. name: string,
  64998. /**
  64999. * Defines the location of the file to load
  65000. */
  65001. url: string);
  65002. /**
  65003. * Execute the current task
  65004. * @param scene defines the scene where you want your assets to be loaded
  65005. * @param onSuccess is a callback called when the task is successfully executed
  65006. * @param onError is a callback called if an error occurs
  65007. */
  65008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65009. }
  65010. /**
  65011. * Define a task used by AssetsManager to load binary data
  65012. */
  65013. export class BinaryFileAssetTask extends AbstractAssetTask {
  65014. /**
  65015. * Defines the name of the task
  65016. */
  65017. name: string;
  65018. /**
  65019. * Defines the location of the file to load
  65020. */
  65021. url: string;
  65022. /**
  65023. * Gets the lodaded data (as an array buffer)
  65024. */
  65025. data: ArrayBuffer;
  65026. /**
  65027. * Callback called when the task is successful
  65028. */
  65029. onSuccess: (task: BinaryFileAssetTask) => void;
  65030. /**
  65031. * Callback called when the task is successful
  65032. */
  65033. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65034. /**
  65035. * Creates a new BinaryFileAssetTask object
  65036. * @param name defines the name of the new task
  65037. * @param url defines the location of the file to load
  65038. */
  65039. constructor(
  65040. /**
  65041. * Defines the name of the task
  65042. */
  65043. name: string,
  65044. /**
  65045. * Defines the location of the file to load
  65046. */
  65047. url: string);
  65048. /**
  65049. * Execute the current task
  65050. * @param scene defines the scene where you want your assets to be loaded
  65051. * @param onSuccess is a callback called when the task is successfully executed
  65052. * @param onError is a callback called if an error occurs
  65053. */
  65054. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65055. }
  65056. /**
  65057. * Define a task used by AssetsManager to load images
  65058. */
  65059. export class ImageAssetTask extends AbstractAssetTask {
  65060. /**
  65061. * Defines the name of the task
  65062. */
  65063. name: string;
  65064. /**
  65065. * Defines the location of the image to load
  65066. */
  65067. url: string;
  65068. /**
  65069. * Gets the loaded images
  65070. */
  65071. image: HTMLImageElement;
  65072. /**
  65073. * Callback called when the task is successful
  65074. */
  65075. onSuccess: (task: ImageAssetTask) => void;
  65076. /**
  65077. * Callback called when the task is successful
  65078. */
  65079. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65080. /**
  65081. * Creates a new ImageAssetTask
  65082. * @param name defines the name of the task
  65083. * @param url defines the location of the image to load
  65084. */
  65085. constructor(
  65086. /**
  65087. * Defines the name of the task
  65088. */
  65089. name: string,
  65090. /**
  65091. * Defines the location of the image to load
  65092. */
  65093. url: string);
  65094. /**
  65095. * Execute the current task
  65096. * @param scene defines the scene where you want your assets to be loaded
  65097. * @param onSuccess is a callback called when the task is successfully executed
  65098. * @param onError is a callback called if an error occurs
  65099. */
  65100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65101. }
  65102. /**
  65103. * Defines the interface used by texture loading tasks
  65104. */
  65105. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65106. /**
  65107. * Gets the loaded texture
  65108. */
  65109. texture: TEX;
  65110. }
  65111. /**
  65112. * Define a task used by AssetsManager to load 2D textures
  65113. */
  65114. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65115. /**
  65116. * Defines the name of the task
  65117. */
  65118. name: string;
  65119. /**
  65120. * Defines the location of the file to load
  65121. */
  65122. url: string;
  65123. /**
  65124. * Defines if mipmap should not be generated (default is false)
  65125. */
  65126. noMipmap?: boolean | undefined;
  65127. /**
  65128. * Defines if texture must be inverted on Y axis (default is false)
  65129. */
  65130. invertY?: boolean | undefined;
  65131. /**
  65132. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65133. */
  65134. samplingMode: number;
  65135. /**
  65136. * Gets the loaded texture
  65137. */
  65138. texture: Texture;
  65139. /**
  65140. * Callback called when the task is successful
  65141. */
  65142. onSuccess: (task: TextureAssetTask) => void;
  65143. /**
  65144. * Callback called when the task is successful
  65145. */
  65146. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65147. /**
  65148. * Creates a new TextureAssetTask object
  65149. * @param name defines the name of the task
  65150. * @param url defines the location of the file to load
  65151. * @param noMipmap defines if mipmap should not be generated (default is false)
  65152. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65153. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65154. */
  65155. constructor(
  65156. /**
  65157. * Defines the name of the task
  65158. */
  65159. name: string,
  65160. /**
  65161. * Defines the location of the file to load
  65162. */
  65163. url: string,
  65164. /**
  65165. * Defines if mipmap should not be generated (default is false)
  65166. */
  65167. noMipmap?: boolean | undefined,
  65168. /**
  65169. * Defines if texture must be inverted on Y axis (default is false)
  65170. */
  65171. invertY?: boolean | undefined,
  65172. /**
  65173. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65174. */
  65175. samplingMode?: number);
  65176. /**
  65177. * Execute the current task
  65178. * @param scene defines the scene where you want your assets to be loaded
  65179. * @param onSuccess is a callback called when the task is successfully executed
  65180. * @param onError is a callback called if an error occurs
  65181. */
  65182. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65183. }
  65184. /**
  65185. * Define a task used by AssetsManager to load cube textures
  65186. */
  65187. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65188. /**
  65189. * Defines the name of the task
  65190. */
  65191. name: string;
  65192. /**
  65193. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65194. */
  65195. url: string;
  65196. /**
  65197. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65198. */
  65199. extensions?: string[] | undefined;
  65200. /**
  65201. * Defines if mipmaps should not be generated (default is false)
  65202. */
  65203. noMipmap?: boolean | undefined;
  65204. /**
  65205. * Defines the explicit list of files (undefined by default)
  65206. */
  65207. files?: string[] | undefined;
  65208. /**
  65209. * Gets the loaded texture
  65210. */
  65211. texture: CubeTexture;
  65212. /**
  65213. * Callback called when the task is successful
  65214. */
  65215. onSuccess: (task: CubeTextureAssetTask) => void;
  65216. /**
  65217. * Callback called when the task is successful
  65218. */
  65219. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65220. /**
  65221. * Creates a new CubeTextureAssetTask
  65222. * @param name defines the name of the task
  65223. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65224. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65225. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65226. * @param files defines the explicit list of files (undefined by default)
  65227. */
  65228. constructor(
  65229. /**
  65230. * Defines the name of the task
  65231. */
  65232. name: string,
  65233. /**
  65234. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65235. */
  65236. url: string,
  65237. /**
  65238. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65239. */
  65240. extensions?: string[] | undefined,
  65241. /**
  65242. * Defines if mipmaps should not be generated (default is false)
  65243. */
  65244. noMipmap?: boolean | undefined,
  65245. /**
  65246. * Defines the explicit list of files (undefined by default)
  65247. */
  65248. files?: string[] | undefined);
  65249. /**
  65250. * Execute the current task
  65251. * @param scene defines the scene where you want your assets to be loaded
  65252. * @param onSuccess is a callback called when the task is successfully executed
  65253. * @param onError is a callback called if an error occurs
  65254. */
  65255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65256. }
  65257. /**
  65258. * Define a task used by AssetsManager to load HDR cube textures
  65259. */
  65260. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65261. /**
  65262. * Defines the name of the task
  65263. */
  65264. name: string;
  65265. /**
  65266. * Defines the location of the file to load
  65267. */
  65268. url: string;
  65269. /**
  65270. * Defines the desired size (the more it increases the longer the generation will be)
  65271. */
  65272. size: number;
  65273. /**
  65274. * Defines if mipmaps should not be generated (default is false)
  65275. */
  65276. noMipmap: boolean;
  65277. /**
  65278. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65279. */
  65280. generateHarmonics: boolean;
  65281. /**
  65282. * 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)
  65283. */
  65284. gammaSpace: boolean;
  65285. /**
  65286. * Internal Use Only
  65287. */
  65288. reserved: boolean;
  65289. /**
  65290. * Gets the loaded texture
  65291. */
  65292. texture: HDRCubeTexture;
  65293. /**
  65294. * Callback called when the task is successful
  65295. */
  65296. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65297. /**
  65298. * Callback called when the task is successful
  65299. */
  65300. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65301. /**
  65302. * Creates a new HDRCubeTextureAssetTask object
  65303. * @param name defines the name of the task
  65304. * @param url defines the location of the file to load
  65305. * @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.
  65306. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65307. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65308. * @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)
  65309. * @param reserved Internal use only
  65310. */
  65311. constructor(
  65312. /**
  65313. * Defines the name of the task
  65314. */
  65315. name: string,
  65316. /**
  65317. * Defines the location of the file to load
  65318. */
  65319. url: string,
  65320. /**
  65321. * Defines the desired size (the more it increases the longer the generation will be)
  65322. */
  65323. size: number,
  65324. /**
  65325. * Defines if mipmaps should not be generated (default is false)
  65326. */
  65327. noMipmap?: boolean,
  65328. /**
  65329. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65330. */
  65331. generateHarmonics?: boolean,
  65332. /**
  65333. * 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)
  65334. */
  65335. gammaSpace?: boolean,
  65336. /**
  65337. * Internal Use Only
  65338. */
  65339. reserved?: boolean);
  65340. /**
  65341. * Execute the current task
  65342. * @param scene defines the scene where you want your assets to be loaded
  65343. * @param onSuccess is a callback called when the task is successfully executed
  65344. * @param onError is a callback called if an error occurs
  65345. */
  65346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65347. }
  65348. /**
  65349. * Define a task used by AssetsManager to load Equirectangular cube textures
  65350. */
  65351. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65352. /**
  65353. * Defines the name of the task
  65354. */
  65355. name: string;
  65356. /**
  65357. * Defines the location of the file to load
  65358. */
  65359. url: string;
  65360. /**
  65361. * Defines the desired size (the more it increases the longer the generation will be)
  65362. */
  65363. size: number;
  65364. /**
  65365. * Defines if mipmaps should not be generated (default is false)
  65366. */
  65367. noMipmap: boolean;
  65368. /**
  65369. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65370. * but the standard material would require them in Gamma space) (default is true)
  65371. */
  65372. gammaSpace: boolean;
  65373. /**
  65374. * Gets the loaded texture
  65375. */
  65376. texture: EquiRectangularCubeTexture;
  65377. /**
  65378. * Callback called when the task is successful
  65379. */
  65380. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65381. /**
  65382. * Callback called when the task is successful
  65383. */
  65384. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65385. /**
  65386. * Creates a new EquiRectangularCubeTextureAssetTask object
  65387. * @param name defines the name of the task
  65388. * @param url defines the location of the file to load
  65389. * @param size defines the desired size (the more it increases the longer the generation will be)
  65390. * If the size is omitted this implies you are using a preprocessed cubemap.
  65391. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65392. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65393. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65394. * (default is true)
  65395. */
  65396. constructor(
  65397. /**
  65398. * Defines the name of the task
  65399. */
  65400. name: string,
  65401. /**
  65402. * Defines the location of the file to load
  65403. */
  65404. url: string,
  65405. /**
  65406. * Defines the desired size (the more it increases the longer the generation will be)
  65407. */
  65408. size: number,
  65409. /**
  65410. * Defines if mipmaps should not be generated (default is false)
  65411. */
  65412. noMipmap?: boolean,
  65413. /**
  65414. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65415. * but the standard material would require them in Gamma space) (default is true)
  65416. */
  65417. gammaSpace?: boolean);
  65418. /**
  65419. * Execute the current task
  65420. * @param scene defines the scene where you want your assets to be loaded
  65421. * @param onSuccess is a callback called when the task is successfully executed
  65422. * @param onError is a callback called if an error occurs
  65423. */
  65424. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65425. }
  65426. /**
  65427. * This class can be used to easily import assets into a scene
  65428. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65429. */
  65430. export class AssetsManager {
  65431. private _scene;
  65432. private _isLoading;
  65433. protected _tasks: AbstractAssetTask[];
  65434. protected _waitingTasksCount: number;
  65435. protected _totalTasksCount: number;
  65436. /**
  65437. * Callback called when all tasks are processed
  65438. */
  65439. onFinish: (tasks: AbstractAssetTask[]) => void;
  65440. /**
  65441. * Callback called when a task is successful
  65442. */
  65443. onTaskSuccess: (task: AbstractAssetTask) => void;
  65444. /**
  65445. * Callback called when a task had an error
  65446. */
  65447. onTaskError: (task: AbstractAssetTask) => void;
  65448. /**
  65449. * Callback called when a task is done (whatever the result is)
  65450. */
  65451. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65452. /**
  65453. * Observable called when all tasks are processed
  65454. */
  65455. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65456. /**
  65457. * Observable called when a task had an error
  65458. */
  65459. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65460. /**
  65461. * Observable called when all tasks were executed
  65462. */
  65463. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65464. /**
  65465. * Observable called when a task is done (whatever the result is)
  65466. */
  65467. onProgressObservable: Observable<IAssetsProgressEvent>;
  65468. /**
  65469. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65470. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65471. */
  65472. useDefaultLoadingScreen: boolean;
  65473. /**
  65474. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65475. * when all assets have been downloaded.
  65476. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65477. */
  65478. autoHideLoadingUI: boolean;
  65479. /**
  65480. * Creates a new AssetsManager
  65481. * @param scene defines the scene to work on
  65482. */
  65483. constructor(scene: Scene);
  65484. /**
  65485. * Add a MeshAssetTask to the list of active tasks
  65486. * @param taskName defines the name of the new task
  65487. * @param meshesNames defines the name of meshes to load
  65488. * @param rootUrl defines the root url to use to locate files
  65489. * @param sceneFilename defines the filename of the scene file
  65490. * @returns a new MeshAssetTask object
  65491. */
  65492. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65493. /**
  65494. * Add a TextFileAssetTask to the list of active tasks
  65495. * @param taskName defines the name of the new task
  65496. * @param url defines the url of the file to load
  65497. * @returns a new TextFileAssetTask object
  65498. */
  65499. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65500. /**
  65501. * Add a BinaryFileAssetTask to the list of active tasks
  65502. * @param taskName defines the name of the new task
  65503. * @param url defines the url of the file to load
  65504. * @returns a new BinaryFileAssetTask object
  65505. */
  65506. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65507. /**
  65508. * Add a ImageAssetTask to the list of active tasks
  65509. * @param taskName defines the name of the new task
  65510. * @param url defines the url of the file to load
  65511. * @returns a new ImageAssetTask object
  65512. */
  65513. addImageTask(taskName: string, url: string): ImageAssetTask;
  65514. /**
  65515. * Add a TextureAssetTask to the list of active tasks
  65516. * @param taskName defines the name of the new task
  65517. * @param url defines the url of the file to load
  65518. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65519. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65520. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65521. * @returns a new TextureAssetTask object
  65522. */
  65523. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65524. /**
  65525. * Add a CubeTextureAssetTask to the list of active tasks
  65526. * @param taskName defines the name of the new task
  65527. * @param url defines the url of the file to load
  65528. * @param extensions defines the extension to use to load the cube map (can be null)
  65529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65530. * @param files defines the list of files to load (can be null)
  65531. * @returns a new CubeTextureAssetTask object
  65532. */
  65533. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65534. /**
  65535. *
  65536. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65537. * @param taskName defines the name of the new task
  65538. * @param url defines the url of the file to load
  65539. * @param size defines the size you want for the cubemap (can be null)
  65540. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65541. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65542. * @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)
  65543. * @param reserved Internal use only
  65544. * @returns a new HDRCubeTextureAssetTask object
  65545. */
  65546. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65547. /**
  65548. *
  65549. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65550. * @param taskName defines the name of the new task
  65551. * @param url defines the url of the file to load
  65552. * @param size defines the size you want for the cubemap (can be null)
  65553. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65554. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65555. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65556. * @returns a new EquiRectangularCubeTextureAssetTask object
  65557. */
  65558. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65559. /**
  65560. * Remove a task from the assets manager.
  65561. * @param task the task to remove
  65562. */
  65563. removeTask(task: AbstractAssetTask): void;
  65564. private _decreaseWaitingTasksCount;
  65565. private _runTask;
  65566. /**
  65567. * Reset the AssetsManager and remove all tasks
  65568. * @return the current instance of the AssetsManager
  65569. */
  65570. reset(): AssetsManager;
  65571. /**
  65572. * Start the loading process
  65573. * @return the current instance of the AssetsManager
  65574. */
  65575. load(): AssetsManager;
  65576. /**
  65577. * Start the loading process as an async operation
  65578. * @return a promise returning the list of failed tasks
  65579. */
  65580. loadAsync(): Promise<void>;
  65581. }
  65582. }
  65583. declare module "babylonjs/Misc/deferred" {
  65584. /**
  65585. * Wrapper class for promise with external resolve and reject.
  65586. */
  65587. export class Deferred<T> {
  65588. /**
  65589. * The promise associated with this deferred object.
  65590. */
  65591. readonly promise: Promise<T>;
  65592. private _resolve;
  65593. private _reject;
  65594. /**
  65595. * The resolve method of the promise associated with this deferred object.
  65596. */
  65597. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65598. /**
  65599. * The reject method of the promise associated with this deferred object.
  65600. */
  65601. readonly reject: (reason?: any) => void;
  65602. /**
  65603. * Constructor for this deferred object.
  65604. */
  65605. constructor();
  65606. }
  65607. }
  65608. declare module "babylonjs/Misc/meshExploder" {
  65609. import { Mesh } from "babylonjs/Meshes/mesh";
  65610. /**
  65611. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65612. */
  65613. export class MeshExploder {
  65614. private _centerMesh;
  65615. private _meshes;
  65616. private _meshesOrigins;
  65617. private _toCenterVectors;
  65618. private _scaledDirection;
  65619. private _newPosition;
  65620. private _centerPosition;
  65621. /**
  65622. * Explodes meshes from a center mesh.
  65623. * @param meshes The meshes to explode.
  65624. * @param centerMesh The mesh to be center of explosion.
  65625. */
  65626. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65627. private _setCenterMesh;
  65628. /**
  65629. * Get class name
  65630. * @returns "MeshExploder"
  65631. */
  65632. getClassName(): string;
  65633. /**
  65634. * "Exploded meshes"
  65635. * @returns Array of meshes with the centerMesh at index 0.
  65636. */
  65637. getMeshes(): Array<Mesh>;
  65638. /**
  65639. * Explodes meshes giving a specific direction
  65640. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65641. */
  65642. explode(direction?: number): void;
  65643. }
  65644. }
  65645. declare module "babylonjs/Misc/filesInput" {
  65646. import { Engine } from "babylonjs/Engines/engine";
  65647. import { Scene } from "babylonjs/scene";
  65648. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65649. /**
  65650. * Class used to help managing file picking and drag'n'drop
  65651. */
  65652. export class FilesInput {
  65653. /**
  65654. * List of files ready to be loaded
  65655. */
  65656. static readonly FilesToLoad: {
  65657. [key: string]: File;
  65658. };
  65659. /**
  65660. * Callback called when a file is processed
  65661. */
  65662. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65663. private _engine;
  65664. private _currentScene;
  65665. private _sceneLoadedCallback;
  65666. private _progressCallback;
  65667. private _additionalRenderLoopLogicCallback;
  65668. private _textureLoadingCallback;
  65669. private _startingProcessingFilesCallback;
  65670. private _onReloadCallback;
  65671. private _errorCallback;
  65672. private _elementToMonitor;
  65673. private _sceneFileToLoad;
  65674. private _filesToLoad;
  65675. /**
  65676. * Creates a new FilesInput
  65677. * @param engine defines the rendering engine
  65678. * @param scene defines the hosting scene
  65679. * @param sceneLoadedCallback callback called when scene is loaded
  65680. * @param progressCallback callback called to track progress
  65681. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65682. * @param textureLoadingCallback callback called when a texture is loading
  65683. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65684. * @param onReloadCallback callback called when a reload is requested
  65685. * @param errorCallback callback call if an error occurs
  65686. */
  65687. 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);
  65688. private _dragEnterHandler;
  65689. private _dragOverHandler;
  65690. private _dropHandler;
  65691. /**
  65692. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65693. * @param elementToMonitor defines the DOM element to track
  65694. */
  65695. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65696. /**
  65697. * Release all associated resources
  65698. */
  65699. dispose(): void;
  65700. private renderFunction;
  65701. private drag;
  65702. private drop;
  65703. private _traverseFolder;
  65704. private _processFiles;
  65705. /**
  65706. * Load files from a drop event
  65707. * @param event defines the drop event to use as source
  65708. */
  65709. loadFiles(event: any): void;
  65710. private _processReload;
  65711. /**
  65712. * Reload the current scene from the loaded files
  65713. */
  65714. reload(): void;
  65715. }
  65716. }
  65717. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65718. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65719. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65720. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65721. }
  65722. declare module "babylonjs/Misc/sceneOptimizer" {
  65723. import { Scene, IDisposable } from "babylonjs/scene";
  65724. import { Observable } from "babylonjs/Misc/observable";
  65725. /**
  65726. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65727. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65728. */
  65729. export class SceneOptimization {
  65730. /**
  65731. * Defines the priority of this optimization (0 by default which means first in the list)
  65732. */
  65733. priority: number;
  65734. /**
  65735. * Gets a string describing the action executed by the current optimization
  65736. * @returns description string
  65737. */
  65738. getDescription(): string;
  65739. /**
  65740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65741. * @param scene defines the current scene where to apply this optimization
  65742. * @param optimizer defines the current optimizer
  65743. * @returns true if everything that can be done was applied
  65744. */
  65745. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65746. /**
  65747. * Creates the SceneOptimization object
  65748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65749. * @param desc defines the description associated with the optimization
  65750. */
  65751. constructor(
  65752. /**
  65753. * Defines the priority of this optimization (0 by default which means first in the list)
  65754. */
  65755. priority?: number);
  65756. }
  65757. /**
  65758. * Defines an optimization used to reduce the size of render target textures
  65759. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65760. */
  65761. export class TextureOptimization extends SceneOptimization {
  65762. /**
  65763. * Defines the priority of this optimization (0 by default which means first in the list)
  65764. */
  65765. priority: number;
  65766. /**
  65767. * 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
  65768. */
  65769. maximumSize: number;
  65770. /**
  65771. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65772. */
  65773. step: number;
  65774. /**
  65775. * Gets a string describing the action executed by the current optimization
  65776. * @returns description string
  65777. */
  65778. getDescription(): string;
  65779. /**
  65780. * Creates the TextureOptimization object
  65781. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65782. * @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
  65783. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65784. */
  65785. constructor(
  65786. /**
  65787. * Defines the priority of this optimization (0 by default which means first in the list)
  65788. */
  65789. priority?: number,
  65790. /**
  65791. * 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
  65792. */
  65793. maximumSize?: number,
  65794. /**
  65795. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65796. */
  65797. step?: number);
  65798. /**
  65799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65800. * @param scene defines the current scene where to apply this optimization
  65801. * @param optimizer defines the current optimizer
  65802. * @returns true if everything that can be done was applied
  65803. */
  65804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65805. }
  65806. /**
  65807. * Defines an optimization used to increase or decrease the rendering resolution
  65808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65809. */
  65810. export class HardwareScalingOptimization extends SceneOptimization {
  65811. /**
  65812. * Defines the priority of this optimization (0 by default which means first in the list)
  65813. */
  65814. priority: number;
  65815. /**
  65816. * Defines the maximum scale to use (2 by default)
  65817. */
  65818. maximumScale: number;
  65819. /**
  65820. * Defines the step to use between two passes (0.5 by default)
  65821. */
  65822. step: number;
  65823. private _currentScale;
  65824. private _directionOffset;
  65825. /**
  65826. * Gets a string describing the action executed by the current optimization
  65827. * @return description string
  65828. */
  65829. getDescription(): string;
  65830. /**
  65831. * Creates the HardwareScalingOptimization object
  65832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65833. * @param maximumScale defines the maximum scale to use (2 by default)
  65834. * @param step defines the step to use between two passes (0.5 by default)
  65835. */
  65836. constructor(
  65837. /**
  65838. * Defines the priority of this optimization (0 by default which means first in the list)
  65839. */
  65840. priority?: number,
  65841. /**
  65842. * Defines the maximum scale to use (2 by default)
  65843. */
  65844. maximumScale?: number,
  65845. /**
  65846. * Defines the step to use between two passes (0.5 by default)
  65847. */
  65848. step?: number);
  65849. /**
  65850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65851. * @param scene defines the current scene where to apply this optimization
  65852. * @param optimizer defines the current optimizer
  65853. * @returns true if everything that can be done was applied
  65854. */
  65855. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65856. }
  65857. /**
  65858. * Defines an optimization used to remove shadows
  65859. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65860. */
  65861. export class ShadowsOptimization extends SceneOptimization {
  65862. /**
  65863. * Gets a string describing the action executed by the current optimization
  65864. * @return description string
  65865. */
  65866. getDescription(): string;
  65867. /**
  65868. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65869. * @param scene defines the current scene where to apply this optimization
  65870. * @param optimizer defines the current optimizer
  65871. * @returns true if everything that can be done was applied
  65872. */
  65873. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65874. }
  65875. /**
  65876. * Defines an optimization used to turn post-processes off
  65877. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65878. */
  65879. export class PostProcessesOptimization extends SceneOptimization {
  65880. /**
  65881. * Gets a string describing the action executed by the current optimization
  65882. * @return description string
  65883. */
  65884. getDescription(): string;
  65885. /**
  65886. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65887. * @param scene defines the current scene where to apply this optimization
  65888. * @param optimizer defines the current optimizer
  65889. * @returns true if everything that can be done was applied
  65890. */
  65891. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65892. }
  65893. /**
  65894. * Defines an optimization used to turn lens flares off
  65895. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65896. */
  65897. export class LensFlaresOptimization extends SceneOptimization {
  65898. /**
  65899. * Gets a string describing the action executed by the current optimization
  65900. * @return description string
  65901. */
  65902. getDescription(): string;
  65903. /**
  65904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65905. * @param scene defines the current scene where to apply this optimization
  65906. * @param optimizer defines the current optimizer
  65907. * @returns true if everything that can be done was applied
  65908. */
  65909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65910. }
  65911. /**
  65912. * Defines an optimization based on user defined callback.
  65913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65914. */
  65915. export class CustomOptimization extends SceneOptimization {
  65916. /**
  65917. * Callback called to apply the custom optimization.
  65918. */
  65919. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65920. /**
  65921. * Callback called to get custom description
  65922. */
  65923. onGetDescription: () => string;
  65924. /**
  65925. * Gets a string describing the action executed by the current optimization
  65926. * @returns description string
  65927. */
  65928. getDescription(): string;
  65929. /**
  65930. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65931. * @param scene defines the current scene where to apply this optimization
  65932. * @param optimizer defines the current optimizer
  65933. * @returns true if everything that can be done was applied
  65934. */
  65935. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65936. }
  65937. /**
  65938. * Defines an optimization used to turn particles off
  65939. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65940. */
  65941. export class ParticlesOptimization extends SceneOptimization {
  65942. /**
  65943. * Gets a string describing the action executed by the current optimization
  65944. * @return description string
  65945. */
  65946. getDescription(): string;
  65947. /**
  65948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65949. * @param scene defines the current scene where to apply this optimization
  65950. * @param optimizer defines the current optimizer
  65951. * @returns true if everything that can be done was applied
  65952. */
  65953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65954. }
  65955. /**
  65956. * Defines an optimization used to turn render targets off
  65957. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65958. */
  65959. export class RenderTargetsOptimization extends SceneOptimization {
  65960. /**
  65961. * Gets a string describing the action executed by the current optimization
  65962. * @return description string
  65963. */
  65964. getDescription(): string;
  65965. /**
  65966. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65967. * @param scene defines the current scene where to apply this optimization
  65968. * @param optimizer defines the current optimizer
  65969. * @returns true if everything that can be done was applied
  65970. */
  65971. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65972. }
  65973. /**
  65974. * Defines an optimization used to merge meshes with compatible materials
  65975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65976. */
  65977. export class MergeMeshesOptimization extends SceneOptimization {
  65978. private static _UpdateSelectionTree;
  65979. /**
  65980. * Gets or sets a boolean which defines if optimization octree has to be updated
  65981. */
  65982. /**
  65983. * Gets or sets a boolean which defines if optimization octree has to be updated
  65984. */
  65985. static UpdateSelectionTree: boolean;
  65986. /**
  65987. * Gets a string describing the action executed by the current optimization
  65988. * @return description string
  65989. */
  65990. getDescription(): string;
  65991. private _canBeMerged;
  65992. /**
  65993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65994. * @param scene defines the current scene where to apply this optimization
  65995. * @param optimizer defines the current optimizer
  65996. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65997. * @returns true if everything that can be done was applied
  65998. */
  65999. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66000. }
  66001. /**
  66002. * Defines a list of options used by SceneOptimizer
  66003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66004. */
  66005. export class SceneOptimizerOptions {
  66006. /**
  66007. * Defines the target frame rate to reach (60 by default)
  66008. */
  66009. targetFrameRate: number;
  66010. /**
  66011. * Defines the interval between two checkes (2000ms by default)
  66012. */
  66013. trackerDuration: number;
  66014. /**
  66015. * Gets the list of optimizations to apply
  66016. */
  66017. optimizations: SceneOptimization[];
  66018. /**
  66019. * Creates a new list of options used by SceneOptimizer
  66020. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66021. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66022. */
  66023. constructor(
  66024. /**
  66025. * Defines the target frame rate to reach (60 by default)
  66026. */
  66027. targetFrameRate?: number,
  66028. /**
  66029. * Defines the interval between two checkes (2000ms by default)
  66030. */
  66031. trackerDuration?: number);
  66032. /**
  66033. * Add a new optimization
  66034. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66035. * @returns the current SceneOptimizerOptions
  66036. */
  66037. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66038. /**
  66039. * Add a new custom optimization
  66040. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66041. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66043. * @returns the current SceneOptimizerOptions
  66044. */
  66045. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66046. /**
  66047. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66048. * @param targetFrameRate defines the target frame rate (60 by default)
  66049. * @returns a SceneOptimizerOptions object
  66050. */
  66051. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66052. /**
  66053. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66054. * @param targetFrameRate defines the target frame rate (60 by default)
  66055. * @returns a SceneOptimizerOptions object
  66056. */
  66057. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66058. /**
  66059. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66060. * @param targetFrameRate defines the target frame rate (60 by default)
  66061. * @returns a SceneOptimizerOptions object
  66062. */
  66063. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66064. }
  66065. /**
  66066. * Class used to run optimizations in order to reach a target frame rate
  66067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66068. */
  66069. export class SceneOptimizer implements IDisposable {
  66070. private _isRunning;
  66071. private _options;
  66072. private _scene;
  66073. private _currentPriorityLevel;
  66074. private _targetFrameRate;
  66075. private _trackerDuration;
  66076. private _currentFrameRate;
  66077. private _sceneDisposeObserver;
  66078. private _improvementMode;
  66079. /**
  66080. * Defines an observable called when the optimizer reaches the target frame rate
  66081. */
  66082. onSuccessObservable: Observable<SceneOptimizer>;
  66083. /**
  66084. * Defines an observable called when the optimizer enables an optimization
  66085. */
  66086. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66087. /**
  66088. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66089. */
  66090. onFailureObservable: Observable<SceneOptimizer>;
  66091. /**
  66092. * Gets a boolean indicating if the optimizer is in improvement mode
  66093. */
  66094. readonly isInImprovementMode: boolean;
  66095. /**
  66096. * Gets the current priority level (0 at start)
  66097. */
  66098. readonly currentPriorityLevel: number;
  66099. /**
  66100. * Gets the current frame rate checked by the SceneOptimizer
  66101. */
  66102. readonly currentFrameRate: number;
  66103. /**
  66104. * Gets or sets the current target frame rate (60 by default)
  66105. */
  66106. /**
  66107. * Gets or sets the current target frame rate (60 by default)
  66108. */
  66109. targetFrameRate: number;
  66110. /**
  66111. * Gets or sets the current interval between two checks (every 2000ms by default)
  66112. */
  66113. /**
  66114. * Gets or sets the current interval between two checks (every 2000ms by default)
  66115. */
  66116. trackerDuration: number;
  66117. /**
  66118. * Gets the list of active optimizations
  66119. */
  66120. readonly optimizations: SceneOptimization[];
  66121. /**
  66122. * Creates a new SceneOptimizer
  66123. * @param scene defines the scene to work on
  66124. * @param options defines the options to use with the SceneOptimizer
  66125. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66126. * @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)
  66127. */
  66128. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66129. /**
  66130. * Stops the current optimizer
  66131. */
  66132. stop(): void;
  66133. /**
  66134. * Reset the optimizer to initial step (current priority level = 0)
  66135. */
  66136. reset(): void;
  66137. /**
  66138. * Start the optimizer. By default it will try to reach a specific framerate
  66139. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66140. */
  66141. start(): void;
  66142. private _checkCurrentState;
  66143. /**
  66144. * Release all resources
  66145. */
  66146. dispose(): void;
  66147. /**
  66148. * Helper function to create a SceneOptimizer with one single line of code
  66149. * @param scene defines the scene to work on
  66150. * @param options defines the options to use with the SceneOptimizer
  66151. * @param onSuccess defines a callback to call on success
  66152. * @param onFailure defines a callback to call on failure
  66153. * @returns the new SceneOptimizer object
  66154. */
  66155. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66156. }
  66157. }
  66158. declare module "babylonjs/Misc/sceneSerializer" {
  66159. import { Scene } from "babylonjs/scene";
  66160. /**
  66161. * Class used to serialize a scene into a string
  66162. */
  66163. export class SceneSerializer {
  66164. /**
  66165. * Clear cache used by a previous serialization
  66166. */
  66167. static ClearCache(): void;
  66168. /**
  66169. * Serialize a scene into a JSON compatible object
  66170. * @param scene defines the scene to serialize
  66171. * @returns a JSON compatible object
  66172. */
  66173. static Serialize(scene: Scene): any;
  66174. /**
  66175. * Serialize a mesh into a JSON compatible object
  66176. * @param toSerialize defines the mesh to serialize
  66177. * @param withParents defines if parents must be serialized as well
  66178. * @param withChildren defines if children must be serialized as well
  66179. * @returns a JSON compatible object
  66180. */
  66181. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66182. }
  66183. }
  66184. declare module "babylonjs/Misc/textureTools" {
  66185. import { Texture } from "babylonjs/Materials/Textures/texture";
  66186. /**
  66187. * Class used to host texture specific utilities
  66188. */
  66189. export class TextureTools {
  66190. /**
  66191. * Uses the GPU to create a copy texture rescaled at a given size
  66192. * @param texture Texture to copy from
  66193. * @param width defines the desired width
  66194. * @param height defines the desired height
  66195. * @param useBilinearMode defines if bilinear mode has to be used
  66196. * @return the generated texture
  66197. */
  66198. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66199. }
  66200. }
  66201. declare module "babylonjs/Misc/videoRecorder" {
  66202. import { Nullable } from "babylonjs/types";
  66203. import { Engine } from "babylonjs/Engines/engine";
  66204. /**
  66205. * This represents the different options available for the video capture.
  66206. */
  66207. export interface VideoRecorderOptions {
  66208. /** Defines the mime type of the video. */
  66209. mimeType: string;
  66210. /** Defines the FPS the video should be recorded at. */
  66211. fps: number;
  66212. /** Defines the chunk size for the recording data. */
  66213. recordChunckSize: number;
  66214. /** The audio tracks to attach to the recording. */
  66215. audioTracks?: MediaStreamTrack[];
  66216. }
  66217. /**
  66218. * This can help with recording videos from BabylonJS.
  66219. * This is based on the available WebRTC functionalities of the browser.
  66220. *
  66221. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66222. */
  66223. export class VideoRecorder {
  66224. private static readonly _defaultOptions;
  66225. /**
  66226. * Returns whether or not the VideoRecorder is available in your browser.
  66227. * @param engine Defines the Babylon Engine.
  66228. * @returns true if supported otherwise false.
  66229. */
  66230. static IsSupported(engine: Engine): boolean;
  66231. private readonly _options;
  66232. private _canvas;
  66233. private _mediaRecorder;
  66234. private _recordedChunks;
  66235. private _fileName;
  66236. private _resolve;
  66237. private _reject;
  66238. /**
  66239. * True when a recording is already in progress.
  66240. */
  66241. readonly isRecording: boolean;
  66242. /**
  66243. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66244. * @param engine Defines the BabylonJS Engine you wish to record.
  66245. * @param options Defines options that can be used to customize the capture.
  66246. */
  66247. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66248. /**
  66249. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66250. */
  66251. stopRecording(): void;
  66252. /**
  66253. * Starts recording the canvas for a max duration specified in parameters.
  66254. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66255. * If null no automatic download will start and you can rely on the promise to get the data back.
  66256. * @param maxDuration Defines the maximum recording time in seconds.
  66257. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66258. * @return A promise callback at the end of the recording with the video data in Blob.
  66259. */
  66260. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66261. /**
  66262. * Releases internal resources used during the recording.
  66263. */
  66264. dispose(): void;
  66265. private _handleDataAvailable;
  66266. private _handleError;
  66267. private _handleStop;
  66268. }
  66269. }
  66270. declare module "babylonjs/Misc/screenshotTools" {
  66271. import { Camera } from "babylonjs/Cameras/camera";
  66272. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66273. import { Engine } from "babylonjs/Engines/engine";
  66274. /**
  66275. * Class containing a set of static utilities functions for screenshots
  66276. */
  66277. export class ScreenshotTools {
  66278. /**
  66279. * Captures a screenshot of the current rendering
  66280. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66281. * @param engine defines the rendering engine
  66282. * @param camera defines the source camera
  66283. * @param size This parameter can be set to a single number or to an object with the
  66284. * following (optional) properties: precision, width, height. If a single number is passed,
  66285. * it will be used for both width and height. If an object is passed, the screenshot size
  66286. * will be derived from the parameters. The precision property is a multiplier allowing
  66287. * rendering at a higher or lower resolution
  66288. * @param successCallback defines the callback receives a single parameter which contains the
  66289. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66290. * src parameter of an <img> to display it
  66291. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66292. * Check your browser for supported MIME types
  66293. */
  66294. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66295. /**
  66296. * Captures a screenshot of the current rendering
  66297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66298. * @param engine defines the rendering engine
  66299. * @param camera defines the source camera
  66300. * @param size This parameter can be set to a single number or to an object with the
  66301. * following (optional) properties: precision, width, height. If a single number is passed,
  66302. * it will be used for both width and height. If an object is passed, the screenshot size
  66303. * will be derived from the parameters. The precision property is a multiplier allowing
  66304. * rendering at a higher or lower resolution
  66305. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66306. * Check your browser for supported MIME types
  66307. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66308. * to the src parameter of an <img> to display it
  66309. */
  66310. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66311. /**
  66312. * Generates an image screenshot from the specified camera.
  66313. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66314. * @param engine The engine to use for rendering
  66315. * @param camera The camera to use for rendering
  66316. * @param size This parameter can be set to a single number or to an object with the
  66317. * following (optional) properties: precision, width, height. If a single number is passed,
  66318. * it will be used for both width and height. If an object is passed, the screenshot size
  66319. * will be derived from the parameters. The precision property is a multiplier allowing
  66320. * rendering at a higher or lower resolution
  66321. * @param successCallback The callback receives a single parameter which contains the
  66322. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66323. * src parameter of an <img> to display it
  66324. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66325. * Check your browser for supported MIME types
  66326. * @param samples Texture samples (default: 1)
  66327. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66328. * @param fileName A name for for the downloaded file.
  66329. */
  66330. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66331. /**
  66332. * Generates an image screenshot from the specified camera.
  66333. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66334. * @param engine The engine to use for rendering
  66335. * @param camera The camera to use for rendering
  66336. * @param size This parameter can be set to a single number or to an object with the
  66337. * following (optional) properties: precision, width, height. If a single number is passed,
  66338. * it will be used for both width and height. If an object is passed, the screenshot size
  66339. * will be derived from the parameters. The precision property is a multiplier allowing
  66340. * rendering at a higher or lower resolution
  66341. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66342. * Check your browser for supported MIME types
  66343. * @param samples Texture samples (default: 1)
  66344. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66345. * @param fileName A name for for the downloaded file.
  66346. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66347. * to the src parameter of an <img> to display it
  66348. */
  66349. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66350. /**
  66351. * Gets height and width for screenshot size
  66352. * @private
  66353. */
  66354. private static _getScreenshotSize;
  66355. }
  66356. }
  66357. declare module "babylonjs/Misc/index" {
  66358. export * from "babylonjs/Misc/andOrNotEvaluator";
  66359. export * from "babylonjs/Misc/assetsManager";
  66360. export * from "babylonjs/Misc/dds";
  66361. export * from "babylonjs/Misc/decorators";
  66362. export * from "babylonjs/Misc/deferred";
  66363. export * from "babylonjs/Misc/environmentTextureTools";
  66364. export * from "babylonjs/Misc/meshExploder";
  66365. export * from "babylonjs/Misc/filesInput";
  66366. export * from "babylonjs/Misc/HighDynamicRange/index";
  66367. export * from "babylonjs/Misc/khronosTextureContainer";
  66368. export * from "babylonjs/Misc/observable";
  66369. export * from "babylonjs/Misc/performanceMonitor";
  66370. export * from "babylonjs/Misc/promise";
  66371. export * from "babylonjs/Misc/sceneOptimizer";
  66372. export * from "babylonjs/Misc/sceneSerializer";
  66373. export * from "babylonjs/Misc/smartArray";
  66374. export * from "babylonjs/Misc/stringDictionary";
  66375. export * from "babylonjs/Misc/tags";
  66376. export * from "babylonjs/Misc/textureTools";
  66377. export * from "babylonjs/Misc/tga";
  66378. export * from "babylonjs/Misc/tools";
  66379. export * from "babylonjs/Misc/videoRecorder";
  66380. export * from "babylonjs/Misc/virtualJoystick";
  66381. export * from "babylonjs/Misc/workerPool";
  66382. export * from "babylonjs/Misc/logger";
  66383. export * from "babylonjs/Misc/typeStore";
  66384. export * from "babylonjs/Misc/filesInputStore";
  66385. export * from "babylonjs/Misc/deepCopier";
  66386. export * from "babylonjs/Misc/pivotTools";
  66387. export * from "babylonjs/Misc/precisionDate";
  66388. export * from "babylonjs/Misc/screenshotTools";
  66389. export * from "babylonjs/Misc/typeStore";
  66390. export * from "babylonjs/Misc/webRequest";
  66391. export * from "babylonjs/Misc/iInspectable";
  66392. export * from "babylonjs/Misc/brdfTextureTools";
  66393. export * from "babylonjs/Misc/rgbdTextureTools";
  66394. export * from "babylonjs/Misc/gradients";
  66395. export * from "babylonjs/Misc/perfCounter";
  66396. export * from "babylonjs/Misc/fileRequest";
  66397. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66398. export * from "babylonjs/Misc/retryStrategy";
  66399. export * from "babylonjs/Misc/loadFileError";
  66400. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66401. }
  66402. declare module "babylonjs/index" {
  66403. export * from "babylonjs/abstractScene";
  66404. export * from "babylonjs/Actions/index";
  66405. export * from "babylonjs/Animations/index";
  66406. export * from "babylonjs/assetContainer";
  66407. export * from "babylonjs/Audio/index";
  66408. export * from "babylonjs/Behaviors/index";
  66409. export * from "babylonjs/Bones/index";
  66410. export * from "babylonjs/Cameras/index";
  66411. export * from "babylonjs/Collisions/index";
  66412. export * from "babylonjs/Culling/index";
  66413. export * from "babylonjs/Debug/index";
  66414. export * from "babylonjs/Engines/index";
  66415. export * from "babylonjs/Events/index";
  66416. export * from "babylonjs/Gamepads/index";
  66417. export * from "babylonjs/Gizmos/index";
  66418. export * from "babylonjs/Helpers/index";
  66419. export * from "babylonjs/Instrumentation/index";
  66420. export * from "babylonjs/Layers/index";
  66421. export * from "babylonjs/LensFlares/index";
  66422. export * from "babylonjs/Lights/index";
  66423. export * from "babylonjs/Loading/index";
  66424. export * from "babylonjs/Materials/index";
  66425. export * from "babylonjs/Maths/index";
  66426. export * from "babylonjs/Meshes/index";
  66427. export * from "babylonjs/Morph/index";
  66428. export * from "babylonjs/Navigation/index";
  66429. export * from "babylonjs/node";
  66430. export * from "babylonjs/Offline/index";
  66431. export * from "babylonjs/Particles/index";
  66432. export * from "babylonjs/Physics/index";
  66433. export * from "babylonjs/PostProcesses/index";
  66434. export * from "babylonjs/Probes/index";
  66435. export * from "babylonjs/Rendering/index";
  66436. export * from "babylonjs/scene";
  66437. export * from "babylonjs/sceneComponent";
  66438. export * from "babylonjs/Sprites/index";
  66439. export * from "babylonjs/States/index";
  66440. export * from "babylonjs/Misc/index";
  66441. export * from "babylonjs/types";
  66442. }
  66443. declare module "babylonjs/Animations/pathCursor" {
  66444. import { Vector3 } from "babylonjs/Maths/math.vector";
  66445. import { Path2 } from "babylonjs/Maths/math.path";
  66446. /**
  66447. * A cursor which tracks a point on a path
  66448. */
  66449. export class PathCursor {
  66450. private path;
  66451. /**
  66452. * Stores path cursor callbacks for when an onchange event is triggered
  66453. */
  66454. private _onchange;
  66455. /**
  66456. * The value of the path cursor
  66457. */
  66458. value: number;
  66459. /**
  66460. * The animation array of the path cursor
  66461. */
  66462. animations: Animation[];
  66463. /**
  66464. * Initializes the path cursor
  66465. * @param path The path to track
  66466. */
  66467. constructor(path: Path2);
  66468. /**
  66469. * Gets the cursor point on the path
  66470. * @returns A point on the path cursor at the cursor location
  66471. */
  66472. getPoint(): Vector3;
  66473. /**
  66474. * Moves the cursor ahead by the step amount
  66475. * @param step The amount to move the cursor forward
  66476. * @returns This path cursor
  66477. */
  66478. moveAhead(step?: number): PathCursor;
  66479. /**
  66480. * Moves the cursor behind by the step amount
  66481. * @param step The amount to move the cursor back
  66482. * @returns This path cursor
  66483. */
  66484. moveBack(step?: number): PathCursor;
  66485. /**
  66486. * Moves the cursor by the step amount
  66487. * If the step amount is greater than one, an exception is thrown
  66488. * @param step The amount to move the cursor
  66489. * @returns This path cursor
  66490. */
  66491. move(step: number): PathCursor;
  66492. /**
  66493. * Ensures that the value is limited between zero and one
  66494. * @returns This path cursor
  66495. */
  66496. private ensureLimits;
  66497. /**
  66498. * Runs onchange callbacks on change (used by the animation engine)
  66499. * @returns This path cursor
  66500. */
  66501. private raiseOnChange;
  66502. /**
  66503. * Executes a function on change
  66504. * @param f A path cursor onchange callback
  66505. * @returns This path cursor
  66506. */
  66507. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66508. }
  66509. }
  66510. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66511. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66512. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66513. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66514. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66515. }
  66516. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66517. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66518. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66519. }
  66520. declare module "babylonjs/Engines/Processors/index" {
  66521. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66522. export * from "babylonjs/Engines/Processors/Expressions/index";
  66523. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66524. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66525. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66526. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66527. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66528. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66529. }
  66530. declare module "babylonjs/Legacy/legacy" {
  66531. import * as Babylon from "babylonjs/index";
  66532. export * from "babylonjs/index";
  66533. }
  66534. declare module "babylonjs/Shaders/blur.fragment" {
  66535. /** @hidden */
  66536. export var blurPixelShader: {
  66537. name: string;
  66538. shader: string;
  66539. };
  66540. }
  66541. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66542. /** @hidden */
  66543. export var pointCloudVertexDeclaration: {
  66544. name: string;
  66545. shader: string;
  66546. };
  66547. }
  66548. declare module "babylonjs" {
  66549. export * from "babylonjs/Legacy/legacy";
  66550. }
  66551. declare module BABYLON {
  66552. /** Alias type for value that can be null */
  66553. export type Nullable<T> = T | null;
  66554. /**
  66555. * Alias type for number that are floats
  66556. * @ignorenaming
  66557. */
  66558. export type float = number;
  66559. /**
  66560. * Alias type for number that are doubles.
  66561. * @ignorenaming
  66562. */
  66563. export type double = number;
  66564. /**
  66565. * Alias type for number that are integer
  66566. * @ignorenaming
  66567. */
  66568. export type int = number;
  66569. /** Alias type for number array or Float32Array */
  66570. export type FloatArray = number[] | Float32Array;
  66571. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66572. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66573. /**
  66574. * Alias for types that can be used by a Buffer or VertexBuffer.
  66575. */
  66576. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66577. /**
  66578. * Alias type for primitive types
  66579. * @ignorenaming
  66580. */
  66581. type Primitive = undefined | null | boolean | string | number | Function;
  66582. /**
  66583. * Type modifier to make all the properties of an object Readonly
  66584. */
  66585. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66586. /**
  66587. * Type modifier to make all the properties of an object Readonly recursively
  66588. */
  66589. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66590. /**
  66591. * Type modifier to make object properties readonly.
  66592. */
  66593. export type DeepImmutableObject<T> = {
  66594. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66595. };
  66596. /** @hidden */
  66597. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66598. }
  66599. }
  66600. declare module BABYLON {
  66601. /**
  66602. * A class serves as a medium between the observable and its observers
  66603. */
  66604. export class EventState {
  66605. /**
  66606. * Create a new EventState
  66607. * @param mask defines the mask associated with this state
  66608. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66609. * @param target defines the original target of the state
  66610. * @param currentTarget defines the current target of the state
  66611. */
  66612. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66613. /**
  66614. * Initialize the current event state
  66615. * @param mask defines the mask associated with this state
  66616. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66617. * @param target defines the original target of the state
  66618. * @param currentTarget defines the current target of the state
  66619. * @returns the current event state
  66620. */
  66621. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66622. /**
  66623. * An Observer can set this property to true to prevent subsequent observers of being notified
  66624. */
  66625. skipNextObservers: boolean;
  66626. /**
  66627. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66628. */
  66629. mask: number;
  66630. /**
  66631. * The object that originally notified the event
  66632. */
  66633. target?: any;
  66634. /**
  66635. * The current object in the bubbling phase
  66636. */
  66637. currentTarget?: any;
  66638. /**
  66639. * This will be populated with the return value of the last function that was executed.
  66640. * If it is the first function in the callback chain it will be the event data.
  66641. */
  66642. lastReturnValue?: any;
  66643. }
  66644. /**
  66645. * Represent an Observer registered to a given Observable object.
  66646. */
  66647. export class Observer<T> {
  66648. /**
  66649. * Defines the callback to call when the observer is notified
  66650. */
  66651. callback: (eventData: T, eventState: EventState) => void;
  66652. /**
  66653. * Defines the mask of the observer (used to filter notifications)
  66654. */
  66655. mask: number;
  66656. /**
  66657. * Defines the current scope used to restore the JS context
  66658. */
  66659. scope: any;
  66660. /** @hidden */
  66661. _willBeUnregistered: boolean;
  66662. /**
  66663. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66664. */
  66665. unregisterOnNextCall: boolean;
  66666. /**
  66667. * Creates a new observer
  66668. * @param callback defines the callback to call when the observer is notified
  66669. * @param mask defines the mask of the observer (used to filter notifications)
  66670. * @param scope defines the current scope used to restore the JS context
  66671. */
  66672. constructor(
  66673. /**
  66674. * Defines the callback to call when the observer is notified
  66675. */
  66676. callback: (eventData: T, eventState: EventState) => void,
  66677. /**
  66678. * Defines the mask of the observer (used to filter notifications)
  66679. */
  66680. mask: number,
  66681. /**
  66682. * Defines the current scope used to restore the JS context
  66683. */
  66684. scope?: any);
  66685. }
  66686. /**
  66687. * Represent a list of observers registered to multiple Observables object.
  66688. */
  66689. export class MultiObserver<T> {
  66690. private _observers;
  66691. private _observables;
  66692. /**
  66693. * Release associated resources
  66694. */
  66695. dispose(): void;
  66696. /**
  66697. * Raise a callback when one of the observable will notify
  66698. * @param observables defines a list of observables to watch
  66699. * @param callback defines the callback to call on notification
  66700. * @param mask defines the mask used to filter notifications
  66701. * @param scope defines the current scope used to restore the JS context
  66702. * @returns the new MultiObserver
  66703. */
  66704. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66705. }
  66706. /**
  66707. * The Observable class is a simple implementation of the Observable pattern.
  66708. *
  66709. * 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.
  66710. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66711. * 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).
  66712. * 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.
  66713. */
  66714. export class Observable<T> {
  66715. private _observers;
  66716. private _eventState;
  66717. private _onObserverAdded;
  66718. /**
  66719. * Gets the list of observers
  66720. */
  66721. readonly observers: Array<Observer<T>>;
  66722. /**
  66723. * Creates a new observable
  66724. * @param onObserverAdded defines a callback to call when a new observer is added
  66725. */
  66726. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66727. /**
  66728. * Create a new Observer with the specified callback
  66729. * @param callback the callback that will be executed for that Observer
  66730. * @param mask the mask used to filter observers
  66731. * @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.
  66732. * @param scope optional scope for the callback to be called from
  66733. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66734. * @returns the new observer created for the callback
  66735. */
  66736. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66737. /**
  66738. * Create a new Observer with the specified callback and unregisters after the next notification
  66739. * @param callback the callback that will be executed for that Observer
  66740. * @returns the new observer created for the callback
  66741. */
  66742. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66743. /**
  66744. * Remove an Observer from the Observable object
  66745. * @param observer the instance of the Observer to remove
  66746. * @returns false if it doesn't belong to this Observable
  66747. */
  66748. remove(observer: Nullable<Observer<T>>): boolean;
  66749. /**
  66750. * Remove a callback from the Observable object
  66751. * @param callback the callback to remove
  66752. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66753. * @returns false if it doesn't belong to this Observable
  66754. */
  66755. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66756. private _deferUnregister;
  66757. private _remove;
  66758. /**
  66759. * Moves the observable to the top of the observer list making it get called first when notified
  66760. * @param observer the observer to move
  66761. */
  66762. makeObserverTopPriority(observer: Observer<T>): void;
  66763. /**
  66764. * Moves the observable to the bottom of the observer list making it get called last when notified
  66765. * @param observer the observer to move
  66766. */
  66767. makeObserverBottomPriority(observer: Observer<T>): void;
  66768. /**
  66769. * Notify all Observers by calling their respective callback with the given data
  66770. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66771. * @param eventData defines the data to send to all observers
  66772. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66773. * @param target defines the original target of the state
  66774. * @param currentTarget defines the current target of the state
  66775. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66776. */
  66777. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66778. /**
  66779. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66780. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66781. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66782. * and it is crucial that all callbacks will be executed.
  66783. * The order of the callbacks is kept, callbacks are not executed parallel.
  66784. *
  66785. * @param eventData The data to be sent to each callback
  66786. * @param mask is used to filter observers defaults to -1
  66787. * @param target defines the callback target (see EventState)
  66788. * @param currentTarget defines he current object in the bubbling phase
  66789. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66790. */
  66791. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66792. /**
  66793. * Notify a specific observer
  66794. * @param observer defines the observer to notify
  66795. * @param eventData defines the data to be sent to each callback
  66796. * @param mask is used to filter observers defaults to -1
  66797. */
  66798. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66799. /**
  66800. * Gets a boolean indicating if the observable has at least one observer
  66801. * @returns true is the Observable has at least one Observer registered
  66802. */
  66803. hasObservers(): boolean;
  66804. /**
  66805. * Clear the list of observers
  66806. */
  66807. clear(): void;
  66808. /**
  66809. * Clone the current observable
  66810. * @returns a new observable
  66811. */
  66812. clone(): Observable<T>;
  66813. /**
  66814. * Does this observable handles observer registered with a given mask
  66815. * @param mask defines the mask to be tested
  66816. * @return whether or not one observer registered with the given mask is handeled
  66817. **/
  66818. hasSpecificMask(mask?: number): boolean;
  66819. }
  66820. }
  66821. declare module BABYLON {
  66822. /**
  66823. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66824. * Babylon.js
  66825. */
  66826. export class DomManagement {
  66827. /**
  66828. * Checks if the window object exists
  66829. * @returns true if the window object exists
  66830. */
  66831. static IsWindowObjectExist(): boolean;
  66832. /**
  66833. * Checks if the navigator object exists
  66834. * @returns true if the navigator object exists
  66835. */
  66836. static IsNavigatorAvailable(): boolean;
  66837. /**
  66838. * Extracts text content from a DOM element hierarchy
  66839. * @param element defines the root element
  66840. * @returns a string
  66841. */
  66842. static GetDOMTextContent(element: HTMLElement): string;
  66843. }
  66844. }
  66845. declare module BABYLON {
  66846. /**
  66847. * Logger used througouht the application to allow configuration of
  66848. * the log level required for the messages.
  66849. */
  66850. export class Logger {
  66851. /**
  66852. * No log
  66853. */
  66854. static readonly NoneLogLevel: number;
  66855. /**
  66856. * Only message logs
  66857. */
  66858. static readonly MessageLogLevel: number;
  66859. /**
  66860. * Only warning logs
  66861. */
  66862. static readonly WarningLogLevel: number;
  66863. /**
  66864. * Only error logs
  66865. */
  66866. static readonly ErrorLogLevel: number;
  66867. /**
  66868. * All logs
  66869. */
  66870. static readonly AllLogLevel: number;
  66871. private static _LogCache;
  66872. /**
  66873. * Gets a value indicating the number of loading errors
  66874. * @ignorenaming
  66875. */
  66876. static errorsCount: number;
  66877. /**
  66878. * Callback called when a new log is added
  66879. */
  66880. static OnNewCacheEntry: (entry: string) => void;
  66881. private static _AddLogEntry;
  66882. private static _FormatMessage;
  66883. private static _LogDisabled;
  66884. private static _LogEnabled;
  66885. private static _WarnDisabled;
  66886. private static _WarnEnabled;
  66887. private static _ErrorDisabled;
  66888. private static _ErrorEnabled;
  66889. /**
  66890. * Log a message to the console
  66891. */
  66892. static Log: (message: string) => void;
  66893. /**
  66894. * Write a warning message to the console
  66895. */
  66896. static Warn: (message: string) => void;
  66897. /**
  66898. * Write an error message to the console
  66899. */
  66900. static Error: (message: string) => void;
  66901. /**
  66902. * Gets current log cache (list of logs)
  66903. */
  66904. static readonly LogCache: string;
  66905. /**
  66906. * Clears the log cache
  66907. */
  66908. static ClearLogCache(): void;
  66909. /**
  66910. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66911. */
  66912. static LogLevels: number;
  66913. }
  66914. }
  66915. declare module BABYLON {
  66916. /** @hidden */
  66917. export class _TypeStore {
  66918. /** @hidden */
  66919. static RegisteredTypes: {
  66920. [key: string]: Object;
  66921. };
  66922. /** @hidden */
  66923. static GetClass(fqdn: string): any;
  66924. }
  66925. }
  66926. declare module BABYLON {
  66927. /**
  66928. * Class containing a set of static utilities functions for deep copy.
  66929. */
  66930. export class DeepCopier {
  66931. /**
  66932. * Tries to copy an object by duplicating every property
  66933. * @param source defines the source object
  66934. * @param destination defines the target object
  66935. * @param doNotCopyList defines a list of properties to avoid
  66936. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66937. */
  66938. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66939. }
  66940. }
  66941. declare module BABYLON {
  66942. /**
  66943. * Class containing a set of static utilities functions for precision date
  66944. */
  66945. export class PrecisionDate {
  66946. /**
  66947. * Gets either window.performance.now() if supported or Date.now() else
  66948. */
  66949. static readonly Now: number;
  66950. }
  66951. }
  66952. declare module BABYLON {
  66953. /** @hidden */
  66954. export class _DevTools {
  66955. static WarnImport(name: string): string;
  66956. }
  66957. }
  66958. declare module BABYLON {
  66959. /**
  66960. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66961. */
  66962. export class WebRequest {
  66963. private _xhr;
  66964. /**
  66965. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66966. * i.e. when loading files, where the server/service expects an Authorization header
  66967. */
  66968. static CustomRequestHeaders: {
  66969. [key: string]: string;
  66970. };
  66971. /**
  66972. * Add callback functions in this array to update all the requests before they get sent to the network
  66973. */
  66974. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66975. private _injectCustomRequestHeaders;
  66976. /**
  66977. * Gets or sets a function to be called when loading progress changes
  66978. */
  66979. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66980. /**
  66981. * Returns client's state
  66982. */
  66983. readonly readyState: number;
  66984. /**
  66985. * Returns client's status
  66986. */
  66987. readonly status: number;
  66988. /**
  66989. * Returns client's status as a text
  66990. */
  66991. readonly statusText: string;
  66992. /**
  66993. * Returns client's response
  66994. */
  66995. readonly response: any;
  66996. /**
  66997. * Returns client's response url
  66998. */
  66999. readonly responseURL: string;
  67000. /**
  67001. * Returns client's response as text
  67002. */
  67003. readonly responseText: string;
  67004. /**
  67005. * Gets or sets the expected response type
  67006. */
  67007. responseType: XMLHttpRequestResponseType;
  67008. /** @hidden */
  67009. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67010. /** @hidden */
  67011. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67012. /**
  67013. * Cancels any network activity
  67014. */
  67015. abort(): void;
  67016. /**
  67017. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67018. * @param body defines an optional request body
  67019. */
  67020. send(body?: Document | BodyInit | null): void;
  67021. /**
  67022. * Sets the request method, request URL
  67023. * @param method defines the method to use (GET, POST, etc..)
  67024. * @param url defines the url to connect with
  67025. */
  67026. open(method: string, url: string): void;
  67027. }
  67028. }
  67029. declare module BABYLON {
  67030. /**
  67031. * File request interface
  67032. */
  67033. export interface IFileRequest {
  67034. /**
  67035. * Raised when the request is complete (success or error).
  67036. */
  67037. onCompleteObservable: Observable<IFileRequest>;
  67038. /**
  67039. * Aborts the request for a file.
  67040. */
  67041. abort: () => void;
  67042. }
  67043. }
  67044. declare module BABYLON {
  67045. /**
  67046. * Scalar computation library
  67047. */
  67048. export class Scalar {
  67049. /**
  67050. * Two pi constants convenient for computation.
  67051. */
  67052. static TwoPi: number;
  67053. /**
  67054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67055. * @param a number
  67056. * @param b number
  67057. * @param epsilon (default = 1.401298E-45)
  67058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67059. */
  67060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67061. /**
  67062. * Returns a string : the upper case translation of the number i to hexadecimal.
  67063. * @param i number
  67064. * @returns the upper case translation of the number i to hexadecimal.
  67065. */
  67066. static ToHex(i: number): string;
  67067. /**
  67068. * Returns -1 if value is negative and +1 is value is positive.
  67069. * @param value the value
  67070. * @returns the value itself if it's equal to zero.
  67071. */
  67072. static Sign(value: number): number;
  67073. /**
  67074. * Returns the value itself if it's between min and max.
  67075. * Returns min if the value is lower than min.
  67076. * Returns max if the value is greater than max.
  67077. * @param value the value to clmap
  67078. * @param min the min value to clamp to (default: 0)
  67079. * @param max the max value to clamp to (default: 1)
  67080. * @returns the clamped value
  67081. */
  67082. static Clamp(value: number, min?: number, max?: number): number;
  67083. /**
  67084. * the log2 of value.
  67085. * @param value the value to compute log2 of
  67086. * @returns the log2 of value.
  67087. */
  67088. static Log2(value: number): number;
  67089. /**
  67090. * Loops the value, so that it is never larger than length and never smaller than 0.
  67091. *
  67092. * This is similar to the modulo operator but it works with floating point numbers.
  67093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67094. * With t = 5 and length = 2.5, the result would be 0.0.
  67095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67096. * @param value the value
  67097. * @param length the length
  67098. * @returns the looped value
  67099. */
  67100. static Repeat(value: number, length: number): number;
  67101. /**
  67102. * Normalize the value between 0.0 and 1.0 using min and max values
  67103. * @param value value to normalize
  67104. * @param min max to normalize between
  67105. * @param max min to normalize between
  67106. * @returns the normalized value
  67107. */
  67108. static Normalize(value: number, min: number, max: number): number;
  67109. /**
  67110. * Denormalize the value from 0.0 and 1.0 using min and max values
  67111. * @param normalized value to denormalize
  67112. * @param min max to denormalize between
  67113. * @param max min to denormalize between
  67114. * @returns the denormalized value
  67115. */
  67116. static Denormalize(normalized: number, min: number, max: number): number;
  67117. /**
  67118. * Calculates the shortest difference between two given angles given in degrees.
  67119. * @param current current angle in degrees
  67120. * @param target target angle in degrees
  67121. * @returns the delta
  67122. */
  67123. static DeltaAngle(current: number, target: number): number;
  67124. /**
  67125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67126. * @param tx value
  67127. * @param length length
  67128. * @returns The returned value will move back and forth between 0 and length
  67129. */
  67130. static PingPong(tx: number, length: number): number;
  67131. /**
  67132. * Interpolates between min and max with smoothing at the limits.
  67133. *
  67134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67136. * @param from from
  67137. * @param to to
  67138. * @param tx value
  67139. * @returns the smooth stepped value
  67140. */
  67141. static SmoothStep(from: number, to: number, tx: number): number;
  67142. /**
  67143. * Moves a value current towards target.
  67144. *
  67145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67146. * Negative values of maxDelta pushes the value away from target.
  67147. * @param current current value
  67148. * @param target target value
  67149. * @param maxDelta max distance to move
  67150. * @returns resulting value
  67151. */
  67152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67153. /**
  67154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67155. *
  67156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67158. * @param current current value
  67159. * @param target target value
  67160. * @param maxDelta max distance to move
  67161. * @returns resulting angle
  67162. */
  67163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67164. /**
  67165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67166. * @param start start value
  67167. * @param end target value
  67168. * @param amount amount to lerp between
  67169. * @returns the lerped value
  67170. */
  67171. static Lerp(start: number, end: number, amount: number): number;
  67172. /**
  67173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67175. * @param start start value
  67176. * @param end target value
  67177. * @param amount amount to lerp between
  67178. * @returns the lerped value
  67179. */
  67180. static LerpAngle(start: number, end: number, amount: number): number;
  67181. /**
  67182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67183. * @param a start value
  67184. * @param b target value
  67185. * @param value value between a and b
  67186. * @returns the inverseLerp value
  67187. */
  67188. static InverseLerp(a: number, b: number, value: number): number;
  67189. /**
  67190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67192. * @param value1 spline value
  67193. * @param tangent1 spline value
  67194. * @param value2 spline value
  67195. * @param tangent2 spline value
  67196. * @param amount input value
  67197. * @returns hermite result
  67198. */
  67199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67200. /**
  67201. * Returns a random float number between and min and max values
  67202. * @param min min value of random
  67203. * @param max max value of random
  67204. * @returns random value
  67205. */
  67206. static RandomRange(min: number, max: number): number;
  67207. /**
  67208. * This function returns percentage of a number in a given range.
  67209. *
  67210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67212. * @param number to convert to percentage
  67213. * @param min min range
  67214. * @param max max range
  67215. * @returns the percentage
  67216. */
  67217. static RangeToPercent(number: number, min: number, max: number): number;
  67218. /**
  67219. * This function returns number that corresponds to the percentage in a given range.
  67220. *
  67221. * PercentToRange(0.34,0,100) will return 34.
  67222. * @param percent to convert to number
  67223. * @param min min range
  67224. * @param max max range
  67225. * @returns the number
  67226. */
  67227. static PercentToRange(percent: number, min: number, max: number): number;
  67228. /**
  67229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67230. * @param angle The angle to normalize in radian.
  67231. * @return The converted angle.
  67232. */
  67233. static NormalizeRadians(angle: number): number;
  67234. }
  67235. }
  67236. declare module BABYLON {
  67237. /**
  67238. * Constant used to convert a value to gamma space
  67239. * @ignorenaming
  67240. */
  67241. export const ToGammaSpace: number;
  67242. /**
  67243. * Constant used to convert a value to linear space
  67244. * @ignorenaming
  67245. */
  67246. export const ToLinearSpace = 2.2;
  67247. /**
  67248. * Constant used to define the minimal number value in Babylon.js
  67249. * @ignorenaming
  67250. */
  67251. let Epsilon: number;
  67252. }
  67253. declare module BABYLON {
  67254. /**
  67255. * Class used to represent a viewport on screen
  67256. */
  67257. export class Viewport {
  67258. /** viewport left coordinate */
  67259. x: number;
  67260. /** viewport top coordinate */
  67261. y: number;
  67262. /**viewport width */
  67263. width: number;
  67264. /** viewport height */
  67265. height: number;
  67266. /**
  67267. * Creates a Viewport object located at (x, y) and sized (width, height)
  67268. * @param x defines viewport left coordinate
  67269. * @param y defines viewport top coordinate
  67270. * @param width defines the viewport width
  67271. * @param height defines the viewport height
  67272. */
  67273. constructor(
  67274. /** viewport left coordinate */
  67275. x: number,
  67276. /** viewport top coordinate */
  67277. y: number,
  67278. /**viewport width */
  67279. width: number,
  67280. /** viewport height */
  67281. height: number);
  67282. /**
  67283. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67284. * @param renderWidth defines the rendering width
  67285. * @param renderHeight defines the rendering height
  67286. * @returns a new Viewport
  67287. */
  67288. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67289. /**
  67290. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67291. * @param renderWidth defines the rendering width
  67292. * @param renderHeight defines the rendering height
  67293. * @param ref defines the target viewport
  67294. * @returns the current viewport
  67295. */
  67296. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67297. /**
  67298. * Returns a new Viewport copied from the current one
  67299. * @returns a new Viewport
  67300. */
  67301. clone(): Viewport;
  67302. }
  67303. }
  67304. declare module BABYLON {
  67305. /**
  67306. * Class containing a set of static utilities functions for arrays.
  67307. */
  67308. export class ArrayTools {
  67309. /**
  67310. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67311. * @param size the number of element to construct and put in the array
  67312. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67313. * @returns a new array filled with new objects
  67314. */
  67315. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67316. }
  67317. }
  67318. declare module BABYLON {
  67319. /**
  67320. * @hidden
  67321. */
  67322. export interface IColor4Like {
  67323. r: float;
  67324. g: float;
  67325. b: float;
  67326. a: float;
  67327. }
  67328. /**
  67329. * @hidden
  67330. */
  67331. export interface IColor3Like {
  67332. r: float;
  67333. g: float;
  67334. b: float;
  67335. }
  67336. /**
  67337. * @hidden
  67338. */
  67339. export interface IVector4Like {
  67340. x: float;
  67341. y: float;
  67342. z: float;
  67343. w: float;
  67344. }
  67345. /**
  67346. * @hidden
  67347. */
  67348. export interface IVector3Like {
  67349. x: float;
  67350. y: float;
  67351. z: float;
  67352. }
  67353. /**
  67354. * @hidden
  67355. */
  67356. export interface IVector2Like {
  67357. x: float;
  67358. y: float;
  67359. }
  67360. /**
  67361. * @hidden
  67362. */
  67363. export interface IMatrixLike {
  67364. toArray(): DeepImmutable<Float32Array>;
  67365. updateFlag: int;
  67366. }
  67367. /**
  67368. * @hidden
  67369. */
  67370. export interface IViewportLike {
  67371. x: float;
  67372. y: float;
  67373. width: float;
  67374. height: float;
  67375. }
  67376. /**
  67377. * @hidden
  67378. */
  67379. export interface IPlaneLike {
  67380. normal: IVector3Like;
  67381. d: float;
  67382. normalize(): void;
  67383. }
  67384. }
  67385. declare module BABYLON {
  67386. /**
  67387. * Class representing a vector containing 2 coordinates
  67388. */
  67389. export class Vector2 {
  67390. /** defines the first coordinate */
  67391. x: number;
  67392. /** defines the second coordinate */
  67393. y: number;
  67394. /**
  67395. * Creates a new Vector2 from the given x and y coordinates
  67396. * @param x defines the first coordinate
  67397. * @param y defines the second coordinate
  67398. */
  67399. constructor(
  67400. /** defines the first coordinate */
  67401. x?: number,
  67402. /** defines the second coordinate */
  67403. y?: number);
  67404. /**
  67405. * Gets a string with the Vector2 coordinates
  67406. * @returns a string with the Vector2 coordinates
  67407. */
  67408. toString(): string;
  67409. /**
  67410. * Gets class name
  67411. * @returns the string "Vector2"
  67412. */
  67413. getClassName(): string;
  67414. /**
  67415. * Gets current vector hash code
  67416. * @returns the Vector2 hash code as a number
  67417. */
  67418. getHashCode(): number;
  67419. /**
  67420. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67421. * @param array defines the source array
  67422. * @param index defines the offset in source array
  67423. * @returns the current Vector2
  67424. */
  67425. toArray(array: FloatArray, index?: number): Vector2;
  67426. /**
  67427. * Copy the current vector to an array
  67428. * @returns a new array with 2 elements: the Vector2 coordinates.
  67429. */
  67430. asArray(): number[];
  67431. /**
  67432. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67433. * @param source defines the source Vector2
  67434. * @returns the current updated Vector2
  67435. */
  67436. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67437. /**
  67438. * Sets the Vector2 coordinates with the given floats
  67439. * @param x defines the first coordinate
  67440. * @param y defines the second coordinate
  67441. * @returns the current updated Vector2
  67442. */
  67443. copyFromFloats(x: number, y: number): Vector2;
  67444. /**
  67445. * Sets the Vector2 coordinates with the given floats
  67446. * @param x defines the first coordinate
  67447. * @param y defines the second coordinate
  67448. * @returns the current updated Vector2
  67449. */
  67450. set(x: number, y: number): Vector2;
  67451. /**
  67452. * Add another vector with the current one
  67453. * @param otherVector defines the other vector
  67454. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67455. */
  67456. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67457. /**
  67458. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67459. * @param otherVector defines the other vector
  67460. * @param result defines the target vector
  67461. * @returns the unmodified current Vector2
  67462. */
  67463. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67464. /**
  67465. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67466. * @param otherVector defines the other vector
  67467. * @returns the current updated Vector2
  67468. */
  67469. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67470. /**
  67471. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67472. * @param otherVector defines the other vector
  67473. * @returns a new Vector2
  67474. */
  67475. addVector3(otherVector: Vector3): Vector2;
  67476. /**
  67477. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67478. * @param otherVector defines the other vector
  67479. * @returns a new Vector2
  67480. */
  67481. subtract(otherVector: Vector2): Vector2;
  67482. /**
  67483. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67484. * @param otherVector defines the other vector
  67485. * @param result defines the target vector
  67486. * @returns the unmodified current Vector2
  67487. */
  67488. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67489. /**
  67490. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67491. * @param otherVector defines the other vector
  67492. * @returns the current updated Vector2
  67493. */
  67494. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67495. /**
  67496. * Multiplies in place the current Vector2 coordinates by the given ones
  67497. * @param otherVector defines the other vector
  67498. * @returns the current updated Vector2
  67499. */
  67500. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67501. /**
  67502. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67503. * @param otherVector defines the other vector
  67504. * @returns a new Vector2
  67505. */
  67506. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67507. /**
  67508. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67509. * @param otherVector defines the other vector
  67510. * @param result defines the target vector
  67511. * @returns the unmodified current Vector2
  67512. */
  67513. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67514. /**
  67515. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67516. * @param x defines the first coordinate
  67517. * @param y defines the second coordinate
  67518. * @returns a new Vector2
  67519. */
  67520. multiplyByFloats(x: number, y: number): Vector2;
  67521. /**
  67522. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67523. * @param otherVector defines the other vector
  67524. * @returns a new Vector2
  67525. */
  67526. divide(otherVector: Vector2): Vector2;
  67527. /**
  67528. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67529. * @param otherVector defines the other vector
  67530. * @param result defines the target vector
  67531. * @returns the unmodified current Vector2
  67532. */
  67533. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67534. /**
  67535. * Divides the current Vector2 coordinates by the given ones
  67536. * @param otherVector defines the other vector
  67537. * @returns the current updated Vector2
  67538. */
  67539. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67540. /**
  67541. * Gets a new Vector2 with current Vector2 negated coordinates
  67542. * @returns a new Vector2
  67543. */
  67544. negate(): Vector2;
  67545. /**
  67546. * Multiply the Vector2 coordinates by scale
  67547. * @param scale defines the scaling factor
  67548. * @returns the current updated Vector2
  67549. */
  67550. scaleInPlace(scale: number): Vector2;
  67551. /**
  67552. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67553. * @param scale defines the scaling factor
  67554. * @returns a new Vector2
  67555. */
  67556. scale(scale: number): Vector2;
  67557. /**
  67558. * Scale the current Vector2 values by a factor to a given Vector2
  67559. * @param scale defines the scale factor
  67560. * @param result defines the Vector2 object where to store the result
  67561. * @returns the unmodified current Vector2
  67562. */
  67563. scaleToRef(scale: number, result: Vector2): Vector2;
  67564. /**
  67565. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67566. * @param scale defines the scale factor
  67567. * @param result defines the Vector2 object where to store the result
  67568. * @returns the unmodified current Vector2
  67569. */
  67570. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67571. /**
  67572. * Gets a boolean if two vectors are equals
  67573. * @param otherVector defines the other vector
  67574. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67575. */
  67576. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67577. /**
  67578. * Gets a boolean if two vectors are equals (using an epsilon value)
  67579. * @param otherVector defines the other vector
  67580. * @param epsilon defines the minimal distance to consider equality
  67581. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67582. */
  67583. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67584. /**
  67585. * Gets a new Vector2 from current Vector2 floored values
  67586. * @returns a new Vector2
  67587. */
  67588. floor(): Vector2;
  67589. /**
  67590. * Gets a new Vector2 from current Vector2 floored values
  67591. * @returns a new Vector2
  67592. */
  67593. fract(): Vector2;
  67594. /**
  67595. * Gets the length of the vector
  67596. * @returns the vector length (float)
  67597. */
  67598. length(): number;
  67599. /**
  67600. * Gets the vector squared length
  67601. * @returns the vector squared length (float)
  67602. */
  67603. lengthSquared(): number;
  67604. /**
  67605. * Normalize the vector
  67606. * @returns the current updated Vector2
  67607. */
  67608. normalize(): Vector2;
  67609. /**
  67610. * Gets a new Vector2 copied from the Vector2
  67611. * @returns a new Vector2
  67612. */
  67613. clone(): Vector2;
  67614. /**
  67615. * Gets a new Vector2(0, 0)
  67616. * @returns a new Vector2
  67617. */
  67618. static Zero(): Vector2;
  67619. /**
  67620. * Gets a new Vector2(1, 1)
  67621. * @returns a new Vector2
  67622. */
  67623. static One(): Vector2;
  67624. /**
  67625. * Gets a new Vector2 set from the given index element of the given array
  67626. * @param array defines the data source
  67627. * @param offset defines the offset in the data source
  67628. * @returns a new Vector2
  67629. */
  67630. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67631. /**
  67632. * Sets "result" from the given index element of the given array
  67633. * @param array defines the data source
  67634. * @param offset defines the offset in the data source
  67635. * @param result defines the target vector
  67636. */
  67637. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67638. /**
  67639. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67640. * @param value1 defines 1st point of control
  67641. * @param value2 defines 2nd point of control
  67642. * @param value3 defines 3rd point of control
  67643. * @param value4 defines 4th point of control
  67644. * @param amount defines the interpolation factor
  67645. * @returns a new Vector2
  67646. */
  67647. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67648. /**
  67649. * 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".
  67650. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67651. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67652. * @param value defines the value to clamp
  67653. * @param min defines the lower limit
  67654. * @param max defines the upper limit
  67655. * @returns a new Vector2
  67656. */
  67657. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67658. /**
  67659. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67660. * @param value1 defines the 1st control point
  67661. * @param tangent1 defines the outgoing tangent
  67662. * @param value2 defines the 2nd control point
  67663. * @param tangent2 defines the incoming tangent
  67664. * @param amount defines the interpolation factor
  67665. * @returns a new Vector2
  67666. */
  67667. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67668. /**
  67669. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67670. * @param start defines the start vector
  67671. * @param end defines the end vector
  67672. * @param amount defines the interpolation factor
  67673. * @returns a new Vector2
  67674. */
  67675. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67676. /**
  67677. * Gets the dot product of the vector "left" and the vector "right"
  67678. * @param left defines first vector
  67679. * @param right defines second vector
  67680. * @returns the dot product (float)
  67681. */
  67682. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67683. /**
  67684. * Returns a new Vector2 equal to the normalized given vector
  67685. * @param vector defines the vector to normalize
  67686. * @returns a new Vector2
  67687. */
  67688. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67689. /**
  67690. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67691. * @param left defines 1st vector
  67692. * @param right defines 2nd vector
  67693. * @returns a new Vector2
  67694. */
  67695. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67696. /**
  67697. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67698. * @param left defines 1st vector
  67699. * @param right defines 2nd vector
  67700. * @returns a new Vector2
  67701. */
  67702. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67703. /**
  67704. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67705. * @param vector defines the vector to transform
  67706. * @param transformation defines the matrix to apply
  67707. * @returns a new Vector2
  67708. */
  67709. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67710. /**
  67711. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67712. * @param vector defines the vector to transform
  67713. * @param transformation defines the matrix to apply
  67714. * @param result defines the target vector
  67715. */
  67716. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67717. /**
  67718. * Determines if a given vector is included in a triangle
  67719. * @param p defines the vector to test
  67720. * @param p0 defines 1st triangle point
  67721. * @param p1 defines 2nd triangle point
  67722. * @param p2 defines 3rd triangle point
  67723. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67724. */
  67725. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67726. /**
  67727. * Gets the distance between the vectors "value1" and "value2"
  67728. * @param value1 defines first vector
  67729. * @param value2 defines second vector
  67730. * @returns the distance between vectors
  67731. */
  67732. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67733. /**
  67734. * Returns the squared distance between the vectors "value1" and "value2"
  67735. * @param value1 defines first vector
  67736. * @param value2 defines second vector
  67737. * @returns the squared distance between vectors
  67738. */
  67739. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67740. /**
  67741. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67742. * @param value1 defines first vector
  67743. * @param value2 defines second vector
  67744. * @returns a new Vector2
  67745. */
  67746. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67747. /**
  67748. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67749. * @param p defines the middle point
  67750. * @param segA defines one point of the segment
  67751. * @param segB defines the other point of the segment
  67752. * @returns the shortest distance
  67753. */
  67754. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67755. }
  67756. /**
  67757. * Classed used to store (x,y,z) vector representation
  67758. * A Vector3 is the main object used in 3D geometry
  67759. * It can represent etiher the coordinates of a point the space, either a direction
  67760. * Reminder: js uses a left handed forward facing system
  67761. */
  67762. export class Vector3 {
  67763. /**
  67764. * Defines the first coordinates (on X axis)
  67765. */
  67766. x: number;
  67767. /**
  67768. * Defines the second coordinates (on Y axis)
  67769. */
  67770. y: number;
  67771. /**
  67772. * Defines the third coordinates (on Z axis)
  67773. */
  67774. z: number;
  67775. private static _UpReadOnly;
  67776. private static _ZeroReadOnly;
  67777. /**
  67778. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67779. * @param x defines the first coordinates (on X axis)
  67780. * @param y defines the second coordinates (on Y axis)
  67781. * @param z defines the third coordinates (on Z axis)
  67782. */
  67783. constructor(
  67784. /**
  67785. * Defines the first coordinates (on X axis)
  67786. */
  67787. x?: number,
  67788. /**
  67789. * Defines the second coordinates (on Y axis)
  67790. */
  67791. y?: number,
  67792. /**
  67793. * Defines the third coordinates (on Z axis)
  67794. */
  67795. z?: number);
  67796. /**
  67797. * Creates a string representation of the Vector3
  67798. * @returns a string with the Vector3 coordinates.
  67799. */
  67800. toString(): string;
  67801. /**
  67802. * Gets the class name
  67803. * @returns the string "Vector3"
  67804. */
  67805. getClassName(): string;
  67806. /**
  67807. * Creates the Vector3 hash code
  67808. * @returns a number which tends to be unique between Vector3 instances
  67809. */
  67810. getHashCode(): number;
  67811. /**
  67812. * Creates an array containing three elements : the coordinates of the Vector3
  67813. * @returns a new array of numbers
  67814. */
  67815. asArray(): number[];
  67816. /**
  67817. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67818. * @param array defines the destination array
  67819. * @param index defines the offset in the destination array
  67820. * @returns the current Vector3
  67821. */
  67822. toArray(array: FloatArray, index?: number): Vector3;
  67823. /**
  67824. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67825. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67826. */
  67827. toQuaternion(): Quaternion;
  67828. /**
  67829. * Adds the given vector to the current Vector3
  67830. * @param otherVector defines the second operand
  67831. * @returns the current updated Vector3
  67832. */
  67833. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67834. /**
  67835. * Adds the given coordinates to the current Vector3
  67836. * @param x defines the x coordinate of the operand
  67837. * @param y defines the y coordinate of the operand
  67838. * @param z defines the z coordinate of the operand
  67839. * @returns the current updated Vector3
  67840. */
  67841. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67842. /**
  67843. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67844. * @param otherVector defines the second operand
  67845. * @returns the resulting Vector3
  67846. */
  67847. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67848. /**
  67849. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67850. * @param otherVector defines the second operand
  67851. * @param result defines the Vector3 object where to store the result
  67852. * @returns the current Vector3
  67853. */
  67854. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67855. /**
  67856. * Subtract the given vector from the current Vector3
  67857. * @param otherVector defines the second operand
  67858. * @returns the current updated Vector3
  67859. */
  67860. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67861. /**
  67862. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67863. * @param otherVector defines the second operand
  67864. * @returns the resulting Vector3
  67865. */
  67866. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67867. /**
  67868. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67869. * @param otherVector defines the second operand
  67870. * @param result defines the Vector3 object where to store the result
  67871. * @returns the current Vector3
  67872. */
  67873. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67874. /**
  67875. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67876. * @param x defines the x coordinate of the operand
  67877. * @param y defines the y coordinate of the operand
  67878. * @param z defines the z coordinate of the operand
  67879. * @returns the resulting Vector3
  67880. */
  67881. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67882. /**
  67883. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67884. * @param x defines the x coordinate of the operand
  67885. * @param y defines the y coordinate of the operand
  67886. * @param z defines the z coordinate of the operand
  67887. * @param result defines the Vector3 object where to store the result
  67888. * @returns the current Vector3
  67889. */
  67890. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67891. /**
  67892. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67893. * @returns a new Vector3
  67894. */
  67895. negate(): Vector3;
  67896. /**
  67897. * Multiplies the Vector3 coordinates by the float "scale"
  67898. * @param scale defines the multiplier factor
  67899. * @returns the current updated Vector3
  67900. */
  67901. scaleInPlace(scale: number): Vector3;
  67902. /**
  67903. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67904. * @param scale defines the multiplier factor
  67905. * @returns a new Vector3
  67906. */
  67907. scale(scale: number): Vector3;
  67908. /**
  67909. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67910. * @param scale defines the multiplier factor
  67911. * @param result defines the Vector3 object where to store the result
  67912. * @returns the current Vector3
  67913. */
  67914. scaleToRef(scale: number, result: Vector3): Vector3;
  67915. /**
  67916. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67917. * @param scale defines the scale factor
  67918. * @param result defines the Vector3 object where to store the result
  67919. * @returns the unmodified current Vector3
  67920. */
  67921. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67922. /**
  67923. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67924. * @param otherVector defines the second operand
  67925. * @returns true if both vectors are equals
  67926. */
  67927. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67928. /**
  67929. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67930. * @param otherVector defines the second operand
  67931. * @param epsilon defines the minimal distance to define values as equals
  67932. * @returns true if both vectors are distant less than epsilon
  67933. */
  67934. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67935. /**
  67936. * Returns true if the current Vector3 coordinates equals the given floats
  67937. * @param x defines the x coordinate of the operand
  67938. * @param y defines the y coordinate of the operand
  67939. * @param z defines the z coordinate of the operand
  67940. * @returns true if both vectors are equals
  67941. */
  67942. equalsToFloats(x: number, y: number, z: number): boolean;
  67943. /**
  67944. * Multiplies the current Vector3 coordinates by the given ones
  67945. * @param otherVector defines the second operand
  67946. * @returns the current updated Vector3
  67947. */
  67948. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67949. /**
  67950. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67951. * @param otherVector defines the second operand
  67952. * @returns the new Vector3
  67953. */
  67954. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67955. /**
  67956. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67957. * @param otherVector defines the second operand
  67958. * @param result defines the Vector3 object where to store the result
  67959. * @returns the current Vector3
  67960. */
  67961. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67962. /**
  67963. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67964. * @param x defines the x coordinate of the operand
  67965. * @param y defines the y coordinate of the operand
  67966. * @param z defines the z coordinate of the operand
  67967. * @returns the new Vector3
  67968. */
  67969. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67970. /**
  67971. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67972. * @param otherVector defines the second operand
  67973. * @returns the new Vector3
  67974. */
  67975. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67976. /**
  67977. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67978. * @param otherVector defines the second operand
  67979. * @param result defines the Vector3 object where to store the result
  67980. * @returns the current Vector3
  67981. */
  67982. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67983. /**
  67984. * Divides the current Vector3 coordinates by the given ones.
  67985. * @param otherVector defines the second operand
  67986. * @returns the current updated Vector3
  67987. */
  67988. divideInPlace(otherVector: Vector3): Vector3;
  67989. /**
  67990. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67991. * @param other defines the second operand
  67992. * @returns the current updated Vector3
  67993. */
  67994. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67995. /**
  67996. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67997. * @param other defines the second operand
  67998. * @returns the current updated Vector3
  67999. */
  68000. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68001. /**
  68002. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68003. * @param x defines the x coordinate of the operand
  68004. * @param y defines the y coordinate of the operand
  68005. * @param z defines the z coordinate of the operand
  68006. * @returns the current updated Vector3
  68007. */
  68008. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68009. /**
  68010. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68011. * @param x defines the x coordinate of the operand
  68012. * @param y defines the y coordinate of the operand
  68013. * @param z defines the z coordinate of the operand
  68014. * @returns the current updated Vector3
  68015. */
  68016. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68017. /**
  68018. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68019. * Check if is non uniform within a certain amount of decimal places to account for this
  68020. * @param epsilon the amount the values can differ
  68021. * @returns if the the vector is non uniform to a certain number of decimal places
  68022. */
  68023. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68024. /**
  68025. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68026. */
  68027. readonly isNonUniform: boolean;
  68028. /**
  68029. * Gets a new Vector3 from current Vector3 floored values
  68030. * @returns a new Vector3
  68031. */
  68032. floor(): Vector3;
  68033. /**
  68034. * Gets a new Vector3 from current Vector3 floored values
  68035. * @returns a new Vector3
  68036. */
  68037. fract(): Vector3;
  68038. /**
  68039. * Gets the length of the Vector3
  68040. * @returns the length of the Vector3
  68041. */
  68042. length(): number;
  68043. /**
  68044. * Gets the squared length of the Vector3
  68045. * @returns squared length of the Vector3
  68046. */
  68047. lengthSquared(): number;
  68048. /**
  68049. * Normalize the current Vector3.
  68050. * Please note that this is an in place operation.
  68051. * @returns the current updated Vector3
  68052. */
  68053. normalize(): Vector3;
  68054. /**
  68055. * Reorders the x y z properties of the vector in place
  68056. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68057. * @returns the current updated vector
  68058. */
  68059. reorderInPlace(order: string): this;
  68060. /**
  68061. * Rotates the vector around 0,0,0 by a quaternion
  68062. * @param quaternion the rotation quaternion
  68063. * @param result vector to store the result
  68064. * @returns the resulting vector
  68065. */
  68066. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68067. /**
  68068. * Rotates a vector around a given point
  68069. * @param quaternion the rotation quaternion
  68070. * @param point the point to rotate around
  68071. * @param result vector to store the result
  68072. * @returns the resulting vector
  68073. */
  68074. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68075. /**
  68076. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68077. * The cross product is then orthogonal to both current and "other"
  68078. * @param other defines the right operand
  68079. * @returns the cross product
  68080. */
  68081. cross(other: Vector3): Vector3;
  68082. /**
  68083. * Normalize the current Vector3 with the given input length.
  68084. * Please note that this is an in place operation.
  68085. * @param len the length of the vector
  68086. * @returns the current updated Vector3
  68087. */
  68088. normalizeFromLength(len: number): Vector3;
  68089. /**
  68090. * Normalize the current Vector3 to a new vector
  68091. * @returns the new Vector3
  68092. */
  68093. normalizeToNew(): Vector3;
  68094. /**
  68095. * Normalize the current Vector3 to the reference
  68096. * @param reference define the Vector3 to update
  68097. * @returns the updated Vector3
  68098. */
  68099. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68100. /**
  68101. * Creates a new Vector3 copied from the current Vector3
  68102. * @returns the new Vector3
  68103. */
  68104. clone(): Vector3;
  68105. /**
  68106. * Copies the given vector coordinates to the current Vector3 ones
  68107. * @param source defines the source Vector3
  68108. * @returns the current updated Vector3
  68109. */
  68110. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68111. /**
  68112. * Copies the given floats to the current Vector3 coordinates
  68113. * @param x defines the x coordinate of the operand
  68114. * @param y defines the y coordinate of the operand
  68115. * @param z defines the z coordinate of the operand
  68116. * @returns the current updated Vector3
  68117. */
  68118. copyFromFloats(x: number, y: number, z: number): Vector3;
  68119. /**
  68120. * Copies the given floats to the current Vector3 coordinates
  68121. * @param x defines the x coordinate of the operand
  68122. * @param y defines the y coordinate of the operand
  68123. * @param z defines the z coordinate of the operand
  68124. * @returns the current updated Vector3
  68125. */
  68126. set(x: number, y: number, z: number): Vector3;
  68127. /**
  68128. * Copies the given float to the current Vector3 coordinates
  68129. * @param v defines the x, y and z coordinates of the operand
  68130. * @returns the current updated Vector3
  68131. */
  68132. setAll(v: number): Vector3;
  68133. /**
  68134. * Get the clip factor between two vectors
  68135. * @param vector0 defines the first operand
  68136. * @param vector1 defines the second operand
  68137. * @param axis defines the axis to use
  68138. * @param size defines the size along the axis
  68139. * @returns the clip factor
  68140. */
  68141. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68142. /**
  68143. * Get angle between two vectors
  68144. * @param vector0 angle between vector0 and vector1
  68145. * @param vector1 angle between vector0 and vector1
  68146. * @param normal direction of the normal
  68147. * @return the angle between vector0 and vector1
  68148. */
  68149. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68150. /**
  68151. * Returns a new Vector3 set from the index "offset" of the given array
  68152. * @param array defines the source array
  68153. * @param offset defines the offset in the source array
  68154. * @returns the new Vector3
  68155. */
  68156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68157. /**
  68158. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68159. * This function is deprecated. Use FromArray instead
  68160. * @param array defines the source array
  68161. * @param offset defines the offset in the source array
  68162. * @returns the new Vector3
  68163. */
  68164. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68165. /**
  68166. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68167. * @param array defines the source array
  68168. * @param offset defines the offset in the source array
  68169. * @param result defines the Vector3 where to store the result
  68170. */
  68171. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68172. /**
  68173. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68174. * This function is deprecated. Use FromArrayToRef instead.
  68175. * @param array defines the source array
  68176. * @param offset defines the offset in the source array
  68177. * @param result defines the Vector3 where to store the result
  68178. */
  68179. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68180. /**
  68181. * Sets the given vector "result" with the given floats.
  68182. * @param x defines the x coordinate of the source
  68183. * @param y defines the y coordinate of the source
  68184. * @param z defines the z coordinate of the source
  68185. * @param result defines the Vector3 where to store the result
  68186. */
  68187. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68188. /**
  68189. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68190. * @returns a new empty Vector3
  68191. */
  68192. static Zero(): Vector3;
  68193. /**
  68194. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68195. * @returns a new unit Vector3
  68196. */
  68197. static One(): Vector3;
  68198. /**
  68199. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68200. * @returns a new up Vector3
  68201. */
  68202. static Up(): Vector3;
  68203. /**
  68204. * Gets a up Vector3 that must not be updated
  68205. */
  68206. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68207. /**
  68208. * Gets a zero Vector3 that must not be updated
  68209. */
  68210. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68211. /**
  68212. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68213. * @returns a new down Vector3
  68214. */
  68215. static Down(): Vector3;
  68216. /**
  68217. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68218. * @returns a new forward Vector3
  68219. */
  68220. static Forward(): Vector3;
  68221. /**
  68222. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68223. * @returns a new forward Vector3
  68224. */
  68225. static Backward(): Vector3;
  68226. /**
  68227. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68228. * @returns a new right Vector3
  68229. */
  68230. static Right(): Vector3;
  68231. /**
  68232. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68233. * @returns a new left Vector3
  68234. */
  68235. static Left(): Vector3;
  68236. /**
  68237. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68238. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68239. * @param vector defines the Vector3 to transform
  68240. * @param transformation defines the transformation matrix
  68241. * @returns the transformed Vector3
  68242. */
  68243. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68244. /**
  68245. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68246. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68247. * @param vector defines the Vector3 to transform
  68248. * @param transformation defines the transformation matrix
  68249. * @param result defines the Vector3 where to store the result
  68250. */
  68251. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68252. /**
  68253. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68254. * This method computes tranformed coordinates only, not transformed direction vectors
  68255. * @param x define the x coordinate of the source vector
  68256. * @param y define the y coordinate of the source vector
  68257. * @param z define the z coordinate of the source vector
  68258. * @param transformation defines the transformation matrix
  68259. * @param result defines the Vector3 where to store the result
  68260. */
  68261. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68262. /**
  68263. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68264. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68265. * @param vector defines the Vector3 to transform
  68266. * @param transformation defines the transformation matrix
  68267. * @returns the new Vector3
  68268. */
  68269. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68270. /**
  68271. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68272. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68273. * @param vector defines the Vector3 to transform
  68274. * @param transformation defines the transformation matrix
  68275. * @param result defines the Vector3 where to store the result
  68276. */
  68277. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68278. /**
  68279. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68280. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68281. * @param x define the x coordinate of the source vector
  68282. * @param y define the y coordinate of the source vector
  68283. * @param z define the z coordinate of the source vector
  68284. * @param transformation defines the transformation matrix
  68285. * @param result defines the Vector3 where to store the result
  68286. */
  68287. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68288. /**
  68289. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68290. * @param value1 defines the first control point
  68291. * @param value2 defines the second control point
  68292. * @param value3 defines the third control point
  68293. * @param value4 defines the fourth control point
  68294. * @param amount defines the amount on the spline to use
  68295. * @returns the new Vector3
  68296. */
  68297. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68298. /**
  68299. * 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"
  68300. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68301. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68302. * @param value defines the current value
  68303. * @param min defines the lower range value
  68304. * @param max defines the upper range value
  68305. * @returns the new Vector3
  68306. */
  68307. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68308. /**
  68309. * 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"
  68310. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68311. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68312. * @param value defines the current value
  68313. * @param min defines the lower range value
  68314. * @param max defines the upper range value
  68315. * @param result defines the Vector3 where to store the result
  68316. */
  68317. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68318. /**
  68319. * Checks if a given vector is inside a specific range
  68320. * @param v defines the vector to test
  68321. * @param min defines the minimum range
  68322. * @param max defines the maximum range
  68323. */
  68324. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68325. /**
  68326. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68327. * @param value1 defines the first control point
  68328. * @param tangent1 defines the first tangent vector
  68329. * @param value2 defines the second control point
  68330. * @param tangent2 defines the second tangent vector
  68331. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68332. * @returns the new Vector3
  68333. */
  68334. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68335. /**
  68336. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68337. * @param start defines the start value
  68338. * @param end defines the end value
  68339. * @param amount max defines amount between both (between 0 and 1)
  68340. * @returns the new Vector3
  68341. */
  68342. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68343. /**
  68344. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68345. * @param start defines the start value
  68346. * @param end defines the end value
  68347. * @param amount max defines amount between both (between 0 and 1)
  68348. * @param result defines the Vector3 where to store the result
  68349. */
  68350. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68351. /**
  68352. * Returns the dot product (float) between the vectors "left" and "right"
  68353. * @param left defines the left operand
  68354. * @param right defines the right operand
  68355. * @returns the dot product
  68356. */
  68357. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68358. /**
  68359. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68360. * The cross product is then orthogonal to both "left" and "right"
  68361. * @param left defines the left operand
  68362. * @param right defines the right operand
  68363. * @returns the cross product
  68364. */
  68365. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68366. /**
  68367. * Sets the given vector "result" with the cross product of "left" and "right"
  68368. * The cross product is then orthogonal to both "left" and "right"
  68369. * @param left defines the left operand
  68370. * @param right defines the right operand
  68371. * @param result defines the Vector3 where to store the result
  68372. */
  68373. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68374. /**
  68375. * Returns a new Vector3 as the normalization of the given vector
  68376. * @param vector defines the Vector3 to normalize
  68377. * @returns the new Vector3
  68378. */
  68379. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68380. /**
  68381. * Sets the given vector "result" with the normalization of the given first vector
  68382. * @param vector defines the Vector3 to normalize
  68383. * @param result defines the Vector3 where to store the result
  68384. */
  68385. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68386. /**
  68387. * Project a Vector3 onto screen space
  68388. * @param vector defines the Vector3 to project
  68389. * @param world defines the world matrix to use
  68390. * @param transform defines the transform (view x projection) matrix to use
  68391. * @param viewport defines the screen viewport to use
  68392. * @returns the new Vector3
  68393. */
  68394. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68395. /** @hidden */
  68396. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68397. /**
  68398. * Unproject from screen space to object space
  68399. * @param source defines the screen space Vector3 to use
  68400. * @param viewportWidth defines the current width of the viewport
  68401. * @param viewportHeight defines the current height of the viewport
  68402. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68403. * @param transform defines the transform (view x projection) matrix to use
  68404. * @returns the new Vector3
  68405. */
  68406. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68407. /**
  68408. * Unproject from screen space to object space
  68409. * @param source defines the screen space Vector3 to use
  68410. * @param viewportWidth defines the current width of the viewport
  68411. * @param viewportHeight defines the current height of the viewport
  68412. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68413. * @param view defines the view matrix to use
  68414. * @param projection defines the projection matrix to use
  68415. * @returns the new Vector3
  68416. */
  68417. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68418. /**
  68419. * Unproject from screen space to object space
  68420. * @param source defines the screen space Vector3 to use
  68421. * @param viewportWidth defines the current width of the viewport
  68422. * @param viewportHeight defines the current height of the viewport
  68423. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68424. * @param view defines the view matrix to use
  68425. * @param projection defines the projection matrix to use
  68426. * @param result defines the Vector3 where to store the result
  68427. */
  68428. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68429. /**
  68430. * Unproject from screen space to object space
  68431. * @param sourceX defines the screen space x coordinate to use
  68432. * @param sourceY defines the screen space y coordinate to use
  68433. * @param sourceZ defines the screen space z coordinate to use
  68434. * @param viewportWidth defines the current width of the viewport
  68435. * @param viewportHeight defines the current height of the viewport
  68436. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68437. * @param view defines the view matrix to use
  68438. * @param projection defines the projection matrix to use
  68439. * @param result defines the Vector3 where to store the result
  68440. */
  68441. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68442. /**
  68443. * Gets the minimal coordinate values between two Vector3
  68444. * @param left defines the first operand
  68445. * @param right defines the second operand
  68446. * @returns the new Vector3
  68447. */
  68448. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68449. /**
  68450. * Gets the maximal coordinate values between two Vector3
  68451. * @param left defines the first operand
  68452. * @param right defines the second operand
  68453. * @returns the new Vector3
  68454. */
  68455. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68456. /**
  68457. * Returns the distance between the vectors "value1" and "value2"
  68458. * @param value1 defines the first operand
  68459. * @param value2 defines the second operand
  68460. * @returns the distance
  68461. */
  68462. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68463. /**
  68464. * Returns the squared distance between the vectors "value1" and "value2"
  68465. * @param value1 defines the first operand
  68466. * @param value2 defines the second operand
  68467. * @returns the squared distance
  68468. */
  68469. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68470. /**
  68471. * Returns a new Vector3 located at the center between "value1" and "value2"
  68472. * @param value1 defines the first operand
  68473. * @param value2 defines the second operand
  68474. * @returns the new Vector3
  68475. */
  68476. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68477. /**
  68478. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68479. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68480. * to something in order to rotate it from its local system to the given target system
  68481. * Note: axis1, axis2 and axis3 are normalized during this operation
  68482. * @param axis1 defines the first axis
  68483. * @param axis2 defines the second axis
  68484. * @param axis3 defines the third axis
  68485. * @returns a new Vector3
  68486. */
  68487. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68488. /**
  68489. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68490. * @param axis1 defines the first axis
  68491. * @param axis2 defines the second axis
  68492. * @param axis3 defines the third axis
  68493. * @param ref defines the Vector3 where to store the result
  68494. */
  68495. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68496. }
  68497. /**
  68498. * Vector4 class created for EulerAngle class conversion to Quaternion
  68499. */
  68500. export class Vector4 {
  68501. /** x value of the vector */
  68502. x: number;
  68503. /** y value of the vector */
  68504. y: number;
  68505. /** z value of the vector */
  68506. z: number;
  68507. /** w value of the vector */
  68508. w: number;
  68509. /**
  68510. * Creates a Vector4 object from the given floats.
  68511. * @param x x value of the vector
  68512. * @param y y value of the vector
  68513. * @param z z value of the vector
  68514. * @param w w value of the vector
  68515. */
  68516. constructor(
  68517. /** x value of the vector */
  68518. x: number,
  68519. /** y value of the vector */
  68520. y: number,
  68521. /** z value of the vector */
  68522. z: number,
  68523. /** w value of the vector */
  68524. w: number);
  68525. /**
  68526. * Returns the string with the Vector4 coordinates.
  68527. * @returns a string containing all the vector values
  68528. */
  68529. toString(): string;
  68530. /**
  68531. * Returns the string "Vector4".
  68532. * @returns "Vector4"
  68533. */
  68534. getClassName(): string;
  68535. /**
  68536. * Returns the Vector4 hash code.
  68537. * @returns a unique hash code
  68538. */
  68539. getHashCode(): number;
  68540. /**
  68541. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68542. * @returns the resulting array
  68543. */
  68544. asArray(): number[];
  68545. /**
  68546. * Populates the given array from the given index with the Vector4 coordinates.
  68547. * @param array array to populate
  68548. * @param index index of the array to start at (default: 0)
  68549. * @returns the Vector4.
  68550. */
  68551. toArray(array: FloatArray, index?: number): Vector4;
  68552. /**
  68553. * Adds the given vector to the current Vector4.
  68554. * @param otherVector the vector to add
  68555. * @returns the updated Vector4.
  68556. */
  68557. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68558. /**
  68559. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68560. * @param otherVector the vector to add
  68561. * @returns the resulting vector
  68562. */
  68563. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68564. /**
  68565. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68566. * @param otherVector the vector to add
  68567. * @param result the vector to store the result
  68568. * @returns the current Vector4.
  68569. */
  68570. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68571. /**
  68572. * Subtract in place the given vector from the current Vector4.
  68573. * @param otherVector the vector to subtract
  68574. * @returns the updated Vector4.
  68575. */
  68576. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68577. /**
  68578. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68579. * @param otherVector the vector to add
  68580. * @returns the new vector with the result
  68581. */
  68582. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68583. /**
  68584. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68585. * @param otherVector the vector to subtract
  68586. * @param result the vector to store the result
  68587. * @returns the current Vector4.
  68588. */
  68589. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68590. /**
  68591. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68592. */
  68593. /**
  68594. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68595. * @param x value to subtract
  68596. * @param y value to subtract
  68597. * @param z value to subtract
  68598. * @param w value to subtract
  68599. * @returns new vector containing the result
  68600. */
  68601. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68602. /**
  68603. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68604. * @param x value to subtract
  68605. * @param y value to subtract
  68606. * @param z value to subtract
  68607. * @param w value to subtract
  68608. * @param result the vector to store the result in
  68609. * @returns the current Vector4.
  68610. */
  68611. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68612. /**
  68613. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68614. * @returns a new vector with the negated values
  68615. */
  68616. negate(): Vector4;
  68617. /**
  68618. * Multiplies the current Vector4 coordinates by scale (float).
  68619. * @param scale the number to scale with
  68620. * @returns the updated Vector4.
  68621. */
  68622. scaleInPlace(scale: number): Vector4;
  68623. /**
  68624. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68625. * @param scale the number to scale with
  68626. * @returns a new vector with the result
  68627. */
  68628. scale(scale: number): Vector4;
  68629. /**
  68630. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68631. * @param scale the number to scale with
  68632. * @param result a vector to store the result in
  68633. * @returns the current Vector4.
  68634. */
  68635. scaleToRef(scale: number, result: Vector4): Vector4;
  68636. /**
  68637. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68638. * @param scale defines the scale factor
  68639. * @param result defines the Vector4 object where to store the result
  68640. * @returns the unmodified current Vector4
  68641. */
  68642. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68643. /**
  68644. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68645. * @param otherVector the vector to compare against
  68646. * @returns true if they are equal
  68647. */
  68648. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68649. /**
  68650. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68651. * @param otherVector vector to compare against
  68652. * @param epsilon (Default: very small number)
  68653. * @returns true if they are equal
  68654. */
  68655. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68656. /**
  68657. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68658. * @param x x value to compare against
  68659. * @param y y value to compare against
  68660. * @param z z value to compare against
  68661. * @param w w value to compare against
  68662. * @returns true if equal
  68663. */
  68664. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68665. /**
  68666. * Multiplies in place the current Vector4 by the given one.
  68667. * @param otherVector vector to multiple with
  68668. * @returns the updated Vector4.
  68669. */
  68670. multiplyInPlace(otherVector: Vector4): Vector4;
  68671. /**
  68672. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68673. * @param otherVector vector to multiple with
  68674. * @returns resulting new vector
  68675. */
  68676. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68677. /**
  68678. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68679. * @param otherVector vector to multiple with
  68680. * @param result vector to store the result
  68681. * @returns the current Vector4.
  68682. */
  68683. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68684. /**
  68685. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68686. * @param x x value multiply with
  68687. * @param y y value multiply with
  68688. * @param z z value multiply with
  68689. * @param w w value multiply with
  68690. * @returns resulting new vector
  68691. */
  68692. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68693. /**
  68694. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68695. * @param otherVector vector to devide with
  68696. * @returns resulting new vector
  68697. */
  68698. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68699. /**
  68700. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68701. * @param otherVector vector to devide with
  68702. * @param result vector to store the result
  68703. * @returns the current Vector4.
  68704. */
  68705. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68706. /**
  68707. * Divides the current Vector3 coordinates by the given ones.
  68708. * @param otherVector vector to devide with
  68709. * @returns the updated Vector3.
  68710. */
  68711. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68712. /**
  68713. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68714. * @param other defines the second operand
  68715. * @returns the current updated Vector4
  68716. */
  68717. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68718. /**
  68719. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68720. * @param other defines the second operand
  68721. * @returns the current updated Vector4
  68722. */
  68723. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68724. /**
  68725. * Gets a new Vector4 from current Vector4 floored values
  68726. * @returns a new Vector4
  68727. */
  68728. floor(): Vector4;
  68729. /**
  68730. * Gets a new Vector4 from current Vector3 floored values
  68731. * @returns a new Vector4
  68732. */
  68733. fract(): Vector4;
  68734. /**
  68735. * Returns the Vector4 length (float).
  68736. * @returns the length
  68737. */
  68738. length(): number;
  68739. /**
  68740. * Returns the Vector4 squared length (float).
  68741. * @returns the length squared
  68742. */
  68743. lengthSquared(): number;
  68744. /**
  68745. * Normalizes in place the Vector4.
  68746. * @returns the updated Vector4.
  68747. */
  68748. normalize(): Vector4;
  68749. /**
  68750. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68751. * @returns this converted to a new vector3
  68752. */
  68753. toVector3(): Vector3;
  68754. /**
  68755. * Returns a new Vector4 copied from the current one.
  68756. * @returns the new cloned vector
  68757. */
  68758. clone(): Vector4;
  68759. /**
  68760. * Updates the current Vector4 with the given one coordinates.
  68761. * @param source the source vector to copy from
  68762. * @returns the updated Vector4.
  68763. */
  68764. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68765. /**
  68766. * Updates the current Vector4 coordinates with the given floats.
  68767. * @param x float to copy from
  68768. * @param y float to copy from
  68769. * @param z float to copy from
  68770. * @param w float to copy from
  68771. * @returns the updated Vector4.
  68772. */
  68773. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68774. /**
  68775. * Updates the current Vector4 coordinates with the given floats.
  68776. * @param x float to set from
  68777. * @param y float to set from
  68778. * @param z float to set from
  68779. * @param w float to set from
  68780. * @returns the updated Vector4.
  68781. */
  68782. set(x: number, y: number, z: number, w: number): Vector4;
  68783. /**
  68784. * Copies the given float to the current Vector3 coordinates
  68785. * @param v defines the x, y, z and w coordinates of the operand
  68786. * @returns the current updated Vector3
  68787. */
  68788. setAll(v: number): Vector4;
  68789. /**
  68790. * Returns a new Vector4 set from the starting index of the given array.
  68791. * @param array the array to pull values from
  68792. * @param offset the offset into the array to start at
  68793. * @returns the new vector
  68794. */
  68795. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68796. /**
  68797. * Updates the given vector "result" from the starting index of the given array.
  68798. * @param array the array to pull values from
  68799. * @param offset the offset into the array to start at
  68800. * @param result the vector to store the result in
  68801. */
  68802. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68803. /**
  68804. * Updates the given vector "result" from the starting index of the given Float32Array.
  68805. * @param array the array to pull values from
  68806. * @param offset the offset into the array to start at
  68807. * @param result the vector to store the result in
  68808. */
  68809. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68810. /**
  68811. * Updates the given vector "result" coordinates from the given floats.
  68812. * @param x float to set from
  68813. * @param y float to set from
  68814. * @param z float to set from
  68815. * @param w float to set from
  68816. * @param result the vector to the floats in
  68817. */
  68818. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68819. /**
  68820. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68821. * @returns the new vector
  68822. */
  68823. static Zero(): Vector4;
  68824. /**
  68825. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68826. * @returns the new vector
  68827. */
  68828. static One(): Vector4;
  68829. /**
  68830. * Returns a new normalized Vector4 from the given one.
  68831. * @param vector the vector to normalize
  68832. * @returns the vector
  68833. */
  68834. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68835. /**
  68836. * Updates the given vector "result" from the normalization of the given one.
  68837. * @param vector the vector to normalize
  68838. * @param result the vector to store the result in
  68839. */
  68840. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68841. /**
  68842. * Returns a vector with the minimum values from the left and right vectors
  68843. * @param left left vector to minimize
  68844. * @param right right vector to minimize
  68845. * @returns a new vector with the minimum of the left and right vector values
  68846. */
  68847. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68848. /**
  68849. * Returns a vector with the maximum values from the left and right vectors
  68850. * @param left left vector to maximize
  68851. * @param right right vector to maximize
  68852. * @returns a new vector with the maximum of the left and right vector values
  68853. */
  68854. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68855. /**
  68856. * Returns the distance (float) between the vectors "value1" and "value2".
  68857. * @param value1 value to calulate the distance between
  68858. * @param value2 value to calulate the distance between
  68859. * @return the distance between the two vectors
  68860. */
  68861. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68862. /**
  68863. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68864. * @param value1 value to calulate the distance between
  68865. * @param value2 value to calulate the distance between
  68866. * @return the distance between the two vectors squared
  68867. */
  68868. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68869. /**
  68870. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68871. * @param value1 value to calulate the center between
  68872. * @param value2 value to calulate the center between
  68873. * @return the center between the two vectors
  68874. */
  68875. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68876. /**
  68877. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68878. * This methods computes transformed normalized direction vectors only.
  68879. * @param vector the vector to transform
  68880. * @param transformation the transformation matrix to apply
  68881. * @returns the new vector
  68882. */
  68883. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68884. /**
  68885. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68886. * This methods computes transformed normalized direction vectors only.
  68887. * @param vector the vector to transform
  68888. * @param transformation the transformation matrix to apply
  68889. * @param result the vector to store the result in
  68890. */
  68891. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68892. /**
  68893. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68894. * This methods computes transformed normalized direction vectors only.
  68895. * @param x value to transform
  68896. * @param y value to transform
  68897. * @param z value to transform
  68898. * @param w value to transform
  68899. * @param transformation the transformation matrix to apply
  68900. * @param result the vector to store the results in
  68901. */
  68902. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68903. /**
  68904. * Creates a new Vector4 from a Vector3
  68905. * @param source defines the source data
  68906. * @param w defines the 4th component (default is 0)
  68907. * @returns a new Vector4
  68908. */
  68909. static FromVector3(source: Vector3, w?: number): Vector4;
  68910. }
  68911. /**
  68912. * Class used to store quaternion data
  68913. * @see https://en.wikipedia.org/wiki/Quaternion
  68914. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68915. */
  68916. export class Quaternion {
  68917. /** defines the first component (0 by default) */
  68918. x: number;
  68919. /** defines the second component (0 by default) */
  68920. y: number;
  68921. /** defines the third component (0 by default) */
  68922. z: number;
  68923. /** defines the fourth component (1.0 by default) */
  68924. w: number;
  68925. /**
  68926. * Creates a new Quaternion from the given floats
  68927. * @param x defines the first component (0 by default)
  68928. * @param y defines the second component (0 by default)
  68929. * @param z defines the third component (0 by default)
  68930. * @param w defines the fourth component (1.0 by default)
  68931. */
  68932. constructor(
  68933. /** defines the first component (0 by default) */
  68934. x?: number,
  68935. /** defines the second component (0 by default) */
  68936. y?: number,
  68937. /** defines the third component (0 by default) */
  68938. z?: number,
  68939. /** defines the fourth component (1.0 by default) */
  68940. w?: number);
  68941. /**
  68942. * Gets a string representation for the current quaternion
  68943. * @returns a string with the Quaternion coordinates
  68944. */
  68945. toString(): string;
  68946. /**
  68947. * Gets the class name of the quaternion
  68948. * @returns the string "Quaternion"
  68949. */
  68950. getClassName(): string;
  68951. /**
  68952. * Gets a hash code for this quaternion
  68953. * @returns the quaternion hash code
  68954. */
  68955. getHashCode(): number;
  68956. /**
  68957. * Copy the quaternion to an array
  68958. * @returns a new array populated with 4 elements from the quaternion coordinates
  68959. */
  68960. asArray(): number[];
  68961. /**
  68962. * Check if two quaternions are equals
  68963. * @param otherQuaternion defines the second operand
  68964. * @return true if the current quaternion and the given one coordinates are strictly equals
  68965. */
  68966. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68967. /**
  68968. * Clone the current quaternion
  68969. * @returns a new quaternion copied from the current one
  68970. */
  68971. clone(): Quaternion;
  68972. /**
  68973. * Copy a quaternion to the current one
  68974. * @param other defines the other quaternion
  68975. * @returns the updated current quaternion
  68976. */
  68977. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68978. /**
  68979. * Updates the current quaternion with the given float coordinates
  68980. * @param x defines the x coordinate
  68981. * @param y defines the y coordinate
  68982. * @param z defines the z coordinate
  68983. * @param w defines the w coordinate
  68984. * @returns the updated current quaternion
  68985. */
  68986. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68987. /**
  68988. * Updates the current quaternion from the given float coordinates
  68989. * @param x defines the x coordinate
  68990. * @param y defines the y coordinate
  68991. * @param z defines the z coordinate
  68992. * @param w defines the w coordinate
  68993. * @returns the updated current quaternion
  68994. */
  68995. set(x: number, y: number, z: number, w: number): Quaternion;
  68996. /**
  68997. * Adds two quaternions
  68998. * @param other defines the second operand
  68999. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69000. */
  69001. add(other: DeepImmutable<Quaternion>): Quaternion;
  69002. /**
  69003. * Add a quaternion to the current one
  69004. * @param other defines the quaternion to add
  69005. * @returns the current quaternion
  69006. */
  69007. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69008. /**
  69009. * Subtract two quaternions
  69010. * @param other defines the second operand
  69011. * @returns a new quaternion as the subtraction result of the given one from the current one
  69012. */
  69013. subtract(other: Quaternion): Quaternion;
  69014. /**
  69015. * Multiplies the current quaternion by a scale factor
  69016. * @param value defines the scale factor
  69017. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69018. */
  69019. scale(value: number): Quaternion;
  69020. /**
  69021. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69022. * @param scale defines the scale factor
  69023. * @param result defines the Quaternion object where to store the result
  69024. * @returns the unmodified current quaternion
  69025. */
  69026. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69027. /**
  69028. * Multiplies in place the current quaternion by a scale factor
  69029. * @param value defines the scale factor
  69030. * @returns the current modified quaternion
  69031. */
  69032. scaleInPlace(value: number): Quaternion;
  69033. /**
  69034. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69035. * @param scale defines the scale factor
  69036. * @param result defines the Quaternion object where to store the result
  69037. * @returns the unmodified current quaternion
  69038. */
  69039. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69040. /**
  69041. * Multiplies two quaternions
  69042. * @param q1 defines the second operand
  69043. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69044. */
  69045. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69046. /**
  69047. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69048. * @param q1 defines the second operand
  69049. * @param result defines the target quaternion
  69050. * @returns the current quaternion
  69051. */
  69052. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69053. /**
  69054. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69055. * @param q1 defines the second operand
  69056. * @returns the currentupdated quaternion
  69057. */
  69058. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69059. /**
  69060. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69061. * @param ref defines the target quaternion
  69062. * @returns the current quaternion
  69063. */
  69064. conjugateToRef(ref: Quaternion): Quaternion;
  69065. /**
  69066. * Conjugates in place (1-q) the current quaternion
  69067. * @returns the current updated quaternion
  69068. */
  69069. conjugateInPlace(): Quaternion;
  69070. /**
  69071. * Conjugates in place (1-q) the current quaternion
  69072. * @returns a new quaternion
  69073. */
  69074. conjugate(): Quaternion;
  69075. /**
  69076. * Gets length of current quaternion
  69077. * @returns the quaternion length (float)
  69078. */
  69079. length(): number;
  69080. /**
  69081. * Normalize in place the current quaternion
  69082. * @returns the current updated quaternion
  69083. */
  69084. normalize(): Quaternion;
  69085. /**
  69086. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69087. * @param order is a reserved parameter and is ignore for now
  69088. * @returns a new Vector3 containing the Euler angles
  69089. */
  69090. toEulerAngles(order?: string): Vector3;
  69091. /**
  69092. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69093. * @param result defines the vector which will be filled with the Euler angles
  69094. * @param order is a reserved parameter and is ignore for now
  69095. * @returns the current unchanged quaternion
  69096. */
  69097. toEulerAnglesToRef(result: Vector3): Quaternion;
  69098. /**
  69099. * Updates the given rotation matrix with the current quaternion values
  69100. * @param result defines the target matrix
  69101. * @returns the current unchanged quaternion
  69102. */
  69103. toRotationMatrix(result: Matrix): Quaternion;
  69104. /**
  69105. * Updates the current quaternion from the given rotation matrix values
  69106. * @param matrix defines the source matrix
  69107. * @returns the current updated quaternion
  69108. */
  69109. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69110. /**
  69111. * Creates a new quaternion from a rotation matrix
  69112. * @param matrix defines the source matrix
  69113. * @returns a new quaternion created from the given rotation matrix values
  69114. */
  69115. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69116. /**
  69117. * Updates the given quaternion with the given rotation matrix values
  69118. * @param matrix defines the source matrix
  69119. * @param result defines the target quaternion
  69120. */
  69121. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69122. /**
  69123. * Returns the dot product (float) between the quaternions "left" and "right"
  69124. * @param left defines the left operand
  69125. * @param right defines the right operand
  69126. * @returns the dot product
  69127. */
  69128. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69129. /**
  69130. * Checks if the two quaternions are close to each other
  69131. * @param quat0 defines the first quaternion to check
  69132. * @param quat1 defines the second quaternion to check
  69133. * @returns true if the two quaternions are close to each other
  69134. */
  69135. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69136. /**
  69137. * Creates an empty quaternion
  69138. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69139. */
  69140. static Zero(): Quaternion;
  69141. /**
  69142. * Inverse a given quaternion
  69143. * @param q defines the source quaternion
  69144. * @returns a new quaternion as the inverted current quaternion
  69145. */
  69146. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69147. /**
  69148. * Inverse a given quaternion
  69149. * @param q defines the source quaternion
  69150. * @param result the quaternion the result will be stored in
  69151. * @returns the result quaternion
  69152. */
  69153. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69154. /**
  69155. * Creates an identity quaternion
  69156. * @returns the identity quaternion
  69157. */
  69158. static Identity(): Quaternion;
  69159. /**
  69160. * Gets a boolean indicating if the given quaternion is identity
  69161. * @param quaternion defines the quaternion to check
  69162. * @returns true if the quaternion is identity
  69163. */
  69164. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69165. /**
  69166. * Creates a quaternion from a rotation around an axis
  69167. * @param axis defines the axis to use
  69168. * @param angle defines the angle to use
  69169. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69170. */
  69171. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69172. /**
  69173. * Creates a rotation around an axis and stores it into the given quaternion
  69174. * @param axis defines the axis to use
  69175. * @param angle defines the angle to use
  69176. * @param result defines the target quaternion
  69177. * @returns the target quaternion
  69178. */
  69179. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69180. /**
  69181. * Creates a new quaternion from data stored into an array
  69182. * @param array defines the data source
  69183. * @param offset defines the offset in the source array where the data starts
  69184. * @returns a new quaternion
  69185. */
  69186. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69187. /**
  69188. * Create a quaternion from Euler rotation angles
  69189. * @param x Pitch
  69190. * @param y Yaw
  69191. * @param z Roll
  69192. * @returns the new Quaternion
  69193. */
  69194. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69195. /**
  69196. * Updates a quaternion from Euler rotation angles
  69197. * @param x Pitch
  69198. * @param y Yaw
  69199. * @param z Roll
  69200. * @param result the quaternion to store the result
  69201. * @returns the updated quaternion
  69202. */
  69203. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69204. /**
  69205. * Create a quaternion from Euler rotation vector
  69206. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69207. * @returns the new Quaternion
  69208. */
  69209. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69210. /**
  69211. * Updates a quaternion from Euler rotation vector
  69212. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69213. * @param result the quaternion to store the result
  69214. * @returns the updated quaternion
  69215. */
  69216. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69217. /**
  69218. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69219. * @param yaw defines the rotation around Y axis
  69220. * @param pitch defines the rotation around X axis
  69221. * @param roll defines the rotation around Z axis
  69222. * @returns the new quaternion
  69223. */
  69224. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69225. /**
  69226. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69227. * @param yaw defines the rotation around Y axis
  69228. * @param pitch defines the rotation around X axis
  69229. * @param roll defines the rotation around Z axis
  69230. * @param result defines the target quaternion
  69231. */
  69232. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69233. /**
  69234. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69235. * @param alpha defines the rotation around first axis
  69236. * @param beta defines the rotation around second axis
  69237. * @param gamma defines the rotation around third axis
  69238. * @returns the new quaternion
  69239. */
  69240. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69241. /**
  69242. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69243. * @param alpha defines the rotation around first axis
  69244. * @param beta defines the rotation around second axis
  69245. * @param gamma defines the rotation around third axis
  69246. * @param result defines the target quaternion
  69247. */
  69248. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69249. /**
  69250. * 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)
  69251. * @param axis1 defines the first axis
  69252. * @param axis2 defines the second axis
  69253. * @param axis3 defines the third axis
  69254. * @returns the new quaternion
  69255. */
  69256. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69257. /**
  69258. * 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
  69259. * @param axis1 defines the first axis
  69260. * @param axis2 defines the second axis
  69261. * @param axis3 defines the third axis
  69262. * @param ref defines the target quaternion
  69263. */
  69264. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69265. /**
  69266. * Interpolates between two quaternions
  69267. * @param left defines first quaternion
  69268. * @param right defines second quaternion
  69269. * @param amount defines the gradient to use
  69270. * @returns the new interpolated quaternion
  69271. */
  69272. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69273. /**
  69274. * Interpolates between two quaternions and stores it into a target quaternion
  69275. * @param left defines first quaternion
  69276. * @param right defines second quaternion
  69277. * @param amount defines the gradient to use
  69278. * @param result defines the target quaternion
  69279. */
  69280. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69281. /**
  69282. * Interpolate between two quaternions using Hermite interpolation
  69283. * @param value1 defines first quaternion
  69284. * @param tangent1 defines the incoming tangent
  69285. * @param value2 defines second quaternion
  69286. * @param tangent2 defines the outgoing tangent
  69287. * @param amount defines the target quaternion
  69288. * @returns the new interpolated quaternion
  69289. */
  69290. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69291. }
  69292. /**
  69293. * Class used to store matrix data (4x4)
  69294. */
  69295. export class Matrix {
  69296. private static _updateFlagSeed;
  69297. private static _identityReadOnly;
  69298. private _isIdentity;
  69299. private _isIdentityDirty;
  69300. private _isIdentity3x2;
  69301. private _isIdentity3x2Dirty;
  69302. /**
  69303. * Gets the update flag of the matrix which is an unique number for the matrix.
  69304. * It will be incremented every time the matrix data change.
  69305. * You can use it to speed the comparison between two versions of the same matrix.
  69306. */
  69307. updateFlag: number;
  69308. private readonly _m;
  69309. /**
  69310. * Gets the internal data of the matrix
  69311. */
  69312. readonly m: DeepImmutable<Float32Array>;
  69313. /** @hidden */
  69314. _markAsUpdated(): void;
  69315. /** @hidden */
  69316. private _updateIdentityStatus;
  69317. /**
  69318. * Creates an empty matrix (filled with zeros)
  69319. */
  69320. constructor();
  69321. /**
  69322. * Check if the current matrix is identity
  69323. * @returns true is the matrix is the identity matrix
  69324. */
  69325. isIdentity(): boolean;
  69326. /**
  69327. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69328. * @returns true is the matrix is the identity matrix
  69329. */
  69330. isIdentityAs3x2(): boolean;
  69331. /**
  69332. * Gets the determinant of the matrix
  69333. * @returns the matrix determinant
  69334. */
  69335. determinant(): number;
  69336. /**
  69337. * Returns the matrix as a Float32Array
  69338. * @returns the matrix underlying array
  69339. */
  69340. toArray(): DeepImmutable<Float32Array>;
  69341. /**
  69342. * Returns the matrix as a Float32Array
  69343. * @returns the matrix underlying array.
  69344. */
  69345. asArray(): DeepImmutable<Float32Array>;
  69346. /**
  69347. * Inverts the current matrix in place
  69348. * @returns the current inverted matrix
  69349. */
  69350. invert(): Matrix;
  69351. /**
  69352. * Sets all the matrix elements to zero
  69353. * @returns the current matrix
  69354. */
  69355. reset(): Matrix;
  69356. /**
  69357. * Adds the current matrix with a second one
  69358. * @param other defines the matrix to add
  69359. * @returns a new matrix as the addition of the current matrix and the given one
  69360. */
  69361. add(other: DeepImmutable<Matrix>): Matrix;
  69362. /**
  69363. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69364. * @param other defines the matrix to add
  69365. * @param result defines the target matrix
  69366. * @returns the current matrix
  69367. */
  69368. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69369. /**
  69370. * Adds in place the given matrix to the current matrix
  69371. * @param other defines the second operand
  69372. * @returns the current updated matrix
  69373. */
  69374. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69375. /**
  69376. * Sets the given matrix to the current inverted Matrix
  69377. * @param other defines the target matrix
  69378. * @returns the unmodified current matrix
  69379. */
  69380. invertToRef(other: Matrix): Matrix;
  69381. /**
  69382. * add a value at the specified position in the current Matrix
  69383. * @param index the index of the value within the matrix. between 0 and 15.
  69384. * @param value the value to be added
  69385. * @returns the current updated matrix
  69386. */
  69387. addAtIndex(index: number, value: number): Matrix;
  69388. /**
  69389. * mutiply the specified position in the current Matrix by a value
  69390. * @param index the index of the value within the matrix. between 0 and 15.
  69391. * @param value the value to be added
  69392. * @returns the current updated matrix
  69393. */
  69394. multiplyAtIndex(index: number, value: number): Matrix;
  69395. /**
  69396. * Inserts the translation vector (using 3 floats) in the current matrix
  69397. * @param x defines the 1st component of the translation
  69398. * @param y defines the 2nd component of the translation
  69399. * @param z defines the 3rd component of the translation
  69400. * @returns the current updated matrix
  69401. */
  69402. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69403. /**
  69404. * Adds the translation vector (using 3 floats) in the current matrix
  69405. * @param x defines the 1st component of the translation
  69406. * @param y defines the 2nd component of the translation
  69407. * @param z defines the 3rd component of the translation
  69408. * @returns the current updated matrix
  69409. */
  69410. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69411. /**
  69412. * Inserts the translation vector in the current matrix
  69413. * @param vector3 defines the translation to insert
  69414. * @returns the current updated matrix
  69415. */
  69416. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69417. /**
  69418. * Gets the translation value of the current matrix
  69419. * @returns a new Vector3 as the extracted translation from the matrix
  69420. */
  69421. getTranslation(): Vector3;
  69422. /**
  69423. * Fill a Vector3 with the extracted translation from the matrix
  69424. * @param result defines the Vector3 where to store the translation
  69425. * @returns the current matrix
  69426. */
  69427. getTranslationToRef(result: Vector3): Matrix;
  69428. /**
  69429. * Remove rotation and scaling part from the matrix
  69430. * @returns the updated matrix
  69431. */
  69432. removeRotationAndScaling(): Matrix;
  69433. /**
  69434. * Multiply two matrices
  69435. * @param other defines the second operand
  69436. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69437. */
  69438. multiply(other: DeepImmutable<Matrix>): Matrix;
  69439. /**
  69440. * Copy the current matrix from the given one
  69441. * @param other defines the source matrix
  69442. * @returns the current updated matrix
  69443. */
  69444. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69445. /**
  69446. * Populates the given array from the starting index with the current matrix values
  69447. * @param array defines the target array
  69448. * @param offset defines the offset in the target array where to start storing values
  69449. * @returns the current matrix
  69450. */
  69451. copyToArray(array: Float32Array, offset?: number): Matrix;
  69452. /**
  69453. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69454. * @param other defines the second operand
  69455. * @param result defines the matrix where to store the multiplication
  69456. * @returns the current matrix
  69457. */
  69458. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69459. /**
  69460. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69461. * @param other defines the second operand
  69462. * @param result defines the array where to store the multiplication
  69463. * @param offset defines the offset in the target array where to start storing values
  69464. * @returns the current matrix
  69465. */
  69466. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69467. /**
  69468. * Check equality between this matrix and a second one
  69469. * @param value defines the second matrix to compare
  69470. * @returns true is the current matrix and the given one values are strictly equal
  69471. */
  69472. equals(value: DeepImmutable<Matrix>): boolean;
  69473. /**
  69474. * Clone the current matrix
  69475. * @returns a new matrix from the current matrix
  69476. */
  69477. clone(): Matrix;
  69478. /**
  69479. * Returns the name of the current matrix class
  69480. * @returns the string "Matrix"
  69481. */
  69482. getClassName(): string;
  69483. /**
  69484. * Gets the hash code of the current matrix
  69485. * @returns the hash code
  69486. */
  69487. getHashCode(): number;
  69488. /**
  69489. * Decomposes the current Matrix into a translation, rotation and scaling components
  69490. * @param scale defines the scale vector3 given as a reference to update
  69491. * @param rotation defines the rotation quaternion given as a reference to update
  69492. * @param translation defines the translation vector3 given as a reference to update
  69493. * @returns true if operation was successful
  69494. */
  69495. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69496. /**
  69497. * Gets specific row of the matrix
  69498. * @param index defines the number of the row to get
  69499. * @returns the index-th row of the current matrix as a new Vector4
  69500. */
  69501. getRow(index: number): Nullable<Vector4>;
  69502. /**
  69503. * Sets the index-th row of the current matrix to the vector4 values
  69504. * @param index defines the number of the row to set
  69505. * @param row defines the target vector4
  69506. * @returns the updated current matrix
  69507. */
  69508. setRow(index: number, row: Vector4): Matrix;
  69509. /**
  69510. * Compute the transpose of the matrix
  69511. * @returns the new transposed matrix
  69512. */
  69513. transpose(): Matrix;
  69514. /**
  69515. * Compute the transpose of the matrix and store it in a given matrix
  69516. * @param result defines the target matrix
  69517. * @returns the current matrix
  69518. */
  69519. transposeToRef(result: Matrix): Matrix;
  69520. /**
  69521. * Sets the index-th row of the current matrix with the given 4 x float values
  69522. * @param index defines the row index
  69523. * @param x defines the x component to set
  69524. * @param y defines the y component to set
  69525. * @param z defines the z component to set
  69526. * @param w defines the w component to set
  69527. * @returns the updated current matrix
  69528. */
  69529. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69530. /**
  69531. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69532. * @param scale defines the scale factor
  69533. * @returns a new matrix
  69534. */
  69535. scale(scale: number): Matrix;
  69536. /**
  69537. * Scale the current matrix values by a factor to a given result matrix
  69538. * @param scale defines the scale factor
  69539. * @param result defines the matrix to store the result
  69540. * @returns the current matrix
  69541. */
  69542. scaleToRef(scale: number, result: Matrix): Matrix;
  69543. /**
  69544. * Scale the current matrix values by a factor and add the result to a given matrix
  69545. * @param scale defines the scale factor
  69546. * @param result defines the Matrix to store the result
  69547. * @returns the current matrix
  69548. */
  69549. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69550. /**
  69551. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69552. * @param ref matrix to store the result
  69553. */
  69554. toNormalMatrix(ref: Matrix): void;
  69555. /**
  69556. * Gets only rotation part of the current matrix
  69557. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69558. */
  69559. getRotationMatrix(): Matrix;
  69560. /**
  69561. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69562. * @param result defines the target matrix to store data to
  69563. * @returns the current matrix
  69564. */
  69565. getRotationMatrixToRef(result: Matrix): Matrix;
  69566. /**
  69567. * Toggles model matrix from being right handed to left handed in place and vice versa
  69568. */
  69569. toggleModelMatrixHandInPlace(): void;
  69570. /**
  69571. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69572. */
  69573. toggleProjectionMatrixHandInPlace(): void;
  69574. /**
  69575. * Creates a matrix from an array
  69576. * @param array defines the source array
  69577. * @param offset defines an offset in the source array
  69578. * @returns a new Matrix set from the starting index of the given array
  69579. */
  69580. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69581. /**
  69582. * Copy the content of an array into a given matrix
  69583. * @param array defines the source array
  69584. * @param offset defines an offset in the source array
  69585. * @param result defines the target matrix
  69586. */
  69587. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69588. /**
  69589. * Stores an array into a matrix after having multiplied each component by a given factor
  69590. * @param array defines the source array
  69591. * @param offset defines the offset in the source array
  69592. * @param scale defines the scaling factor
  69593. * @param result defines the target matrix
  69594. */
  69595. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69596. /**
  69597. * Gets an identity matrix that must not be updated
  69598. */
  69599. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69600. /**
  69601. * Stores a list of values (16) inside a given matrix
  69602. * @param initialM11 defines 1st value of 1st row
  69603. * @param initialM12 defines 2nd value of 1st row
  69604. * @param initialM13 defines 3rd value of 1st row
  69605. * @param initialM14 defines 4th value of 1st row
  69606. * @param initialM21 defines 1st value of 2nd row
  69607. * @param initialM22 defines 2nd value of 2nd row
  69608. * @param initialM23 defines 3rd value of 2nd row
  69609. * @param initialM24 defines 4th value of 2nd row
  69610. * @param initialM31 defines 1st value of 3rd row
  69611. * @param initialM32 defines 2nd value of 3rd row
  69612. * @param initialM33 defines 3rd value of 3rd row
  69613. * @param initialM34 defines 4th value of 3rd row
  69614. * @param initialM41 defines 1st value of 4th row
  69615. * @param initialM42 defines 2nd value of 4th row
  69616. * @param initialM43 defines 3rd value of 4th row
  69617. * @param initialM44 defines 4th value of 4th row
  69618. * @param result defines the target matrix
  69619. */
  69620. 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;
  69621. /**
  69622. * Creates new matrix from a list of values (16)
  69623. * @param initialM11 defines 1st value of 1st row
  69624. * @param initialM12 defines 2nd value of 1st row
  69625. * @param initialM13 defines 3rd value of 1st row
  69626. * @param initialM14 defines 4th value of 1st row
  69627. * @param initialM21 defines 1st value of 2nd row
  69628. * @param initialM22 defines 2nd value of 2nd row
  69629. * @param initialM23 defines 3rd value of 2nd row
  69630. * @param initialM24 defines 4th value of 2nd row
  69631. * @param initialM31 defines 1st value of 3rd row
  69632. * @param initialM32 defines 2nd value of 3rd row
  69633. * @param initialM33 defines 3rd value of 3rd row
  69634. * @param initialM34 defines 4th value of 3rd row
  69635. * @param initialM41 defines 1st value of 4th row
  69636. * @param initialM42 defines 2nd value of 4th row
  69637. * @param initialM43 defines 3rd value of 4th row
  69638. * @param initialM44 defines 4th value of 4th row
  69639. * @returns the new matrix
  69640. */
  69641. 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;
  69642. /**
  69643. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69644. * @param scale defines the scale vector3
  69645. * @param rotation defines the rotation quaternion
  69646. * @param translation defines the translation vector3
  69647. * @returns a new matrix
  69648. */
  69649. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69650. /**
  69651. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69652. * @param scale defines the scale vector3
  69653. * @param rotation defines the rotation quaternion
  69654. * @param translation defines the translation vector3
  69655. * @param result defines the target matrix
  69656. */
  69657. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69658. /**
  69659. * Creates a new identity matrix
  69660. * @returns a new identity matrix
  69661. */
  69662. static Identity(): Matrix;
  69663. /**
  69664. * Creates a new identity matrix and stores the result in a given matrix
  69665. * @param result defines the target matrix
  69666. */
  69667. static IdentityToRef(result: Matrix): void;
  69668. /**
  69669. * Creates a new zero matrix
  69670. * @returns a new zero matrix
  69671. */
  69672. static Zero(): Matrix;
  69673. /**
  69674. * Creates a new rotation matrix for "angle" radians around the X axis
  69675. * @param angle defines the angle (in radians) to use
  69676. * @return the new matrix
  69677. */
  69678. static RotationX(angle: number): Matrix;
  69679. /**
  69680. * Creates a new matrix as the invert of a given matrix
  69681. * @param source defines the source matrix
  69682. * @returns the new matrix
  69683. */
  69684. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69685. /**
  69686. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69687. * @param angle defines the angle (in radians) to use
  69688. * @param result defines the target matrix
  69689. */
  69690. static RotationXToRef(angle: number, result: Matrix): void;
  69691. /**
  69692. * Creates a new rotation matrix for "angle" radians around the Y axis
  69693. * @param angle defines the angle (in radians) to use
  69694. * @return the new matrix
  69695. */
  69696. static RotationY(angle: number): Matrix;
  69697. /**
  69698. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69699. * @param angle defines the angle (in radians) to use
  69700. * @param result defines the target matrix
  69701. */
  69702. static RotationYToRef(angle: number, result: Matrix): void;
  69703. /**
  69704. * Creates a new rotation matrix for "angle" radians around the Z axis
  69705. * @param angle defines the angle (in radians) to use
  69706. * @return the new matrix
  69707. */
  69708. static RotationZ(angle: number): Matrix;
  69709. /**
  69710. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69711. * @param angle defines the angle (in radians) to use
  69712. * @param result defines the target matrix
  69713. */
  69714. static RotationZToRef(angle: number, result: Matrix): void;
  69715. /**
  69716. * Creates a new rotation matrix for "angle" radians around the given axis
  69717. * @param axis defines the axis to use
  69718. * @param angle defines the angle (in radians) to use
  69719. * @return the new matrix
  69720. */
  69721. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69722. /**
  69723. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69724. * @param axis defines the axis to use
  69725. * @param angle defines the angle (in radians) to use
  69726. * @param result defines the target matrix
  69727. */
  69728. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69729. /**
  69730. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69731. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69732. * @param from defines the vector to align
  69733. * @param to defines the vector to align to
  69734. * @param result defines the target matrix
  69735. */
  69736. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69737. /**
  69738. * Creates a rotation matrix
  69739. * @param yaw defines the yaw angle in radians (Y axis)
  69740. * @param pitch defines the pitch angle in radians (X axis)
  69741. * @param roll defines the roll angle in radians (X axis)
  69742. * @returns the new rotation matrix
  69743. */
  69744. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69745. /**
  69746. * Creates a rotation matrix and stores it in a given matrix
  69747. * @param yaw defines the yaw angle in radians (Y axis)
  69748. * @param pitch defines the pitch angle in radians (X axis)
  69749. * @param roll defines the roll angle in radians (X axis)
  69750. * @param result defines the target matrix
  69751. */
  69752. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69753. /**
  69754. * Creates a scaling matrix
  69755. * @param x defines the scale factor on X axis
  69756. * @param y defines the scale factor on Y axis
  69757. * @param z defines the scale factor on Z axis
  69758. * @returns the new matrix
  69759. */
  69760. static Scaling(x: number, y: number, z: number): Matrix;
  69761. /**
  69762. * Creates a scaling matrix and stores it in a given matrix
  69763. * @param x defines the scale factor on X axis
  69764. * @param y defines the scale factor on Y axis
  69765. * @param z defines the scale factor on Z axis
  69766. * @param result defines the target matrix
  69767. */
  69768. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69769. /**
  69770. * Creates a translation matrix
  69771. * @param x defines the translation on X axis
  69772. * @param y defines the translation on Y axis
  69773. * @param z defines the translationon Z axis
  69774. * @returns the new matrix
  69775. */
  69776. static Translation(x: number, y: number, z: number): Matrix;
  69777. /**
  69778. * Creates a translation matrix and stores it in a given matrix
  69779. * @param x defines the translation on X axis
  69780. * @param y defines the translation on Y axis
  69781. * @param z defines the translationon Z axis
  69782. * @param result defines the target matrix
  69783. */
  69784. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69785. /**
  69786. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69787. * @param startValue defines the start value
  69788. * @param endValue defines the end value
  69789. * @param gradient defines the gradient factor
  69790. * @returns the new matrix
  69791. */
  69792. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69793. /**
  69794. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69795. * @param startValue defines the start value
  69796. * @param endValue defines the end value
  69797. * @param gradient defines the gradient factor
  69798. * @param result defines the Matrix object where to store data
  69799. */
  69800. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69801. /**
  69802. * Builds a new matrix whose values are computed by:
  69803. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69804. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69805. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69806. * @param startValue defines the first matrix
  69807. * @param endValue defines the second matrix
  69808. * @param gradient defines the gradient between the two matrices
  69809. * @returns the new matrix
  69810. */
  69811. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69812. /**
  69813. * Update a matrix to values which are computed by:
  69814. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69815. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69816. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69817. * @param startValue defines the first matrix
  69818. * @param endValue defines the second matrix
  69819. * @param gradient defines the gradient between the two matrices
  69820. * @param result defines the target matrix
  69821. */
  69822. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69823. /**
  69824. * 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"
  69825. * This function works in left handed mode
  69826. * @param eye defines the final position of the entity
  69827. * @param target defines where the entity should look at
  69828. * @param up defines the up vector for the entity
  69829. * @returns the new matrix
  69830. */
  69831. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69832. /**
  69833. * 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".
  69834. * This function works in left handed mode
  69835. * @param eye defines the final position of the entity
  69836. * @param target defines where the entity should look at
  69837. * @param up defines the up vector for the entity
  69838. * @param result defines the target matrix
  69839. */
  69840. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69841. /**
  69842. * 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"
  69843. * This function works in right handed mode
  69844. * @param eye defines the final position of the entity
  69845. * @param target defines where the entity should look at
  69846. * @param up defines the up vector for the entity
  69847. * @returns the new matrix
  69848. */
  69849. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69850. /**
  69851. * 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".
  69852. * This function works in right handed mode
  69853. * @param eye defines the final position of the entity
  69854. * @param target defines where the entity should look at
  69855. * @param up defines the up vector for the entity
  69856. * @param result defines the target matrix
  69857. */
  69858. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69859. /**
  69860. * Create a left-handed orthographic projection matrix
  69861. * @param width defines the viewport width
  69862. * @param height defines the viewport height
  69863. * @param znear defines the near clip plane
  69864. * @param zfar defines the far clip plane
  69865. * @returns a new matrix as a left-handed orthographic projection matrix
  69866. */
  69867. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69868. /**
  69869. * Store a left-handed orthographic projection to a given matrix
  69870. * @param width defines the viewport width
  69871. * @param height defines the viewport height
  69872. * @param znear defines the near clip plane
  69873. * @param zfar defines the far clip plane
  69874. * @param result defines the target matrix
  69875. */
  69876. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69877. /**
  69878. * Create a left-handed orthographic projection matrix
  69879. * @param left defines the viewport left coordinate
  69880. * @param right defines the viewport right coordinate
  69881. * @param bottom defines the viewport bottom coordinate
  69882. * @param top defines the viewport top coordinate
  69883. * @param znear defines the near clip plane
  69884. * @param zfar defines the far clip plane
  69885. * @returns a new matrix as a left-handed orthographic projection matrix
  69886. */
  69887. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69888. /**
  69889. * Stores a left-handed orthographic projection into a given matrix
  69890. * @param left defines the viewport left coordinate
  69891. * @param right defines the viewport right coordinate
  69892. * @param bottom defines the viewport bottom coordinate
  69893. * @param top defines the viewport top coordinate
  69894. * @param znear defines the near clip plane
  69895. * @param zfar defines the far clip plane
  69896. * @param result defines the target matrix
  69897. */
  69898. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69899. /**
  69900. * Creates a right-handed orthographic projection matrix
  69901. * @param left defines the viewport left coordinate
  69902. * @param right defines the viewport right coordinate
  69903. * @param bottom defines the viewport bottom coordinate
  69904. * @param top defines the viewport top coordinate
  69905. * @param znear defines the near clip plane
  69906. * @param zfar defines the far clip plane
  69907. * @returns a new matrix as a right-handed orthographic projection matrix
  69908. */
  69909. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69910. /**
  69911. * Stores a right-handed orthographic projection into a given matrix
  69912. * @param left defines the viewport left coordinate
  69913. * @param right defines the viewport right coordinate
  69914. * @param bottom defines the viewport bottom coordinate
  69915. * @param top defines the viewport top coordinate
  69916. * @param znear defines the near clip plane
  69917. * @param zfar defines the far clip plane
  69918. * @param result defines the target matrix
  69919. */
  69920. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69921. /**
  69922. * Creates a left-handed perspective projection matrix
  69923. * @param width defines the viewport width
  69924. * @param height defines the viewport height
  69925. * @param znear defines the near clip plane
  69926. * @param zfar defines the far clip plane
  69927. * @returns a new matrix as a left-handed perspective projection matrix
  69928. */
  69929. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69930. /**
  69931. * Creates a left-handed perspective projection matrix
  69932. * @param fov defines the horizontal field of view
  69933. * @param aspect defines the aspect ratio
  69934. * @param znear defines the near clip plane
  69935. * @param zfar defines the far clip plane
  69936. * @returns a new matrix as a left-handed perspective projection matrix
  69937. */
  69938. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69939. /**
  69940. * Stores a left-handed perspective projection into a given matrix
  69941. * @param fov defines the horizontal field of view
  69942. * @param aspect defines the aspect ratio
  69943. * @param znear defines the near clip plane
  69944. * @param zfar defines the far clip plane
  69945. * @param result defines the target matrix
  69946. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69947. */
  69948. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69949. /**
  69950. * Creates a right-handed perspective projection matrix
  69951. * @param fov defines the horizontal field of view
  69952. * @param aspect defines the aspect ratio
  69953. * @param znear defines the near clip plane
  69954. * @param zfar defines the far clip plane
  69955. * @returns a new matrix as a right-handed perspective projection matrix
  69956. */
  69957. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69958. /**
  69959. * Stores a right-handed perspective projection into a given matrix
  69960. * @param fov defines the horizontal field of view
  69961. * @param aspect defines the aspect ratio
  69962. * @param znear defines the near clip plane
  69963. * @param zfar defines the far clip plane
  69964. * @param result defines the target matrix
  69965. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69966. */
  69967. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69968. /**
  69969. * Stores a perspective projection for WebVR info a given matrix
  69970. * @param fov defines the field of view
  69971. * @param znear defines the near clip plane
  69972. * @param zfar defines the far clip plane
  69973. * @param result defines the target matrix
  69974. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69975. */
  69976. static PerspectiveFovWebVRToRef(fov: {
  69977. upDegrees: number;
  69978. downDegrees: number;
  69979. leftDegrees: number;
  69980. rightDegrees: number;
  69981. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69982. /**
  69983. * Computes a complete transformation matrix
  69984. * @param viewport defines the viewport to use
  69985. * @param world defines the world matrix
  69986. * @param view defines the view matrix
  69987. * @param projection defines the projection matrix
  69988. * @param zmin defines the near clip plane
  69989. * @param zmax defines the far clip plane
  69990. * @returns the transformation matrix
  69991. */
  69992. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69993. /**
  69994. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69995. * @param matrix defines the matrix to use
  69996. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69997. */
  69998. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69999. /**
  70000. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70001. * @param matrix defines the matrix to use
  70002. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70003. */
  70004. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70005. /**
  70006. * Compute the transpose of a given matrix
  70007. * @param matrix defines the matrix to transpose
  70008. * @returns the new matrix
  70009. */
  70010. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70011. /**
  70012. * Compute the transpose of a matrix and store it in a target matrix
  70013. * @param matrix defines the matrix to transpose
  70014. * @param result defines the target matrix
  70015. */
  70016. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70017. /**
  70018. * Computes a reflection matrix from a plane
  70019. * @param plane defines the reflection plane
  70020. * @returns a new matrix
  70021. */
  70022. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70023. /**
  70024. * Computes a reflection matrix from a plane
  70025. * @param plane defines the reflection plane
  70026. * @param result defines the target matrix
  70027. */
  70028. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70029. /**
  70030. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70031. * @param xaxis defines the value of the 1st axis
  70032. * @param yaxis defines the value of the 2nd axis
  70033. * @param zaxis defines the value of the 3rd axis
  70034. * @param result defines the target matrix
  70035. */
  70036. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70037. /**
  70038. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70039. * @param quat defines the quaternion to use
  70040. * @param result defines the target matrix
  70041. */
  70042. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70043. }
  70044. /**
  70045. * @hidden
  70046. */
  70047. export class TmpVectors {
  70048. static Vector2: Vector2[];
  70049. static Vector3: Vector3[];
  70050. static Vector4: Vector4[];
  70051. static Quaternion: Quaternion[];
  70052. static Matrix: Matrix[];
  70053. }
  70054. }
  70055. declare module BABYLON {
  70056. /**
  70057. * Class used to hold a RBG color
  70058. */
  70059. export class Color3 {
  70060. /**
  70061. * Defines the red component (between 0 and 1, default is 0)
  70062. */
  70063. r: number;
  70064. /**
  70065. * Defines the green component (between 0 and 1, default is 0)
  70066. */
  70067. g: number;
  70068. /**
  70069. * Defines the blue component (between 0 and 1, default is 0)
  70070. */
  70071. b: number;
  70072. /**
  70073. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70074. * @param r defines the red component (between 0 and 1, default is 0)
  70075. * @param g defines the green component (between 0 and 1, default is 0)
  70076. * @param b defines the blue component (between 0 and 1, default is 0)
  70077. */
  70078. constructor(
  70079. /**
  70080. * Defines the red component (between 0 and 1, default is 0)
  70081. */
  70082. r?: number,
  70083. /**
  70084. * Defines the green component (between 0 and 1, default is 0)
  70085. */
  70086. g?: number,
  70087. /**
  70088. * Defines the blue component (between 0 and 1, default is 0)
  70089. */
  70090. b?: number);
  70091. /**
  70092. * Creates a string with the Color3 current values
  70093. * @returns the string representation of the Color3 object
  70094. */
  70095. toString(): string;
  70096. /**
  70097. * Returns the string "Color3"
  70098. * @returns "Color3"
  70099. */
  70100. getClassName(): string;
  70101. /**
  70102. * Compute the Color3 hash code
  70103. * @returns an unique number that can be used to hash Color3 objects
  70104. */
  70105. getHashCode(): number;
  70106. /**
  70107. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70108. * @param array defines the array where to store the r,g,b components
  70109. * @param index defines an optional index in the target array to define where to start storing values
  70110. * @returns the current Color3 object
  70111. */
  70112. toArray(array: FloatArray, index?: number): Color3;
  70113. /**
  70114. * Returns a new Color4 object from the current Color3 and the given alpha
  70115. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70116. * @returns a new Color4 object
  70117. */
  70118. toColor4(alpha?: number): Color4;
  70119. /**
  70120. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70121. * @returns the new array
  70122. */
  70123. asArray(): number[];
  70124. /**
  70125. * Returns the luminance value
  70126. * @returns a float value
  70127. */
  70128. toLuminance(): number;
  70129. /**
  70130. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70131. * @param otherColor defines the second operand
  70132. * @returns the new Color3 object
  70133. */
  70134. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70135. /**
  70136. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70137. * @param otherColor defines the second operand
  70138. * @param result defines the Color3 object where to store the result
  70139. * @returns the current Color3
  70140. */
  70141. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70142. /**
  70143. * Determines equality between Color3 objects
  70144. * @param otherColor defines the second operand
  70145. * @returns true if the rgb values are equal to the given ones
  70146. */
  70147. equals(otherColor: DeepImmutable<Color3>): boolean;
  70148. /**
  70149. * Determines equality between the current Color3 object and a set of r,b,g values
  70150. * @param r defines the red component to check
  70151. * @param g defines the green component to check
  70152. * @param b defines the blue component to check
  70153. * @returns true if the rgb values are equal to the given ones
  70154. */
  70155. equalsFloats(r: number, g: number, b: number): boolean;
  70156. /**
  70157. * Multiplies in place each rgb value by scale
  70158. * @param scale defines the scaling factor
  70159. * @returns the updated Color3
  70160. */
  70161. scale(scale: number): Color3;
  70162. /**
  70163. * Multiplies the rgb values by scale and stores the result into "result"
  70164. * @param scale defines the scaling factor
  70165. * @param result defines the Color3 object where to store the result
  70166. * @returns the unmodified current Color3
  70167. */
  70168. scaleToRef(scale: number, result: Color3): Color3;
  70169. /**
  70170. * Scale the current Color3 values by a factor and add the result to a given Color3
  70171. * @param scale defines the scale factor
  70172. * @param result defines color to store the result into
  70173. * @returns the unmodified current Color3
  70174. */
  70175. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70176. /**
  70177. * Clamps the rgb values by the min and max values and stores the result into "result"
  70178. * @param min defines minimum clamping value (default is 0)
  70179. * @param max defines maximum clamping value (default is 1)
  70180. * @param result defines color to store the result into
  70181. * @returns the original Color3
  70182. */
  70183. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70184. /**
  70185. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70186. * @param otherColor defines the second operand
  70187. * @returns the new Color3
  70188. */
  70189. add(otherColor: DeepImmutable<Color3>): Color3;
  70190. /**
  70191. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70192. * @param otherColor defines the second operand
  70193. * @param result defines Color3 object to store the result into
  70194. * @returns the unmodified current Color3
  70195. */
  70196. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70197. /**
  70198. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70199. * @param otherColor defines the second operand
  70200. * @returns the new Color3
  70201. */
  70202. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70203. /**
  70204. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70205. * @param otherColor defines the second operand
  70206. * @param result defines Color3 object to store the result into
  70207. * @returns the unmodified current Color3
  70208. */
  70209. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70210. /**
  70211. * Copy the current object
  70212. * @returns a new Color3 copied the current one
  70213. */
  70214. clone(): Color3;
  70215. /**
  70216. * Copies the rgb values from the source in the current Color3
  70217. * @param source defines the source Color3 object
  70218. * @returns the updated Color3 object
  70219. */
  70220. copyFrom(source: DeepImmutable<Color3>): Color3;
  70221. /**
  70222. * Updates the Color3 rgb values from the given floats
  70223. * @param r defines the red component to read from
  70224. * @param g defines the green component to read from
  70225. * @param b defines the blue component to read from
  70226. * @returns the current Color3 object
  70227. */
  70228. copyFromFloats(r: number, g: number, b: number): Color3;
  70229. /**
  70230. * Updates the Color3 rgb values from the given floats
  70231. * @param r defines the red component to read from
  70232. * @param g defines the green component to read from
  70233. * @param b defines the blue component to read from
  70234. * @returns the current Color3 object
  70235. */
  70236. set(r: number, g: number, b: number): Color3;
  70237. /**
  70238. * Compute the Color3 hexadecimal code as a string
  70239. * @returns a string containing the hexadecimal representation of the Color3 object
  70240. */
  70241. toHexString(): string;
  70242. /**
  70243. * Computes a new Color3 converted from the current one to linear space
  70244. * @returns a new Color3 object
  70245. */
  70246. toLinearSpace(): Color3;
  70247. /**
  70248. * Converts current color in rgb space to HSV values
  70249. * @returns a new color3 representing the HSV values
  70250. */
  70251. toHSV(): Color3;
  70252. /**
  70253. * Converts current color in rgb space to HSV values
  70254. * @param result defines the Color3 where to store the HSV values
  70255. */
  70256. toHSVToRef(result: Color3): void;
  70257. /**
  70258. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70259. * @param convertedColor defines the Color3 object where to store the linear space version
  70260. * @returns the unmodified Color3
  70261. */
  70262. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70263. /**
  70264. * Computes a new Color3 converted from the current one to gamma space
  70265. * @returns a new Color3 object
  70266. */
  70267. toGammaSpace(): Color3;
  70268. /**
  70269. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70270. * @param convertedColor defines the Color3 object where to store the gamma space version
  70271. * @returns the unmodified Color3
  70272. */
  70273. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70274. private static _BlackReadOnly;
  70275. /**
  70276. * Convert Hue, saturation and value to a Color3 (RGB)
  70277. * @param hue defines the hue
  70278. * @param saturation defines the saturation
  70279. * @param value defines the value
  70280. * @param result defines the Color3 where to store the RGB values
  70281. */
  70282. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70283. /**
  70284. * Creates a new Color3 from the string containing valid hexadecimal values
  70285. * @param hex defines a string containing valid hexadecimal values
  70286. * @returns a new Color3 object
  70287. */
  70288. static FromHexString(hex: string): Color3;
  70289. /**
  70290. * Creates a new Color3 from the starting index of the given array
  70291. * @param array defines the source array
  70292. * @param offset defines an offset in the source array
  70293. * @returns a new Color3 object
  70294. */
  70295. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70296. /**
  70297. * Creates a new Color3 from integer values (< 256)
  70298. * @param r defines the red component to read from (value between 0 and 255)
  70299. * @param g defines the green component to read from (value between 0 and 255)
  70300. * @param b defines the blue component to read from (value between 0 and 255)
  70301. * @returns a new Color3 object
  70302. */
  70303. static FromInts(r: number, g: number, b: number): Color3;
  70304. /**
  70305. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70306. * @param start defines the start Color3 value
  70307. * @param end defines the end Color3 value
  70308. * @param amount defines the gradient value between start and end
  70309. * @returns a new Color3 object
  70310. */
  70311. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70312. /**
  70313. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70314. * @param left defines the start value
  70315. * @param right defines the end value
  70316. * @param amount defines the gradient factor
  70317. * @param result defines the Color3 object where to store the result
  70318. */
  70319. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70320. /**
  70321. * Returns a Color3 value containing a red color
  70322. * @returns a new Color3 object
  70323. */
  70324. static Red(): Color3;
  70325. /**
  70326. * Returns a Color3 value containing a green color
  70327. * @returns a new Color3 object
  70328. */
  70329. static Green(): Color3;
  70330. /**
  70331. * Returns a Color3 value containing a blue color
  70332. * @returns a new Color3 object
  70333. */
  70334. static Blue(): Color3;
  70335. /**
  70336. * Returns a Color3 value containing a black color
  70337. * @returns a new Color3 object
  70338. */
  70339. static Black(): Color3;
  70340. /**
  70341. * Gets a Color3 value containing a black color that must not be updated
  70342. */
  70343. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70344. /**
  70345. * Returns a Color3 value containing a white color
  70346. * @returns a new Color3 object
  70347. */
  70348. static White(): Color3;
  70349. /**
  70350. * Returns a Color3 value containing a purple color
  70351. * @returns a new Color3 object
  70352. */
  70353. static Purple(): Color3;
  70354. /**
  70355. * Returns a Color3 value containing a magenta color
  70356. * @returns a new Color3 object
  70357. */
  70358. static Magenta(): Color3;
  70359. /**
  70360. * Returns a Color3 value containing a yellow color
  70361. * @returns a new Color3 object
  70362. */
  70363. static Yellow(): Color3;
  70364. /**
  70365. * Returns a Color3 value containing a gray color
  70366. * @returns a new Color3 object
  70367. */
  70368. static Gray(): Color3;
  70369. /**
  70370. * Returns a Color3 value containing a teal color
  70371. * @returns a new Color3 object
  70372. */
  70373. static Teal(): Color3;
  70374. /**
  70375. * Returns a Color3 value containing a random color
  70376. * @returns a new Color3 object
  70377. */
  70378. static Random(): Color3;
  70379. }
  70380. /**
  70381. * Class used to hold a RBGA color
  70382. */
  70383. export class Color4 {
  70384. /**
  70385. * Defines the red component (between 0 and 1, default is 0)
  70386. */
  70387. r: number;
  70388. /**
  70389. * Defines the green component (between 0 and 1, default is 0)
  70390. */
  70391. g: number;
  70392. /**
  70393. * Defines the blue component (between 0 and 1, default is 0)
  70394. */
  70395. b: number;
  70396. /**
  70397. * Defines the alpha component (between 0 and 1, default is 1)
  70398. */
  70399. a: number;
  70400. /**
  70401. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70402. * @param r defines the red component (between 0 and 1, default is 0)
  70403. * @param g defines the green component (between 0 and 1, default is 0)
  70404. * @param b defines the blue component (between 0 and 1, default is 0)
  70405. * @param a defines the alpha component (between 0 and 1, default is 1)
  70406. */
  70407. constructor(
  70408. /**
  70409. * Defines the red component (between 0 and 1, default is 0)
  70410. */
  70411. r?: number,
  70412. /**
  70413. * Defines the green component (between 0 and 1, default is 0)
  70414. */
  70415. g?: number,
  70416. /**
  70417. * Defines the blue component (between 0 and 1, default is 0)
  70418. */
  70419. b?: number,
  70420. /**
  70421. * Defines the alpha component (between 0 and 1, default is 1)
  70422. */
  70423. a?: number);
  70424. /**
  70425. * Adds in place the given Color4 values to the current Color4 object
  70426. * @param right defines the second operand
  70427. * @returns the current updated Color4 object
  70428. */
  70429. addInPlace(right: DeepImmutable<Color4>): Color4;
  70430. /**
  70431. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70432. * @returns the new array
  70433. */
  70434. asArray(): number[];
  70435. /**
  70436. * Stores from the starting index in the given array the Color4 successive values
  70437. * @param array defines the array where to store the r,g,b components
  70438. * @param index defines an optional index in the target array to define where to start storing values
  70439. * @returns the current Color4 object
  70440. */
  70441. toArray(array: number[], index?: number): Color4;
  70442. /**
  70443. * Determines equality between Color4 objects
  70444. * @param otherColor defines the second operand
  70445. * @returns true if the rgba values are equal to the given ones
  70446. */
  70447. equals(otherColor: DeepImmutable<Color4>): boolean;
  70448. /**
  70449. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70450. * @param right defines the second operand
  70451. * @returns a new Color4 object
  70452. */
  70453. add(right: DeepImmutable<Color4>): Color4;
  70454. /**
  70455. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70456. * @param right defines the second operand
  70457. * @returns a new Color4 object
  70458. */
  70459. subtract(right: DeepImmutable<Color4>): Color4;
  70460. /**
  70461. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70462. * @param right defines the second operand
  70463. * @param result defines the Color4 object where to store the result
  70464. * @returns the current Color4 object
  70465. */
  70466. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70467. /**
  70468. * Creates a new Color4 with the current Color4 values multiplied by scale
  70469. * @param scale defines the scaling factor to apply
  70470. * @returns a new Color4 object
  70471. */
  70472. scale(scale: number): Color4;
  70473. /**
  70474. * Multiplies the current Color4 values by scale and stores the result in "result"
  70475. * @param scale defines the scaling factor to apply
  70476. * @param result defines the Color4 object where to store the result
  70477. * @returns the current unmodified Color4
  70478. */
  70479. scaleToRef(scale: number, result: Color4): Color4;
  70480. /**
  70481. * Scale the current Color4 values by a factor and add the result to a given Color4
  70482. * @param scale defines the scale factor
  70483. * @param result defines the Color4 object where to store the result
  70484. * @returns the unmodified current Color4
  70485. */
  70486. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70487. /**
  70488. * Clamps the rgb values by the min and max values and stores the result into "result"
  70489. * @param min defines minimum clamping value (default is 0)
  70490. * @param max defines maximum clamping value (default is 1)
  70491. * @param result defines color to store the result into.
  70492. * @returns the cuurent Color4
  70493. */
  70494. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70495. /**
  70496. * Multipy an Color4 value by another and return a new Color4 object
  70497. * @param color defines the Color4 value to multiply by
  70498. * @returns a new Color4 object
  70499. */
  70500. multiply(color: Color4): Color4;
  70501. /**
  70502. * Multipy a Color4 value by another and push the result in a reference value
  70503. * @param color defines the Color4 value to multiply by
  70504. * @param result defines the Color4 to fill the result in
  70505. * @returns the result Color4
  70506. */
  70507. multiplyToRef(color: Color4, result: Color4): Color4;
  70508. /**
  70509. * Creates a string with the Color4 current values
  70510. * @returns the string representation of the Color4 object
  70511. */
  70512. toString(): string;
  70513. /**
  70514. * Returns the string "Color4"
  70515. * @returns "Color4"
  70516. */
  70517. getClassName(): string;
  70518. /**
  70519. * Compute the Color4 hash code
  70520. * @returns an unique number that can be used to hash Color4 objects
  70521. */
  70522. getHashCode(): number;
  70523. /**
  70524. * Creates a new Color4 copied from the current one
  70525. * @returns a new Color4 object
  70526. */
  70527. clone(): Color4;
  70528. /**
  70529. * Copies the given Color4 values into the current one
  70530. * @param source defines the source Color4 object
  70531. * @returns the current updated Color4 object
  70532. */
  70533. copyFrom(source: Color4): Color4;
  70534. /**
  70535. * Copies the given float values into the current one
  70536. * @param r defines the red component to read from
  70537. * @param g defines the green component to read from
  70538. * @param b defines the blue component to read from
  70539. * @param a defines the alpha component to read from
  70540. * @returns the current updated Color4 object
  70541. */
  70542. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70543. /**
  70544. * Copies the given float values into the current one
  70545. * @param r defines the red component to read from
  70546. * @param g defines the green component to read from
  70547. * @param b defines the blue component to read from
  70548. * @param a defines the alpha component to read from
  70549. * @returns the current updated Color4 object
  70550. */
  70551. set(r: number, g: number, b: number, a: number): Color4;
  70552. /**
  70553. * Compute the Color4 hexadecimal code as a string
  70554. * @returns a string containing the hexadecimal representation of the Color4 object
  70555. */
  70556. toHexString(): string;
  70557. /**
  70558. * Computes a new Color4 converted from the current one to linear space
  70559. * @returns a new Color4 object
  70560. */
  70561. toLinearSpace(): Color4;
  70562. /**
  70563. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70564. * @param convertedColor defines the Color4 object where to store the linear space version
  70565. * @returns the unmodified Color4
  70566. */
  70567. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70568. /**
  70569. * Computes a new Color4 converted from the current one to gamma space
  70570. * @returns a new Color4 object
  70571. */
  70572. toGammaSpace(): Color4;
  70573. /**
  70574. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70575. * @param convertedColor defines the Color4 object where to store the gamma space version
  70576. * @returns the unmodified Color4
  70577. */
  70578. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70579. /**
  70580. * Creates a new Color4 from the string containing valid hexadecimal values
  70581. * @param hex defines a string containing valid hexadecimal values
  70582. * @returns a new Color4 object
  70583. */
  70584. static FromHexString(hex: string): Color4;
  70585. /**
  70586. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70587. * @param left defines the start value
  70588. * @param right defines the end value
  70589. * @param amount defines the gradient factor
  70590. * @returns a new Color4 object
  70591. */
  70592. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70593. /**
  70594. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70595. * @param left defines the start value
  70596. * @param right defines the end value
  70597. * @param amount defines the gradient factor
  70598. * @param result defines the Color4 object where to store data
  70599. */
  70600. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70601. /**
  70602. * Creates a new Color4 from a Color3 and an alpha value
  70603. * @param color3 defines the source Color3 to read from
  70604. * @param alpha defines the alpha component (1.0 by default)
  70605. * @returns a new Color4 object
  70606. */
  70607. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70608. /**
  70609. * Creates a new Color4 from the starting index element of the given array
  70610. * @param array defines the source array to read from
  70611. * @param offset defines the offset in the source array
  70612. * @returns a new Color4 object
  70613. */
  70614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70615. /**
  70616. * Creates a new Color3 from integer values (< 256)
  70617. * @param r defines the red component to read from (value between 0 and 255)
  70618. * @param g defines the green component to read from (value between 0 and 255)
  70619. * @param b defines the blue component to read from (value between 0 and 255)
  70620. * @param a defines the alpha component to read from (value between 0 and 255)
  70621. * @returns a new Color3 object
  70622. */
  70623. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70624. /**
  70625. * Check the content of a given array and convert it to an array containing RGBA data
  70626. * If the original array was already containing count * 4 values then it is returned directly
  70627. * @param colors defines the array to check
  70628. * @param count defines the number of RGBA data to expect
  70629. * @returns an array containing count * 4 values (RGBA)
  70630. */
  70631. static CheckColors4(colors: number[], count: number): number[];
  70632. }
  70633. /**
  70634. * @hidden
  70635. */
  70636. export class TmpColors {
  70637. static Color3: Color3[];
  70638. static Color4: Color4[];
  70639. }
  70640. }
  70641. declare module BABYLON {
  70642. /**
  70643. * Class representing spherical harmonics coefficients to the 3rd degree
  70644. */
  70645. export class SphericalHarmonics {
  70646. /**
  70647. * Defines whether or not the harmonics have been prescaled for rendering.
  70648. */
  70649. preScaled: boolean;
  70650. /**
  70651. * The l0,0 coefficients of the spherical harmonics
  70652. */
  70653. l00: Vector3;
  70654. /**
  70655. * The l1,-1 coefficients of the spherical harmonics
  70656. */
  70657. l1_1: Vector3;
  70658. /**
  70659. * The l1,0 coefficients of the spherical harmonics
  70660. */
  70661. l10: Vector3;
  70662. /**
  70663. * The l1,1 coefficients of the spherical harmonics
  70664. */
  70665. l11: Vector3;
  70666. /**
  70667. * The l2,-2 coefficients of the spherical harmonics
  70668. */
  70669. l2_2: Vector3;
  70670. /**
  70671. * The l2,-1 coefficients of the spherical harmonics
  70672. */
  70673. l2_1: Vector3;
  70674. /**
  70675. * The l2,0 coefficients of the spherical harmonics
  70676. */
  70677. l20: Vector3;
  70678. /**
  70679. * The l2,1 coefficients of the spherical harmonics
  70680. */
  70681. l21: Vector3;
  70682. /**
  70683. * The l2,2 coefficients of the spherical harmonics
  70684. */
  70685. l22: Vector3;
  70686. /**
  70687. * Adds a light to the spherical harmonics
  70688. * @param direction the direction of the light
  70689. * @param color the color of the light
  70690. * @param deltaSolidAngle the delta solid angle of the light
  70691. */
  70692. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70693. /**
  70694. * Scales the spherical harmonics by the given amount
  70695. * @param scale the amount to scale
  70696. */
  70697. scaleInPlace(scale: number): void;
  70698. /**
  70699. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70700. *
  70701. * ```
  70702. * E_lm = A_l * L_lm
  70703. * ```
  70704. *
  70705. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70706. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70707. * the scaling factors are given in equation 9.
  70708. */
  70709. convertIncidentRadianceToIrradiance(): void;
  70710. /**
  70711. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70712. *
  70713. * ```
  70714. * L = (1/pi) * E * rho
  70715. * ```
  70716. *
  70717. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70718. */
  70719. convertIrradianceToLambertianRadiance(): void;
  70720. /**
  70721. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70722. * required operations at run time.
  70723. *
  70724. * This is simply done by scaling back the SH with Ylm constants parameter.
  70725. * The trigonometric part being applied by the shader at run time.
  70726. */
  70727. preScaleForRendering(): void;
  70728. /**
  70729. * Constructs a spherical harmonics from an array.
  70730. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70731. * @returns the spherical harmonics
  70732. */
  70733. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70734. /**
  70735. * Gets the spherical harmonics from polynomial
  70736. * @param polynomial the spherical polynomial
  70737. * @returns the spherical harmonics
  70738. */
  70739. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70740. }
  70741. /**
  70742. * Class representing spherical polynomial coefficients to the 3rd degree
  70743. */
  70744. export class SphericalPolynomial {
  70745. private _harmonics;
  70746. /**
  70747. * The spherical harmonics used to create the polynomials.
  70748. */
  70749. readonly preScaledHarmonics: SphericalHarmonics;
  70750. /**
  70751. * The x coefficients of the spherical polynomial
  70752. */
  70753. x: Vector3;
  70754. /**
  70755. * The y coefficients of the spherical polynomial
  70756. */
  70757. y: Vector3;
  70758. /**
  70759. * The z coefficients of the spherical polynomial
  70760. */
  70761. z: Vector3;
  70762. /**
  70763. * The xx coefficients of the spherical polynomial
  70764. */
  70765. xx: Vector3;
  70766. /**
  70767. * The yy coefficients of the spherical polynomial
  70768. */
  70769. yy: Vector3;
  70770. /**
  70771. * The zz coefficients of the spherical polynomial
  70772. */
  70773. zz: Vector3;
  70774. /**
  70775. * The xy coefficients of the spherical polynomial
  70776. */
  70777. xy: Vector3;
  70778. /**
  70779. * The yz coefficients of the spherical polynomial
  70780. */
  70781. yz: Vector3;
  70782. /**
  70783. * The zx coefficients of the spherical polynomial
  70784. */
  70785. zx: Vector3;
  70786. /**
  70787. * Adds an ambient color to the spherical polynomial
  70788. * @param color the color to add
  70789. */
  70790. addAmbient(color: Color3): void;
  70791. /**
  70792. * Scales the spherical polynomial by the given amount
  70793. * @param scale the amount to scale
  70794. */
  70795. scaleInPlace(scale: number): void;
  70796. /**
  70797. * Gets the spherical polynomial from harmonics
  70798. * @param harmonics the spherical harmonics
  70799. * @returns the spherical polynomial
  70800. */
  70801. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70802. /**
  70803. * Constructs a spherical polynomial from an array.
  70804. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70805. * @returns the spherical polynomial
  70806. */
  70807. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70808. }
  70809. }
  70810. declare module BABYLON {
  70811. /**
  70812. * Define options used to create a render target texture
  70813. */
  70814. export class RenderTargetCreationOptions {
  70815. /**
  70816. * Specifies is mipmaps must be generated
  70817. */
  70818. generateMipMaps?: boolean;
  70819. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70820. generateDepthBuffer?: boolean;
  70821. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70822. generateStencilBuffer?: boolean;
  70823. /** Defines texture type (int by default) */
  70824. type?: number;
  70825. /** Defines sampling mode (trilinear by default) */
  70826. samplingMode?: number;
  70827. /** Defines format (RGBA by default) */
  70828. format?: number;
  70829. }
  70830. }
  70831. declare module BABYLON {
  70832. /**
  70833. * @hidden
  70834. **/
  70835. export class _TimeToken {
  70836. _startTimeQuery: Nullable<WebGLQuery>;
  70837. _endTimeQuery: Nullable<WebGLQuery>;
  70838. _timeElapsedQuery: Nullable<WebGLQuery>;
  70839. _timeElapsedQueryEnded: boolean;
  70840. }
  70841. }
  70842. declare module BABYLON {
  70843. /** Defines the cross module used constants to avoid circular dependncies */
  70844. export class Constants {
  70845. /** Defines that alpha blending is disabled */
  70846. static readonly ALPHA_DISABLE: number;
  70847. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  70848. static readonly ALPHA_ADD: number;
  70849. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  70850. static readonly ALPHA_COMBINE: number;
  70851. /** Defines that alpha blending to DEST - SRC * DEST */
  70852. static readonly ALPHA_SUBTRACT: number;
  70853. /** Defines that alpha blending to SRC * DEST */
  70854. static readonly ALPHA_MULTIPLY: number;
  70855. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  70856. static readonly ALPHA_MAXIMIZED: number;
  70857. /** Defines that alpha blending to SRC + DEST */
  70858. static readonly ALPHA_ONEONE: number;
  70859. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  70860. static readonly ALPHA_PREMULTIPLIED: number;
  70861. /**
  70862. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  70863. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  70864. */
  70865. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  70866. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  70867. static readonly ALPHA_INTERPOLATE: number;
  70868. /**
  70869. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  70870. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  70871. */
  70872. static readonly ALPHA_SCREENMODE: number;
  70873. /**
  70874. * Defines that alpha blending to SRC + DST
  70875. * Alpha will be set to SRC ALPHA + DST ALPHA
  70876. */
  70877. static readonly ALPHA_ONEONE_ONEONE: number;
  70878. /**
  70879. * Defines that alpha blending to SRC * DST ALPHA + DST
  70880. * Alpha will be set to 0
  70881. */
  70882. static readonly ALPHA_ALPHATOCOLOR: number;
  70883. /**
  70884. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  70885. */
  70886. static readonly ALPHA_REVERSEONEMINUS: number;
  70887. /**
  70888. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  70889. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  70890. */
  70891. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  70892. /**
  70893. * Defines that alpha blending to SRC + DST
  70894. * Alpha will be set to SRC ALPHA
  70895. */
  70896. static readonly ALPHA_ONEONE_ONEZERO: number;
  70897. /** Defines that alpha blending equation a SUM */
  70898. static readonly ALPHA_EQUATION_ADD: number;
  70899. /** Defines that alpha blending equation a SUBSTRACTION */
  70900. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  70901. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  70902. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  70903. /** Defines that alpha blending equation a MAX operation */
  70904. static readonly ALPHA_EQUATION_MAX: number;
  70905. /** Defines that alpha blending equation a MIN operation */
  70906. static readonly ALPHA_EQUATION_MIN: number;
  70907. /**
  70908. * Defines that alpha blending equation a DARKEN operation:
  70909. * It takes the min of the src and sums the alpha channels.
  70910. */
  70911. static readonly ALPHA_EQUATION_DARKEN: number;
  70912. /** Defines that the ressource is not delayed*/
  70913. static readonly DELAYLOADSTATE_NONE: number;
  70914. /** Defines that the ressource was successfully delay loaded */
  70915. static readonly DELAYLOADSTATE_LOADED: number;
  70916. /** Defines that the ressource is currently delay loading */
  70917. static readonly DELAYLOADSTATE_LOADING: number;
  70918. /** Defines that the ressource is delayed and has not started loading */
  70919. static readonly DELAYLOADSTATE_NOTLOADED: number;
  70920. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  70921. static readonly NEVER: number;
  70922. /** 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 */
  70923. static readonly ALWAYS: number;
  70924. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  70925. static readonly LESS: number;
  70926. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  70927. static readonly EQUAL: number;
  70928. /** 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 */
  70929. static readonly LEQUAL: number;
  70930. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  70931. static readonly GREATER: number;
  70932. /** 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 */
  70933. static readonly GEQUAL: number;
  70934. /** 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 */
  70935. static readonly NOTEQUAL: number;
  70936. /** Passed to stencilOperation to specify that stencil value must be kept */
  70937. static readonly KEEP: number;
  70938. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70939. static readonly REPLACE: number;
  70940. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70941. static readonly INCR: number;
  70942. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70943. static readonly DECR: number;
  70944. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70945. static readonly INVERT: number;
  70946. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70947. static readonly INCR_WRAP: number;
  70948. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70949. static readonly DECR_WRAP: number;
  70950. /** Texture is not repeating outside of 0..1 UVs */
  70951. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70952. /** Texture is repeating outside of 0..1 UVs */
  70953. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70954. /** Texture is repeating and mirrored */
  70955. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70956. /** ALPHA */
  70957. static readonly TEXTUREFORMAT_ALPHA: number;
  70958. /** LUMINANCE */
  70959. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70960. /** LUMINANCE_ALPHA */
  70961. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70962. /** RGB */
  70963. static readonly TEXTUREFORMAT_RGB: number;
  70964. /** RGBA */
  70965. static readonly TEXTUREFORMAT_RGBA: number;
  70966. /** RED */
  70967. static readonly TEXTUREFORMAT_RED: number;
  70968. /** RED (2nd reference) */
  70969. static readonly TEXTUREFORMAT_R: number;
  70970. /** RG */
  70971. static readonly TEXTUREFORMAT_RG: number;
  70972. /** RED_INTEGER */
  70973. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70974. /** RED_INTEGER (2nd reference) */
  70975. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70976. /** RG_INTEGER */
  70977. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70978. /** RGB_INTEGER */
  70979. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70980. /** RGBA_INTEGER */
  70981. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70982. /** UNSIGNED_BYTE */
  70983. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70984. /** UNSIGNED_BYTE (2nd reference) */
  70985. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70986. /** FLOAT */
  70987. static readonly TEXTURETYPE_FLOAT: number;
  70988. /** HALF_FLOAT */
  70989. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70990. /** BYTE */
  70991. static readonly TEXTURETYPE_BYTE: number;
  70992. /** SHORT */
  70993. static readonly TEXTURETYPE_SHORT: number;
  70994. /** UNSIGNED_SHORT */
  70995. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70996. /** INT */
  70997. static readonly TEXTURETYPE_INT: number;
  70998. /** UNSIGNED_INT */
  70999. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71000. /** UNSIGNED_SHORT_4_4_4_4 */
  71001. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71002. /** UNSIGNED_SHORT_5_5_5_1 */
  71003. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71004. /** UNSIGNED_SHORT_5_6_5 */
  71005. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71006. /** UNSIGNED_INT_2_10_10_10_REV */
  71007. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71008. /** UNSIGNED_INT_24_8 */
  71009. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71010. /** UNSIGNED_INT_10F_11F_11F_REV */
  71011. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71012. /** UNSIGNED_INT_5_9_9_9_REV */
  71013. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71014. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71015. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71016. /** nearest is mag = nearest and min = nearest and mip = linear */
  71017. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71018. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71019. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71020. /** Trilinear is mag = linear and min = linear and mip = linear */
  71021. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71022. /** nearest is mag = nearest and min = nearest and mip = linear */
  71023. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71024. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71025. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71026. /** Trilinear is mag = linear and min = linear and mip = linear */
  71027. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71028. /** mag = nearest and min = nearest and mip = nearest */
  71029. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71030. /** mag = nearest and min = linear and mip = nearest */
  71031. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71032. /** mag = nearest and min = linear and mip = linear */
  71033. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71034. /** mag = nearest and min = linear and mip = none */
  71035. static readonly TEXTURE_NEAREST_LINEAR: number;
  71036. /** mag = nearest and min = nearest and mip = none */
  71037. static readonly TEXTURE_NEAREST_NEAREST: number;
  71038. /** mag = linear and min = nearest and mip = nearest */
  71039. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71040. /** mag = linear and min = nearest and mip = linear */
  71041. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71042. /** mag = linear and min = linear and mip = none */
  71043. static readonly TEXTURE_LINEAR_LINEAR: number;
  71044. /** mag = linear and min = nearest and mip = none */
  71045. static readonly TEXTURE_LINEAR_NEAREST: number;
  71046. /** Explicit coordinates mode */
  71047. static readonly TEXTURE_EXPLICIT_MODE: number;
  71048. /** Spherical coordinates mode */
  71049. static readonly TEXTURE_SPHERICAL_MODE: number;
  71050. /** Planar coordinates mode */
  71051. static readonly TEXTURE_PLANAR_MODE: number;
  71052. /** Cubic coordinates mode */
  71053. static readonly TEXTURE_CUBIC_MODE: number;
  71054. /** Projection coordinates mode */
  71055. static readonly TEXTURE_PROJECTION_MODE: number;
  71056. /** Skybox coordinates mode */
  71057. static readonly TEXTURE_SKYBOX_MODE: number;
  71058. /** Inverse Cubic coordinates mode */
  71059. static readonly TEXTURE_INVCUBIC_MODE: number;
  71060. /** Equirectangular coordinates mode */
  71061. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71062. /** Equirectangular Fixed coordinates mode */
  71063. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71064. /** Equirectangular Fixed Mirrored coordinates mode */
  71065. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71066. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71067. static readonly SCALEMODE_FLOOR: number;
  71068. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71069. static readonly SCALEMODE_NEAREST: number;
  71070. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71071. static readonly SCALEMODE_CEILING: number;
  71072. /**
  71073. * The dirty texture flag value
  71074. */
  71075. static readonly MATERIAL_TextureDirtyFlag: number;
  71076. /**
  71077. * The dirty light flag value
  71078. */
  71079. static readonly MATERIAL_LightDirtyFlag: number;
  71080. /**
  71081. * The dirty fresnel flag value
  71082. */
  71083. static readonly MATERIAL_FresnelDirtyFlag: number;
  71084. /**
  71085. * The dirty attribute flag value
  71086. */
  71087. static readonly MATERIAL_AttributesDirtyFlag: number;
  71088. /**
  71089. * The dirty misc flag value
  71090. */
  71091. static readonly MATERIAL_MiscDirtyFlag: number;
  71092. /**
  71093. * The all dirty flag value
  71094. */
  71095. static readonly MATERIAL_AllDirtyFlag: number;
  71096. /**
  71097. * Returns the triangle fill mode
  71098. */
  71099. static readonly MATERIAL_TriangleFillMode: number;
  71100. /**
  71101. * Returns the wireframe mode
  71102. */
  71103. static readonly MATERIAL_WireFrameFillMode: number;
  71104. /**
  71105. * Returns the point fill mode
  71106. */
  71107. static readonly MATERIAL_PointFillMode: number;
  71108. /**
  71109. * Returns the point list draw mode
  71110. */
  71111. static readonly MATERIAL_PointListDrawMode: number;
  71112. /**
  71113. * Returns the line list draw mode
  71114. */
  71115. static readonly MATERIAL_LineListDrawMode: number;
  71116. /**
  71117. * Returns the line loop draw mode
  71118. */
  71119. static readonly MATERIAL_LineLoopDrawMode: number;
  71120. /**
  71121. * Returns the line strip draw mode
  71122. */
  71123. static readonly MATERIAL_LineStripDrawMode: number;
  71124. /**
  71125. * Returns the triangle strip draw mode
  71126. */
  71127. static readonly MATERIAL_TriangleStripDrawMode: number;
  71128. /**
  71129. * Returns the triangle fan draw mode
  71130. */
  71131. static readonly MATERIAL_TriangleFanDrawMode: number;
  71132. /**
  71133. * Stores the clock-wise side orientation
  71134. */
  71135. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71136. /**
  71137. * Stores the counter clock-wise side orientation
  71138. */
  71139. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71140. /**
  71141. * Nothing
  71142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71143. */
  71144. static readonly ACTION_NothingTrigger: number;
  71145. /**
  71146. * On pick
  71147. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71148. */
  71149. static readonly ACTION_OnPickTrigger: number;
  71150. /**
  71151. * On left pick
  71152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71153. */
  71154. static readonly ACTION_OnLeftPickTrigger: number;
  71155. /**
  71156. * On right pick
  71157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71158. */
  71159. static readonly ACTION_OnRightPickTrigger: number;
  71160. /**
  71161. * On center pick
  71162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71163. */
  71164. static readonly ACTION_OnCenterPickTrigger: number;
  71165. /**
  71166. * On pick down
  71167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71168. */
  71169. static readonly ACTION_OnPickDownTrigger: number;
  71170. /**
  71171. * On double pick
  71172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71173. */
  71174. static readonly ACTION_OnDoublePickTrigger: number;
  71175. /**
  71176. * On pick up
  71177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71178. */
  71179. static readonly ACTION_OnPickUpTrigger: number;
  71180. /**
  71181. * On pick out.
  71182. * This trigger will only be raised if you also declared a OnPickDown
  71183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71184. */
  71185. static readonly ACTION_OnPickOutTrigger: number;
  71186. /**
  71187. * On long press
  71188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71189. */
  71190. static readonly ACTION_OnLongPressTrigger: number;
  71191. /**
  71192. * On pointer over
  71193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71194. */
  71195. static readonly ACTION_OnPointerOverTrigger: number;
  71196. /**
  71197. * On pointer out
  71198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71199. */
  71200. static readonly ACTION_OnPointerOutTrigger: number;
  71201. /**
  71202. * On every frame
  71203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71204. */
  71205. static readonly ACTION_OnEveryFrameTrigger: number;
  71206. /**
  71207. * On intersection enter
  71208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71209. */
  71210. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71211. /**
  71212. * On intersection exit
  71213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71214. */
  71215. static readonly ACTION_OnIntersectionExitTrigger: number;
  71216. /**
  71217. * On key down
  71218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71219. */
  71220. static readonly ACTION_OnKeyDownTrigger: number;
  71221. /**
  71222. * On key up
  71223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71224. */
  71225. static readonly ACTION_OnKeyUpTrigger: number;
  71226. /**
  71227. * Billboard mode will only apply to Y axis
  71228. */
  71229. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71230. /**
  71231. * Billboard mode will apply to all axes
  71232. */
  71233. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71234. /**
  71235. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71236. */
  71237. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71238. /**
  71239. * Gets or sets base Assets URL
  71240. */
  71241. static PARTICLES_BaseAssetsUrl: string;
  71242. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71243. * Test order :
  71244. * Is the bounding sphere outside the frustum ?
  71245. * If not, are the bounding box vertices outside the frustum ?
  71246. * It not, then the cullable object is in the frustum.
  71247. */
  71248. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71249. /** Culling strategy : Bounding Sphere Only.
  71250. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71251. * It's also less accurate than the standard because some not visible objects can still be selected.
  71252. * Test : is the bounding sphere outside the frustum ?
  71253. * If not, then the cullable object is in the frustum.
  71254. */
  71255. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71256. /** Culling strategy : Optimistic Inclusion.
  71257. * This in an inclusion test first, then the standard exclusion test.
  71258. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71259. * 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.
  71260. * Anyway, it's as accurate as the standard strategy.
  71261. * Test :
  71262. * Is the cullable object bounding sphere center in the frustum ?
  71263. * If not, apply the default culling strategy.
  71264. */
  71265. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71266. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71267. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71268. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71269. * 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.
  71270. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71271. * Test :
  71272. * Is the cullable object bounding sphere center in the frustum ?
  71273. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71274. */
  71275. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71276. /**
  71277. * No logging while loading
  71278. */
  71279. static readonly SCENELOADER_NO_LOGGING: number;
  71280. /**
  71281. * Minimal logging while loading
  71282. */
  71283. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71284. /**
  71285. * Summary logging while loading
  71286. */
  71287. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71288. /**
  71289. * Detailled logging while loading
  71290. */
  71291. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71292. }
  71293. }
  71294. declare module BABYLON {
  71295. /**
  71296. * This represents the required contract to create a new type of texture loader.
  71297. */
  71298. export interface IInternalTextureLoader {
  71299. /**
  71300. * Defines wether the loader supports cascade loading the different faces.
  71301. */
  71302. supportCascades: boolean;
  71303. /**
  71304. * This returns if the loader support the current file information.
  71305. * @param extension defines the file extension of the file being loaded
  71306. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71307. * @param fallback defines the fallback internal texture if any
  71308. * @param isBase64 defines whether the texture is encoded as a base64
  71309. * @param isBuffer defines whether the texture data are stored as a buffer
  71310. * @returns true if the loader can load the specified file
  71311. */
  71312. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71313. /**
  71314. * Transform the url before loading if required.
  71315. * @param rootUrl the url of the texture
  71316. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71317. * @returns the transformed texture
  71318. */
  71319. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71320. /**
  71321. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71322. * @param rootUrl the url of the texture
  71323. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71324. * @returns the fallback texture
  71325. */
  71326. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71327. /**
  71328. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71329. * @param data contains the texture data
  71330. * @param texture defines the BabylonJS internal texture
  71331. * @param createPolynomials will be true if polynomials have been requested
  71332. * @param onLoad defines the callback to trigger once the texture is ready
  71333. * @param onError defines the callback to trigger in case of error
  71334. */
  71335. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71336. /**
  71337. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71338. * @param data contains the texture data
  71339. * @param texture defines the BabylonJS internal texture
  71340. * @param callback defines the method to call once ready to upload
  71341. */
  71342. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71343. }
  71344. }
  71345. declare module BABYLON {
  71346. /**
  71347. * Class used to store and describe the pipeline context associated with an effect
  71348. */
  71349. export interface IPipelineContext {
  71350. /**
  71351. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71352. */
  71353. isAsync: boolean;
  71354. /**
  71355. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71356. */
  71357. isReady: boolean;
  71358. /** @hidden */
  71359. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71360. }
  71361. }
  71362. declare module BABYLON {
  71363. /**
  71364. * Class used to store gfx data (like WebGLBuffer)
  71365. */
  71366. export class DataBuffer {
  71367. /**
  71368. * Gets or sets the number of objects referencing this buffer
  71369. */
  71370. references: number;
  71371. /** Gets or sets the size of the underlying buffer */
  71372. capacity: number;
  71373. /**
  71374. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71375. */
  71376. is32Bits: boolean;
  71377. /**
  71378. * Gets the underlying buffer
  71379. */
  71380. readonly underlyingResource: any;
  71381. }
  71382. }
  71383. declare module BABYLON {
  71384. /** @hidden */
  71385. export interface IShaderProcessor {
  71386. attributeProcessor?: (attribute: string) => string;
  71387. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71388. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71389. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71390. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71391. lineProcessor?: (line: string, isFragment: boolean) => string;
  71392. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71393. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71394. }
  71395. }
  71396. declare module BABYLON {
  71397. /** @hidden */
  71398. export interface ProcessingOptions {
  71399. defines: string[];
  71400. indexParameters: any;
  71401. isFragment: boolean;
  71402. shouldUseHighPrecisionShader: boolean;
  71403. supportsUniformBuffers: boolean;
  71404. shadersRepository: string;
  71405. includesShadersStore: {
  71406. [key: string]: string;
  71407. };
  71408. processor?: IShaderProcessor;
  71409. version: string;
  71410. platformName: string;
  71411. lookForClosingBracketForUniformBuffer?: boolean;
  71412. }
  71413. }
  71414. declare module BABYLON {
  71415. /**
  71416. * Helper to manipulate strings
  71417. */
  71418. export class StringTools {
  71419. /**
  71420. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71421. * @param str Source string
  71422. * @param suffix Suffix to search for in the source string
  71423. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71424. */
  71425. static EndsWith(str: string, suffix: string): boolean;
  71426. /**
  71427. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71428. * @param str Source string
  71429. * @param suffix Suffix to search for in the source string
  71430. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71431. */
  71432. static StartsWith(str: string, suffix: string): boolean;
  71433. }
  71434. }
  71435. declare module BABYLON {
  71436. /** @hidden */
  71437. export class ShaderCodeNode {
  71438. line: string;
  71439. children: ShaderCodeNode[];
  71440. additionalDefineKey?: string;
  71441. additionalDefineValue?: string;
  71442. isValid(preprocessors: {
  71443. [key: string]: string;
  71444. }): boolean;
  71445. process(preprocessors: {
  71446. [key: string]: string;
  71447. }, options: ProcessingOptions): string;
  71448. }
  71449. }
  71450. declare module BABYLON {
  71451. /** @hidden */
  71452. export class ShaderCodeCursor {
  71453. private _lines;
  71454. lineIndex: number;
  71455. readonly currentLine: string;
  71456. readonly canRead: boolean;
  71457. lines: string[];
  71458. }
  71459. }
  71460. declare module BABYLON {
  71461. /** @hidden */
  71462. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71463. process(preprocessors: {
  71464. [key: string]: string;
  71465. }, options: ProcessingOptions): string;
  71466. }
  71467. }
  71468. declare module BABYLON {
  71469. /** @hidden */
  71470. export class ShaderDefineExpression {
  71471. isTrue(preprocessors: {
  71472. [key: string]: string;
  71473. }): boolean;
  71474. }
  71475. }
  71476. declare module BABYLON {
  71477. /** @hidden */
  71478. export class ShaderCodeTestNode extends ShaderCodeNode {
  71479. testExpression: ShaderDefineExpression;
  71480. isValid(preprocessors: {
  71481. [key: string]: string;
  71482. }): boolean;
  71483. }
  71484. }
  71485. declare module BABYLON {
  71486. /** @hidden */
  71487. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71488. define: string;
  71489. not: boolean;
  71490. constructor(define: string, not?: boolean);
  71491. isTrue(preprocessors: {
  71492. [key: string]: string;
  71493. }): boolean;
  71494. }
  71495. }
  71496. declare module BABYLON {
  71497. /** @hidden */
  71498. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71499. leftOperand: ShaderDefineExpression;
  71500. rightOperand: ShaderDefineExpression;
  71501. isTrue(preprocessors: {
  71502. [key: string]: string;
  71503. }): boolean;
  71504. }
  71505. }
  71506. declare module BABYLON {
  71507. /** @hidden */
  71508. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71509. leftOperand: ShaderDefineExpression;
  71510. rightOperand: ShaderDefineExpression;
  71511. isTrue(preprocessors: {
  71512. [key: string]: string;
  71513. }): boolean;
  71514. }
  71515. }
  71516. declare module BABYLON {
  71517. /** @hidden */
  71518. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71519. define: string;
  71520. operand: string;
  71521. testValue: string;
  71522. constructor(define: string, operand: string, testValue: string);
  71523. isTrue(preprocessors: {
  71524. [key: string]: string;
  71525. }): boolean;
  71526. }
  71527. }
  71528. declare module BABYLON {
  71529. /**
  71530. * @ignore
  71531. * Application error to support additional information when loading a file
  71532. */
  71533. export class LoadFileError extends Error {
  71534. /** defines the optional web request */
  71535. request?: WebRequest | undefined;
  71536. private static _setPrototypeOf;
  71537. /**
  71538. * Creates a new LoadFileError
  71539. * @param message defines the message of the error
  71540. * @param request defines the optional web request
  71541. */
  71542. constructor(message: string,
  71543. /** defines the optional web request */
  71544. request?: WebRequest | undefined);
  71545. }
  71546. }
  71547. declare module BABYLON {
  71548. /**
  71549. * Class used to enable access to offline support
  71550. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71551. */
  71552. export interface IOfflineProvider {
  71553. /**
  71554. * Gets a boolean indicating if scene must be saved in the database
  71555. */
  71556. enableSceneOffline: boolean;
  71557. /**
  71558. * Gets a boolean indicating if textures must be saved in the database
  71559. */
  71560. enableTexturesOffline: boolean;
  71561. /**
  71562. * Open the offline support and make it available
  71563. * @param successCallback defines the callback to call on success
  71564. * @param errorCallback defines the callback to call on error
  71565. */
  71566. open(successCallback: () => void, errorCallback: () => void): void;
  71567. /**
  71568. * Loads an image from the offline support
  71569. * @param url defines the url to load from
  71570. * @param image defines the target DOM image
  71571. */
  71572. loadImage(url: string, image: HTMLImageElement): void;
  71573. /**
  71574. * Loads a file from offline support
  71575. * @param url defines the URL to load from
  71576. * @param sceneLoaded defines a callback to call on success
  71577. * @param progressCallBack defines a callback to call when progress changed
  71578. * @param errorCallback defines a callback to call on error
  71579. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71580. */
  71581. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71582. }
  71583. }
  71584. declare module BABYLON {
  71585. /**
  71586. * Class used to help managing file picking and drag'n'drop
  71587. * File Storage
  71588. */
  71589. export class FilesInputStore {
  71590. /**
  71591. * List of files ready to be loaded
  71592. */
  71593. static FilesToLoad: {
  71594. [key: string]: File;
  71595. };
  71596. }
  71597. }
  71598. declare module BABYLON {
  71599. /**
  71600. * Class used to define a retry strategy when error happens while loading assets
  71601. */
  71602. export class RetryStrategy {
  71603. /**
  71604. * Function used to defines an exponential back off strategy
  71605. * @param maxRetries defines the maximum number of retries (3 by default)
  71606. * @param baseInterval defines the interval between retries
  71607. * @returns the strategy function to use
  71608. */
  71609. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71610. }
  71611. }
  71612. declare module BABYLON {
  71613. /**
  71614. * @hidden
  71615. */
  71616. export class FileTools {
  71617. /**
  71618. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71619. */
  71620. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71621. /**
  71622. * Gets or sets the base URL to use to load assets
  71623. */
  71624. static BaseUrl: string;
  71625. /**
  71626. * Default behaviour for cors in the application.
  71627. * It can be a string if the expected behavior is identical in the entire app.
  71628. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71629. */
  71630. static CorsBehavior: string | ((url: string | string[]) => string);
  71631. /**
  71632. * Gets or sets a function used to pre-process url before using them to load assets
  71633. */
  71634. static PreprocessUrl: (url: string) => string;
  71635. /**
  71636. * Removes unwanted characters from an url
  71637. * @param url defines the url to clean
  71638. * @returns the cleaned url
  71639. */
  71640. private static _CleanUrl;
  71641. /**
  71642. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71643. * @param url define the url we are trying
  71644. * @param element define the dom element where to configure the cors policy
  71645. */
  71646. static SetCorsBehavior(url: string | string[], element: {
  71647. crossOrigin: string | null;
  71648. }): void;
  71649. /**
  71650. * Loads an image as an HTMLImageElement.
  71651. * @param input url string, ArrayBuffer, or Blob to load
  71652. * @param onLoad callback called when the image successfully loads
  71653. * @param onError callback called when the image fails to load
  71654. * @param offlineProvider offline provider for caching
  71655. * @returns the HTMLImageElement of the loaded image
  71656. */
  71657. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71658. /**
  71659. * Loads a file
  71660. * @param fileToLoad defines the file to load
  71661. * @param callback defines the callback to call when data is loaded
  71662. * @param progressCallBack defines the callback to call during loading process
  71663. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71664. * @returns a file request object
  71665. */
  71666. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71667. /**
  71668. * Loads a file
  71669. * @param url url string, ArrayBuffer, or Blob to load
  71670. * @param onSuccess callback called when the file successfully loads
  71671. * @param onProgress callback called while file is loading (if the server supports this mode)
  71672. * @param offlineProvider defines the offline provider for caching
  71673. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71674. * @param onError callback called when the file fails to load
  71675. * @returns a file request object
  71676. */
  71677. 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;
  71678. /**
  71679. * Checks if the loaded document was accessed via `file:`-Protocol.
  71680. * @returns boolean
  71681. */
  71682. static IsFileURL(): boolean;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /** @hidden */
  71687. export class ShaderProcessor {
  71688. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71689. private static _ProcessPrecision;
  71690. private static _ExtractOperation;
  71691. private static _BuildSubExpression;
  71692. private static _BuildExpression;
  71693. private static _MoveCursorWithinIf;
  71694. private static _MoveCursor;
  71695. private static _EvaluatePreProcessors;
  71696. private static _PreparePreProcessors;
  71697. private static _ProcessShaderConversion;
  71698. private static _ProcessIncludes;
  71699. }
  71700. }
  71701. declare module BABYLON {
  71702. /**
  71703. * Interface used to define common properties for effect fallbacks
  71704. */
  71705. export interface IEffectFallbacks {
  71706. /**
  71707. * Removes the defines that should be removed when falling back.
  71708. * @param currentDefines defines the current define statements for the shader.
  71709. * @param effect defines the current effect we try to compile
  71710. * @returns The resulting defines with defines of the current rank removed.
  71711. */
  71712. reduce(currentDefines: string, effect: Effect): string;
  71713. /**
  71714. * Removes the fallback from the bound mesh.
  71715. */
  71716. unBindMesh(): void;
  71717. /**
  71718. * Checks to see if more fallbacks are still availible.
  71719. */
  71720. hasMoreFallbacks: boolean;
  71721. }
  71722. }
  71723. declare module BABYLON {
  71724. /**
  71725. * Class used to evalaute queries containing `and` and `or` operators
  71726. */
  71727. export class AndOrNotEvaluator {
  71728. /**
  71729. * Evaluate a query
  71730. * @param query defines the query to evaluate
  71731. * @param evaluateCallback defines the callback used to filter result
  71732. * @returns true if the query matches
  71733. */
  71734. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71735. private static _HandleParenthesisContent;
  71736. private static _SimplifyNegation;
  71737. }
  71738. }
  71739. declare module BABYLON {
  71740. /**
  71741. * Class used to store custom tags
  71742. */
  71743. export class Tags {
  71744. /**
  71745. * Adds support for tags on the given object
  71746. * @param obj defines the object to use
  71747. */
  71748. static EnableFor(obj: any): void;
  71749. /**
  71750. * Removes tags support
  71751. * @param obj defines the object to use
  71752. */
  71753. static DisableFor(obj: any): void;
  71754. /**
  71755. * Gets a boolean indicating if the given object has tags
  71756. * @param obj defines the object to use
  71757. * @returns a boolean
  71758. */
  71759. static HasTags(obj: any): boolean;
  71760. /**
  71761. * Gets the tags available on a given object
  71762. * @param obj defines the object to use
  71763. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71764. * @returns the tags
  71765. */
  71766. static GetTags(obj: any, asString?: boolean): any;
  71767. /**
  71768. * Adds tags to an object
  71769. * @param obj defines the object to use
  71770. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71771. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71772. */
  71773. static AddTagsTo(obj: any, tagsString: string): void;
  71774. /**
  71775. * @hidden
  71776. */
  71777. static _AddTagTo(obj: any, tag: string): void;
  71778. /**
  71779. * Removes specific tags from a specific object
  71780. * @param obj defines the object to use
  71781. * @param tagsString defines the tags to remove
  71782. */
  71783. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71784. /**
  71785. * @hidden
  71786. */
  71787. static _RemoveTagFrom(obj: any, tag: string): void;
  71788. /**
  71789. * Defines if tags hosted on an object match a given query
  71790. * @param obj defines the object to use
  71791. * @param tagsQuery defines the tag query
  71792. * @returns a boolean
  71793. */
  71794. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71795. }
  71796. }
  71797. declare module BABYLON {
  71798. /**
  71799. * Defines potential orientation for back face culling
  71800. */
  71801. export enum Orientation {
  71802. /**
  71803. * Clockwise
  71804. */
  71805. CW = 0,
  71806. /** Counter clockwise */
  71807. CCW = 1
  71808. }
  71809. /** Class used to represent a Bezier curve */
  71810. export class BezierCurve {
  71811. /**
  71812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71813. * @param t defines the time
  71814. * @param x1 defines the left coordinate on X axis
  71815. * @param y1 defines the left coordinate on Y axis
  71816. * @param x2 defines the right coordinate on X axis
  71817. * @param y2 defines the right coordinate on Y axis
  71818. * @returns the interpolated value
  71819. */
  71820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71821. }
  71822. /**
  71823. * Defines angle representation
  71824. */
  71825. export class Angle {
  71826. private _radians;
  71827. /**
  71828. * Creates an Angle object of "radians" radians (float).
  71829. * @param radians the angle in radians
  71830. */
  71831. constructor(radians: number);
  71832. /**
  71833. * Get value in degrees
  71834. * @returns the Angle value in degrees (float)
  71835. */
  71836. degrees(): number;
  71837. /**
  71838. * Get value in radians
  71839. * @returns the Angle value in radians (float)
  71840. */
  71841. radians(): number;
  71842. /**
  71843. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71844. * @param a defines first vector
  71845. * @param b defines second vector
  71846. * @returns a new Angle
  71847. */
  71848. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71849. /**
  71850. * Gets a new Angle object from the given float in radians
  71851. * @param radians defines the angle value in radians
  71852. * @returns a new Angle
  71853. */
  71854. static FromRadians(radians: number): Angle;
  71855. /**
  71856. * Gets a new Angle object from the given float in degrees
  71857. * @param degrees defines the angle value in degrees
  71858. * @returns a new Angle
  71859. */
  71860. static FromDegrees(degrees: number): Angle;
  71861. }
  71862. /**
  71863. * This represents an arc in a 2d space.
  71864. */
  71865. export class Arc2 {
  71866. /** Defines the start point of the arc */
  71867. startPoint: Vector2;
  71868. /** Defines the mid point of the arc */
  71869. midPoint: Vector2;
  71870. /** Defines the end point of the arc */
  71871. endPoint: Vector2;
  71872. /**
  71873. * Defines the center point of the arc.
  71874. */
  71875. centerPoint: Vector2;
  71876. /**
  71877. * Defines the radius of the arc.
  71878. */
  71879. radius: number;
  71880. /**
  71881. * Defines the angle of the arc (from mid point to end point).
  71882. */
  71883. angle: Angle;
  71884. /**
  71885. * Defines the start angle of the arc (from start point to middle point).
  71886. */
  71887. startAngle: Angle;
  71888. /**
  71889. * Defines the orientation of the arc (clock wise/counter clock wise).
  71890. */
  71891. orientation: Orientation;
  71892. /**
  71893. * Creates an Arc object from the three given points : start, middle and end.
  71894. * @param startPoint Defines the start point of the arc
  71895. * @param midPoint Defines the midlle point of the arc
  71896. * @param endPoint Defines the end point of the arc
  71897. */
  71898. constructor(
  71899. /** Defines the start point of the arc */
  71900. startPoint: Vector2,
  71901. /** Defines the mid point of the arc */
  71902. midPoint: Vector2,
  71903. /** Defines the end point of the arc */
  71904. endPoint: Vector2);
  71905. }
  71906. /**
  71907. * Represents a 2D path made up of multiple 2D points
  71908. */
  71909. export class Path2 {
  71910. private _points;
  71911. private _length;
  71912. /**
  71913. * If the path start and end point are the same
  71914. */
  71915. closed: boolean;
  71916. /**
  71917. * Creates a Path2 object from the starting 2D coordinates x and y.
  71918. * @param x the starting points x value
  71919. * @param y the starting points y value
  71920. */
  71921. constructor(x: number, y: number);
  71922. /**
  71923. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71924. * @param x the added points x value
  71925. * @param y the added points y value
  71926. * @returns the updated Path2.
  71927. */
  71928. addLineTo(x: number, y: number): Path2;
  71929. /**
  71930. * 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.
  71931. * @param midX middle point x value
  71932. * @param midY middle point y value
  71933. * @param endX end point x value
  71934. * @param endY end point y value
  71935. * @param numberOfSegments (default: 36)
  71936. * @returns the updated Path2.
  71937. */
  71938. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71939. /**
  71940. * Closes the Path2.
  71941. * @returns the Path2.
  71942. */
  71943. close(): Path2;
  71944. /**
  71945. * Gets the sum of the distance between each sequential point in the path
  71946. * @returns the Path2 total length (float).
  71947. */
  71948. length(): number;
  71949. /**
  71950. * Gets the points which construct the path
  71951. * @returns the Path2 internal array of points.
  71952. */
  71953. getPoints(): Vector2[];
  71954. /**
  71955. * Retreives the point at the distance aways from the starting point
  71956. * @param normalizedLengthPosition the length along the path to retreive the point from
  71957. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71958. */
  71959. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71960. /**
  71961. * Creates a new path starting from an x and y position
  71962. * @param x starting x value
  71963. * @param y starting y value
  71964. * @returns a new Path2 starting at the coordinates (x, y).
  71965. */
  71966. static StartingAt(x: number, y: number): Path2;
  71967. }
  71968. /**
  71969. * Represents a 3D path made up of multiple 3D points
  71970. */
  71971. export class Path3D {
  71972. /**
  71973. * an array of Vector3, the curve axis of the Path3D
  71974. */
  71975. path: Vector3[];
  71976. private _curve;
  71977. private _distances;
  71978. private _tangents;
  71979. private _normals;
  71980. private _binormals;
  71981. private _raw;
  71982. /**
  71983. * new Path3D(path, normal, raw)
  71984. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71985. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71986. * @param path an array of Vector3, the curve axis of the Path3D
  71987. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71988. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71989. */
  71990. constructor(
  71991. /**
  71992. * an array of Vector3, the curve axis of the Path3D
  71993. */
  71994. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71995. /**
  71996. * Returns the Path3D array of successive Vector3 designing its curve.
  71997. * @returns the Path3D array of successive Vector3 designing its curve.
  71998. */
  71999. getCurve(): Vector3[];
  72000. /**
  72001. * Returns an array populated with tangent vectors on each Path3D curve point.
  72002. * @returns an array populated with tangent vectors on each Path3D curve point.
  72003. */
  72004. getTangents(): Vector3[];
  72005. /**
  72006. * Returns an array populated with normal vectors on each Path3D curve point.
  72007. * @returns an array populated with normal vectors on each Path3D curve point.
  72008. */
  72009. getNormals(): Vector3[];
  72010. /**
  72011. * Returns an array populated with binormal vectors on each Path3D curve point.
  72012. * @returns an array populated with binormal vectors on each Path3D curve point.
  72013. */
  72014. getBinormals(): Vector3[];
  72015. /**
  72016. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72017. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72018. */
  72019. getDistances(): number[];
  72020. /**
  72021. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72022. * @param path path which all values are copied into the curves points
  72023. * @param firstNormal which should be projected onto the curve
  72024. * @returns the same object updated.
  72025. */
  72026. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72027. private _compute;
  72028. private _getFirstNonNullVector;
  72029. private _getLastNonNullVector;
  72030. private _normalVector;
  72031. }
  72032. /**
  72033. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72034. * A Curve3 is designed from a series of successive Vector3.
  72035. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72036. */
  72037. export class Curve3 {
  72038. private _points;
  72039. private _length;
  72040. /**
  72041. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72042. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72043. * @param v1 (Vector3) the control point
  72044. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72045. * @param nbPoints (integer) the wanted number of points in the curve
  72046. * @returns the created Curve3
  72047. */
  72048. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72049. /**
  72050. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72051. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72052. * @param v1 (Vector3) the first control point
  72053. * @param v2 (Vector3) the second control point
  72054. * @param v3 (Vector3) the end point of the Cubic Bezier
  72055. * @param nbPoints (integer) the wanted number of points in the curve
  72056. * @returns the created Curve3
  72057. */
  72058. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72059. /**
  72060. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72061. * @param p1 (Vector3) the origin point of the Hermite Spline
  72062. * @param t1 (Vector3) the tangent vector at the origin point
  72063. * @param p2 (Vector3) the end point of the Hermite Spline
  72064. * @param t2 (Vector3) the tangent vector at the end point
  72065. * @param nbPoints (integer) the wanted number of points in the curve
  72066. * @returns the created Curve3
  72067. */
  72068. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72069. /**
  72070. * Returns a Curve3 object along a CatmullRom Spline curve :
  72071. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72072. * @param nbPoints (integer) the wanted number of points between each curve control points
  72073. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72074. * @returns the created Curve3
  72075. */
  72076. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72077. /**
  72078. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72079. * A Curve3 is designed from a series of successive Vector3.
  72080. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72081. * @param points points which make up the curve
  72082. */
  72083. constructor(points: Vector3[]);
  72084. /**
  72085. * @returns the Curve3 stored array of successive Vector3
  72086. */
  72087. getPoints(): Vector3[];
  72088. /**
  72089. * @returns the computed length (float) of the curve.
  72090. */
  72091. length(): number;
  72092. /**
  72093. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72094. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72095. * curveA and curveB keep unchanged.
  72096. * @param curve the curve to continue from this curve
  72097. * @returns the newly constructed curve
  72098. */
  72099. continue(curve: DeepImmutable<Curve3>): Curve3;
  72100. private _computeLength;
  72101. }
  72102. }
  72103. declare module BABYLON {
  72104. /**
  72105. * This represents the main contract an easing function should follow.
  72106. * Easing functions are used throughout the animation system.
  72107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72108. */
  72109. export interface IEasingFunction {
  72110. /**
  72111. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72112. * of the easing function.
  72113. * The link below provides some of the most common examples of easing functions.
  72114. * @see https://easings.net/
  72115. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72116. * @returns the corresponding value on the curve defined by the easing function
  72117. */
  72118. ease(gradient: number): number;
  72119. }
  72120. /**
  72121. * Base class used for every default easing function.
  72122. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72123. */
  72124. export class EasingFunction implements IEasingFunction {
  72125. /**
  72126. * Interpolation follows the mathematical formula associated with the easing function.
  72127. */
  72128. static readonly EASINGMODE_EASEIN: number;
  72129. /**
  72130. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72131. */
  72132. static readonly EASINGMODE_EASEOUT: number;
  72133. /**
  72134. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72135. */
  72136. static readonly EASINGMODE_EASEINOUT: number;
  72137. private _easingMode;
  72138. /**
  72139. * Sets the easing mode of the current function.
  72140. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72141. */
  72142. setEasingMode(easingMode: number): void;
  72143. /**
  72144. * Gets the current easing mode.
  72145. * @returns the easing mode
  72146. */
  72147. getEasingMode(): number;
  72148. /**
  72149. * @hidden
  72150. */
  72151. easeInCore(gradient: number): number;
  72152. /**
  72153. * Given an input gradient between 0 and 1, this returns the corresponding value
  72154. * of the easing function.
  72155. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72156. * @returns the corresponding value on the curve defined by the easing function
  72157. */
  72158. ease(gradient: number): number;
  72159. }
  72160. /**
  72161. * Easing function with a circle shape (see link below).
  72162. * @see https://easings.net/#easeInCirc
  72163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72164. */
  72165. export class CircleEase extends EasingFunction implements IEasingFunction {
  72166. /** @hidden */
  72167. easeInCore(gradient: number): number;
  72168. }
  72169. /**
  72170. * Easing function with a ease back shape (see link below).
  72171. * @see https://easings.net/#easeInBack
  72172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72173. */
  72174. export class BackEase extends EasingFunction implements IEasingFunction {
  72175. /** Defines the amplitude of the function */
  72176. amplitude: number;
  72177. /**
  72178. * Instantiates a back ease easing
  72179. * @see https://easings.net/#easeInBack
  72180. * @param amplitude Defines the amplitude of the function
  72181. */
  72182. constructor(
  72183. /** Defines the amplitude of the function */
  72184. amplitude?: number);
  72185. /** @hidden */
  72186. easeInCore(gradient: number): number;
  72187. }
  72188. /**
  72189. * Easing function with a bouncing shape (see link below).
  72190. * @see https://easings.net/#easeInBounce
  72191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72192. */
  72193. export class BounceEase extends EasingFunction implements IEasingFunction {
  72194. /** Defines the number of bounces */
  72195. bounces: number;
  72196. /** Defines the amplitude of the bounce */
  72197. bounciness: number;
  72198. /**
  72199. * Instantiates a bounce easing
  72200. * @see https://easings.net/#easeInBounce
  72201. * @param bounces Defines the number of bounces
  72202. * @param bounciness Defines the amplitude of the bounce
  72203. */
  72204. constructor(
  72205. /** Defines the number of bounces */
  72206. bounces?: number,
  72207. /** Defines the amplitude of the bounce */
  72208. bounciness?: number);
  72209. /** @hidden */
  72210. easeInCore(gradient: number): number;
  72211. }
  72212. /**
  72213. * Easing function with a power of 3 shape (see link below).
  72214. * @see https://easings.net/#easeInCubic
  72215. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72216. */
  72217. export class CubicEase extends EasingFunction implements IEasingFunction {
  72218. /** @hidden */
  72219. easeInCore(gradient: number): number;
  72220. }
  72221. /**
  72222. * Easing function with an elastic shape (see link below).
  72223. * @see https://easings.net/#easeInElastic
  72224. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72225. */
  72226. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72227. /** Defines the number of oscillations*/
  72228. oscillations: number;
  72229. /** Defines the amplitude of the oscillations*/
  72230. springiness: number;
  72231. /**
  72232. * Instantiates an elastic easing function
  72233. * @see https://easings.net/#easeInElastic
  72234. * @param oscillations Defines the number of oscillations
  72235. * @param springiness Defines the amplitude of the oscillations
  72236. */
  72237. constructor(
  72238. /** Defines the number of oscillations*/
  72239. oscillations?: number,
  72240. /** Defines the amplitude of the oscillations*/
  72241. springiness?: number);
  72242. /** @hidden */
  72243. easeInCore(gradient: number): number;
  72244. }
  72245. /**
  72246. * Easing function with an exponential shape (see link below).
  72247. * @see https://easings.net/#easeInExpo
  72248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72249. */
  72250. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72251. /** Defines the exponent of the function */
  72252. exponent: number;
  72253. /**
  72254. * Instantiates an exponential easing function
  72255. * @see https://easings.net/#easeInExpo
  72256. * @param exponent Defines the exponent of the function
  72257. */
  72258. constructor(
  72259. /** Defines the exponent of the function */
  72260. exponent?: number);
  72261. /** @hidden */
  72262. easeInCore(gradient: number): number;
  72263. }
  72264. /**
  72265. * Easing function with a power shape (see link below).
  72266. * @see https://easings.net/#easeInQuad
  72267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72268. */
  72269. export class PowerEase extends EasingFunction implements IEasingFunction {
  72270. /** Defines the power of the function */
  72271. power: number;
  72272. /**
  72273. * Instantiates an power base easing function
  72274. * @see https://easings.net/#easeInQuad
  72275. * @param power Defines the power of the function
  72276. */
  72277. constructor(
  72278. /** Defines the power of the function */
  72279. power?: number);
  72280. /** @hidden */
  72281. easeInCore(gradient: number): number;
  72282. }
  72283. /**
  72284. * Easing function with a power of 2 shape (see link below).
  72285. * @see https://easings.net/#easeInQuad
  72286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72287. */
  72288. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72289. /** @hidden */
  72290. easeInCore(gradient: number): number;
  72291. }
  72292. /**
  72293. * Easing function with a power of 4 shape (see link below).
  72294. * @see https://easings.net/#easeInQuart
  72295. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72296. */
  72297. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72298. /** @hidden */
  72299. easeInCore(gradient: number): number;
  72300. }
  72301. /**
  72302. * Easing function with a power of 5 shape (see link below).
  72303. * @see https://easings.net/#easeInQuint
  72304. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72305. */
  72306. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72307. /** @hidden */
  72308. easeInCore(gradient: number): number;
  72309. }
  72310. /**
  72311. * Easing function with a sin shape (see link below).
  72312. * @see https://easings.net/#easeInSine
  72313. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72314. */
  72315. export class SineEase extends EasingFunction implements IEasingFunction {
  72316. /** @hidden */
  72317. easeInCore(gradient: number): number;
  72318. }
  72319. /**
  72320. * Easing function with a bezier shape (see link below).
  72321. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72322. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72323. */
  72324. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72325. /** Defines the x component of the start tangent in the bezier curve */
  72326. x1: number;
  72327. /** Defines the y component of the start tangent in the bezier curve */
  72328. y1: number;
  72329. /** Defines the x component of the end tangent in the bezier curve */
  72330. x2: number;
  72331. /** Defines the y component of the end tangent in the bezier curve */
  72332. y2: number;
  72333. /**
  72334. * Instantiates a bezier function
  72335. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72336. * @param x1 Defines the x component of the start tangent in the bezier curve
  72337. * @param y1 Defines the y component of the start tangent in the bezier curve
  72338. * @param x2 Defines the x component of the end tangent in the bezier curve
  72339. * @param y2 Defines the y component of the end tangent in the bezier curve
  72340. */
  72341. constructor(
  72342. /** Defines the x component of the start tangent in the bezier curve */
  72343. x1?: number,
  72344. /** Defines the y component of the start tangent in the bezier curve */
  72345. y1?: number,
  72346. /** Defines the x component of the end tangent in the bezier curve */
  72347. x2?: number,
  72348. /** Defines the y component of the end tangent in the bezier curve */
  72349. y2?: number);
  72350. /** @hidden */
  72351. easeInCore(gradient: number): number;
  72352. }
  72353. }
  72354. declare module BABYLON {
  72355. /**
  72356. * Defines an interface which represents an animation key frame
  72357. */
  72358. export interface IAnimationKey {
  72359. /**
  72360. * Frame of the key frame
  72361. */
  72362. frame: number;
  72363. /**
  72364. * Value at the specifies key frame
  72365. */
  72366. value: any;
  72367. /**
  72368. * The input tangent for the cubic hermite spline
  72369. */
  72370. inTangent?: any;
  72371. /**
  72372. * The output tangent for the cubic hermite spline
  72373. */
  72374. outTangent?: any;
  72375. /**
  72376. * The animation interpolation type
  72377. */
  72378. interpolation?: AnimationKeyInterpolation;
  72379. }
  72380. /**
  72381. * Enum for the animation key frame interpolation type
  72382. */
  72383. export enum AnimationKeyInterpolation {
  72384. /**
  72385. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72386. */
  72387. STEP = 1
  72388. }
  72389. }
  72390. declare module BABYLON {
  72391. /**
  72392. * Represents the range of an animation
  72393. */
  72394. export class AnimationRange {
  72395. /**The name of the animation range**/
  72396. name: string;
  72397. /**The starting frame of the animation */
  72398. from: number;
  72399. /**The ending frame of the animation*/
  72400. to: number;
  72401. /**
  72402. * Initializes the range of an animation
  72403. * @param name The name of the animation range
  72404. * @param from The starting frame of the animation
  72405. * @param to The ending frame of the animation
  72406. */
  72407. constructor(
  72408. /**The name of the animation range**/
  72409. name: string,
  72410. /**The starting frame of the animation */
  72411. from: number,
  72412. /**The ending frame of the animation*/
  72413. to: number);
  72414. /**
  72415. * Makes a copy of the animation range
  72416. * @returns A copy of the animation range
  72417. */
  72418. clone(): AnimationRange;
  72419. }
  72420. }
  72421. declare module BABYLON {
  72422. /**
  72423. * Composed of a frame, and an action function
  72424. */
  72425. export class AnimationEvent {
  72426. /** The frame for which the event is triggered **/
  72427. frame: number;
  72428. /** The event to perform when triggered **/
  72429. action: (currentFrame: number) => void;
  72430. /** Specifies if the event should be triggered only once**/
  72431. onlyOnce?: boolean | undefined;
  72432. /**
  72433. * Specifies if the animation event is done
  72434. */
  72435. isDone: boolean;
  72436. /**
  72437. * Initializes the animation event
  72438. * @param frame The frame for which the event is triggered
  72439. * @param action The event to perform when triggered
  72440. * @param onlyOnce Specifies if the event should be triggered only once
  72441. */
  72442. constructor(
  72443. /** The frame for which the event is triggered **/
  72444. frame: number,
  72445. /** The event to perform when triggered **/
  72446. action: (currentFrame: number) => void,
  72447. /** Specifies if the event should be triggered only once**/
  72448. onlyOnce?: boolean | undefined);
  72449. /** @hidden */
  72450. _clone(): AnimationEvent;
  72451. }
  72452. }
  72453. declare module BABYLON {
  72454. /**
  72455. * Interface used to define a behavior
  72456. */
  72457. export interface Behavior<T> {
  72458. /** gets or sets behavior's name */
  72459. name: string;
  72460. /**
  72461. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72462. */
  72463. init(): void;
  72464. /**
  72465. * Called when the behavior is attached to a target
  72466. * @param target defines the target where the behavior is attached to
  72467. */
  72468. attach(target: T): void;
  72469. /**
  72470. * Called when the behavior is detached from its target
  72471. */
  72472. detach(): void;
  72473. }
  72474. /**
  72475. * Interface implemented by classes supporting behaviors
  72476. */
  72477. export interface IBehaviorAware<T> {
  72478. /**
  72479. * Attach a behavior
  72480. * @param behavior defines the behavior to attach
  72481. * @returns the current host
  72482. */
  72483. addBehavior(behavior: Behavior<T>): T;
  72484. /**
  72485. * Remove a behavior from the current object
  72486. * @param behavior defines the behavior to detach
  72487. * @returns the current host
  72488. */
  72489. removeBehavior(behavior: Behavior<T>): T;
  72490. /**
  72491. * Gets a behavior using its name to search
  72492. * @param name defines the name to search
  72493. * @returns the behavior or null if not found
  72494. */
  72495. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72496. }
  72497. }
  72498. declare module BABYLON {
  72499. /**
  72500. * Defines an array and its length.
  72501. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72502. */
  72503. export interface ISmartArrayLike<T> {
  72504. /**
  72505. * The data of the array.
  72506. */
  72507. data: Array<T>;
  72508. /**
  72509. * The active length of the array.
  72510. */
  72511. length: number;
  72512. }
  72513. /**
  72514. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72515. */
  72516. export class SmartArray<T> implements ISmartArrayLike<T> {
  72517. /**
  72518. * The full set of data from the array.
  72519. */
  72520. data: Array<T>;
  72521. /**
  72522. * The active length of the array.
  72523. */
  72524. length: number;
  72525. protected _id: number;
  72526. /**
  72527. * Instantiates a Smart Array.
  72528. * @param capacity defines the default capacity of the array.
  72529. */
  72530. constructor(capacity: number);
  72531. /**
  72532. * Pushes a value at the end of the active data.
  72533. * @param value defines the object to push in the array.
  72534. */
  72535. push(value: T): void;
  72536. /**
  72537. * Iterates over the active data and apply the lambda to them.
  72538. * @param func defines the action to apply on each value.
  72539. */
  72540. forEach(func: (content: T) => void): void;
  72541. /**
  72542. * Sorts the full sets of data.
  72543. * @param compareFn defines the comparison function to apply.
  72544. */
  72545. sort(compareFn: (a: T, b: T) => number): void;
  72546. /**
  72547. * Resets the active data to an empty array.
  72548. */
  72549. reset(): void;
  72550. /**
  72551. * Releases all the data from the array as well as the array.
  72552. */
  72553. dispose(): void;
  72554. /**
  72555. * Concats the active data with a given array.
  72556. * @param array defines the data to concatenate with.
  72557. */
  72558. concat(array: any): void;
  72559. /**
  72560. * Returns the position of a value in the active data.
  72561. * @param value defines the value to find the index for
  72562. * @returns the index if found in the active data otherwise -1
  72563. */
  72564. indexOf(value: T): number;
  72565. /**
  72566. * Returns whether an element is part of the active data.
  72567. * @param value defines the value to look for
  72568. * @returns true if found in the active data otherwise false
  72569. */
  72570. contains(value: T): boolean;
  72571. private static _GlobalId;
  72572. }
  72573. /**
  72574. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72575. * The data in this array can only be present once
  72576. */
  72577. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72578. private _duplicateId;
  72579. /**
  72580. * Pushes a value at the end of the active data.
  72581. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72582. * @param value defines the object to push in the array.
  72583. */
  72584. push(value: T): void;
  72585. /**
  72586. * Pushes a value at the end of the active data.
  72587. * If the data is already present, it won t be added again
  72588. * @param value defines the object to push in the array.
  72589. * @returns true if added false if it was already present
  72590. */
  72591. pushNoDuplicate(value: T): boolean;
  72592. /**
  72593. * Resets the active data to an empty array.
  72594. */
  72595. reset(): void;
  72596. /**
  72597. * Concats the active data with a given array.
  72598. * This ensures no dupplicate will be present in the result.
  72599. * @param array defines the data to concatenate with.
  72600. */
  72601. concatWithNoDuplicate(array: any): void;
  72602. }
  72603. }
  72604. declare module BABYLON {
  72605. /**
  72606. * @ignore
  72607. * This is a list of all the different input types that are available in the application.
  72608. * Fo instance: ArcRotateCameraGamepadInput...
  72609. */
  72610. export var CameraInputTypes: {};
  72611. /**
  72612. * This is the contract to implement in order to create a new input class.
  72613. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72614. */
  72615. export interface ICameraInput<TCamera extends Camera> {
  72616. /**
  72617. * Defines the camera the input is attached to.
  72618. */
  72619. camera: Nullable<TCamera>;
  72620. /**
  72621. * Gets the class name of the current intput.
  72622. * @returns the class name
  72623. */
  72624. getClassName(): string;
  72625. /**
  72626. * Get the friendly name associated with the input class.
  72627. * @returns the input friendly name
  72628. */
  72629. getSimpleName(): string;
  72630. /**
  72631. * Attach the input controls to a specific dom element to get the input from.
  72632. * @param element Defines the element the controls should be listened from
  72633. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72634. */
  72635. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72636. /**
  72637. * Detach the current controls from the specified dom element.
  72638. * @param element Defines the element to stop listening the inputs from
  72639. */
  72640. detachControl(element: Nullable<HTMLElement>): void;
  72641. /**
  72642. * Update the current camera state depending on the inputs that have been used this frame.
  72643. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72644. */
  72645. checkInputs?: () => void;
  72646. }
  72647. /**
  72648. * Represents a map of input types to input instance or input index to input instance.
  72649. */
  72650. export interface CameraInputsMap<TCamera extends Camera> {
  72651. /**
  72652. * Accessor to the input by input type.
  72653. */
  72654. [name: string]: ICameraInput<TCamera>;
  72655. /**
  72656. * Accessor to the input by input index.
  72657. */
  72658. [idx: number]: ICameraInput<TCamera>;
  72659. }
  72660. /**
  72661. * This represents the input manager used within a camera.
  72662. * It helps dealing with all the different kind of input attached to a camera.
  72663. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72664. */
  72665. export class CameraInputsManager<TCamera extends Camera> {
  72666. /**
  72667. * Defines the list of inputs attahed to the camera.
  72668. */
  72669. attached: CameraInputsMap<TCamera>;
  72670. /**
  72671. * Defines the dom element the camera is collecting inputs from.
  72672. * This is null if the controls have not been attached.
  72673. */
  72674. attachedElement: Nullable<HTMLElement>;
  72675. /**
  72676. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72677. */
  72678. noPreventDefault: boolean;
  72679. /**
  72680. * Defined the camera the input manager belongs to.
  72681. */
  72682. camera: TCamera;
  72683. /**
  72684. * Update the current camera state depending on the inputs that have been used this frame.
  72685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72686. */
  72687. checkInputs: () => void;
  72688. /**
  72689. * Instantiate a new Camera Input Manager.
  72690. * @param camera Defines the camera the input manager blongs to
  72691. */
  72692. constructor(camera: TCamera);
  72693. /**
  72694. * Add an input method to a camera
  72695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72696. * @param input camera input method
  72697. */
  72698. add(input: ICameraInput<TCamera>): void;
  72699. /**
  72700. * Remove a specific input method from a camera
  72701. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72702. * @param inputToRemove camera input method
  72703. */
  72704. remove(inputToRemove: ICameraInput<TCamera>): void;
  72705. /**
  72706. * Remove a specific input type from a camera
  72707. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72708. * @param inputType the type of the input to remove
  72709. */
  72710. removeByType(inputType: string): void;
  72711. private _addCheckInputs;
  72712. /**
  72713. * Attach the input controls to the currently attached dom element to listen the events from.
  72714. * @param input Defines the input to attach
  72715. */
  72716. attachInput(input: ICameraInput<TCamera>): void;
  72717. /**
  72718. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72719. * @param element Defines the dom element to collect the events from
  72720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72721. */
  72722. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72723. /**
  72724. * Detach the current manager inputs controls from a specific dom element.
  72725. * @param element Defines the dom element to collect the events from
  72726. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72727. */
  72728. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72729. /**
  72730. * Rebuild the dynamic inputCheck function from the current list of
  72731. * defined inputs in the manager.
  72732. */
  72733. rebuildInputCheck(): void;
  72734. /**
  72735. * Remove all attached input methods from a camera
  72736. */
  72737. clear(): void;
  72738. /**
  72739. * Serialize the current input manager attached to a camera.
  72740. * This ensures than once parsed,
  72741. * the input associated to the camera will be identical to the current ones
  72742. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72743. */
  72744. serialize(serializedCamera: any): void;
  72745. /**
  72746. * Parses an input manager serialized JSON to restore the previous list of inputs
  72747. * and states associated to a camera.
  72748. * @param parsedCamera Defines the JSON to parse
  72749. */
  72750. parse(parsedCamera: any): void;
  72751. }
  72752. }
  72753. declare module BABYLON {
  72754. /**
  72755. * Class used to store data that will be store in GPU memory
  72756. */
  72757. export class Buffer {
  72758. private _engine;
  72759. private _buffer;
  72760. /** @hidden */
  72761. _data: Nullable<DataArray>;
  72762. private _updatable;
  72763. private _instanced;
  72764. /**
  72765. * Gets the byte stride.
  72766. */
  72767. readonly byteStride: number;
  72768. /**
  72769. * Constructor
  72770. * @param engine the engine
  72771. * @param data the data to use for this buffer
  72772. * @param updatable whether the data is updatable
  72773. * @param stride the stride (optional)
  72774. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72775. * @param instanced whether the buffer is instanced (optional)
  72776. * @param useBytes set to true if the stride in in bytes (optional)
  72777. */
  72778. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72779. /**
  72780. * Create a new VertexBuffer based on the current buffer
  72781. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72782. * @param offset defines offset in the buffer (0 by default)
  72783. * @param size defines the size in floats of attributes (position is 3 for instance)
  72784. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72785. * @param instanced defines if the vertex buffer contains indexed data
  72786. * @param useBytes defines if the offset and stride are in bytes
  72787. * @returns the new vertex buffer
  72788. */
  72789. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72790. /**
  72791. * Gets a boolean indicating if the Buffer is updatable?
  72792. * @returns true if the buffer is updatable
  72793. */
  72794. isUpdatable(): boolean;
  72795. /**
  72796. * Gets current buffer's data
  72797. * @returns a DataArray or null
  72798. */
  72799. getData(): Nullable<DataArray>;
  72800. /**
  72801. * Gets underlying native buffer
  72802. * @returns underlying native buffer
  72803. */
  72804. getBuffer(): Nullable<DataBuffer>;
  72805. /**
  72806. * Gets the stride in float32 units (i.e. byte stride / 4).
  72807. * May not be an integer if the byte stride is not divisible by 4.
  72808. * DEPRECATED. Use byteStride instead.
  72809. * @returns the stride in float32 units
  72810. */
  72811. getStrideSize(): number;
  72812. /**
  72813. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72814. * @param data defines the data to store
  72815. */
  72816. create(data?: Nullable<DataArray>): void;
  72817. /** @hidden */
  72818. _rebuild(): void;
  72819. /**
  72820. * Update current buffer data
  72821. * @param data defines the data to store
  72822. */
  72823. update(data: DataArray): void;
  72824. /**
  72825. * Updates the data directly.
  72826. * @param data the new data
  72827. * @param offset the new offset
  72828. * @param vertexCount the vertex count (optional)
  72829. * @param useBytes set to true if the offset is in bytes
  72830. */
  72831. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72832. /**
  72833. * Release all resources
  72834. */
  72835. dispose(): void;
  72836. }
  72837. /**
  72838. * Specialized buffer used to store vertex data
  72839. */
  72840. export class VertexBuffer {
  72841. /** @hidden */
  72842. _buffer: Buffer;
  72843. private _kind;
  72844. private _size;
  72845. private _ownsBuffer;
  72846. private _instanced;
  72847. private _instanceDivisor;
  72848. /**
  72849. * The byte type.
  72850. */
  72851. static readonly BYTE: number;
  72852. /**
  72853. * The unsigned byte type.
  72854. */
  72855. static readonly UNSIGNED_BYTE: number;
  72856. /**
  72857. * The short type.
  72858. */
  72859. static readonly SHORT: number;
  72860. /**
  72861. * The unsigned short type.
  72862. */
  72863. static readonly UNSIGNED_SHORT: number;
  72864. /**
  72865. * The integer type.
  72866. */
  72867. static readonly INT: number;
  72868. /**
  72869. * The unsigned integer type.
  72870. */
  72871. static readonly UNSIGNED_INT: number;
  72872. /**
  72873. * The float type.
  72874. */
  72875. static readonly FLOAT: number;
  72876. /**
  72877. * Gets or sets the instance divisor when in instanced mode
  72878. */
  72879. instanceDivisor: number;
  72880. /**
  72881. * Gets the byte stride.
  72882. */
  72883. readonly byteStride: number;
  72884. /**
  72885. * Gets the byte offset.
  72886. */
  72887. readonly byteOffset: number;
  72888. /**
  72889. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  72890. */
  72891. readonly normalized: boolean;
  72892. /**
  72893. * Gets the data type of each component in the array.
  72894. */
  72895. readonly type: number;
  72896. /**
  72897. * Constructor
  72898. * @param engine the engine
  72899. * @param data the data to use for this vertex buffer
  72900. * @param kind the vertex buffer kind
  72901. * @param updatable whether the data is updatable
  72902. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72903. * @param stride the stride (optional)
  72904. * @param instanced whether the buffer is instanced (optional)
  72905. * @param offset the offset of the data (optional)
  72906. * @param size the number of components (optional)
  72907. * @param type the type of the component (optional)
  72908. * @param normalized whether the data contains normalized data (optional)
  72909. * @param useBytes set to true if stride and offset are in bytes (optional)
  72910. */
  72911. 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);
  72912. /** @hidden */
  72913. _rebuild(): void;
  72914. /**
  72915. * Returns the kind of the VertexBuffer (string)
  72916. * @returns a string
  72917. */
  72918. getKind(): string;
  72919. /**
  72920. * Gets a boolean indicating if the VertexBuffer is updatable?
  72921. * @returns true if the buffer is updatable
  72922. */
  72923. isUpdatable(): boolean;
  72924. /**
  72925. * Gets current buffer's data
  72926. * @returns a DataArray or null
  72927. */
  72928. getData(): Nullable<DataArray>;
  72929. /**
  72930. * Gets underlying native buffer
  72931. * @returns underlying native buffer
  72932. */
  72933. getBuffer(): Nullable<DataBuffer>;
  72934. /**
  72935. * Gets the stride in float32 units (i.e. byte stride / 4).
  72936. * May not be an integer if the byte stride is not divisible by 4.
  72937. * DEPRECATED. Use byteStride instead.
  72938. * @returns the stride in float32 units
  72939. */
  72940. getStrideSize(): number;
  72941. /**
  72942. * Returns the offset as a multiple of the type byte length.
  72943. * DEPRECATED. Use byteOffset instead.
  72944. * @returns the offset in bytes
  72945. */
  72946. getOffset(): number;
  72947. /**
  72948. * Returns the number of components per vertex attribute (integer)
  72949. * @returns the size in float
  72950. */
  72951. getSize(): number;
  72952. /**
  72953. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  72954. * @returns true if this buffer is instanced
  72955. */
  72956. getIsInstanced(): boolean;
  72957. /**
  72958. * Returns the instancing divisor, zero for non-instanced (integer).
  72959. * @returns a number
  72960. */
  72961. getInstanceDivisor(): number;
  72962. /**
  72963. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72964. * @param data defines the data to store
  72965. */
  72966. create(data?: DataArray): void;
  72967. /**
  72968. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  72969. * This function will create a new buffer if the current one is not updatable
  72970. * @param data defines the data to store
  72971. */
  72972. update(data: DataArray): void;
  72973. /**
  72974. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  72975. * Returns the directly updated WebGLBuffer.
  72976. * @param data the new data
  72977. * @param offset the new offset
  72978. * @param useBytes set to true if the offset is in bytes
  72979. */
  72980. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  72981. /**
  72982. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  72983. */
  72984. dispose(): void;
  72985. /**
  72986. * Enumerates each value of this vertex buffer as numbers.
  72987. * @param count the number of values to enumerate
  72988. * @param callback the callback function called for each value
  72989. */
  72990. forEach(count: number, callback: (value: number, index: number) => void): void;
  72991. /**
  72992. * Positions
  72993. */
  72994. static readonly PositionKind: string;
  72995. /**
  72996. * Normals
  72997. */
  72998. static readonly NormalKind: string;
  72999. /**
  73000. * Tangents
  73001. */
  73002. static readonly TangentKind: string;
  73003. /**
  73004. * Texture coordinates
  73005. */
  73006. static readonly UVKind: string;
  73007. /**
  73008. * Texture coordinates 2
  73009. */
  73010. static readonly UV2Kind: string;
  73011. /**
  73012. * Texture coordinates 3
  73013. */
  73014. static readonly UV3Kind: string;
  73015. /**
  73016. * Texture coordinates 4
  73017. */
  73018. static readonly UV4Kind: string;
  73019. /**
  73020. * Texture coordinates 5
  73021. */
  73022. static readonly UV5Kind: string;
  73023. /**
  73024. * Texture coordinates 6
  73025. */
  73026. static readonly UV6Kind: string;
  73027. /**
  73028. * Colors
  73029. */
  73030. static readonly ColorKind: string;
  73031. /**
  73032. * Matrix indices (for bones)
  73033. */
  73034. static readonly MatricesIndicesKind: string;
  73035. /**
  73036. * Matrix weights (for bones)
  73037. */
  73038. static readonly MatricesWeightsKind: string;
  73039. /**
  73040. * Additional matrix indices (for bones)
  73041. */
  73042. static readonly MatricesIndicesExtraKind: string;
  73043. /**
  73044. * Additional matrix weights (for bones)
  73045. */
  73046. static readonly MatricesWeightsExtraKind: string;
  73047. /**
  73048. * Deduces the stride given a kind.
  73049. * @param kind The kind string to deduce
  73050. * @returns The deduced stride
  73051. */
  73052. static DeduceStride(kind: string): number;
  73053. /**
  73054. * Gets the byte length of the given type.
  73055. * @param type the type
  73056. * @returns the number of bytes
  73057. */
  73058. static GetTypeByteLength(type: number): number;
  73059. /**
  73060. * Enumerates each value of the given parameters as numbers.
  73061. * @param data the data to enumerate
  73062. * @param byteOffset the byte offset of the data
  73063. * @param byteStride the byte stride of the data
  73064. * @param componentCount the number of components per element
  73065. * @param componentType the type of the component
  73066. * @param count the number of values to enumerate
  73067. * @param normalized whether the data is normalized
  73068. * @param callback the callback function called for each value
  73069. */
  73070. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73071. private static _GetFloatValue;
  73072. }
  73073. }
  73074. declare module BABYLON {
  73075. /**
  73076. * @hidden
  73077. */
  73078. export class IntersectionInfo {
  73079. bu: Nullable<number>;
  73080. bv: Nullable<number>;
  73081. distance: number;
  73082. faceId: number;
  73083. subMeshId: number;
  73084. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73085. }
  73086. }
  73087. declare module BABYLON {
  73088. /**
  73089. * Represens a plane by the equation ax + by + cz + d = 0
  73090. */
  73091. export class Plane {
  73092. private static _TmpMatrix;
  73093. /**
  73094. * Normal of the plane (a,b,c)
  73095. */
  73096. normal: Vector3;
  73097. /**
  73098. * d component of the plane
  73099. */
  73100. d: number;
  73101. /**
  73102. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73103. * @param a a component of the plane
  73104. * @param b b component of the plane
  73105. * @param c c component of the plane
  73106. * @param d d component of the plane
  73107. */
  73108. constructor(a: number, b: number, c: number, d: number);
  73109. /**
  73110. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73111. */
  73112. asArray(): number[];
  73113. /**
  73114. * @returns a new plane copied from the current Plane.
  73115. */
  73116. clone(): Plane;
  73117. /**
  73118. * @returns the string "Plane".
  73119. */
  73120. getClassName(): string;
  73121. /**
  73122. * @returns the Plane hash code.
  73123. */
  73124. getHashCode(): number;
  73125. /**
  73126. * Normalize the current Plane in place.
  73127. * @returns the updated Plane.
  73128. */
  73129. normalize(): Plane;
  73130. /**
  73131. * Applies a transformation the plane and returns the result
  73132. * @param transformation the transformation matrix to be applied to the plane
  73133. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73134. */
  73135. transform(transformation: DeepImmutable<Matrix>): Plane;
  73136. /**
  73137. * Calcualtte the dot product between the point and the plane normal
  73138. * @param point point to calculate the dot product with
  73139. * @returns the dot product (float) of the point coordinates and the plane normal.
  73140. */
  73141. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73142. /**
  73143. * Updates the current Plane from the plane defined by the three given points.
  73144. * @param point1 one of the points used to contruct the plane
  73145. * @param point2 one of the points used to contruct the plane
  73146. * @param point3 one of the points used to contruct the plane
  73147. * @returns the updated Plane.
  73148. */
  73149. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73150. /**
  73151. * Checks if the plane is facing a given direction
  73152. * @param direction the direction to check if the plane is facing
  73153. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73154. * @returns True is the vector "direction" is the same side than the plane normal.
  73155. */
  73156. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73157. /**
  73158. * Calculates the distance to a point
  73159. * @param point point to calculate distance to
  73160. * @returns the signed distance (float) from the given point to the Plane.
  73161. */
  73162. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73163. /**
  73164. * Creates a plane from an array
  73165. * @param array the array to create a plane from
  73166. * @returns a new Plane from the given array.
  73167. */
  73168. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73169. /**
  73170. * Creates a plane from three points
  73171. * @param point1 point used to create the plane
  73172. * @param point2 point used to create the plane
  73173. * @param point3 point used to create the plane
  73174. * @returns a new Plane defined by the three given points.
  73175. */
  73176. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73177. /**
  73178. * Creates a plane from an origin point and a normal
  73179. * @param origin origin of the plane to be constructed
  73180. * @param normal normal of the plane to be constructed
  73181. * @returns a new Plane the normal vector to this plane at the given origin point.
  73182. * Note : the vector "normal" is updated because normalized.
  73183. */
  73184. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73185. /**
  73186. * Calculates the distance from a plane and a point
  73187. * @param origin origin of the plane to be constructed
  73188. * @param normal normal of the plane to be constructed
  73189. * @param point point to calculate distance to
  73190. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73191. */
  73192. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73193. }
  73194. }
  73195. declare module BABYLON {
  73196. /**
  73197. * Class used to store bounding sphere information
  73198. */
  73199. export class BoundingSphere {
  73200. /**
  73201. * Gets the center of the bounding sphere in local space
  73202. */
  73203. readonly center: Vector3;
  73204. /**
  73205. * Radius of the bounding sphere in local space
  73206. */
  73207. radius: number;
  73208. /**
  73209. * Gets the center of the bounding sphere in world space
  73210. */
  73211. readonly centerWorld: Vector3;
  73212. /**
  73213. * Radius of the bounding sphere in world space
  73214. */
  73215. radiusWorld: number;
  73216. /**
  73217. * Gets the minimum vector in local space
  73218. */
  73219. readonly minimum: Vector3;
  73220. /**
  73221. * Gets the maximum vector in local space
  73222. */
  73223. readonly maximum: Vector3;
  73224. private _worldMatrix;
  73225. private static readonly TmpVector3;
  73226. /**
  73227. * Creates a new bounding sphere
  73228. * @param min defines the minimum vector (in local space)
  73229. * @param max defines the maximum vector (in local space)
  73230. * @param worldMatrix defines the new world matrix
  73231. */
  73232. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73233. /**
  73234. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73235. * @param min defines the new minimum vector (in local space)
  73236. * @param max defines the new maximum vector (in local space)
  73237. * @param worldMatrix defines the new world matrix
  73238. */
  73239. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73240. /**
  73241. * Scale the current bounding sphere by applying a scale factor
  73242. * @param factor defines the scale factor to apply
  73243. * @returns the current bounding box
  73244. */
  73245. scale(factor: number): BoundingSphere;
  73246. /**
  73247. * Gets the world matrix of the bounding box
  73248. * @returns a matrix
  73249. */
  73250. getWorldMatrix(): DeepImmutable<Matrix>;
  73251. /** @hidden */
  73252. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73253. /**
  73254. * Tests if the bounding sphere is intersecting the frustum planes
  73255. * @param frustumPlanes defines the frustum planes to test
  73256. * @returns true if there is an intersection
  73257. */
  73258. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73259. /**
  73260. * Tests if the bounding sphere center is in between the frustum planes.
  73261. * Used for optimistic fast inclusion.
  73262. * @param frustumPlanes defines the frustum planes to test
  73263. * @returns true if the sphere center is in between the frustum planes
  73264. */
  73265. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73266. /**
  73267. * Tests if a point is inside the bounding sphere
  73268. * @param point defines the point to test
  73269. * @returns true if the point is inside the bounding sphere
  73270. */
  73271. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73272. /**
  73273. * Checks if two sphere intersct
  73274. * @param sphere0 sphere 0
  73275. * @param sphere1 sphere 1
  73276. * @returns true if the speres intersect
  73277. */
  73278. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73279. }
  73280. }
  73281. declare module BABYLON {
  73282. /**
  73283. * Class used to store bounding box information
  73284. */
  73285. export class BoundingBox implements ICullable {
  73286. /**
  73287. * Gets the 8 vectors representing the bounding box in local space
  73288. */
  73289. readonly vectors: Vector3[];
  73290. /**
  73291. * Gets the center of the bounding box in local space
  73292. */
  73293. readonly center: Vector3;
  73294. /**
  73295. * Gets the center of the bounding box in world space
  73296. */
  73297. readonly centerWorld: Vector3;
  73298. /**
  73299. * Gets the extend size in local space
  73300. */
  73301. readonly extendSize: Vector3;
  73302. /**
  73303. * Gets the extend size in world space
  73304. */
  73305. readonly extendSizeWorld: Vector3;
  73306. /**
  73307. * Gets the OBB (object bounding box) directions
  73308. */
  73309. readonly directions: Vector3[];
  73310. /**
  73311. * Gets the 8 vectors representing the bounding box in world space
  73312. */
  73313. readonly vectorsWorld: Vector3[];
  73314. /**
  73315. * Gets the minimum vector in world space
  73316. */
  73317. readonly minimumWorld: Vector3;
  73318. /**
  73319. * Gets the maximum vector in world space
  73320. */
  73321. readonly maximumWorld: Vector3;
  73322. /**
  73323. * Gets the minimum vector in local space
  73324. */
  73325. readonly minimum: Vector3;
  73326. /**
  73327. * Gets the maximum vector in local space
  73328. */
  73329. readonly maximum: Vector3;
  73330. private _worldMatrix;
  73331. private static readonly TmpVector3;
  73332. /**
  73333. * @hidden
  73334. */
  73335. _tag: number;
  73336. /**
  73337. * Creates a new bounding box
  73338. * @param min defines the minimum vector (in local space)
  73339. * @param max defines the maximum vector (in local space)
  73340. * @param worldMatrix defines the new world matrix
  73341. */
  73342. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73343. /**
  73344. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73345. * @param min defines the new minimum vector (in local space)
  73346. * @param max defines the new maximum vector (in local space)
  73347. * @param worldMatrix defines the new world matrix
  73348. */
  73349. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73350. /**
  73351. * Scale the current bounding box by applying a scale factor
  73352. * @param factor defines the scale factor to apply
  73353. * @returns the current bounding box
  73354. */
  73355. scale(factor: number): BoundingBox;
  73356. /**
  73357. * Gets the world matrix of the bounding box
  73358. * @returns a matrix
  73359. */
  73360. getWorldMatrix(): DeepImmutable<Matrix>;
  73361. /** @hidden */
  73362. _update(world: DeepImmutable<Matrix>): void;
  73363. /**
  73364. * Tests if the bounding box is intersecting the frustum planes
  73365. * @param frustumPlanes defines the frustum planes to test
  73366. * @returns true if there is an intersection
  73367. */
  73368. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73369. /**
  73370. * Tests if the bounding box is entirely inside the frustum planes
  73371. * @param frustumPlanes defines the frustum planes to test
  73372. * @returns true if there is an inclusion
  73373. */
  73374. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73375. /**
  73376. * Tests if a point is inside the bounding box
  73377. * @param point defines the point to test
  73378. * @returns true if the point is inside the bounding box
  73379. */
  73380. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73381. /**
  73382. * Tests if the bounding box intersects with a bounding sphere
  73383. * @param sphere defines the sphere to test
  73384. * @returns true if there is an intersection
  73385. */
  73386. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73387. /**
  73388. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73389. * @param min defines the min vector to use
  73390. * @param max defines the max vector to use
  73391. * @returns true if there is an intersection
  73392. */
  73393. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73394. /**
  73395. * Tests if two bounding boxes are intersections
  73396. * @param box0 defines the first box to test
  73397. * @param box1 defines the second box to test
  73398. * @returns true if there is an intersection
  73399. */
  73400. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73401. /**
  73402. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73403. * @param minPoint defines the minimum vector of the bounding box
  73404. * @param maxPoint defines the maximum vector of the bounding box
  73405. * @param sphereCenter defines the sphere center
  73406. * @param sphereRadius defines the sphere radius
  73407. * @returns true if there is an intersection
  73408. */
  73409. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73410. /**
  73411. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73412. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73413. * @param frustumPlanes defines the frustum planes to test
  73414. * @return true if there is an inclusion
  73415. */
  73416. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73417. /**
  73418. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73419. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73420. * @param frustumPlanes defines the frustum planes to test
  73421. * @return true if there is an intersection
  73422. */
  73423. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73424. }
  73425. }
  73426. declare module BABYLON {
  73427. /** @hidden */
  73428. export class Collider {
  73429. /** Define if a collision was found */
  73430. collisionFound: boolean;
  73431. /**
  73432. * Define last intersection point in local space
  73433. */
  73434. intersectionPoint: Vector3;
  73435. /**
  73436. * Define last collided mesh
  73437. */
  73438. collidedMesh: Nullable<AbstractMesh>;
  73439. private _collisionPoint;
  73440. private _planeIntersectionPoint;
  73441. private _tempVector;
  73442. private _tempVector2;
  73443. private _tempVector3;
  73444. private _tempVector4;
  73445. private _edge;
  73446. private _baseToVertex;
  73447. private _destinationPoint;
  73448. private _slidePlaneNormal;
  73449. private _displacementVector;
  73450. /** @hidden */
  73451. _radius: Vector3;
  73452. /** @hidden */
  73453. _retry: number;
  73454. private _velocity;
  73455. private _basePoint;
  73456. private _epsilon;
  73457. /** @hidden */
  73458. _velocityWorldLength: number;
  73459. /** @hidden */
  73460. _basePointWorld: Vector3;
  73461. private _velocityWorld;
  73462. private _normalizedVelocity;
  73463. /** @hidden */
  73464. _initialVelocity: Vector3;
  73465. /** @hidden */
  73466. _initialPosition: Vector3;
  73467. private _nearestDistance;
  73468. private _collisionMask;
  73469. collisionMask: number;
  73470. /**
  73471. * Gets the plane normal used to compute the sliding response (in local space)
  73472. */
  73473. readonly slidePlaneNormal: Vector3;
  73474. /** @hidden */
  73475. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73476. /** @hidden */
  73477. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73478. /** @hidden */
  73479. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73480. /** @hidden */
  73481. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73482. /** @hidden */
  73483. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73484. /** @hidden */
  73485. _getResponse(pos: Vector3, vel: Vector3): void;
  73486. }
  73487. }
  73488. declare module BABYLON {
  73489. /**
  73490. * Interface for cullable objects
  73491. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73492. */
  73493. export interface ICullable {
  73494. /**
  73495. * Checks if the object or part of the object is in the frustum
  73496. * @param frustumPlanes Camera near/planes
  73497. * @returns true if the object is in frustum otherwise false
  73498. */
  73499. isInFrustum(frustumPlanes: Plane[]): boolean;
  73500. /**
  73501. * Checks if a cullable object (mesh...) is in the camera frustum
  73502. * Unlike isInFrustum this cheks the full bounding box
  73503. * @param frustumPlanes Camera near/planes
  73504. * @returns true if the object is in frustum otherwise false
  73505. */
  73506. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73507. }
  73508. /**
  73509. * Info for a bounding data of a mesh
  73510. */
  73511. export class BoundingInfo implements ICullable {
  73512. /**
  73513. * Bounding box for the mesh
  73514. */
  73515. readonly boundingBox: BoundingBox;
  73516. /**
  73517. * Bounding sphere for the mesh
  73518. */
  73519. readonly boundingSphere: BoundingSphere;
  73520. private _isLocked;
  73521. private static readonly TmpVector3;
  73522. /**
  73523. * Constructs bounding info
  73524. * @param minimum min vector of the bounding box/sphere
  73525. * @param maximum max vector of the bounding box/sphere
  73526. * @param worldMatrix defines the new world matrix
  73527. */
  73528. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73529. /**
  73530. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73531. * @param min defines the new minimum vector (in local space)
  73532. * @param max defines the new maximum vector (in local space)
  73533. * @param worldMatrix defines the new world matrix
  73534. */
  73535. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73536. /**
  73537. * min vector of the bounding box/sphere
  73538. */
  73539. readonly minimum: Vector3;
  73540. /**
  73541. * max vector of the bounding box/sphere
  73542. */
  73543. readonly maximum: Vector3;
  73544. /**
  73545. * If the info is locked and won't be updated to avoid perf overhead
  73546. */
  73547. isLocked: boolean;
  73548. /**
  73549. * Updates the bounding sphere and box
  73550. * @param world world matrix to be used to update
  73551. */
  73552. update(world: DeepImmutable<Matrix>): void;
  73553. /**
  73554. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73555. * @param center New center of the bounding info
  73556. * @param extend New extend of the bounding info
  73557. * @returns the current bounding info
  73558. */
  73559. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73560. /**
  73561. * Scale the current bounding info by applying a scale factor
  73562. * @param factor defines the scale factor to apply
  73563. * @returns the current bounding info
  73564. */
  73565. scale(factor: number): BoundingInfo;
  73566. /**
  73567. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73568. * @param frustumPlanes defines the frustum to test
  73569. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73570. * @returns true if the bounding info is in the frustum planes
  73571. */
  73572. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73573. /**
  73574. * Gets the world distance between the min and max points of the bounding box
  73575. */
  73576. readonly diagonalLength: number;
  73577. /**
  73578. * Checks if a cullable object (mesh...) is in the camera frustum
  73579. * Unlike isInFrustum this cheks the full bounding box
  73580. * @param frustumPlanes Camera near/planes
  73581. * @returns true if the object is in frustum otherwise false
  73582. */
  73583. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73584. /** @hidden */
  73585. _checkCollision(collider: Collider): boolean;
  73586. /**
  73587. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73588. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73589. * @param point the point to check intersection with
  73590. * @returns if the point intersects
  73591. */
  73592. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73593. /**
  73594. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73595. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73596. * @param boundingInfo the bounding info to check intersection with
  73597. * @param precise if the intersection should be done using OBB
  73598. * @returns if the bounding info intersects
  73599. */
  73600. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73601. }
  73602. }
  73603. declare module BABYLON {
  73604. /**
  73605. * Extracts minimum and maximum values from a list of indexed positions
  73606. * @param positions defines the positions to use
  73607. * @param indices defines the indices to the positions
  73608. * @param indexStart defines the start index
  73609. * @param indexCount defines the end index
  73610. * @param bias defines bias value to add to the result
  73611. * @return minimum and maximum values
  73612. */
  73613. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73614. minimum: Vector3;
  73615. maximum: Vector3;
  73616. };
  73617. /**
  73618. * Extracts minimum and maximum values from a list of positions
  73619. * @param positions defines the positions to use
  73620. * @param start defines the start index in the positions array
  73621. * @param count defines the number of positions to handle
  73622. * @param bias defines bias value to add to the result
  73623. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73624. * @return minimum and maximum values
  73625. */
  73626. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73627. minimum: Vector3;
  73628. maximum: Vector3;
  73629. };
  73630. }
  73631. declare module BABYLON {
  73632. /** @hidden */
  73633. export class WebGLDataBuffer extends DataBuffer {
  73634. private _buffer;
  73635. constructor(resource: WebGLBuffer);
  73636. readonly underlyingResource: any;
  73637. }
  73638. }
  73639. declare module BABYLON {
  73640. /** @hidden */
  73641. export class WebGLPipelineContext implements IPipelineContext {
  73642. engine: ThinEngine;
  73643. program: Nullable<WebGLProgram>;
  73644. context?: WebGLRenderingContext;
  73645. vertexShader?: WebGLShader;
  73646. fragmentShader?: WebGLShader;
  73647. isParallelCompiled: boolean;
  73648. onCompiled?: () => void;
  73649. transformFeedback?: WebGLTransformFeedback | null;
  73650. readonly isAsync: boolean;
  73651. readonly isReady: boolean;
  73652. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73653. }
  73654. }
  73655. declare module BABYLON {
  73656. interface ThinEngine {
  73657. /**
  73658. * Create an uniform buffer
  73659. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73660. * @param elements defines the content of the uniform buffer
  73661. * @returns the webGL uniform buffer
  73662. */
  73663. createUniformBuffer(elements: FloatArray): DataBuffer;
  73664. /**
  73665. * Create a dynamic uniform buffer
  73666. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73667. * @param elements defines the content of the uniform buffer
  73668. * @returns the webGL uniform buffer
  73669. */
  73670. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73671. /**
  73672. * Update an existing uniform buffer
  73673. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73674. * @param uniformBuffer defines the target uniform buffer
  73675. * @param elements defines the content to update
  73676. * @param offset defines the offset in the uniform buffer where update should start
  73677. * @param count defines the size of the data to update
  73678. */
  73679. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73680. /**
  73681. * Bind an uniform buffer to the current webGL context
  73682. * @param buffer defines the buffer to bind
  73683. */
  73684. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73685. /**
  73686. * Bind a buffer to the current webGL context at a given location
  73687. * @param buffer defines the buffer to bind
  73688. * @param location defines the index where to bind the buffer
  73689. */
  73690. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73691. /**
  73692. * Bind a specific block at a given index in a specific shader program
  73693. * @param pipelineContext defines the pipeline context to use
  73694. * @param blockName defines the block name
  73695. * @param index defines the index where to bind the block
  73696. */
  73697. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /**
  73702. * Uniform buffer objects.
  73703. *
  73704. * Handles blocks of uniform on the GPU.
  73705. *
  73706. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73707. *
  73708. * For more information, please refer to :
  73709. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73710. */
  73711. export class UniformBuffer {
  73712. private _engine;
  73713. private _buffer;
  73714. private _data;
  73715. private _bufferData;
  73716. private _dynamic?;
  73717. private _uniformLocations;
  73718. private _uniformSizes;
  73719. private _uniformLocationPointer;
  73720. private _needSync;
  73721. private _noUBO;
  73722. private _currentEffect;
  73723. private static _MAX_UNIFORM_SIZE;
  73724. private static _tempBuffer;
  73725. /**
  73726. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73727. * This is dynamic to allow compat with webgl 1 and 2.
  73728. * You will need to pass the name of the uniform as well as the value.
  73729. */
  73730. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73731. /**
  73732. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73733. * This is dynamic to allow compat with webgl 1 and 2.
  73734. * You will need to pass the name of the uniform as well as the value.
  73735. */
  73736. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73737. /**
  73738. * Lambda to Update a single float in a uniform buffer.
  73739. * This is dynamic to allow compat with webgl 1 and 2.
  73740. * You will need to pass the name of the uniform as well as the value.
  73741. */
  73742. updateFloat: (name: string, x: number) => void;
  73743. /**
  73744. * Lambda to Update a vec2 of float in a uniform buffer.
  73745. * This is dynamic to allow compat with webgl 1 and 2.
  73746. * You will need to pass the name of the uniform as well as the value.
  73747. */
  73748. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73749. /**
  73750. * Lambda to Update a vec3 of float in a uniform buffer.
  73751. * This is dynamic to allow compat with webgl 1 and 2.
  73752. * You will need to pass the name of the uniform as well as the value.
  73753. */
  73754. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73755. /**
  73756. * Lambda to Update a vec4 of float in a uniform buffer.
  73757. * This is dynamic to allow compat with webgl 1 and 2.
  73758. * You will need to pass the name of the uniform as well as the value.
  73759. */
  73760. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73761. /**
  73762. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73763. * This is dynamic to allow compat with webgl 1 and 2.
  73764. * You will need to pass the name of the uniform as well as the value.
  73765. */
  73766. updateMatrix: (name: string, mat: Matrix) => void;
  73767. /**
  73768. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73769. * This is dynamic to allow compat with webgl 1 and 2.
  73770. * You will need to pass the name of the uniform as well as the value.
  73771. */
  73772. updateVector3: (name: string, vector: Vector3) => void;
  73773. /**
  73774. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73775. * This is dynamic to allow compat with webgl 1 and 2.
  73776. * You will need to pass the name of the uniform as well as the value.
  73777. */
  73778. updateVector4: (name: string, vector: Vector4) => void;
  73779. /**
  73780. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73781. * This is dynamic to allow compat with webgl 1 and 2.
  73782. * You will need to pass the name of the uniform as well as the value.
  73783. */
  73784. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73785. /**
  73786. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73787. * This is dynamic to allow compat with webgl 1 and 2.
  73788. * You will need to pass the name of the uniform as well as the value.
  73789. */
  73790. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73791. /**
  73792. * Instantiates a new Uniform buffer objects.
  73793. *
  73794. * Handles blocks of uniform on the GPU.
  73795. *
  73796. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73797. *
  73798. * For more information, please refer to :
  73799. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73800. * @param engine Define the engine the buffer is associated with
  73801. * @param data Define the data contained in the buffer
  73802. * @param dynamic Define if the buffer is updatable
  73803. */
  73804. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73805. /**
  73806. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73807. * or just falling back on setUniformXXX calls.
  73808. */
  73809. readonly useUbo: boolean;
  73810. /**
  73811. * Indicates if the WebGL underlying uniform buffer is in sync
  73812. * with the javascript cache data.
  73813. */
  73814. readonly isSync: boolean;
  73815. /**
  73816. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73817. * Also, a dynamic UniformBuffer will disable cache verification and always
  73818. * update the underlying WebGL uniform buffer to the GPU.
  73819. * @returns if Dynamic, otherwise false
  73820. */
  73821. isDynamic(): boolean;
  73822. /**
  73823. * The data cache on JS side.
  73824. * @returns the underlying data as a float array
  73825. */
  73826. getData(): Float32Array;
  73827. /**
  73828. * The underlying WebGL Uniform buffer.
  73829. * @returns the webgl buffer
  73830. */
  73831. getBuffer(): Nullable<DataBuffer>;
  73832. /**
  73833. * std140 layout specifies how to align data within an UBO structure.
  73834. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73835. * for specs.
  73836. */
  73837. private _fillAlignment;
  73838. /**
  73839. * Adds an uniform in the buffer.
  73840. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73841. * for the layout to be correct !
  73842. * @param name Name of the uniform, as used in the uniform block in the shader.
  73843. * @param size Data size, or data directly.
  73844. */
  73845. addUniform(name: string, size: number | number[]): void;
  73846. /**
  73847. * Adds a Matrix 4x4 to the uniform buffer.
  73848. * @param name Name of the uniform, as used in the uniform block in the shader.
  73849. * @param mat A 4x4 matrix.
  73850. */
  73851. addMatrix(name: string, mat: Matrix): void;
  73852. /**
  73853. * Adds a vec2 to the uniform buffer.
  73854. * @param name Name of the uniform, as used in the uniform block in the shader.
  73855. * @param x Define the x component value of the vec2
  73856. * @param y Define the y component value of the vec2
  73857. */
  73858. addFloat2(name: string, x: number, y: number): void;
  73859. /**
  73860. * Adds a vec3 to the uniform buffer.
  73861. * @param name Name of the uniform, as used in the uniform block in the shader.
  73862. * @param x Define the x component value of the vec3
  73863. * @param y Define the y component value of the vec3
  73864. * @param z Define the z component value of the vec3
  73865. */
  73866. addFloat3(name: string, x: number, y: number, z: number): void;
  73867. /**
  73868. * Adds a vec3 to the uniform buffer.
  73869. * @param name Name of the uniform, as used in the uniform block in the shader.
  73870. * @param color Define the vec3 from a Color
  73871. */
  73872. addColor3(name: string, color: Color3): void;
  73873. /**
  73874. * Adds a vec4 to the uniform buffer.
  73875. * @param name Name of the uniform, as used in the uniform block in the shader.
  73876. * @param color Define the rgb components from a Color
  73877. * @param alpha Define the a component of the vec4
  73878. */
  73879. addColor4(name: string, color: Color3, alpha: number): void;
  73880. /**
  73881. * Adds a vec3 to the uniform buffer.
  73882. * @param name Name of the uniform, as used in the uniform block in the shader.
  73883. * @param vector Define the vec3 components from a Vector
  73884. */
  73885. addVector3(name: string, vector: Vector3): void;
  73886. /**
  73887. * Adds a Matrix 3x3 to the uniform buffer.
  73888. * @param name Name of the uniform, as used in the uniform block in the shader.
  73889. */
  73890. addMatrix3x3(name: string): void;
  73891. /**
  73892. * Adds a Matrix 2x2 to the uniform buffer.
  73893. * @param name Name of the uniform, as used in the uniform block in the shader.
  73894. */
  73895. addMatrix2x2(name: string): void;
  73896. /**
  73897. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  73898. */
  73899. create(): void;
  73900. /** @hidden */
  73901. _rebuild(): void;
  73902. /**
  73903. * Updates the WebGL Uniform Buffer on the GPU.
  73904. * If the `dynamic` flag is set to true, no cache comparison is done.
  73905. * Otherwise, the buffer will be updated only if the cache differs.
  73906. */
  73907. update(): void;
  73908. /**
  73909. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  73910. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73911. * @param data Define the flattened data
  73912. * @param size Define the size of the data.
  73913. */
  73914. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  73915. private _valueCache;
  73916. private _cacheMatrix;
  73917. private _updateMatrix3x3ForUniform;
  73918. private _updateMatrix3x3ForEffect;
  73919. private _updateMatrix2x2ForEffect;
  73920. private _updateMatrix2x2ForUniform;
  73921. private _updateFloatForEffect;
  73922. private _updateFloatForUniform;
  73923. private _updateFloat2ForEffect;
  73924. private _updateFloat2ForUniform;
  73925. private _updateFloat3ForEffect;
  73926. private _updateFloat3ForUniform;
  73927. private _updateFloat4ForEffect;
  73928. private _updateFloat4ForUniform;
  73929. private _updateMatrixForEffect;
  73930. private _updateMatrixForUniform;
  73931. private _updateVector3ForEffect;
  73932. private _updateVector3ForUniform;
  73933. private _updateVector4ForEffect;
  73934. private _updateVector4ForUniform;
  73935. private _updateColor3ForEffect;
  73936. private _updateColor3ForUniform;
  73937. private _updateColor4ForEffect;
  73938. private _updateColor4ForUniform;
  73939. /**
  73940. * Sets a sampler uniform on the effect.
  73941. * @param name Define the name of the sampler.
  73942. * @param texture Define the texture to set in the sampler
  73943. */
  73944. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  73945. /**
  73946. * Directly updates the value of the uniform in the cache AND on the GPU.
  73947. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  73948. * @param data Define the flattened data
  73949. */
  73950. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  73951. /**
  73952. * Binds this uniform buffer to an effect.
  73953. * @param effect Define the effect to bind the buffer to
  73954. * @param name Name of the uniform block in the shader.
  73955. */
  73956. bindToEffect(effect: Effect, name: string): void;
  73957. /**
  73958. * Disposes the uniform buffer.
  73959. */
  73960. dispose(): void;
  73961. }
  73962. }
  73963. declare module BABYLON {
  73964. /**
  73965. * Enum that determines the text-wrapping mode to use.
  73966. */
  73967. export enum InspectableType {
  73968. /**
  73969. * Checkbox for booleans
  73970. */
  73971. Checkbox = 0,
  73972. /**
  73973. * Sliders for numbers
  73974. */
  73975. Slider = 1,
  73976. /**
  73977. * Vector3
  73978. */
  73979. Vector3 = 2,
  73980. /**
  73981. * Quaternions
  73982. */
  73983. Quaternion = 3,
  73984. /**
  73985. * Color3
  73986. */
  73987. Color3 = 4,
  73988. /**
  73989. * String
  73990. */
  73991. String = 5
  73992. }
  73993. /**
  73994. * Interface used to define custom inspectable properties.
  73995. * This interface is used by the inspector to display custom property grids
  73996. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73997. */
  73998. export interface IInspectable {
  73999. /**
  74000. * Gets the label to display
  74001. */
  74002. label: string;
  74003. /**
  74004. * Gets the name of the property to edit
  74005. */
  74006. propertyName: string;
  74007. /**
  74008. * Gets the type of the editor to use
  74009. */
  74010. type: InspectableType;
  74011. /**
  74012. * Gets the minimum value of the property when using in "slider" mode
  74013. */
  74014. min?: number;
  74015. /**
  74016. * Gets the maximum value of the property when using in "slider" mode
  74017. */
  74018. max?: number;
  74019. /**
  74020. * Gets the setp to use when using in "slider" mode
  74021. */
  74022. step?: number;
  74023. }
  74024. }
  74025. declare module BABYLON {
  74026. /**
  74027. * Class used to provide helper for timing
  74028. */
  74029. export class TimingTools {
  74030. /**
  74031. * Polyfill for setImmediate
  74032. * @param action defines the action to execute after the current execution block
  74033. */
  74034. static SetImmediate(action: () => void): void;
  74035. }
  74036. }
  74037. declare module BABYLON {
  74038. /**
  74039. * Class used to enable instatition of objects by class name
  74040. */
  74041. export class InstantiationTools {
  74042. /**
  74043. * Use this object to register external classes like custom textures or material
  74044. * to allow the laoders to instantiate them
  74045. */
  74046. static RegisteredExternalClasses: {
  74047. [key: string]: Object;
  74048. };
  74049. /**
  74050. * Tries to instantiate a new object from a given class name
  74051. * @param className defines the class name to instantiate
  74052. * @returns the new object or null if the system was not able to do the instantiation
  74053. */
  74054. static Instantiate(className: string): any;
  74055. }
  74056. }
  74057. declare module BABYLON {
  74058. /**
  74059. * Define options used to create a depth texture
  74060. */
  74061. export class DepthTextureCreationOptions {
  74062. /** Specifies whether or not a stencil should be allocated in the texture */
  74063. generateStencil?: boolean;
  74064. /** Specifies whether or not bilinear filtering is enable on the texture */
  74065. bilinearFiltering?: boolean;
  74066. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74067. comparisonFunction?: number;
  74068. /** Specifies if the created texture is a cube texture */
  74069. isCube?: boolean;
  74070. }
  74071. }
  74072. declare module BABYLON {
  74073. interface ThinEngine {
  74074. /**
  74075. * Creates a depth stencil cube texture.
  74076. * This is only available in WebGL 2.
  74077. * @param size The size of face edge in the cube texture.
  74078. * @param options The options defining the cube texture.
  74079. * @returns The cube texture
  74080. */
  74081. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74082. /**
  74083. * Creates a cube texture
  74084. * @param rootUrl defines the url where the files to load is located
  74085. * @param scene defines the current scene
  74086. * @param files defines the list of files to load (1 per face)
  74087. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74088. * @param onLoad defines an optional callback raised when the texture is loaded
  74089. * @param onError defines an optional callback raised if there is an issue to load the texture
  74090. * @param format defines the format of the data
  74091. * @param forcedExtension defines the extension to use to pick the right loader
  74092. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74093. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74094. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74095. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74096. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74097. * @returns the cube texture as an InternalTexture
  74098. */
  74099. 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;
  74100. /**
  74101. * Creates a cube texture
  74102. * @param rootUrl defines the url where the files to load is located
  74103. * @param scene defines the current scene
  74104. * @param files defines the list of files to load (1 per face)
  74105. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74106. * @param onLoad defines an optional callback raised when the texture is loaded
  74107. * @param onError defines an optional callback raised if there is an issue to load the texture
  74108. * @param format defines the format of the data
  74109. * @param forcedExtension defines the extension to use to pick the right loader
  74110. * @returns the cube texture as an InternalTexture
  74111. */
  74112. 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;
  74113. /**
  74114. * Creates a cube texture
  74115. * @param rootUrl defines the url where the files to load is located
  74116. * @param scene defines the current scene
  74117. * @param files defines the list of files to load (1 per face)
  74118. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74119. * @param onLoad defines an optional callback raised when the texture is loaded
  74120. * @param onError defines an optional callback raised if there is an issue to load the texture
  74121. * @param format defines the format of the data
  74122. * @param forcedExtension defines the extension to use to pick the right loader
  74123. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74124. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74125. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74126. * @returns the cube texture as an InternalTexture
  74127. */
  74128. 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;
  74129. /** @hidden */
  74130. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74131. /** @hidden */
  74132. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74133. /** @hidden */
  74134. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74135. /** @hidden */
  74136. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74137. }
  74138. }
  74139. declare module BABYLON {
  74140. /**
  74141. * Class for creating a cube texture
  74142. */
  74143. export class CubeTexture extends BaseTexture {
  74144. private _delayedOnLoad;
  74145. /**
  74146. * The url of the texture
  74147. */
  74148. url: string;
  74149. /**
  74150. * Gets or sets the center of the bounding box associated with the cube texture.
  74151. * It must define where the camera used to render the texture was set
  74152. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74153. */
  74154. boundingBoxPosition: Vector3;
  74155. private _boundingBoxSize;
  74156. /**
  74157. * Gets or sets the size of the bounding box associated with the cube texture
  74158. * When defined, the cubemap will switch to local mode
  74159. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74160. * @example https://www.babylonjs-playground.com/#RNASML
  74161. */
  74162. /**
  74163. * Returns the bounding box size
  74164. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74165. */
  74166. boundingBoxSize: Vector3;
  74167. protected _rotationY: number;
  74168. /**
  74169. * Sets texture matrix rotation angle around Y axis in radians.
  74170. */
  74171. /**
  74172. * Gets texture matrix rotation angle around Y axis radians.
  74173. */
  74174. rotationY: number;
  74175. /**
  74176. * Are mip maps generated for this texture or not.
  74177. */
  74178. readonly noMipmap: boolean;
  74179. private _noMipmap;
  74180. private _files;
  74181. private _extensions;
  74182. private _textureMatrix;
  74183. private _format;
  74184. private _createPolynomials;
  74185. /** @hidden */
  74186. _prefiltered: boolean;
  74187. /**
  74188. * Creates a cube texture from an array of image urls
  74189. * @param files defines an array of image urls
  74190. * @param scene defines the hosting scene
  74191. * @param noMipmap specifies if mip maps are not used
  74192. * @returns a cube texture
  74193. */
  74194. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74195. /**
  74196. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74197. * @param url defines the url of the prefiltered texture
  74198. * @param scene defines the scene the texture is attached to
  74199. * @param forcedExtension defines the extension of the file if different from the url
  74200. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74201. * @return the prefiltered texture
  74202. */
  74203. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74204. /**
  74205. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74206. * as prefiltered data.
  74207. * @param rootUrl defines the url of the texture or the root name of the six images
  74208. * @param scene defines the scene the texture is attached to
  74209. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74210. * @param noMipmap defines if mipmaps should be created or not
  74211. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74212. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74213. * @param onError defines a callback triggered in case of error during load
  74214. * @param format defines the internal format to use for the texture once loaded
  74215. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74216. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74217. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74218. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74219. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74220. * @return the cube texture
  74221. */
  74222. 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);
  74223. /**
  74224. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74225. */
  74226. readonly isPrefiltered: boolean;
  74227. /**
  74228. * Get the current class name of the texture useful for serialization or dynamic coding.
  74229. * @returns "CubeTexture"
  74230. */
  74231. getClassName(): string;
  74232. /**
  74233. * Update the url (and optional buffer) of this texture if url was null during construction.
  74234. * @param url the url of the texture
  74235. * @param forcedExtension defines the extension to use
  74236. * @param onLoad callback called when the texture is loaded (defaults to null)
  74237. */
  74238. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74239. /**
  74240. * Delays loading of the cube texture
  74241. * @param forcedExtension defines the extension to use
  74242. */
  74243. delayLoad(forcedExtension?: string): void;
  74244. /**
  74245. * Returns the reflection texture matrix
  74246. * @returns the reflection texture matrix
  74247. */
  74248. getReflectionTextureMatrix(): Matrix;
  74249. /**
  74250. * Sets the reflection texture matrix
  74251. * @param value Reflection texture matrix
  74252. */
  74253. setReflectionTextureMatrix(value: Matrix): void;
  74254. /**
  74255. * Parses text to create a cube texture
  74256. * @param parsedTexture define the serialized text to read from
  74257. * @param scene defines the hosting scene
  74258. * @param rootUrl defines the root url of the cube texture
  74259. * @returns a cube texture
  74260. */
  74261. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74262. /**
  74263. * Makes a clone, or deep copy, of the cube texture
  74264. * @returns a new cube texture
  74265. */
  74266. clone(): CubeTexture;
  74267. }
  74268. }
  74269. declare module BABYLON {
  74270. /**
  74271. * Manages the defines for the Material
  74272. */
  74273. export class MaterialDefines {
  74274. /** @hidden */
  74275. protected _keys: string[];
  74276. private _isDirty;
  74277. /** @hidden */
  74278. _renderId: number;
  74279. /** @hidden */
  74280. _areLightsDirty: boolean;
  74281. /** @hidden */
  74282. _areLightsDisposed: boolean;
  74283. /** @hidden */
  74284. _areAttributesDirty: boolean;
  74285. /** @hidden */
  74286. _areTexturesDirty: boolean;
  74287. /** @hidden */
  74288. _areFresnelDirty: boolean;
  74289. /** @hidden */
  74290. _areMiscDirty: boolean;
  74291. /** @hidden */
  74292. _areImageProcessingDirty: boolean;
  74293. /** @hidden */
  74294. _normals: boolean;
  74295. /** @hidden */
  74296. _uvs: boolean;
  74297. /** @hidden */
  74298. _needNormals: boolean;
  74299. /** @hidden */
  74300. _needUVs: boolean;
  74301. [id: string]: any;
  74302. /**
  74303. * Specifies if the material needs to be re-calculated
  74304. */
  74305. readonly isDirty: boolean;
  74306. /**
  74307. * Marks the material to indicate that it has been re-calculated
  74308. */
  74309. markAsProcessed(): void;
  74310. /**
  74311. * Marks the material to indicate that it needs to be re-calculated
  74312. */
  74313. markAsUnprocessed(): void;
  74314. /**
  74315. * Marks the material to indicate all of its defines need to be re-calculated
  74316. */
  74317. markAllAsDirty(): void;
  74318. /**
  74319. * Marks the material to indicate that image processing needs to be re-calculated
  74320. */
  74321. markAsImageProcessingDirty(): void;
  74322. /**
  74323. * Marks the material to indicate the lights need to be re-calculated
  74324. * @param disposed Defines whether the light is dirty due to dispose or not
  74325. */
  74326. markAsLightDirty(disposed?: boolean): void;
  74327. /**
  74328. * Marks the attribute state as changed
  74329. */
  74330. markAsAttributesDirty(): void;
  74331. /**
  74332. * Marks the texture state as changed
  74333. */
  74334. markAsTexturesDirty(): void;
  74335. /**
  74336. * Marks the fresnel state as changed
  74337. */
  74338. markAsFresnelDirty(): void;
  74339. /**
  74340. * Marks the misc state as changed
  74341. */
  74342. markAsMiscDirty(): void;
  74343. /**
  74344. * Rebuilds the material defines
  74345. */
  74346. rebuild(): void;
  74347. /**
  74348. * Specifies if two material defines are equal
  74349. * @param other - A material define instance to compare to
  74350. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74351. */
  74352. isEqual(other: MaterialDefines): boolean;
  74353. /**
  74354. * Clones this instance's defines to another instance
  74355. * @param other - material defines to clone values to
  74356. */
  74357. cloneTo(other: MaterialDefines): void;
  74358. /**
  74359. * Resets the material define values
  74360. */
  74361. reset(): void;
  74362. /**
  74363. * Converts the material define values to a string
  74364. * @returns - String of material define information
  74365. */
  74366. toString(): string;
  74367. }
  74368. }
  74369. declare module BABYLON {
  74370. /**
  74371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74373. * 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;
  74374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74375. */
  74376. export class ColorCurves {
  74377. private _dirty;
  74378. private _tempColor;
  74379. private _globalCurve;
  74380. private _highlightsCurve;
  74381. private _midtonesCurve;
  74382. private _shadowsCurve;
  74383. private _positiveCurve;
  74384. private _negativeCurve;
  74385. private _globalHue;
  74386. private _globalDensity;
  74387. private _globalSaturation;
  74388. private _globalExposure;
  74389. /**
  74390. * Gets the global Hue value.
  74391. * 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).
  74392. */
  74393. /**
  74394. * Sets the global Hue value.
  74395. * 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).
  74396. */
  74397. globalHue: number;
  74398. /**
  74399. * Gets the global Density value.
  74400. * 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.
  74401. * Values less than zero provide a filter of opposite hue.
  74402. */
  74403. /**
  74404. * Sets the global Density value.
  74405. * 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.
  74406. * Values less than zero provide a filter of opposite hue.
  74407. */
  74408. globalDensity: number;
  74409. /**
  74410. * Gets the global Saturation value.
  74411. * 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.
  74412. */
  74413. /**
  74414. * Sets the global Saturation value.
  74415. * 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.
  74416. */
  74417. globalSaturation: number;
  74418. /**
  74419. * Gets the global Exposure value.
  74420. * 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.
  74421. */
  74422. /**
  74423. * Sets the global Exposure value.
  74424. * 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.
  74425. */
  74426. globalExposure: number;
  74427. private _highlightsHue;
  74428. private _highlightsDensity;
  74429. private _highlightsSaturation;
  74430. private _highlightsExposure;
  74431. /**
  74432. * Gets the highlights Hue value.
  74433. * 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).
  74434. */
  74435. /**
  74436. * Sets the highlights Hue value.
  74437. * 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).
  74438. */
  74439. highlightsHue: number;
  74440. /**
  74441. * Gets the highlights Density value.
  74442. * 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.
  74443. * Values less than zero provide a filter of opposite hue.
  74444. */
  74445. /**
  74446. * Sets the highlights Density value.
  74447. * 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.
  74448. * Values less than zero provide a filter of opposite hue.
  74449. */
  74450. highlightsDensity: number;
  74451. /**
  74452. * Gets the highlights Saturation value.
  74453. * 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.
  74454. */
  74455. /**
  74456. * Sets the highlights Saturation value.
  74457. * 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.
  74458. */
  74459. highlightsSaturation: number;
  74460. /**
  74461. * Gets the highlights Exposure value.
  74462. * 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.
  74463. */
  74464. /**
  74465. * Sets the highlights Exposure value.
  74466. * 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.
  74467. */
  74468. highlightsExposure: number;
  74469. private _midtonesHue;
  74470. private _midtonesDensity;
  74471. private _midtonesSaturation;
  74472. private _midtonesExposure;
  74473. /**
  74474. * Gets the midtones Hue value.
  74475. * 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).
  74476. */
  74477. /**
  74478. * Sets the midtones Hue value.
  74479. * 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).
  74480. */
  74481. midtonesHue: number;
  74482. /**
  74483. * Gets the midtones Density value.
  74484. * 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.
  74485. * Values less than zero provide a filter of opposite hue.
  74486. */
  74487. /**
  74488. * Sets the midtones Density value.
  74489. * 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.
  74490. * Values less than zero provide a filter of opposite hue.
  74491. */
  74492. midtonesDensity: number;
  74493. /**
  74494. * Gets the midtones Saturation value.
  74495. * 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.
  74496. */
  74497. /**
  74498. * Sets the midtones Saturation value.
  74499. * 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.
  74500. */
  74501. midtonesSaturation: number;
  74502. /**
  74503. * Gets the midtones Exposure value.
  74504. * 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.
  74505. */
  74506. /**
  74507. * Sets the midtones Exposure value.
  74508. * 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.
  74509. */
  74510. midtonesExposure: number;
  74511. private _shadowsHue;
  74512. private _shadowsDensity;
  74513. private _shadowsSaturation;
  74514. private _shadowsExposure;
  74515. /**
  74516. * Gets the shadows Hue value.
  74517. * 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).
  74518. */
  74519. /**
  74520. * Sets the shadows Hue value.
  74521. * 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).
  74522. */
  74523. shadowsHue: number;
  74524. /**
  74525. * Gets the shadows Density value.
  74526. * 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.
  74527. * Values less than zero provide a filter of opposite hue.
  74528. */
  74529. /**
  74530. * Sets the shadows Density value.
  74531. * 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.
  74532. * Values less than zero provide a filter of opposite hue.
  74533. */
  74534. shadowsDensity: number;
  74535. /**
  74536. * Gets the shadows Saturation value.
  74537. * 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.
  74538. */
  74539. /**
  74540. * Sets the shadows Saturation value.
  74541. * 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.
  74542. */
  74543. shadowsSaturation: number;
  74544. /**
  74545. * Gets the shadows Exposure value.
  74546. * 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.
  74547. */
  74548. /**
  74549. * Sets the shadows Exposure value.
  74550. * 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.
  74551. */
  74552. shadowsExposure: number;
  74553. /**
  74554. * Returns the class name
  74555. * @returns The class name
  74556. */
  74557. getClassName(): string;
  74558. /**
  74559. * Binds the color curves to the shader.
  74560. * @param colorCurves The color curve to bind
  74561. * @param effect The effect to bind to
  74562. * @param positiveUniform The positive uniform shader parameter
  74563. * @param neutralUniform The neutral uniform shader parameter
  74564. * @param negativeUniform The negative uniform shader parameter
  74565. */
  74566. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74567. /**
  74568. * Prepare the list of uniforms associated with the ColorCurves effects.
  74569. * @param uniformsList The list of uniforms used in the effect
  74570. */
  74571. static PrepareUniforms(uniformsList: string[]): void;
  74572. /**
  74573. * Returns color grading data based on a hue, density, saturation and exposure value.
  74574. * @param filterHue The hue of the color filter.
  74575. * @param filterDensity The density of the color filter.
  74576. * @param saturation The saturation.
  74577. * @param exposure The exposure.
  74578. * @param result The result data container.
  74579. */
  74580. private getColorGradingDataToRef;
  74581. /**
  74582. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74583. * @param value The input slider value in range [-100,100].
  74584. * @returns Adjusted value.
  74585. */
  74586. private static applyColorGradingSliderNonlinear;
  74587. /**
  74588. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74589. * @param hue The hue (H) input.
  74590. * @param saturation The saturation (S) input.
  74591. * @param brightness The brightness (B) input.
  74592. * @result An RGBA color represented as Vector4.
  74593. */
  74594. private static fromHSBToRef;
  74595. /**
  74596. * Returns a value clamped between min and max
  74597. * @param value The value to clamp
  74598. * @param min The minimum of value
  74599. * @param max The maximum of value
  74600. * @returns The clamped value.
  74601. */
  74602. private static clamp;
  74603. /**
  74604. * Clones the current color curve instance.
  74605. * @return The cloned curves
  74606. */
  74607. clone(): ColorCurves;
  74608. /**
  74609. * Serializes the current color curve instance to a json representation.
  74610. * @return a JSON representation
  74611. */
  74612. serialize(): any;
  74613. /**
  74614. * Parses the color curve from a json representation.
  74615. * @param source the JSON source to parse
  74616. * @return The parsed curves
  74617. */
  74618. static Parse(source: any): ColorCurves;
  74619. }
  74620. }
  74621. declare module BABYLON {
  74622. /**
  74623. * Interface to follow in your material defines to integrate easily the
  74624. * Image proccessing functions.
  74625. * @hidden
  74626. */
  74627. export interface IImageProcessingConfigurationDefines {
  74628. IMAGEPROCESSING: boolean;
  74629. VIGNETTE: boolean;
  74630. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74631. VIGNETTEBLENDMODEOPAQUE: boolean;
  74632. TONEMAPPING: boolean;
  74633. TONEMAPPING_ACES: boolean;
  74634. CONTRAST: boolean;
  74635. EXPOSURE: boolean;
  74636. COLORCURVES: boolean;
  74637. COLORGRADING: boolean;
  74638. COLORGRADING3D: boolean;
  74639. SAMPLER3DGREENDEPTH: boolean;
  74640. SAMPLER3DBGRMAP: boolean;
  74641. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74642. }
  74643. /**
  74644. * @hidden
  74645. */
  74646. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74647. IMAGEPROCESSING: boolean;
  74648. VIGNETTE: boolean;
  74649. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74650. VIGNETTEBLENDMODEOPAQUE: boolean;
  74651. TONEMAPPING: boolean;
  74652. TONEMAPPING_ACES: boolean;
  74653. CONTRAST: boolean;
  74654. COLORCURVES: boolean;
  74655. COLORGRADING: boolean;
  74656. COLORGRADING3D: boolean;
  74657. SAMPLER3DGREENDEPTH: boolean;
  74658. SAMPLER3DBGRMAP: boolean;
  74659. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74660. EXPOSURE: boolean;
  74661. constructor();
  74662. }
  74663. /**
  74664. * This groups together the common properties used for image processing either in direct forward pass
  74665. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74666. * or not.
  74667. */
  74668. export class ImageProcessingConfiguration {
  74669. /**
  74670. * Default tone mapping applied in BabylonJS.
  74671. */
  74672. static readonly TONEMAPPING_STANDARD: number;
  74673. /**
  74674. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74675. * to other engines rendering to increase portability.
  74676. */
  74677. static readonly TONEMAPPING_ACES: number;
  74678. /**
  74679. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74680. */
  74681. colorCurves: Nullable<ColorCurves>;
  74682. private _colorCurvesEnabled;
  74683. /**
  74684. * Gets wether the color curves effect is enabled.
  74685. */
  74686. /**
  74687. * Sets wether the color curves effect is enabled.
  74688. */
  74689. colorCurvesEnabled: boolean;
  74690. private _colorGradingTexture;
  74691. /**
  74692. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74693. */
  74694. /**
  74695. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74696. */
  74697. colorGradingTexture: Nullable<BaseTexture>;
  74698. private _colorGradingEnabled;
  74699. /**
  74700. * Gets wether the color grading effect is enabled.
  74701. */
  74702. /**
  74703. * Sets wether the color grading effect is enabled.
  74704. */
  74705. colorGradingEnabled: boolean;
  74706. private _colorGradingWithGreenDepth;
  74707. /**
  74708. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74709. */
  74710. /**
  74711. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74712. */
  74713. colorGradingWithGreenDepth: boolean;
  74714. private _colorGradingBGR;
  74715. /**
  74716. * Gets wether the color grading texture contains BGR values.
  74717. */
  74718. /**
  74719. * Sets wether the color grading texture contains BGR values.
  74720. */
  74721. colorGradingBGR: boolean;
  74722. /** @hidden */
  74723. _exposure: number;
  74724. /**
  74725. * Gets the Exposure used in the effect.
  74726. */
  74727. /**
  74728. * Sets the Exposure used in the effect.
  74729. */
  74730. exposure: number;
  74731. private _toneMappingEnabled;
  74732. /**
  74733. * Gets wether the tone mapping effect is enabled.
  74734. */
  74735. /**
  74736. * Sets wether the tone mapping effect is enabled.
  74737. */
  74738. toneMappingEnabled: boolean;
  74739. private _toneMappingType;
  74740. /**
  74741. * Gets the type of tone mapping effect.
  74742. */
  74743. /**
  74744. * Sets the type of tone mapping effect used in BabylonJS.
  74745. */
  74746. toneMappingType: number;
  74747. protected _contrast: number;
  74748. /**
  74749. * Gets the contrast used in the effect.
  74750. */
  74751. /**
  74752. * Sets the contrast used in the effect.
  74753. */
  74754. contrast: number;
  74755. /**
  74756. * Vignette stretch size.
  74757. */
  74758. vignetteStretch: number;
  74759. /**
  74760. * Vignette centre X Offset.
  74761. */
  74762. vignetteCentreX: number;
  74763. /**
  74764. * Vignette centre Y Offset.
  74765. */
  74766. vignetteCentreY: number;
  74767. /**
  74768. * Vignette weight or intensity of the vignette effect.
  74769. */
  74770. vignetteWeight: number;
  74771. /**
  74772. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74773. * if vignetteEnabled is set to true.
  74774. */
  74775. vignetteColor: Color4;
  74776. /**
  74777. * Camera field of view used by the Vignette effect.
  74778. */
  74779. vignetteCameraFov: number;
  74780. private _vignetteBlendMode;
  74781. /**
  74782. * Gets the vignette blend mode allowing different kind of effect.
  74783. */
  74784. /**
  74785. * Sets the vignette blend mode allowing different kind of effect.
  74786. */
  74787. vignetteBlendMode: number;
  74788. private _vignetteEnabled;
  74789. /**
  74790. * Gets wether the vignette effect is enabled.
  74791. */
  74792. /**
  74793. * Sets wether the vignette effect is enabled.
  74794. */
  74795. vignetteEnabled: boolean;
  74796. private _applyByPostProcess;
  74797. /**
  74798. * Gets wether the image processing is applied through a post process or not.
  74799. */
  74800. /**
  74801. * Sets wether the image processing is applied through a post process or not.
  74802. */
  74803. applyByPostProcess: boolean;
  74804. private _isEnabled;
  74805. /**
  74806. * Gets wether the image processing is enabled or not.
  74807. */
  74808. /**
  74809. * Sets wether the image processing is enabled or not.
  74810. */
  74811. isEnabled: boolean;
  74812. /**
  74813. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74814. */
  74815. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74816. /**
  74817. * Method called each time the image processing information changes requires to recompile the effect.
  74818. */
  74819. protected _updateParameters(): void;
  74820. /**
  74821. * Gets the current class name.
  74822. * @return "ImageProcessingConfiguration"
  74823. */
  74824. getClassName(): string;
  74825. /**
  74826. * Prepare the list of uniforms associated with the Image Processing effects.
  74827. * @param uniforms The list of uniforms used in the effect
  74828. * @param defines the list of defines currently in use
  74829. */
  74830. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74831. /**
  74832. * Prepare the list of samplers associated with the Image Processing effects.
  74833. * @param samplersList The list of uniforms used in the effect
  74834. * @param defines the list of defines currently in use
  74835. */
  74836. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74837. /**
  74838. * Prepare the list of defines associated to the shader.
  74839. * @param defines the list of defines to complete
  74840. * @param forPostProcess Define if we are currently in post process mode or not
  74841. */
  74842. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74843. /**
  74844. * Returns true if all the image processing information are ready.
  74845. * @returns True if ready, otherwise, false
  74846. */
  74847. isReady(): boolean;
  74848. /**
  74849. * Binds the image processing to the shader.
  74850. * @param effect The effect to bind to
  74851. * @param aspectRatio Define the current aspect ratio of the effect
  74852. */
  74853. bind(effect: Effect, aspectRatio?: number): void;
  74854. /**
  74855. * Clones the current image processing instance.
  74856. * @return The cloned image processing
  74857. */
  74858. clone(): ImageProcessingConfiguration;
  74859. /**
  74860. * Serializes the current image processing instance to a json representation.
  74861. * @return a JSON representation
  74862. */
  74863. serialize(): any;
  74864. /**
  74865. * Parses the image processing from a json representation.
  74866. * @param source the JSON source to parse
  74867. * @return The parsed image processing
  74868. */
  74869. static Parse(source: any): ImageProcessingConfiguration;
  74870. private static _VIGNETTEMODE_MULTIPLY;
  74871. private static _VIGNETTEMODE_OPAQUE;
  74872. /**
  74873. * Used to apply the vignette as a mix with the pixel color.
  74874. */
  74875. static readonly VIGNETTEMODE_MULTIPLY: number;
  74876. /**
  74877. * Used to apply the vignette as a replacement of the pixel color.
  74878. */
  74879. static readonly VIGNETTEMODE_OPAQUE: number;
  74880. }
  74881. }
  74882. declare module BABYLON {
  74883. /** @hidden */
  74884. export var postprocessVertexShader: {
  74885. name: string;
  74886. shader: string;
  74887. };
  74888. }
  74889. declare module BABYLON {
  74890. /** Defines supported spaces */
  74891. export enum Space {
  74892. /** Local (object) space */
  74893. LOCAL = 0,
  74894. /** World space */
  74895. WORLD = 1,
  74896. /** Bone space */
  74897. BONE = 2
  74898. }
  74899. /** Defines the 3 main axes */
  74900. export class Axis {
  74901. /** X axis */
  74902. static X: Vector3;
  74903. /** Y axis */
  74904. static Y: Vector3;
  74905. /** Z axis */
  74906. static Z: Vector3;
  74907. }
  74908. }
  74909. declare module BABYLON {
  74910. /**
  74911. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74912. * This is the base of the follow, arc rotate cameras and Free camera
  74913. * @see http://doc.babylonjs.com/features/cameras
  74914. */
  74915. export class TargetCamera extends Camera {
  74916. private static _RigCamTransformMatrix;
  74917. private static _TargetTransformMatrix;
  74918. private static _TargetFocalPoint;
  74919. /**
  74920. * Define the current direction the camera is moving to
  74921. */
  74922. cameraDirection: Vector3;
  74923. /**
  74924. * Define the current rotation the camera is rotating to
  74925. */
  74926. cameraRotation: Vector2;
  74927. /**
  74928. * When set, the up vector of the camera will be updated by the rotation of the camera
  74929. */
  74930. updateUpVectorFromRotation: boolean;
  74931. private _tmpQuaternion;
  74932. /**
  74933. * Define the current rotation of the camera
  74934. */
  74935. rotation: Vector3;
  74936. /**
  74937. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74938. */
  74939. rotationQuaternion: Quaternion;
  74940. /**
  74941. * Define the current speed of the camera
  74942. */
  74943. speed: number;
  74944. /**
  74945. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74946. * around all axis.
  74947. */
  74948. noRotationConstraint: boolean;
  74949. /**
  74950. * Define the current target of the camera as an object or a position.
  74951. */
  74952. lockedTarget: any;
  74953. /** @hidden */
  74954. _currentTarget: Vector3;
  74955. /** @hidden */
  74956. _initialFocalDistance: number;
  74957. /** @hidden */
  74958. _viewMatrix: Matrix;
  74959. /** @hidden */
  74960. _camMatrix: Matrix;
  74961. /** @hidden */
  74962. _cameraTransformMatrix: Matrix;
  74963. /** @hidden */
  74964. _cameraRotationMatrix: Matrix;
  74965. /** @hidden */
  74966. _referencePoint: Vector3;
  74967. /** @hidden */
  74968. _transformedReferencePoint: Vector3;
  74969. protected _globalCurrentTarget: Vector3;
  74970. protected _globalCurrentUpVector: Vector3;
  74971. /** @hidden */
  74972. _reset: () => void;
  74973. private _defaultUp;
  74974. /**
  74975. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74976. * This is the base of the follow, arc rotate cameras and Free camera
  74977. * @see http://doc.babylonjs.com/features/cameras
  74978. * @param name Defines the name of the camera in the scene
  74979. * @param position Defines the start position of the camera in the scene
  74980. * @param scene Defines the scene the camera belongs to
  74981. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74982. */
  74983. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74984. /**
  74985. * Gets the position in front of the camera at a given distance.
  74986. * @param distance The distance from the camera we want the position to be
  74987. * @returns the position
  74988. */
  74989. getFrontPosition(distance: number): Vector3;
  74990. /** @hidden */
  74991. _getLockedTargetPosition(): Nullable<Vector3>;
  74992. private _storedPosition;
  74993. private _storedRotation;
  74994. private _storedRotationQuaternion;
  74995. /**
  74996. * Store current camera state of the camera (fov, position, rotation, etc..)
  74997. * @returns the camera
  74998. */
  74999. storeState(): Camera;
  75000. /**
  75001. * Restored camera state. You must call storeState() first
  75002. * @returns whether it was successful or not
  75003. * @hidden
  75004. */
  75005. _restoreStateValues(): boolean;
  75006. /** @hidden */
  75007. _initCache(): void;
  75008. /** @hidden */
  75009. _updateCache(ignoreParentClass?: boolean): void;
  75010. /** @hidden */
  75011. _isSynchronizedViewMatrix(): boolean;
  75012. /** @hidden */
  75013. _computeLocalCameraSpeed(): number;
  75014. /**
  75015. * Defines the target the camera should look at.
  75016. * @param target Defines the new target as a Vector or a mesh
  75017. */
  75018. setTarget(target: Vector3): void;
  75019. /**
  75020. * Return the current target position of the camera. This value is expressed in local space.
  75021. * @returns the target position
  75022. */
  75023. getTarget(): Vector3;
  75024. /** @hidden */
  75025. _decideIfNeedsToMove(): boolean;
  75026. /** @hidden */
  75027. _updatePosition(): void;
  75028. /** @hidden */
  75029. _checkInputs(): void;
  75030. protected _updateCameraRotationMatrix(): void;
  75031. /**
  75032. * 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)
  75033. * @returns the current camera
  75034. */
  75035. private _rotateUpVectorWithCameraRotationMatrix;
  75036. private _cachedRotationZ;
  75037. private _cachedQuaternionRotationZ;
  75038. /** @hidden */
  75039. _getViewMatrix(): Matrix;
  75040. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75041. /**
  75042. * @hidden
  75043. */
  75044. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75045. /**
  75046. * @hidden
  75047. */
  75048. _updateRigCameras(): void;
  75049. private _getRigCamPositionAndTarget;
  75050. /**
  75051. * Gets the current object class name.
  75052. * @return the class name
  75053. */
  75054. getClassName(): string;
  75055. }
  75056. }
  75057. declare module BABYLON {
  75058. /**
  75059. * Gather the list of keyboard event types as constants.
  75060. */
  75061. export class KeyboardEventTypes {
  75062. /**
  75063. * The keydown event is fired when a key becomes active (pressed).
  75064. */
  75065. static readonly KEYDOWN: number;
  75066. /**
  75067. * The keyup event is fired when a key has been released.
  75068. */
  75069. static readonly KEYUP: number;
  75070. }
  75071. /**
  75072. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75073. */
  75074. export class KeyboardInfo {
  75075. /**
  75076. * Defines the type of event (KeyboardEventTypes)
  75077. */
  75078. type: number;
  75079. /**
  75080. * Defines the related dom event
  75081. */
  75082. event: KeyboardEvent;
  75083. /**
  75084. * Instantiates a new keyboard info.
  75085. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75086. * @param type Defines the type of event (KeyboardEventTypes)
  75087. * @param event Defines the related dom event
  75088. */
  75089. constructor(
  75090. /**
  75091. * Defines the type of event (KeyboardEventTypes)
  75092. */
  75093. type: number,
  75094. /**
  75095. * Defines the related dom event
  75096. */
  75097. event: KeyboardEvent);
  75098. }
  75099. /**
  75100. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75101. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75102. */
  75103. export class KeyboardInfoPre extends KeyboardInfo {
  75104. /**
  75105. * Defines the type of event (KeyboardEventTypes)
  75106. */
  75107. type: number;
  75108. /**
  75109. * Defines the related dom event
  75110. */
  75111. event: KeyboardEvent;
  75112. /**
  75113. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75114. */
  75115. skipOnPointerObservable: boolean;
  75116. /**
  75117. * Instantiates a new keyboard pre info.
  75118. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75119. * @param type Defines the type of event (KeyboardEventTypes)
  75120. * @param event Defines the related dom event
  75121. */
  75122. constructor(
  75123. /**
  75124. * Defines the type of event (KeyboardEventTypes)
  75125. */
  75126. type: number,
  75127. /**
  75128. * Defines the related dom event
  75129. */
  75130. event: KeyboardEvent);
  75131. }
  75132. }
  75133. declare module BABYLON {
  75134. /**
  75135. * Manage the keyboard inputs to control the movement of a free camera.
  75136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75137. */
  75138. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75139. /**
  75140. * Defines the camera the input is attached to.
  75141. */
  75142. camera: FreeCamera;
  75143. /**
  75144. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75145. */
  75146. keysUp: number[];
  75147. /**
  75148. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75149. */
  75150. keysDown: number[];
  75151. /**
  75152. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75153. */
  75154. keysLeft: number[];
  75155. /**
  75156. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75157. */
  75158. keysRight: number[];
  75159. private _keys;
  75160. private _onCanvasBlurObserver;
  75161. private _onKeyboardObserver;
  75162. private _engine;
  75163. private _scene;
  75164. /**
  75165. * Attach the input controls to a specific dom element to get the input from.
  75166. * @param element Defines the element the controls should be listened from
  75167. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75168. */
  75169. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75170. /**
  75171. * Detach the current controls from the specified dom element.
  75172. * @param element Defines the element to stop listening the inputs from
  75173. */
  75174. detachControl(element: Nullable<HTMLElement>): void;
  75175. /**
  75176. * Update the current camera state depending on the inputs that have been used this frame.
  75177. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75178. */
  75179. checkInputs(): void;
  75180. /**
  75181. * Gets the class name of the current intput.
  75182. * @returns the class name
  75183. */
  75184. getClassName(): string;
  75185. /** @hidden */
  75186. _onLostFocus(): void;
  75187. /**
  75188. * Get the friendly name associated with the input class.
  75189. * @returns the input friendly name
  75190. */
  75191. getSimpleName(): string;
  75192. }
  75193. }
  75194. declare module BABYLON {
  75195. /**
  75196. * Interface describing all the common properties and methods a shadow light needs to implement.
  75197. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75198. * as well as binding the different shadow properties to the effects.
  75199. */
  75200. export interface IShadowLight extends Light {
  75201. /**
  75202. * The light id in the scene (used in scene.findLighById for instance)
  75203. */
  75204. id: string;
  75205. /**
  75206. * The position the shdow will be casted from.
  75207. */
  75208. position: Vector3;
  75209. /**
  75210. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75211. */
  75212. direction: Vector3;
  75213. /**
  75214. * The transformed position. Position of the light in world space taking parenting in account.
  75215. */
  75216. transformedPosition: Vector3;
  75217. /**
  75218. * The transformed direction. Direction of the light in world space taking parenting in account.
  75219. */
  75220. transformedDirection: Vector3;
  75221. /**
  75222. * The friendly name of the light in the scene.
  75223. */
  75224. name: string;
  75225. /**
  75226. * Defines the shadow projection clipping minimum z value.
  75227. */
  75228. shadowMinZ: number;
  75229. /**
  75230. * Defines the shadow projection clipping maximum z value.
  75231. */
  75232. shadowMaxZ: number;
  75233. /**
  75234. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75235. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75236. */
  75237. computeTransformedInformation(): boolean;
  75238. /**
  75239. * Gets the scene the light belongs to.
  75240. * @returns The scene
  75241. */
  75242. getScene(): Scene;
  75243. /**
  75244. * Callback defining a custom Projection Matrix Builder.
  75245. * This can be used to override the default projection matrix computation.
  75246. */
  75247. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75248. /**
  75249. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75250. * @param matrix The materix to updated with the projection information
  75251. * @param viewMatrix The transform matrix of the light
  75252. * @param renderList The list of mesh to render in the map
  75253. * @returns The current light
  75254. */
  75255. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75256. /**
  75257. * Gets the current depth scale used in ESM.
  75258. * @returns The scale
  75259. */
  75260. getDepthScale(): number;
  75261. /**
  75262. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75263. * @returns true if a cube texture needs to be use
  75264. */
  75265. needCube(): boolean;
  75266. /**
  75267. * Detects if the projection matrix requires to be recomputed this frame.
  75268. * @returns true if it requires to be recomputed otherwise, false.
  75269. */
  75270. needProjectionMatrixCompute(): boolean;
  75271. /**
  75272. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75273. */
  75274. forceProjectionMatrixCompute(): void;
  75275. /**
  75276. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75277. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75278. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75279. */
  75280. getShadowDirection(faceIndex?: number): Vector3;
  75281. /**
  75282. * Gets the minZ used for shadow according to both the scene and the light.
  75283. * @param activeCamera The camera we are returning the min for
  75284. * @returns the depth min z
  75285. */
  75286. getDepthMinZ(activeCamera: Camera): number;
  75287. /**
  75288. * Gets the maxZ used for shadow according to both the scene and the light.
  75289. * @param activeCamera The camera we are returning the max for
  75290. * @returns the depth max z
  75291. */
  75292. getDepthMaxZ(activeCamera: Camera): number;
  75293. }
  75294. /**
  75295. * Base implementation IShadowLight
  75296. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75297. */
  75298. export abstract class ShadowLight extends Light implements IShadowLight {
  75299. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75300. protected _position: Vector3;
  75301. protected _setPosition(value: Vector3): void;
  75302. /**
  75303. * Sets the position the shadow will be casted from. Also use as the light position for both
  75304. * point and spot lights.
  75305. */
  75306. /**
  75307. * Sets the position the shadow will be casted from. Also use as the light position for both
  75308. * point and spot lights.
  75309. */
  75310. position: Vector3;
  75311. protected _direction: Vector3;
  75312. protected _setDirection(value: Vector3): void;
  75313. /**
  75314. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75315. * Also use as the light direction on spot and directional lights.
  75316. */
  75317. /**
  75318. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75319. * Also use as the light direction on spot and directional lights.
  75320. */
  75321. direction: Vector3;
  75322. private _shadowMinZ;
  75323. /**
  75324. * Gets the shadow projection clipping minimum z value.
  75325. */
  75326. /**
  75327. * Sets the shadow projection clipping minimum z value.
  75328. */
  75329. shadowMinZ: number;
  75330. private _shadowMaxZ;
  75331. /**
  75332. * Sets the shadow projection clipping maximum z value.
  75333. */
  75334. /**
  75335. * Gets the shadow projection clipping maximum z value.
  75336. */
  75337. shadowMaxZ: number;
  75338. /**
  75339. * Callback defining a custom Projection Matrix Builder.
  75340. * This can be used to override the default projection matrix computation.
  75341. */
  75342. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75343. /**
  75344. * The transformed position. Position of the light in world space taking parenting in account.
  75345. */
  75346. transformedPosition: Vector3;
  75347. /**
  75348. * The transformed direction. Direction of the light in world space taking parenting in account.
  75349. */
  75350. transformedDirection: Vector3;
  75351. private _needProjectionMatrixCompute;
  75352. /**
  75353. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75354. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75355. */
  75356. computeTransformedInformation(): boolean;
  75357. /**
  75358. * Return the depth scale used for the shadow map.
  75359. * @returns the depth scale.
  75360. */
  75361. getDepthScale(): number;
  75362. /**
  75363. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75364. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75365. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75366. */
  75367. getShadowDirection(faceIndex?: number): Vector3;
  75368. /**
  75369. * Returns the ShadowLight absolute position in the World.
  75370. * @returns the position vector in world space
  75371. */
  75372. getAbsolutePosition(): Vector3;
  75373. /**
  75374. * Sets the ShadowLight direction toward the passed target.
  75375. * @param target The point to target in local space
  75376. * @returns the updated ShadowLight direction
  75377. */
  75378. setDirectionToTarget(target: Vector3): Vector3;
  75379. /**
  75380. * Returns the light rotation in euler definition.
  75381. * @returns the x y z rotation in local space.
  75382. */
  75383. getRotation(): Vector3;
  75384. /**
  75385. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75386. * @returns true if a cube texture needs to be use
  75387. */
  75388. needCube(): boolean;
  75389. /**
  75390. * Detects if the projection matrix requires to be recomputed this frame.
  75391. * @returns true if it requires to be recomputed otherwise, false.
  75392. */
  75393. needProjectionMatrixCompute(): boolean;
  75394. /**
  75395. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75396. */
  75397. forceProjectionMatrixCompute(): void;
  75398. /** @hidden */
  75399. _initCache(): void;
  75400. /** @hidden */
  75401. _isSynchronized(): boolean;
  75402. /**
  75403. * Computes the world matrix of the node
  75404. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75405. * @returns the world matrix
  75406. */
  75407. computeWorldMatrix(force?: boolean): Matrix;
  75408. /**
  75409. * Gets the minZ used for shadow according to both the scene and the light.
  75410. * @param activeCamera The camera we are returning the min for
  75411. * @returns the depth min z
  75412. */
  75413. getDepthMinZ(activeCamera: Camera): number;
  75414. /**
  75415. * Gets the maxZ used for shadow according to both the scene and the light.
  75416. * @param activeCamera The camera we are returning the max for
  75417. * @returns the depth max z
  75418. */
  75419. getDepthMaxZ(activeCamera: Camera): number;
  75420. /**
  75421. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75422. * @param matrix The materix to updated with the projection information
  75423. * @param viewMatrix The transform matrix of the light
  75424. * @param renderList The list of mesh to render in the map
  75425. * @returns The current light
  75426. */
  75427. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75428. }
  75429. }
  75430. declare module BABYLON {
  75431. /**
  75432. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75433. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75434. */
  75435. export class EffectFallbacks implements IEffectFallbacks {
  75436. private _defines;
  75437. private _currentRank;
  75438. private _maxRank;
  75439. private _mesh;
  75440. /**
  75441. * Removes the fallback from the bound mesh.
  75442. */
  75443. unBindMesh(): void;
  75444. /**
  75445. * Adds a fallback on the specified property.
  75446. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75447. * @param define The name of the define in the shader
  75448. */
  75449. addFallback(rank: number, define: string): void;
  75450. /**
  75451. * Sets the mesh to use CPU skinning when needing to fallback.
  75452. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75453. * @param mesh The mesh to use the fallbacks.
  75454. */
  75455. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75456. /**
  75457. * Checks to see if more fallbacks are still availible.
  75458. */
  75459. readonly hasMoreFallbacks: boolean;
  75460. /**
  75461. * Removes the defines that should be removed when falling back.
  75462. * @param currentDefines defines the current define statements for the shader.
  75463. * @param effect defines the current effect we try to compile
  75464. * @returns The resulting defines with defines of the current rank removed.
  75465. */
  75466. reduce(currentDefines: string, effect: Effect): string;
  75467. }
  75468. }
  75469. declare module BABYLON {
  75470. /**
  75471. * "Static Class" containing the most commonly used helper while dealing with material for
  75472. * rendering purpose.
  75473. *
  75474. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75475. *
  75476. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75477. */
  75478. export class MaterialHelper {
  75479. /**
  75480. * Bind the current view position to an effect.
  75481. * @param effect The effect to be bound
  75482. * @param scene The scene the eyes position is used from
  75483. */
  75484. static BindEyePosition(effect: Effect, scene: Scene): void;
  75485. /**
  75486. * Helps preparing the defines values about the UVs in used in the effect.
  75487. * UVs are shared as much as we can accross channels in the shaders.
  75488. * @param texture The texture we are preparing the UVs for
  75489. * @param defines The defines to update
  75490. * @param key The channel key "diffuse", "specular"... used in the shader
  75491. */
  75492. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75493. /**
  75494. * Binds a texture matrix value to its corrsponding uniform
  75495. * @param texture The texture to bind the matrix for
  75496. * @param uniformBuffer The uniform buffer receivin the data
  75497. * @param key The channel key "diffuse", "specular"... used in the shader
  75498. */
  75499. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75500. /**
  75501. * Gets the current status of the fog (should it be enabled?)
  75502. * @param mesh defines the mesh to evaluate for fog support
  75503. * @param scene defines the hosting scene
  75504. * @returns true if fog must be enabled
  75505. */
  75506. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75507. /**
  75508. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75509. * @param mesh defines the current mesh
  75510. * @param scene defines the current scene
  75511. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75512. * @param pointsCloud defines if point cloud rendering has to be turned on
  75513. * @param fogEnabled defines if fog has to be turned on
  75514. * @param alphaTest defines if alpha testing has to be turned on
  75515. * @param defines defines the current list of defines
  75516. */
  75517. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75518. /**
  75519. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75520. * @param scene defines the current scene
  75521. * @param engine defines the current engine
  75522. * @param defines specifies the list of active defines
  75523. * @param useInstances defines if instances have to be turned on
  75524. * @param useClipPlane defines if clip plane have to be turned on
  75525. */
  75526. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75527. /**
  75528. * Prepares the defines for bones
  75529. * @param mesh The mesh containing the geometry data we will draw
  75530. * @param defines The defines to update
  75531. */
  75532. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75533. /**
  75534. * Prepares the defines for morph targets
  75535. * @param mesh The mesh containing the geometry data we will draw
  75536. * @param defines The defines to update
  75537. */
  75538. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75539. /**
  75540. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75541. * @param mesh The mesh containing the geometry data we will draw
  75542. * @param defines The defines to update
  75543. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75544. * @param useBones Precise whether bones should be used or not (override mesh info)
  75545. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75546. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75547. * @returns false if defines are considered not dirty and have not been checked
  75548. */
  75549. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75550. /**
  75551. * Prepares the defines related to multiview
  75552. * @param scene The scene we are intending to draw
  75553. * @param defines The defines to update
  75554. */
  75555. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75556. /**
  75557. * Prepares the defines related to the light information passed in parameter
  75558. * @param scene The scene we are intending to draw
  75559. * @param mesh The mesh the effect is compiling for
  75560. * @param light The light the effect is compiling for
  75561. * @param lightIndex The index of the light
  75562. * @param defines The defines to update
  75563. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75564. * @param state Defines the current state regarding what is needed (normals, etc...)
  75565. */
  75566. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75567. needNormals: boolean;
  75568. needRebuild: boolean;
  75569. shadowEnabled: boolean;
  75570. specularEnabled: boolean;
  75571. lightmapMode: boolean;
  75572. }): void;
  75573. /**
  75574. * Prepares the defines related to the light information passed in parameter
  75575. * @param scene The scene we are intending to draw
  75576. * @param mesh The mesh the effect is compiling for
  75577. * @param defines The defines to update
  75578. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75579. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75580. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75581. * @returns true if normals will be required for the rest of the effect
  75582. */
  75583. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75584. /**
  75585. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75586. * @param lightIndex defines the light index
  75587. * @param uniformsList The uniform list
  75588. * @param samplersList The sampler list
  75589. * @param projectedLightTexture defines if projected texture must be used
  75590. * @param uniformBuffersList defines an optional list of uniform buffers
  75591. */
  75592. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75593. /**
  75594. * Prepares the uniforms and samplers list to be used in the effect
  75595. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75596. * @param samplersList The sampler list
  75597. * @param defines The defines helping in the list generation
  75598. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75599. */
  75600. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75601. /**
  75602. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75603. * @param defines The defines to update while falling back
  75604. * @param fallbacks The authorized effect fallbacks
  75605. * @param maxSimultaneousLights The maximum number of lights allowed
  75606. * @param rank the current rank of the Effect
  75607. * @returns The newly affected rank
  75608. */
  75609. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75610. private static _TmpMorphInfluencers;
  75611. /**
  75612. * Prepares the list of attributes required for morph targets according to the effect defines.
  75613. * @param attribs The current list of supported attribs
  75614. * @param mesh The mesh to prepare the morph targets attributes for
  75615. * @param influencers The number of influencers
  75616. */
  75617. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75618. /**
  75619. * Prepares the list of attributes required for morph targets according to the effect defines.
  75620. * @param attribs The current list of supported attribs
  75621. * @param mesh The mesh to prepare the morph targets attributes for
  75622. * @param defines The current Defines of the effect
  75623. */
  75624. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75625. /**
  75626. * Prepares the list of attributes required for bones according to the effect defines.
  75627. * @param attribs The current list of supported attribs
  75628. * @param mesh The mesh to prepare the bones attributes for
  75629. * @param defines The current Defines of the effect
  75630. * @param fallbacks The current efffect fallback strategy
  75631. */
  75632. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75633. /**
  75634. * Check and prepare the list of attributes required for instances according to the effect defines.
  75635. * @param attribs The current list of supported attribs
  75636. * @param defines The current MaterialDefines of the effect
  75637. */
  75638. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75639. /**
  75640. * Add the list of attributes required for instances to the attribs array.
  75641. * @param attribs The current list of supported attribs
  75642. */
  75643. static PushAttributesForInstances(attribs: string[]): void;
  75644. /**
  75645. * Binds the light shadow information to the effect for the given mesh.
  75646. * @param light The light containing the generator
  75647. * @param scene The scene the lights belongs to
  75648. * @param mesh The mesh we are binding the information to render
  75649. * @param lightIndex The light index in the effect used to render the mesh
  75650. * @param effect The effect we are binding the data to
  75651. */
  75652. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75653. /**
  75654. * Binds the light information to the effect.
  75655. * @param light The light containing the generator
  75656. * @param effect The effect we are binding the data to
  75657. * @param lightIndex The light index in the effect used to render
  75658. */
  75659. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75660. /**
  75661. * Binds the lights information from the scene to the effect for the given mesh.
  75662. * @param light Light to bind
  75663. * @param lightIndex Light index
  75664. * @param scene The scene where the light belongs to
  75665. * @param mesh The mesh we are binding the information to render
  75666. * @param effect The effect we are binding the data to
  75667. * @param useSpecular Defines if specular is supported
  75668. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75669. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75670. */
  75671. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75672. /**
  75673. * Binds the lights information from the scene to the effect for the given mesh.
  75674. * @param scene The scene the lights belongs to
  75675. * @param mesh The mesh we are binding the information to render
  75676. * @param effect The effect we are binding the data to
  75677. * @param defines The generated defines for the effect
  75678. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75679. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75680. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75681. */
  75682. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75683. private static _tempFogColor;
  75684. /**
  75685. * Binds the fog information from the scene to the effect for the given mesh.
  75686. * @param scene The scene the lights belongs to
  75687. * @param mesh The mesh we are binding the information to render
  75688. * @param effect The effect we are binding the data to
  75689. * @param linearSpace Defines if the fog effect is applied in linear space
  75690. */
  75691. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75692. /**
  75693. * Binds the bones information from the mesh to the effect.
  75694. * @param mesh The mesh we are binding the information to render
  75695. * @param effect The effect we are binding the data to
  75696. */
  75697. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75698. /**
  75699. * Binds the morph targets information from the mesh to the effect.
  75700. * @param abstractMesh The mesh we are binding the information to render
  75701. * @param effect The effect we are binding the data to
  75702. */
  75703. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75704. /**
  75705. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75706. * @param defines The generated defines used in the effect
  75707. * @param effect The effect we are binding the data to
  75708. * @param scene The scene we are willing to render with logarithmic scale for
  75709. */
  75710. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75711. /**
  75712. * Binds the clip plane information from the scene to the effect.
  75713. * @param scene The scene the clip plane information are extracted from
  75714. * @param effect The effect we are binding the data to
  75715. */
  75716. static BindClipPlane(effect: Effect, scene: Scene): void;
  75717. }
  75718. }
  75719. declare module BABYLON {
  75720. /** @hidden */
  75721. export var packingFunctions: {
  75722. name: string;
  75723. shader: string;
  75724. };
  75725. }
  75726. declare module BABYLON {
  75727. /** @hidden */
  75728. export var shadowMapPixelShader: {
  75729. name: string;
  75730. shader: string;
  75731. };
  75732. }
  75733. declare module BABYLON {
  75734. /** @hidden */
  75735. export var bonesDeclaration: {
  75736. name: string;
  75737. shader: string;
  75738. };
  75739. }
  75740. declare module BABYLON {
  75741. /** @hidden */
  75742. export var morphTargetsVertexGlobalDeclaration: {
  75743. name: string;
  75744. shader: string;
  75745. };
  75746. }
  75747. declare module BABYLON {
  75748. /** @hidden */
  75749. export var morphTargetsVertexDeclaration: {
  75750. name: string;
  75751. shader: string;
  75752. };
  75753. }
  75754. declare module BABYLON {
  75755. /** @hidden */
  75756. export var instancesDeclaration: {
  75757. name: string;
  75758. shader: string;
  75759. };
  75760. }
  75761. declare module BABYLON {
  75762. /** @hidden */
  75763. export var helperFunctions: {
  75764. name: string;
  75765. shader: string;
  75766. };
  75767. }
  75768. declare module BABYLON {
  75769. /** @hidden */
  75770. export var morphTargetsVertex: {
  75771. name: string;
  75772. shader: string;
  75773. };
  75774. }
  75775. declare module BABYLON {
  75776. /** @hidden */
  75777. export var instancesVertex: {
  75778. name: string;
  75779. shader: string;
  75780. };
  75781. }
  75782. declare module BABYLON {
  75783. /** @hidden */
  75784. export var bonesVertex: {
  75785. name: string;
  75786. shader: string;
  75787. };
  75788. }
  75789. declare module BABYLON {
  75790. /** @hidden */
  75791. export var shadowMapVertexShader: {
  75792. name: string;
  75793. shader: string;
  75794. };
  75795. }
  75796. declare module BABYLON {
  75797. /** @hidden */
  75798. export var depthBoxBlurPixelShader: {
  75799. name: string;
  75800. shader: string;
  75801. };
  75802. }
  75803. declare module BABYLON {
  75804. /**
  75805. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75806. */
  75807. export interface ICustomShaderOptions {
  75808. /**
  75809. * Gets or sets the custom shader name to use
  75810. */
  75811. shaderName: string;
  75812. /**
  75813. * The list of attribute names used in the shader
  75814. */
  75815. attributes?: string[];
  75816. /**
  75817. * The list of unifrom names used in the shader
  75818. */
  75819. uniforms?: string[];
  75820. /**
  75821. * The list of sampler names used in the shader
  75822. */
  75823. samplers?: string[];
  75824. /**
  75825. * The list of defines used in the shader
  75826. */
  75827. defines?: string[];
  75828. }
  75829. /**
  75830. * Interface to implement to create a shadow generator compatible with BJS.
  75831. */
  75832. export interface IShadowGenerator {
  75833. /**
  75834. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75835. * @returns The render target texture if present otherwise, null
  75836. */
  75837. getShadowMap(): Nullable<RenderTargetTexture>;
  75838. /**
  75839. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75840. * @returns The render target texture if the shadow map is present otherwise, null
  75841. */
  75842. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75843. /**
  75844. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75845. * @param subMesh The submesh we want to render in the shadow map
  75846. * @param useInstances Defines wether will draw in the map using instances
  75847. * @returns true if ready otherwise, false
  75848. */
  75849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75850. /**
  75851. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75852. * @param defines Defines of the material we want to update
  75853. * @param lightIndex Index of the light in the enabled light list of the material
  75854. */
  75855. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75856. /**
  75857. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75858. * defined in the generator but impacting the effect).
  75859. * It implies the unifroms available on the materials are the standard BJS ones.
  75860. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75861. * @param effect The effect we are binfing the information for
  75862. */
  75863. bindShadowLight(lightIndex: string, effect: Effect): void;
  75864. /**
  75865. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75866. * (eq to shadow prjection matrix * light transform matrix)
  75867. * @returns The transform matrix used to create the shadow map
  75868. */
  75869. getTransformMatrix(): Matrix;
  75870. /**
  75871. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75872. * Cube and 2D textures for instance.
  75873. */
  75874. recreateShadowMap(): void;
  75875. /**
  75876. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75877. * @param onCompiled Callback triggered at the and of the effects compilation
  75878. * @param options Sets of optional options forcing the compilation with different modes
  75879. */
  75880. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75881. useInstances: boolean;
  75882. }>): void;
  75883. /**
  75884. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75885. * @param options Sets of optional options forcing the compilation with different modes
  75886. * @returns A promise that resolves when the compilation completes
  75887. */
  75888. forceCompilationAsync(options?: Partial<{
  75889. useInstances: boolean;
  75890. }>): Promise<void>;
  75891. /**
  75892. * Serializes the shadow generator setup to a json object.
  75893. * @returns The serialized JSON object
  75894. */
  75895. serialize(): any;
  75896. /**
  75897. * Disposes the Shadow map and related Textures and effects.
  75898. */
  75899. dispose(): void;
  75900. }
  75901. /**
  75902. * Default implementation IShadowGenerator.
  75903. * This is the main object responsible of generating shadows in the framework.
  75904. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75905. */
  75906. export class ShadowGenerator implements IShadowGenerator {
  75907. /**
  75908. * Shadow generator mode None: no filtering applied.
  75909. */
  75910. static readonly FILTER_NONE: number;
  75911. /**
  75912. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75913. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75914. */
  75915. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75916. /**
  75917. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75918. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75919. */
  75920. static readonly FILTER_POISSONSAMPLING: number;
  75921. /**
  75922. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75923. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75924. */
  75925. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75926. /**
  75927. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75928. * edge artifacts on steep falloff.
  75929. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75930. */
  75931. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75932. /**
  75933. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75934. * edge artifacts on steep falloff.
  75935. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75936. */
  75937. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75938. /**
  75939. * Shadow generator mode PCF: Percentage Closer Filtering
  75940. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75941. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75942. */
  75943. static readonly FILTER_PCF: number;
  75944. /**
  75945. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75946. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75947. * Contact Hardening
  75948. */
  75949. static readonly FILTER_PCSS: number;
  75950. /**
  75951. * Reserved for PCF and PCSS
  75952. * Highest Quality.
  75953. *
  75954. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75955. *
  75956. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75957. */
  75958. static readonly QUALITY_HIGH: number;
  75959. /**
  75960. * Reserved for PCF and PCSS
  75961. * Good tradeoff for quality/perf cross devices
  75962. *
  75963. * Execute PCF on a 3*3 kernel.
  75964. *
  75965. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75966. */
  75967. static readonly QUALITY_MEDIUM: number;
  75968. /**
  75969. * Reserved for PCF and PCSS
  75970. * The lowest quality but the fastest.
  75971. *
  75972. * Execute PCF on a 1*1 kernel.
  75973. *
  75974. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75975. */
  75976. static readonly QUALITY_LOW: number;
  75977. /** Gets or sets the custom shader name to use */
  75978. customShaderOptions: ICustomShaderOptions;
  75979. /**
  75980. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75981. */
  75982. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75983. /**
  75984. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75985. */
  75986. onAfterShadowMapRenderObservable: Observable<Effect>;
  75987. /**
  75988. * Observable triggered before a mesh is rendered in the shadow map.
  75989. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75990. */
  75991. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75992. /**
  75993. * Observable triggered after a mesh is rendered in the shadow map.
  75994. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75995. */
  75996. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75997. private _bias;
  75998. /**
  75999. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76000. */
  76001. /**
  76002. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76003. */
  76004. bias: number;
  76005. private _normalBias;
  76006. /**
  76007. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76008. */
  76009. /**
  76010. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76011. */
  76012. normalBias: number;
  76013. private _blurBoxOffset;
  76014. /**
  76015. * Gets the blur box offset: offset applied during the blur pass.
  76016. * Only useful if useKernelBlur = false
  76017. */
  76018. /**
  76019. * Sets the blur box offset: offset applied during the blur pass.
  76020. * Only useful if useKernelBlur = false
  76021. */
  76022. blurBoxOffset: number;
  76023. private _blurScale;
  76024. /**
  76025. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76026. * 2 means half of the size.
  76027. */
  76028. /**
  76029. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76030. * 2 means half of the size.
  76031. */
  76032. blurScale: number;
  76033. private _blurKernel;
  76034. /**
  76035. * Gets the blur kernel: kernel size of the blur pass.
  76036. * Only useful if useKernelBlur = true
  76037. */
  76038. /**
  76039. * Sets the blur kernel: kernel size of the blur pass.
  76040. * Only useful if useKernelBlur = true
  76041. */
  76042. blurKernel: number;
  76043. private _useKernelBlur;
  76044. /**
  76045. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76046. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76047. */
  76048. /**
  76049. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76050. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76051. */
  76052. useKernelBlur: boolean;
  76053. private _depthScale;
  76054. /**
  76055. * Gets the depth scale used in ESM mode.
  76056. */
  76057. /**
  76058. * Sets the depth scale used in ESM mode.
  76059. * This can override the scale stored on the light.
  76060. */
  76061. depthScale: number;
  76062. private _filter;
  76063. /**
  76064. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76065. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76066. */
  76067. /**
  76068. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76069. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76070. */
  76071. filter: number;
  76072. /**
  76073. * Gets if the current filter is set to Poisson Sampling.
  76074. */
  76075. /**
  76076. * Sets the current filter to Poisson Sampling.
  76077. */
  76078. usePoissonSampling: boolean;
  76079. /**
  76080. * Gets if the current filter is set to ESM.
  76081. */
  76082. /**
  76083. * Sets the current filter is to ESM.
  76084. */
  76085. useExponentialShadowMap: boolean;
  76086. /**
  76087. * Gets if the current filter is set to filtered ESM.
  76088. */
  76089. /**
  76090. * Gets if the current filter is set to filtered ESM.
  76091. */
  76092. useBlurExponentialShadowMap: boolean;
  76093. /**
  76094. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76095. * exponential to prevent steep falloff artifacts).
  76096. */
  76097. /**
  76098. * Sets the current filter to "close ESM" (using the inverse of the
  76099. * exponential to prevent steep falloff artifacts).
  76100. */
  76101. useCloseExponentialShadowMap: boolean;
  76102. /**
  76103. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76104. * exponential to prevent steep falloff artifacts).
  76105. */
  76106. /**
  76107. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76108. * exponential to prevent steep falloff artifacts).
  76109. */
  76110. useBlurCloseExponentialShadowMap: boolean;
  76111. /**
  76112. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76113. */
  76114. /**
  76115. * Sets the current filter to "PCF" (percentage closer filtering).
  76116. */
  76117. usePercentageCloserFiltering: boolean;
  76118. private _filteringQuality;
  76119. /**
  76120. * Gets the PCF or PCSS Quality.
  76121. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76122. */
  76123. /**
  76124. * Sets the PCF or PCSS Quality.
  76125. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76126. */
  76127. filteringQuality: number;
  76128. /**
  76129. * Gets if the current filter is set to "PCSS" (contact hardening).
  76130. */
  76131. /**
  76132. * Sets the current filter to "PCSS" (contact hardening).
  76133. */
  76134. useContactHardeningShadow: boolean;
  76135. private _contactHardeningLightSizeUVRatio;
  76136. /**
  76137. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76138. * Using a ratio helps keeping shape stability independently of the map size.
  76139. *
  76140. * It does not account for the light projection as it was having too much
  76141. * instability during the light setup or during light position changes.
  76142. *
  76143. * Only valid if useContactHardeningShadow is true.
  76144. */
  76145. /**
  76146. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76147. * Using a ratio helps keeping shape stability independently of the map size.
  76148. *
  76149. * It does not account for the light projection as it was having too much
  76150. * instability during the light setup or during light position changes.
  76151. *
  76152. * Only valid if useContactHardeningShadow is true.
  76153. */
  76154. contactHardeningLightSizeUVRatio: number;
  76155. private _darkness;
  76156. /** Gets or sets the actual darkness of a shadow */
  76157. darkness: number;
  76158. /**
  76159. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76160. * 0 means strongest and 1 would means no shadow.
  76161. * @returns the darkness.
  76162. */
  76163. getDarkness(): number;
  76164. /**
  76165. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76166. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76167. * @returns the shadow generator allowing fluent coding.
  76168. */
  76169. setDarkness(darkness: number): ShadowGenerator;
  76170. private _transparencyShadow;
  76171. /** Gets or sets the ability to have transparent shadow */
  76172. transparencyShadow: boolean;
  76173. /**
  76174. * Sets the ability to have transparent shadow (boolean).
  76175. * @param transparent True if transparent else False
  76176. * @returns the shadow generator allowing fluent coding
  76177. */
  76178. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76179. private _shadowMap;
  76180. private _shadowMap2;
  76181. /**
  76182. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76183. * @returns The render target texture if present otherwise, null
  76184. */
  76185. getShadowMap(): Nullable<RenderTargetTexture>;
  76186. /**
  76187. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76188. * @returns The render target texture if the shadow map is present otherwise, null
  76189. */
  76190. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76191. /**
  76192. * Gets the class name of that object
  76193. * @returns "ShadowGenerator"
  76194. */
  76195. getClassName(): string;
  76196. /**
  76197. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76198. * @param mesh Mesh to add
  76199. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76200. * @returns the Shadow Generator itself
  76201. */
  76202. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76203. /**
  76204. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76205. * @param mesh Mesh to remove
  76206. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76207. * @returns the Shadow Generator itself
  76208. */
  76209. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76210. /**
  76211. * Controls the extent to which the shadows fade out at the edge of the frustum
  76212. * Used only by directionals and spots
  76213. */
  76214. frustumEdgeFalloff: number;
  76215. private _light;
  76216. /**
  76217. * Returns the associated light object.
  76218. * @returns the light generating the shadow
  76219. */
  76220. getLight(): IShadowLight;
  76221. /**
  76222. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76223. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76224. * It might on the other hand introduce peter panning.
  76225. */
  76226. forceBackFacesOnly: boolean;
  76227. private _scene;
  76228. private _lightDirection;
  76229. private _effect;
  76230. private _viewMatrix;
  76231. private _projectionMatrix;
  76232. private _transformMatrix;
  76233. private _cachedPosition;
  76234. private _cachedDirection;
  76235. private _cachedDefines;
  76236. private _currentRenderID;
  76237. private _boxBlurPostprocess;
  76238. private _kernelBlurXPostprocess;
  76239. private _kernelBlurYPostprocess;
  76240. private _blurPostProcesses;
  76241. private _mapSize;
  76242. private _currentFaceIndex;
  76243. private _currentFaceIndexCache;
  76244. private _textureType;
  76245. private _defaultTextureMatrix;
  76246. /** @hidden */
  76247. static _SceneComponentInitialization: (scene: Scene) => void;
  76248. /**
  76249. * Creates a ShadowGenerator object.
  76250. * A ShadowGenerator is the required tool to use the shadows.
  76251. * Each light casting shadows needs to use its own ShadowGenerator.
  76252. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76253. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76254. * @param light The light object generating the shadows.
  76255. * @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.
  76256. */
  76257. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76258. private _initializeGenerator;
  76259. private _initializeShadowMap;
  76260. private _initializeBlurRTTAndPostProcesses;
  76261. private _renderForShadowMap;
  76262. private _renderSubMeshForShadowMap;
  76263. private _applyFilterValues;
  76264. /**
  76265. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76266. * @param onCompiled Callback triggered at the and of the effects compilation
  76267. * @param options Sets of optional options forcing the compilation with different modes
  76268. */
  76269. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76270. useInstances: boolean;
  76271. }>): void;
  76272. /**
  76273. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76274. * @param options Sets of optional options forcing the compilation with different modes
  76275. * @returns A promise that resolves when the compilation completes
  76276. */
  76277. forceCompilationAsync(options?: Partial<{
  76278. useInstances: boolean;
  76279. }>): Promise<void>;
  76280. /**
  76281. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76282. * @param subMesh The submesh we want to render in the shadow map
  76283. * @param useInstances Defines wether will draw in the map using instances
  76284. * @returns true if ready otherwise, false
  76285. */
  76286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76287. /**
  76288. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76289. * @param defines Defines of the material we want to update
  76290. * @param lightIndex Index of the light in the enabled light list of the material
  76291. */
  76292. prepareDefines(defines: any, lightIndex: number): void;
  76293. /**
  76294. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76295. * defined in the generator but impacting the effect).
  76296. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76297. * @param effect The effect we are binfing the information for
  76298. */
  76299. bindShadowLight(lightIndex: string, effect: Effect): void;
  76300. /**
  76301. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76302. * (eq to shadow prjection matrix * light transform matrix)
  76303. * @returns The transform matrix used to create the shadow map
  76304. */
  76305. getTransformMatrix(): Matrix;
  76306. /**
  76307. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76308. * Cube and 2D textures for instance.
  76309. */
  76310. recreateShadowMap(): void;
  76311. private _disposeBlurPostProcesses;
  76312. private _disposeRTTandPostProcesses;
  76313. /**
  76314. * Disposes the ShadowGenerator.
  76315. * Returns nothing.
  76316. */
  76317. dispose(): void;
  76318. /**
  76319. * Serializes the shadow generator setup to a json object.
  76320. * @returns The serialized JSON object
  76321. */
  76322. serialize(): any;
  76323. /**
  76324. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76325. * @param parsedShadowGenerator The JSON object to parse
  76326. * @param scene The scene to create the shadow map for
  76327. * @returns The parsed shadow generator
  76328. */
  76329. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76330. }
  76331. }
  76332. declare module BABYLON {
  76333. /**
  76334. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76335. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76336. * 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.
  76337. */
  76338. export abstract class Light extends Node {
  76339. /**
  76340. * Falloff Default: light is falling off following the material specification:
  76341. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76342. */
  76343. static readonly FALLOFF_DEFAULT: number;
  76344. /**
  76345. * Falloff Physical: light is falling off following the inverse squared distance law.
  76346. */
  76347. static readonly FALLOFF_PHYSICAL: number;
  76348. /**
  76349. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76350. * to enhance interoperability with other engines.
  76351. */
  76352. static readonly FALLOFF_GLTF: number;
  76353. /**
  76354. * Falloff Standard: light is falling off like in the standard material
  76355. * to enhance interoperability with other materials.
  76356. */
  76357. static readonly FALLOFF_STANDARD: number;
  76358. /**
  76359. * If every light affecting the material is in this lightmapMode,
  76360. * material.lightmapTexture adds or multiplies
  76361. * (depends on material.useLightmapAsShadowmap)
  76362. * after every other light calculations.
  76363. */
  76364. static readonly LIGHTMAP_DEFAULT: number;
  76365. /**
  76366. * material.lightmapTexture as only diffuse lighting from this light
  76367. * adds only specular lighting from this light
  76368. * adds dynamic shadows
  76369. */
  76370. static readonly LIGHTMAP_SPECULAR: number;
  76371. /**
  76372. * material.lightmapTexture as only lighting
  76373. * no light calculation from this light
  76374. * only adds dynamic shadows from this light
  76375. */
  76376. static readonly LIGHTMAP_SHADOWSONLY: number;
  76377. /**
  76378. * Each light type uses the default quantity according to its type:
  76379. * point/spot lights use luminous intensity
  76380. * directional lights use illuminance
  76381. */
  76382. static readonly INTENSITYMODE_AUTOMATIC: number;
  76383. /**
  76384. * lumen (lm)
  76385. */
  76386. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76387. /**
  76388. * candela (lm/sr)
  76389. */
  76390. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76391. /**
  76392. * lux (lm/m^2)
  76393. */
  76394. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76395. /**
  76396. * nit (cd/m^2)
  76397. */
  76398. static readonly INTENSITYMODE_LUMINANCE: number;
  76399. /**
  76400. * Light type const id of the point light.
  76401. */
  76402. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76403. /**
  76404. * Light type const id of the directional light.
  76405. */
  76406. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76407. /**
  76408. * Light type const id of the spot light.
  76409. */
  76410. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76411. /**
  76412. * Light type const id of the hemispheric light.
  76413. */
  76414. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76415. /**
  76416. * Diffuse gives the basic color to an object.
  76417. */
  76418. diffuse: Color3;
  76419. /**
  76420. * Specular produces a highlight color on an object.
  76421. * Note: This is note affecting PBR materials.
  76422. */
  76423. specular: Color3;
  76424. /**
  76425. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76426. * falling off base on range or angle.
  76427. * This can be set to any values in Light.FALLOFF_x.
  76428. *
  76429. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76430. * other types of materials.
  76431. */
  76432. falloffType: number;
  76433. /**
  76434. * Strength of the light.
  76435. * Note: By default it is define in the framework own unit.
  76436. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76437. */
  76438. intensity: number;
  76439. private _range;
  76440. protected _inverseSquaredRange: number;
  76441. /**
  76442. * Defines how far from the source the light is impacting in scene units.
  76443. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76444. */
  76445. /**
  76446. * Defines how far from the source the light is impacting in scene units.
  76447. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76448. */
  76449. range: number;
  76450. /**
  76451. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76452. * of light.
  76453. */
  76454. private _photometricScale;
  76455. private _intensityMode;
  76456. /**
  76457. * Gets the photometric scale used to interpret the intensity.
  76458. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76459. */
  76460. /**
  76461. * Sets the photometric scale used to interpret the intensity.
  76462. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76463. */
  76464. intensityMode: number;
  76465. private _radius;
  76466. /**
  76467. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76468. */
  76469. /**
  76470. * sets the light radius used by PBR Materials to simulate soft area lights.
  76471. */
  76472. radius: number;
  76473. private _renderPriority;
  76474. /**
  76475. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76476. * exceeding the number allowed of the materials.
  76477. */
  76478. renderPriority: number;
  76479. private _shadowEnabled;
  76480. /**
  76481. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76482. * the current shadow generator.
  76483. */
  76484. /**
  76485. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76486. * the current shadow generator.
  76487. */
  76488. shadowEnabled: boolean;
  76489. private _includedOnlyMeshes;
  76490. /**
  76491. * Gets the only meshes impacted by this light.
  76492. */
  76493. /**
  76494. * Sets the only meshes impacted by this light.
  76495. */
  76496. includedOnlyMeshes: AbstractMesh[];
  76497. private _excludedMeshes;
  76498. /**
  76499. * Gets the meshes not impacted by this light.
  76500. */
  76501. /**
  76502. * Sets the meshes not impacted by this light.
  76503. */
  76504. excludedMeshes: AbstractMesh[];
  76505. private _excludeWithLayerMask;
  76506. /**
  76507. * Gets the layer id use to find what meshes are not impacted by the light.
  76508. * Inactive if 0
  76509. */
  76510. /**
  76511. * Sets the layer id use to find what meshes are not impacted by the light.
  76512. * Inactive if 0
  76513. */
  76514. excludeWithLayerMask: number;
  76515. private _includeOnlyWithLayerMask;
  76516. /**
  76517. * Gets the layer id use to find what meshes are impacted by the light.
  76518. * Inactive if 0
  76519. */
  76520. /**
  76521. * Sets the layer id use to find what meshes are impacted by the light.
  76522. * Inactive if 0
  76523. */
  76524. includeOnlyWithLayerMask: number;
  76525. private _lightmapMode;
  76526. /**
  76527. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76528. */
  76529. /**
  76530. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76531. */
  76532. lightmapMode: number;
  76533. /**
  76534. * Shadow generator associted to the light.
  76535. * @hidden Internal use only.
  76536. */
  76537. _shadowGenerator: Nullable<IShadowGenerator>;
  76538. /**
  76539. * @hidden Internal use only.
  76540. */
  76541. _excludedMeshesIds: string[];
  76542. /**
  76543. * @hidden Internal use only.
  76544. */
  76545. _includedOnlyMeshesIds: string[];
  76546. /**
  76547. * The current light unifom buffer.
  76548. * @hidden Internal use only.
  76549. */
  76550. _uniformBuffer: UniformBuffer;
  76551. /**
  76552. * Creates a Light object in the scene.
  76553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76554. * @param name The firendly name of the light
  76555. * @param scene The scene the light belongs too
  76556. */
  76557. constructor(name: string, scene: Scene);
  76558. protected abstract _buildUniformLayout(): void;
  76559. /**
  76560. * Sets the passed Effect "effect" with the Light information.
  76561. * @param effect The effect to update
  76562. * @param lightIndex The index of the light in the effect to update
  76563. * @returns The light
  76564. */
  76565. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76566. /**
  76567. * Sets the passed Effect "effect" with the Light information.
  76568. * @param effect The effect to update
  76569. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76570. * @returns The light
  76571. */
  76572. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76573. /**
  76574. * Returns the string "Light".
  76575. * @returns the class name
  76576. */
  76577. getClassName(): string;
  76578. /** @hidden */
  76579. readonly _isLight: boolean;
  76580. /**
  76581. * Converts the light information to a readable string for debug purpose.
  76582. * @param fullDetails Supports for multiple levels of logging within scene loading
  76583. * @returns the human readable light info
  76584. */
  76585. toString(fullDetails?: boolean): string;
  76586. /** @hidden */
  76587. protected _syncParentEnabledState(): void;
  76588. /**
  76589. * Set the enabled state of this node.
  76590. * @param value - the new enabled state
  76591. */
  76592. setEnabled(value: boolean): void;
  76593. /**
  76594. * Returns the Light associated shadow generator if any.
  76595. * @return the associated shadow generator.
  76596. */
  76597. getShadowGenerator(): Nullable<IShadowGenerator>;
  76598. /**
  76599. * Returns a Vector3, the absolute light position in the World.
  76600. * @returns the world space position of the light
  76601. */
  76602. getAbsolutePosition(): Vector3;
  76603. /**
  76604. * Specifies if the light will affect the passed mesh.
  76605. * @param mesh The mesh to test against the light
  76606. * @return true the mesh is affected otherwise, false.
  76607. */
  76608. canAffectMesh(mesh: AbstractMesh): boolean;
  76609. /**
  76610. * Sort function to order lights for rendering.
  76611. * @param a First Light object to compare to second.
  76612. * @param b Second Light object to compare first.
  76613. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76614. */
  76615. static CompareLightsPriority(a: Light, b: Light): number;
  76616. /**
  76617. * Releases resources associated with this node.
  76618. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76619. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76620. */
  76621. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76622. /**
  76623. * Returns the light type ID (integer).
  76624. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76625. */
  76626. getTypeID(): number;
  76627. /**
  76628. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76629. * @returns the scaled intensity in intensity mode unit
  76630. */
  76631. getScaledIntensity(): number;
  76632. /**
  76633. * Returns a new Light object, named "name", from the current one.
  76634. * @param name The name of the cloned light
  76635. * @returns the new created light
  76636. */
  76637. clone(name: string): Nullable<Light>;
  76638. /**
  76639. * Serializes the current light into a Serialization object.
  76640. * @returns the serialized object.
  76641. */
  76642. serialize(): any;
  76643. /**
  76644. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76645. * This new light is named "name" and added to the passed scene.
  76646. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76647. * @param name The friendly name of the light
  76648. * @param scene The scene the new light will belong to
  76649. * @returns the constructor function
  76650. */
  76651. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76652. /**
  76653. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76654. * @param parsedLight The JSON representation of the light
  76655. * @param scene The scene to create the parsed light in
  76656. * @returns the created light after parsing
  76657. */
  76658. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76659. private _hookArrayForExcluded;
  76660. private _hookArrayForIncludedOnly;
  76661. private _resyncMeshes;
  76662. /**
  76663. * Forces the meshes to update their light related information in their rendering used effects
  76664. * @hidden Internal Use Only
  76665. */
  76666. _markMeshesAsLightDirty(): void;
  76667. /**
  76668. * Recomputes the cached photometric scale if needed.
  76669. */
  76670. private _computePhotometricScale;
  76671. /**
  76672. * Returns the Photometric Scale according to the light type and intensity mode.
  76673. */
  76674. private _getPhotometricScale;
  76675. /**
  76676. * Reorder the light in the scene according to their defined priority.
  76677. * @hidden Internal Use Only
  76678. */
  76679. _reorderLightsInScene(): void;
  76680. /**
  76681. * Prepares the list of defines specific to the light type.
  76682. * @param defines the list of defines
  76683. * @param lightIndex defines the index of the light for the effect
  76684. */
  76685. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76686. }
  76687. }
  76688. declare module BABYLON {
  76689. /**
  76690. * Interface used to define Action
  76691. */
  76692. export interface IAction {
  76693. /**
  76694. * Trigger for the action
  76695. */
  76696. trigger: number;
  76697. /** Options of the trigger */
  76698. triggerOptions: any;
  76699. /**
  76700. * Gets the trigger parameters
  76701. * @returns the trigger parameters
  76702. */
  76703. getTriggerParameter(): any;
  76704. /**
  76705. * Internal only - executes current action event
  76706. * @hidden
  76707. */
  76708. _executeCurrent(evt?: ActionEvent): void;
  76709. /**
  76710. * Serialize placeholder for child classes
  76711. * @param parent of child
  76712. * @returns the serialized object
  76713. */
  76714. serialize(parent: any): any;
  76715. /**
  76716. * Internal only
  76717. * @hidden
  76718. */
  76719. _prepare(): void;
  76720. /**
  76721. * Internal only - manager for action
  76722. * @hidden
  76723. */
  76724. _actionManager: AbstractActionManager;
  76725. /**
  76726. * Adds action to chain of actions, may be a DoNothingAction
  76727. * @param action defines the next action to execute
  76728. * @returns The action passed in
  76729. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76730. */
  76731. then(action: IAction): IAction;
  76732. }
  76733. /**
  76734. * The action to be carried out following a trigger
  76735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76736. */
  76737. export class Action implements IAction {
  76738. /** the trigger, with or without parameters, for the action */
  76739. triggerOptions: any;
  76740. /**
  76741. * Trigger for the action
  76742. */
  76743. trigger: number;
  76744. /**
  76745. * Internal only - manager for action
  76746. * @hidden
  76747. */
  76748. _actionManager: ActionManager;
  76749. private _nextActiveAction;
  76750. private _child;
  76751. private _condition?;
  76752. private _triggerParameter;
  76753. /**
  76754. * An event triggered prior to action being executed.
  76755. */
  76756. onBeforeExecuteObservable: Observable<Action>;
  76757. /**
  76758. * Creates a new Action
  76759. * @param triggerOptions the trigger, with or without parameters, for the action
  76760. * @param condition an optional determinant of action
  76761. */
  76762. constructor(
  76763. /** the trigger, with or without parameters, for the action */
  76764. triggerOptions: any, condition?: Condition);
  76765. /**
  76766. * Internal only
  76767. * @hidden
  76768. */
  76769. _prepare(): void;
  76770. /**
  76771. * Gets the trigger parameters
  76772. * @returns the trigger parameters
  76773. */
  76774. getTriggerParameter(): any;
  76775. /**
  76776. * Internal only - executes current action event
  76777. * @hidden
  76778. */
  76779. _executeCurrent(evt?: ActionEvent): void;
  76780. /**
  76781. * Execute placeholder for child classes
  76782. * @param evt optional action event
  76783. */
  76784. execute(evt?: ActionEvent): void;
  76785. /**
  76786. * Skips to next active action
  76787. */
  76788. skipToNextActiveAction(): void;
  76789. /**
  76790. * Adds action to chain of actions, may be a DoNothingAction
  76791. * @param action defines the next action to execute
  76792. * @returns The action passed in
  76793. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76794. */
  76795. then(action: Action): Action;
  76796. /**
  76797. * Internal only
  76798. * @hidden
  76799. */
  76800. _getProperty(propertyPath: string): string;
  76801. /**
  76802. * Internal only
  76803. * @hidden
  76804. */
  76805. _getEffectiveTarget(target: any, propertyPath: string): any;
  76806. /**
  76807. * Serialize placeholder for child classes
  76808. * @param parent of child
  76809. * @returns the serialized object
  76810. */
  76811. serialize(parent: any): any;
  76812. /**
  76813. * Internal only called by serialize
  76814. * @hidden
  76815. */
  76816. protected _serialize(serializedAction: any, parent?: any): any;
  76817. /**
  76818. * Internal only
  76819. * @hidden
  76820. */
  76821. static _SerializeValueAsString: (value: any) => string;
  76822. /**
  76823. * Internal only
  76824. * @hidden
  76825. */
  76826. static _GetTargetProperty: (target: Node | Scene) => {
  76827. name: string;
  76828. targetType: string;
  76829. value: string;
  76830. };
  76831. }
  76832. }
  76833. declare module BABYLON {
  76834. /**
  76835. * A Condition applied to an Action
  76836. */
  76837. export class Condition {
  76838. /**
  76839. * Internal only - manager for action
  76840. * @hidden
  76841. */
  76842. _actionManager: ActionManager;
  76843. /**
  76844. * Internal only
  76845. * @hidden
  76846. */
  76847. _evaluationId: number;
  76848. /**
  76849. * Internal only
  76850. * @hidden
  76851. */
  76852. _currentResult: boolean;
  76853. /**
  76854. * Creates a new Condition
  76855. * @param actionManager the manager of the action the condition is applied to
  76856. */
  76857. constructor(actionManager: ActionManager);
  76858. /**
  76859. * Check if the current condition is valid
  76860. * @returns a boolean
  76861. */
  76862. isValid(): boolean;
  76863. /**
  76864. * Internal only
  76865. * @hidden
  76866. */
  76867. _getProperty(propertyPath: string): string;
  76868. /**
  76869. * Internal only
  76870. * @hidden
  76871. */
  76872. _getEffectiveTarget(target: any, propertyPath: string): any;
  76873. /**
  76874. * Serialize placeholder for child classes
  76875. * @returns the serialized object
  76876. */
  76877. serialize(): any;
  76878. /**
  76879. * Internal only
  76880. * @hidden
  76881. */
  76882. protected _serialize(serializedCondition: any): any;
  76883. }
  76884. /**
  76885. * Defines specific conditional operators as extensions of Condition
  76886. */
  76887. export class ValueCondition extends Condition {
  76888. /** path to specify the property of the target the conditional operator uses */
  76889. propertyPath: string;
  76890. /** the value compared by the conditional operator against the current value of the property */
  76891. value: any;
  76892. /** the conditional operator, default ValueCondition.IsEqual */
  76893. operator: number;
  76894. /**
  76895. * Internal only
  76896. * @hidden
  76897. */
  76898. private static _IsEqual;
  76899. /**
  76900. * Internal only
  76901. * @hidden
  76902. */
  76903. private static _IsDifferent;
  76904. /**
  76905. * Internal only
  76906. * @hidden
  76907. */
  76908. private static _IsGreater;
  76909. /**
  76910. * Internal only
  76911. * @hidden
  76912. */
  76913. private static _IsLesser;
  76914. /**
  76915. * returns the number for IsEqual
  76916. */
  76917. static readonly IsEqual: number;
  76918. /**
  76919. * Returns the number for IsDifferent
  76920. */
  76921. static readonly IsDifferent: number;
  76922. /**
  76923. * Returns the number for IsGreater
  76924. */
  76925. static readonly IsGreater: number;
  76926. /**
  76927. * Returns the number for IsLesser
  76928. */
  76929. static readonly IsLesser: number;
  76930. /**
  76931. * Internal only The action manager for the condition
  76932. * @hidden
  76933. */
  76934. _actionManager: ActionManager;
  76935. /**
  76936. * Internal only
  76937. * @hidden
  76938. */
  76939. private _target;
  76940. /**
  76941. * Internal only
  76942. * @hidden
  76943. */
  76944. private _effectiveTarget;
  76945. /**
  76946. * Internal only
  76947. * @hidden
  76948. */
  76949. private _property;
  76950. /**
  76951. * Creates a new ValueCondition
  76952. * @param actionManager manager for the action the condition applies to
  76953. * @param target for the action
  76954. * @param propertyPath path to specify the property of the target the conditional operator uses
  76955. * @param value the value compared by the conditional operator against the current value of the property
  76956. * @param operator the conditional operator, default ValueCondition.IsEqual
  76957. */
  76958. constructor(actionManager: ActionManager, target: any,
  76959. /** path to specify the property of the target the conditional operator uses */
  76960. propertyPath: string,
  76961. /** the value compared by the conditional operator against the current value of the property */
  76962. value: any,
  76963. /** the conditional operator, default ValueCondition.IsEqual */
  76964. operator?: number);
  76965. /**
  76966. * Compares the given value with the property value for the specified conditional operator
  76967. * @returns the result of the comparison
  76968. */
  76969. isValid(): boolean;
  76970. /**
  76971. * Serialize the ValueCondition into a JSON compatible object
  76972. * @returns serialization object
  76973. */
  76974. serialize(): any;
  76975. /**
  76976. * Gets the name of the conditional operator for the ValueCondition
  76977. * @param operator the conditional operator
  76978. * @returns the name
  76979. */
  76980. static GetOperatorName(operator: number): string;
  76981. }
  76982. /**
  76983. * Defines a predicate condition as an extension of Condition
  76984. */
  76985. export class PredicateCondition extends Condition {
  76986. /** defines the predicate function used to validate the condition */
  76987. predicate: () => boolean;
  76988. /**
  76989. * Internal only - manager for action
  76990. * @hidden
  76991. */
  76992. _actionManager: ActionManager;
  76993. /**
  76994. * Creates a new PredicateCondition
  76995. * @param actionManager manager for the action the condition applies to
  76996. * @param predicate defines the predicate function used to validate the condition
  76997. */
  76998. constructor(actionManager: ActionManager,
  76999. /** defines the predicate function used to validate the condition */
  77000. predicate: () => boolean);
  77001. /**
  77002. * @returns the validity of the predicate condition
  77003. */
  77004. isValid(): boolean;
  77005. }
  77006. /**
  77007. * Defines a state condition as an extension of Condition
  77008. */
  77009. export class StateCondition extends Condition {
  77010. /** Value to compare with target state */
  77011. value: string;
  77012. /**
  77013. * Internal only - manager for action
  77014. * @hidden
  77015. */
  77016. _actionManager: ActionManager;
  77017. /**
  77018. * Internal only
  77019. * @hidden
  77020. */
  77021. private _target;
  77022. /**
  77023. * Creates a new StateCondition
  77024. * @param actionManager manager for the action the condition applies to
  77025. * @param target of the condition
  77026. * @param value to compare with target state
  77027. */
  77028. constructor(actionManager: ActionManager, target: any,
  77029. /** Value to compare with target state */
  77030. value: string);
  77031. /**
  77032. * Gets a boolean indicating if the current condition is met
  77033. * @returns the validity of the state
  77034. */
  77035. isValid(): boolean;
  77036. /**
  77037. * Serialize the StateCondition into a JSON compatible object
  77038. * @returns serialization object
  77039. */
  77040. serialize(): any;
  77041. }
  77042. }
  77043. declare module BABYLON {
  77044. /**
  77045. * This defines an action responsible to toggle a boolean once triggered.
  77046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77047. */
  77048. export class SwitchBooleanAction extends Action {
  77049. /**
  77050. * The path to the boolean property in the target object
  77051. */
  77052. propertyPath: string;
  77053. private _target;
  77054. private _effectiveTarget;
  77055. private _property;
  77056. /**
  77057. * Instantiate the action
  77058. * @param triggerOptions defines the trigger options
  77059. * @param target defines the object containing the boolean
  77060. * @param propertyPath defines the path to the boolean property in the target object
  77061. * @param condition defines the trigger related conditions
  77062. */
  77063. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77064. /** @hidden */
  77065. _prepare(): void;
  77066. /**
  77067. * Execute the action toggle the boolean value.
  77068. */
  77069. execute(): void;
  77070. /**
  77071. * Serializes the actions and its related information.
  77072. * @param parent defines the object to serialize in
  77073. * @returns the serialized object
  77074. */
  77075. serialize(parent: any): any;
  77076. }
  77077. /**
  77078. * This defines an action responsible to set a the state field of the target
  77079. * to a desired value once triggered.
  77080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77081. */
  77082. export class SetStateAction extends Action {
  77083. /**
  77084. * The value to store in the state field.
  77085. */
  77086. value: string;
  77087. private _target;
  77088. /**
  77089. * Instantiate the action
  77090. * @param triggerOptions defines the trigger options
  77091. * @param target defines the object containing the state property
  77092. * @param value defines the value to store in the state field
  77093. * @param condition defines the trigger related conditions
  77094. */
  77095. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77096. /**
  77097. * Execute the action and store the value on the target state property.
  77098. */
  77099. execute(): void;
  77100. /**
  77101. * Serializes the actions and its related information.
  77102. * @param parent defines the object to serialize in
  77103. * @returns the serialized object
  77104. */
  77105. serialize(parent: any): any;
  77106. }
  77107. /**
  77108. * This defines an action responsible to set a property of the target
  77109. * to a desired value once triggered.
  77110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77111. */
  77112. export class SetValueAction extends Action {
  77113. /**
  77114. * The path of the property to set in the target.
  77115. */
  77116. propertyPath: string;
  77117. /**
  77118. * The value to set in the property
  77119. */
  77120. value: any;
  77121. private _target;
  77122. private _effectiveTarget;
  77123. private _property;
  77124. /**
  77125. * Instantiate the action
  77126. * @param triggerOptions defines the trigger options
  77127. * @param target defines the object containing the property
  77128. * @param propertyPath defines the path of the property to set in the target
  77129. * @param value defines the value to set in the property
  77130. * @param condition defines the trigger related conditions
  77131. */
  77132. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77133. /** @hidden */
  77134. _prepare(): void;
  77135. /**
  77136. * Execute the action and set the targetted property to the desired value.
  77137. */
  77138. execute(): void;
  77139. /**
  77140. * Serializes the actions and its related information.
  77141. * @param parent defines the object to serialize in
  77142. * @returns the serialized object
  77143. */
  77144. serialize(parent: any): any;
  77145. }
  77146. /**
  77147. * This defines an action responsible to increment the target value
  77148. * to a desired value once triggered.
  77149. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77150. */
  77151. export class IncrementValueAction extends Action {
  77152. /**
  77153. * The path of the property to increment in the target.
  77154. */
  77155. propertyPath: string;
  77156. /**
  77157. * The value we should increment the property by.
  77158. */
  77159. value: any;
  77160. private _target;
  77161. private _effectiveTarget;
  77162. private _property;
  77163. /**
  77164. * Instantiate the action
  77165. * @param triggerOptions defines the trigger options
  77166. * @param target defines the object containing the property
  77167. * @param propertyPath defines the path of the property to increment in the target
  77168. * @param value defines the value value we should increment the property by
  77169. * @param condition defines the trigger related conditions
  77170. */
  77171. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77172. /** @hidden */
  77173. _prepare(): void;
  77174. /**
  77175. * Execute the action and increment the target of the value amount.
  77176. */
  77177. execute(): void;
  77178. /**
  77179. * Serializes the actions and its related information.
  77180. * @param parent defines the object to serialize in
  77181. * @returns the serialized object
  77182. */
  77183. serialize(parent: any): any;
  77184. }
  77185. /**
  77186. * This defines an action responsible to start an animation once triggered.
  77187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77188. */
  77189. export class PlayAnimationAction extends Action {
  77190. /**
  77191. * Where the animation should start (animation frame)
  77192. */
  77193. from: number;
  77194. /**
  77195. * Where the animation should stop (animation frame)
  77196. */
  77197. to: number;
  77198. /**
  77199. * Define if the animation should loop or stop after the first play.
  77200. */
  77201. loop?: boolean;
  77202. private _target;
  77203. /**
  77204. * Instantiate the action
  77205. * @param triggerOptions defines the trigger options
  77206. * @param target defines the target animation or animation name
  77207. * @param from defines from where the animation should start (animation frame)
  77208. * @param end defines where the animation should stop (animation frame)
  77209. * @param loop defines if the animation should loop or stop after the first play
  77210. * @param condition defines the trigger related conditions
  77211. */
  77212. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77213. /** @hidden */
  77214. _prepare(): void;
  77215. /**
  77216. * Execute the action and play the animation.
  77217. */
  77218. execute(): void;
  77219. /**
  77220. * Serializes the actions and its related information.
  77221. * @param parent defines the object to serialize in
  77222. * @returns the serialized object
  77223. */
  77224. serialize(parent: any): any;
  77225. }
  77226. /**
  77227. * This defines an action responsible to stop an animation once triggered.
  77228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77229. */
  77230. export class StopAnimationAction extends Action {
  77231. private _target;
  77232. /**
  77233. * Instantiate the action
  77234. * @param triggerOptions defines the trigger options
  77235. * @param target defines the target animation or animation name
  77236. * @param condition defines the trigger related conditions
  77237. */
  77238. constructor(triggerOptions: any, target: any, condition?: Condition);
  77239. /** @hidden */
  77240. _prepare(): void;
  77241. /**
  77242. * Execute the action and stop the animation.
  77243. */
  77244. execute(): void;
  77245. /**
  77246. * Serializes the actions and its related information.
  77247. * @param parent defines the object to serialize in
  77248. * @returns the serialized object
  77249. */
  77250. serialize(parent: any): any;
  77251. }
  77252. /**
  77253. * This defines an action responsible that does nothing once triggered.
  77254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77255. */
  77256. export class DoNothingAction extends Action {
  77257. /**
  77258. * Instantiate the action
  77259. * @param triggerOptions defines the trigger options
  77260. * @param condition defines the trigger related conditions
  77261. */
  77262. constructor(triggerOptions?: any, condition?: Condition);
  77263. /**
  77264. * Execute the action and do nothing.
  77265. */
  77266. execute(): void;
  77267. /**
  77268. * Serializes the actions and its related information.
  77269. * @param parent defines the object to serialize in
  77270. * @returns the serialized object
  77271. */
  77272. serialize(parent: any): any;
  77273. }
  77274. /**
  77275. * This defines an action responsible to trigger several actions once triggered.
  77276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77277. */
  77278. export class CombineAction extends Action {
  77279. /**
  77280. * The list of aggregated animations to run.
  77281. */
  77282. children: Action[];
  77283. /**
  77284. * Instantiate the action
  77285. * @param triggerOptions defines the trigger options
  77286. * @param children defines the list of aggregated animations to run
  77287. * @param condition defines the trigger related conditions
  77288. */
  77289. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77290. /** @hidden */
  77291. _prepare(): void;
  77292. /**
  77293. * Execute the action and executes all the aggregated actions.
  77294. */
  77295. execute(evt: ActionEvent): void;
  77296. /**
  77297. * Serializes the actions and its related information.
  77298. * @param parent defines the object to serialize in
  77299. * @returns the serialized object
  77300. */
  77301. serialize(parent: any): any;
  77302. }
  77303. /**
  77304. * This defines an action responsible to run code (external event) once triggered.
  77305. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77306. */
  77307. export class ExecuteCodeAction extends Action {
  77308. /**
  77309. * The callback function to run.
  77310. */
  77311. func: (evt: ActionEvent) => void;
  77312. /**
  77313. * Instantiate the action
  77314. * @param triggerOptions defines the trigger options
  77315. * @param func defines the callback function to run
  77316. * @param condition defines the trigger related conditions
  77317. */
  77318. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77319. /**
  77320. * Execute the action and run the attached code.
  77321. */
  77322. execute(evt: ActionEvent): void;
  77323. }
  77324. /**
  77325. * This defines an action responsible to set the parent property of the target once triggered.
  77326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77327. */
  77328. export class SetParentAction extends Action {
  77329. private _parent;
  77330. private _target;
  77331. /**
  77332. * Instantiate the action
  77333. * @param triggerOptions defines the trigger options
  77334. * @param target defines the target containing the parent property
  77335. * @param parent defines from where the animation should start (animation frame)
  77336. * @param condition defines the trigger related conditions
  77337. */
  77338. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77339. /** @hidden */
  77340. _prepare(): void;
  77341. /**
  77342. * Execute the action and set the parent property.
  77343. */
  77344. execute(): void;
  77345. /**
  77346. * Serializes the actions and its related information.
  77347. * @param parent defines the object to serialize in
  77348. * @returns the serialized object
  77349. */
  77350. serialize(parent: any): any;
  77351. }
  77352. }
  77353. declare module BABYLON {
  77354. /**
  77355. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77356. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77358. */
  77359. export class ActionManager extends AbstractActionManager {
  77360. /**
  77361. * Nothing
  77362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77363. */
  77364. static readonly NothingTrigger: number;
  77365. /**
  77366. * On pick
  77367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77368. */
  77369. static readonly OnPickTrigger: number;
  77370. /**
  77371. * On left pick
  77372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77373. */
  77374. static readonly OnLeftPickTrigger: number;
  77375. /**
  77376. * On right pick
  77377. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77378. */
  77379. static readonly OnRightPickTrigger: number;
  77380. /**
  77381. * On center pick
  77382. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77383. */
  77384. static readonly OnCenterPickTrigger: number;
  77385. /**
  77386. * On pick down
  77387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77388. */
  77389. static readonly OnPickDownTrigger: number;
  77390. /**
  77391. * On double pick
  77392. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77393. */
  77394. static readonly OnDoublePickTrigger: number;
  77395. /**
  77396. * On pick up
  77397. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77398. */
  77399. static readonly OnPickUpTrigger: number;
  77400. /**
  77401. * On pick out.
  77402. * This trigger will only be raised if you also declared a OnPickDown
  77403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77404. */
  77405. static readonly OnPickOutTrigger: number;
  77406. /**
  77407. * On long press
  77408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77409. */
  77410. static readonly OnLongPressTrigger: number;
  77411. /**
  77412. * On pointer over
  77413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77414. */
  77415. static readonly OnPointerOverTrigger: number;
  77416. /**
  77417. * On pointer out
  77418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77419. */
  77420. static readonly OnPointerOutTrigger: number;
  77421. /**
  77422. * On every frame
  77423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77424. */
  77425. static readonly OnEveryFrameTrigger: number;
  77426. /**
  77427. * On intersection enter
  77428. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77429. */
  77430. static readonly OnIntersectionEnterTrigger: number;
  77431. /**
  77432. * On intersection exit
  77433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77434. */
  77435. static readonly OnIntersectionExitTrigger: number;
  77436. /**
  77437. * On key down
  77438. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77439. */
  77440. static readonly OnKeyDownTrigger: number;
  77441. /**
  77442. * On key up
  77443. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77444. */
  77445. static readonly OnKeyUpTrigger: number;
  77446. private _scene;
  77447. /**
  77448. * Creates a new action manager
  77449. * @param scene defines the hosting scene
  77450. */
  77451. constructor(scene: Scene);
  77452. /**
  77453. * Releases all associated resources
  77454. */
  77455. dispose(): void;
  77456. /**
  77457. * Gets hosting scene
  77458. * @returns the hosting scene
  77459. */
  77460. getScene(): Scene;
  77461. /**
  77462. * Does this action manager handles actions of any of the given triggers
  77463. * @param triggers defines the triggers to be tested
  77464. * @return a boolean indicating whether one (or more) of the triggers is handled
  77465. */
  77466. hasSpecificTriggers(triggers: number[]): boolean;
  77467. /**
  77468. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77469. * speed.
  77470. * @param triggerA defines the trigger to be tested
  77471. * @param triggerB defines the trigger to be tested
  77472. * @return a boolean indicating whether one (or more) of the triggers is handled
  77473. */
  77474. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77475. /**
  77476. * Does this action manager handles actions of a given trigger
  77477. * @param trigger defines the trigger to be tested
  77478. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77479. * @return whether the trigger is handled
  77480. */
  77481. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77482. /**
  77483. * Does this action manager has pointer triggers
  77484. */
  77485. readonly hasPointerTriggers: boolean;
  77486. /**
  77487. * Does this action manager has pick triggers
  77488. */
  77489. readonly hasPickTriggers: boolean;
  77490. /**
  77491. * Registers an action to this action manager
  77492. * @param action defines the action to be registered
  77493. * @return the action amended (prepared) after registration
  77494. */
  77495. registerAction(action: IAction): Nullable<IAction>;
  77496. /**
  77497. * Unregisters an action to this action manager
  77498. * @param action defines the action to be unregistered
  77499. * @return a boolean indicating whether the action has been unregistered
  77500. */
  77501. unregisterAction(action: IAction): Boolean;
  77502. /**
  77503. * Process a specific trigger
  77504. * @param trigger defines the trigger to process
  77505. * @param evt defines the event details to be processed
  77506. */
  77507. processTrigger(trigger: number, evt?: IActionEvent): void;
  77508. /** @hidden */
  77509. _getEffectiveTarget(target: any, propertyPath: string): any;
  77510. /** @hidden */
  77511. _getProperty(propertyPath: string): string;
  77512. /**
  77513. * Serialize this manager to a JSON object
  77514. * @param name defines the property name to store this manager
  77515. * @returns a JSON representation of this manager
  77516. */
  77517. serialize(name: string): any;
  77518. /**
  77519. * Creates a new ActionManager from a JSON data
  77520. * @param parsedActions defines the JSON data to read from
  77521. * @param object defines the hosting mesh
  77522. * @param scene defines the hosting scene
  77523. */
  77524. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77525. /**
  77526. * Get a trigger name by index
  77527. * @param trigger defines the trigger index
  77528. * @returns a trigger name
  77529. */
  77530. static GetTriggerName(trigger: number): string;
  77531. }
  77532. }
  77533. declare module BABYLON {
  77534. /**
  77535. * Class representing a ray with position and direction
  77536. */
  77537. export class Ray {
  77538. /** origin point */
  77539. origin: Vector3;
  77540. /** direction */
  77541. direction: Vector3;
  77542. /** length of the ray */
  77543. length: number;
  77544. private static readonly TmpVector3;
  77545. private _tmpRay;
  77546. /**
  77547. * Creates a new ray
  77548. * @param origin origin point
  77549. * @param direction direction
  77550. * @param length length of the ray
  77551. */
  77552. constructor(
  77553. /** origin point */
  77554. origin: Vector3,
  77555. /** direction */
  77556. direction: Vector3,
  77557. /** length of the ray */
  77558. length?: number);
  77559. /**
  77560. * Checks if the ray intersects a box
  77561. * @param minimum bound of the box
  77562. * @param maximum bound of the box
  77563. * @param intersectionTreshold extra extend to be added to the box in all direction
  77564. * @returns if the box was hit
  77565. */
  77566. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77567. /**
  77568. * Checks if the ray intersects a box
  77569. * @param box the bounding box to check
  77570. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77571. * @returns if the box was hit
  77572. */
  77573. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77574. /**
  77575. * If the ray hits a sphere
  77576. * @param sphere the bounding sphere to check
  77577. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77578. * @returns true if it hits the sphere
  77579. */
  77580. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77581. /**
  77582. * If the ray hits a triange
  77583. * @param vertex0 triangle vertex
  77584. * @param vertex1 triangle vertex
  77585. * @param vertex2 triangle vertex
  77586. * @returns intersection information if hit
  77587. */
  77588. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77589. /**
  77590. * Checks if ray intersects a plane
  77591. * @param plane the plane to check
  77592. * @returns the distance away it was hit
  77593. */
  77594. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77595. /**
  77596. * Calculate the intercept of a ray on a given axis
  77597. * @param axis to check 'x' | 'y' | 'z'
  77598. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77599. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77600. */
  77601. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77602. /**
  77603. * Checks if ray intersects a mesh
  77604. * @param mesh the mesh to check
  77605. * @param fastCheck if only the bounding box should checked
  77606. * @returns picking info of the intersecton
  77607. */
  77608. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77609. /**
  77610. * Checks if ray intersects a mesh
  77611. * @param meshes the meshes to check
  77612. * @param fastCheck if only the bounding box should checked
  77613. * @param results array to store result in
  77614. * @returns Array of picking infos
  77615. */
  77616. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77617. private _comparePickingInfo;
  77618. private static smallnum;
  77619. private static rayl;
  77620. /**
  77621. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77622. * @param sega the first point of the segment to test the intersection against
  77623. * @param segb the second point of the segment to test the intersection against
  77624. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77625. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77626. */
  77627. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77628. /**
  77629. * Update the ray from viewport position
  77630. * @param x position
  77631. * @param y y position
  77632. * @param viewportWidth viewport width
  77633. * @param viewportHeight viewport height
  77634. * @param world world matrix
  77635. * @param view view matrix
  77636. * @param projection projection matrix
  77637. * @returns this ray updated
  77638. */
  77639. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77640. /**
  77641. * Creates a ray with origin and direction of 0,0,0
  77642. * @returns the new ray
  77643. */
  77644. static Zero(): Ray;
  77645. /**
  77646. * Creates a new ray from screen space and viewport
  77647. * @param x position
  77648. * @param y y position
  77649. * @param viewportWidth viewport width
  77650. * @param viewportHeight viewport height
  77651. * @param world world matrix
  77652. * @param view view matrix
  77653. * @param projection projection matrix
  77654. * @returns new ray
  77655. */
  77656. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77657. /**
  77658. * 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
  77659. * transformed to the given world matrix.
  77660. * @param origin The origin point
  77661. * @param end The end point
  77662. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77663. * @returns the new ray
  77664. */
  77665. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77666. /**
  77667. * Transforms a ray by a matrix
  77668. * @param ray ray to transform
  77669. * @param matrix matrix to apply
  77670. * @returns the resulting new ray
  77671. */
  77672. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77673. /**
  77674. * Transforms a ray by a matrix
  77675. * @param ray ray to transform
  77676. * @param matrix matrix to apply
  77677. * @param result ray to store result in
  77678. */
  77679. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77680. /**
  77681. * Unproject a ray from screen space to object space
  77682. * @param sourceX defines the screen space x coordinate to use
  77683. * @param sourceY defines the screen space y coordinate to use
  77684. * @param viewportWidth defines the current width of the viewport
  77685. * @param viewportHeight defines the current height of the viewport
  77686. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77687. * @param view defines the view matrix to use
  77688. * @param projection defines the projection matrix to use
  77689. */
  77690. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77691. }
  77692. /**
  77693. * Type used to define predicate used to select faces when a mesh intersection is detected
  77694. */
  77695. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77696. interface Scene {
  77697. /** @hidden */
  77698. _tempPickingRay: Nullable<Ray>;
  77699. /** @hidden */
  77700. _cachedRayForTransform: Ray;
  77701. /** @hidden */
  77702. _pickWithRayInverseMatrix: Matrix;
  77703. /** @hidden */
  77704. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77705. /** @hidden */
  77706. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77707. }
  77708. }
  77709. declare module BABYLON {
  77710. /**
  77711. * Groups all the scene component constants in one place to ease maintenance.
  77712. * @hidden
  77713. */
  77714. export class SceneComponentConstants {
  77715. static readonly NAME_EFFECTLAYER: string;
  77716. static readonly NAME_LAYER: string;
  77717. static readonly NAME_LENSFLARESYSTEM: string;
  77718. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77719. static readonly NAME_PARTICLESYSTEM: string;
  77720. static readonly NAME_GAMEPAD: string;
  77721. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77722. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77723. static readonly NAME_DEPTHRENDERER: string;
  77724. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77725. static readonly NAME_SPRITE: string;
  77726. static readonly NAME_OUTLINERENDERER: string;
  77727. static readonly NAME_PROCEDURALTEXTURE: string;
  77728. static readonly NAME_SHADOWGENERATOR: string;
  77729. static readonly NAME_OCTREE: string;
  77730. static readonly NAME_PHYSICSENGINE: string;
  77731. static readonly NAME_AUDIO: string;
  77732. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77733. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77734. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77735. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77736. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77737. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77738. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77739. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77740. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77741. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77742. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77743. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77744. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77745. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77746. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77747. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77748. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77749. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77750. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77751. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77752. static readonly STEP_AFTERRENDER_AUDIO: number;
  77753. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77754. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77755. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77756. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77757. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77758. static readonly STEP_POINTERMOVE_SPRITE: number;
  77759. static readonly STEP_POINTERDOWN_SPRITE: number;
  77760. static readonly STEP_POINTERUP_SPRITE: number;
  77761. }
  77762. /**
  77763. * This represents a scene component.
  77764. *
  77765. * This is used to decouple the dependency the scene is having on the different workloads like
  77766. * layers, post processes...
  77767. */
  77768. export interface ISceneComponent {
  77769. /**
  77770. * The name of the component. Each component must have a unique name.
  77771. */
  77772. name: string;
  77773. /**
  77774. * The scene the component belongs to.
  77775. */
  77776. scene: Scene;
  77777. /**
  77778. * Register the component to one instance of a scene.
  77779. */
  77780. register(): void;
  77781. /**
  77782. * Rebuilds the elements related to this component in case of
  77783. * context lost for instance.
  77784. */
  77785. rebuild(): void;
  77786. /**
  77787. * Disposes the component and the associated ressources.
  77788. */
  77789. dispose(): void;
  77790. }
  77791. /**
  77792. * This represents a SERIALIZABLE scene component.
  77793. *
  77794. * This extends Scene Component to add Serialization methods on top.
  77795. */
  77796. export interface ISceneSerializableComponent extends ISceneComponent {
  77797. /**
  77798. * Adds all the elements from the container to the scene
  77799. * @param container the container holding the elements
  77800. */
  77801. addFromContainer(container: AbstractScene): void;
  77802. /**
  77803. * Removes all the elements in the container from the scene
  77804. * @param container contains the elements to remove
  77805. * @param dispose if the removed element should be disposed (default: false)
  77806. */
  77807. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77808. /**
  77809. * Serializes the component data to the specified json object
  77810. * @param serializationObject The object to serialize to
  77811. */
  77812. serialize(serializationObject: any): void;
  77813. }
  77814. /**
  77815. * Strong typing of a Mesh related stage step action
  77816. */
  77817. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77818. /**
  77819. * Strong typing of a Evaluate Sub Mesh related stage step action
  77820. */
  77821. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77822. /**
  77823. * Strong typing of a Active Mesh related stage step action
  77824. */
  77825. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77826. /**
  77827. * Strong typing of a Camera related stage step action
  77828. */
  77829. export type CameraStageAction = (camera: Camera) => void;
  77830. /**
  77831. * Strong typing of a Camera Frame buffer related stage step action
  77832. */
  77833. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77834. /**
  77835. * Strong typing of a Render Target related stage step action
  77836. */
  77837. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77838. /**
  77839. * Strong typing of a RenderingGroup related stage step action
  77840. */
  77841. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77842. /**
  77843. * Strong typing of a Mesh Render related stage step action
  77844. */
  77845. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77846. /**
  77847. * Strong typing of a simple stage step action
  77848. */
  77849. export type SimpleStageAction = () => void;
  77850. /**
  77851. * Strong typing of a render target action.
  77852. */
  77853. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77854. /**
  77855. * Strong typing of a pointer move action.
  77856. */
  77857. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77858. /**
  77859. * Strong typing of a pointer up/down action.
  77860. */
  77861. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77862. /**
  77863. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77864. * @hidden
  77865. */
  77866. export class Stage<T extends Function> extends Array<{
  77867. index: number;
  77868. component: ISceneComponent;
  77869. action: T;
  77870. }> {
  77871. /**
  77872. * Hide ctor from the rest of the world.
  77873. * @param items The items to add.
  77874. */
  77875. private constructor();
  77876. /**
  77877. * Creates a new Stage.
  77878. * @returns A new instance of a Stage
  77879. */
  77880. static Create<T extends Function>(): Stage<T>;
  77881. /**
  77882. * Registers a step in an ordered way in the targeted stage.
  77883. * @param index Defines the position to register the step in
  77884. * @param component Defines the component attached to the step
  77885. * @param action Defines the action to launch during the step
  77886. */
  77887. registerStep(index: number, component: ISceneComponent, action: T): void;
  77888. /**
  77889. * Clears all the steps from the stage.
  77890. */
  77891. clear(): void;
  77892. }
  77893. }
  77894. declare module BABYLON {
  77895. interface Scene {
  77896. /** @hidden */
  77897. _pointerOverSprite: Nullable<Sprite>;
  77898. /** @hidden */
  77899. _pickedDownSprite: Nullable<Sprite>;
  77900. /** @hidden */
  77901. _tempSpritePickingRay: Nullable<Ray>;
  77902. /**
  77903. * All of the sprite managers added to this scene
  77904. * @see http://doc.babylonjs.com/babylon101/sprites
  77905. */
  77906. spriteManagers: Array<ISpriteManager>;
  77907. /**
  77908. * An event triggered when sprites rendering is about to start
  77909. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77910. */
  77911. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77912. /**
  77913. * An event triggered when sprites rendering is done
  77914. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77915. */
  77916. onAfterSpritesRenderingObservable: Observable<Scene>;
  77917. /** @hidden */
  77918. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77919. /** Launch a ray to try to pick a sprite in the scene
  77920. * @param x position on screen
  77921. * @param y position on screen
  77922. * @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
  77923. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77924. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77925. * @returns a PickingInfo
  77926. */
  77927. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77928. /** Use the given ray to pick a sprite in the scene
  77929. * @param ray The ray (in world space) to use to pick meshes
  77930. * @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
  77931. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77932. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77933. * @returns a PickingInfo
  77934. */
  77935. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77936. /** @hidden */
  77937. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77938. /** Launch a ray to try to pick sprites in the scene
  77939. * @param x position on screen
  77940. * @param y position on screen
  77941. * @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
  77942. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77943. * @returns a PickingInfo array
  77944. */
  77945. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77946. /** Use the given ray to pick sprites in the scene
  77947. * @param ray The ray (in world space) to use to pick meshes
  77948. * @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
  77949. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77950. * @returns a PickingInfo array
  77951. */
  77952. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77953. /**
  77954. * Force the sprite under the pointer
  77955. * @param sprite defines the sprite to use
  77956. */
  77957. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77958. /**
  77959. * Gets the sprite under the pointer
  77960. * @returns a Sprite or null if no sprite is under the pointer
  77961. */
  77962. getPointerOverSprite(): Nullable<Sprite>;
  77963. }
  77964. /**
  77965. * Defines the sprite scene component responsible to manage sprites
  77966. * in a given scene.
  77967. */
  77968. export class SpriteSceneComponent implements ISceneComponent {
  77969. /**
  77970. * The component name helpfull to identify the component in the list of scene components.
  77971. */
  77972. readonly name: string;
  77973. /**
  77974. * The scene the component belongs to.
  77975. */
  77976. scene: Scene;
  77977. /** @hidden */
  77978. private _spritePredicate;
  77979. /**
  77980. * Creates a new instance of the component for the given scene
  77981. * @param scene Defines the scene to register the component in
  77982. */
  77983. constructor(scene: Scene);
  77984. /**
  77985. * Registers the component in a given scene
  77986. */
  77987. register(): void;
  77988. /**
  77989. * Rebuilds the elements related to this component in case of
  77990. * context lost for instance.
  77991. */
  77992. rebuild(): void;
  77993. /**
  77994. * Disposes the component and the associated ressources.
  77995. */
  77996. dispose(): void;
  77997. private _pickSpriteButKeepRay;
  77998. private _pointerMove;
  77999. private _pointerDown;
  78000. private _pointerUp;
  78001. }
  78002. }
  78003. declare module BABYLON {
  78004. /** @hidden */
  78005. export var fogFragmentDeclaration: {
  78006. name: string;
  78007. shader: string;
  78008. };
  78009. }
  78010. declare module BABYLON {
  78011. /** @hidden */
  78012. export var fogFragment: {
  78013. name: string;
  78014. shader: string;
  78015. };
  78016. }
  78017. declare module BABYLON {
  78018. /** @hidden */
  78019. export var spritesPixelShader: {
  78020. name: string;
  78021. shader: string;
  78022. };
  78023. }
  78024. declare module BABYLON {
  78025. /** @hidden */
  78026. export var fogVertexDeclaration: {
  78027. name: string;
  78028. shader: string;
  78029. };
  78030. }
  78031. declare module BABYLON {
  78032. /** @hidden */
  78033. export var spritesVertexShader: {
  78034. name: string;
  78035. shader: string;
  78036. };
  78037. }
  78038. declare module BABYLON {
  78039. /**
  78040. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78041. */
  78042. export interface ISpriteManager extends IDisposable {
  78043. /**
  78044. * Restricts the camera to viewing objects with the same layerMask.
  78045. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78046. */
  78047. layerMask: number;
  78048. /**
  78049. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78050. */
  78051. isPickable: boolean;
  78052. /**
  78053. * Specifies the rendering group id for this mesh (0 by default)
  78054. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78055. */
  78056. renderingGroupId: number;
  78057. /**
  78058. * Defines the list of sprites managed by the manager.
  78059. */
  78060. sprites: Array<Sprite>;
  78061. /**
  78062. * Tests the intersection of a sprite with a specific ray.
  78063. * @param ray The ray we are sending to test the collision
  78064. * @param camera The camera space we are sending rays in
  78065. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78066. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78067. * @returns picking info or null.
  78068. */
  78069. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78070. /**
  78071. * Intersects the sprites with a ray
  78072. * @param ray defines the ray to intersect with
  78073. * @param camera defines the current active camera
  78074. * @param predicate defines a predicate used to select candidate sprites
  78075. * @returns null if no hit or a PickingInfo array
  78076. */
  78077. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78078. /**
  78079. * Renders the list of sprites on screen.
  78080. */
  78081. render(): void;
  78082. }
  78083. /**
  78084. * Class used to manage multiple sprites on the same spritesheet
  78085. * @see http://doc.babylonjs.com/babylon101/sprites
  78086. */
  78087. export class SpriteManager implements ISpriteManager {
  78088. /** defines the manager's name */
  78089. name: string;
  78090. /** Gets the list of sprites */
  78091. sprites: Sprite[];
  78092. /** Gets or sets the rendering group id (0 by default) */
  78093. renderingGroupId: number;
  78094. /** Gets or sets camera layer mask */
  78095. layerMask: number;
  78096. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78097. fogEnabled: boolean;
  78098. /** Gets or sets a boolean indicating if the sprites are pickable */
  78099. isPickable: boolean;
  78100. /** Defines the default width of a cell in the spritesheet */
  78101. cellWidth: number;
  78102. /** Defines the default height of a cell in the spritesheet */
  78103. cellHeight: number;
  78104. /** Associative array from JSON sprite data file */
  78105. private _cellData;
  78106. /** Array of sprite names from JSON sprite data file */
  78107. private _spriteMap;
  78108. /** True when packed cell data from JSON file is ready*/
  78109. private _packedAndReady;
  78110. /**
  78111. * An event triggered when the manager is disposed.
  78112. */
  78113. onDisposeObservable: Observable<SpriteManager>;
  78114. private _onDisposeObserver;
  78115. /**
  78116. * Callback called when the manager is disposed
  78117. */
  78118. onDispose: () => void;
  78119. private _capacity;
  78120. private _fromPacked;
  78121. private _spriteTexture;
  78122. private _epsilon;
  78123. private _scene;
  78124. private _vertexData;
  78125. private _buffer;
  78126. private _vertexBuffers;
  78127. private _indexBuffer;
  78128. private _effectBase;
  78129. private _effectFog;
  78130. /**
  78131. * Gets or sets the spritesheet texture
  78132. */
  78133. texture: Texture;
  78134. /**
  78135. * Creates a new sprite manager
  78136. * @param name defines the manager's name
  78137. * @param imgUrl defines the sprite sheet url
  78138. * @param capacity defines the maximum allowed number of sprites
  78139. * @param cellSize defines the size of a sprite cell
  78140. * @param scene defines the hosting scene
  78141. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78142. * @param samplingMode defines the smapling mode to use with spritesheet
  78143. * @param fromPacked set to false; do not alter
  78144. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78145. */
  78146. constructor(
  78147. /** defines the manager's name */
  78148. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78149. private _makePacked;
  78150. private _appendSpriteVertex;
  78151. /**
  78152. * Intersects the sprites with a ray
  78153. * @param ray defines the ray to intersect with
  78154. * @param camera defines the current active camera
  78155. * @param predicate defines a predicate used to select candidate sprites
  78156. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78157. * @returns null if no hit or a PickingInfo
  78158. */
  78159. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78160. /**
  78161. * Intersects the sprites with a ray
  78162. * @param ray defines the ray to intersect with
  78163. * @param camera defines the current active camera
  78164. * @param predicate defines a predicate used to select candidate sprites
  78165. * @returns null if no hit or a PickingInfo array
  78166. */
  78167. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78168. /**
  78169. * Render all child sprites
  78170. */
  78171. render(): void;
  78172. /**
  78173. * Release associated resources
  78174. */
  78175. dispose(): void;
  78176. }
  78177. }
  78178. declare module BABYLON {
  78179. /**
  78180. * Class used to represent a sprite
  78181. * @see http://doc.babylonjs.com/babylon101/sprites
  78182. */
  78183. export class Sprite {
  78184. /** defines the name */
  78185. name: string;
  78186. /** Gets or sets the current world position */
  78187. position: Vector3;
  78188. /** Gets or sets the main color */
  78189. color: Color4;
  78190. /** Gets or sets the width */
  78191. width: number;
  78192. /** Gets or sets the height */
  78193. height: number;
  78194. /** Gets or sets rotation angle */
  78195. angle: number;
  78196. /** Gets or sets the cell index in the sprite sheet */
  78197. cellIndex: number;
  78198. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78199. cellRef: string;
  78200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78201. invertU: number;
  78202. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78203. invertV: number;
  78204. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78205. disposeWhenFinishedAnimating: boolean;
  78206. /** Gets the list of attached animations */
  78207. animations: Animation[];
  78208. /** Gets or sets a boolean indicating if the sprite can be picked */
  78209. isPickable: boolean;
  78210. /**
  78211. * Gets or sets the associated action manager
  78212. */
  78213. actionManager: Nullable<ActionManager>;
  78214. private _animationStarted;
  78215. private _loopAnimation;
  78216. private _fromIndex;
  78217. private _toIndex;
  78218. private _delay;
  78219. private _direction;
  78220. private _manager;
  78221. private _time;
  78222. private _onAnimationEnd;
  78223. /**
  78224. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78225. */
  78226. isVisible: boolean;
  78227. /**
  78228. * Gets or sets the sprite size
  78229. */
  78230. size: number;
  78231. /**
  78232. * Creates a new Sprite
  78233. * @param name defines the name
  78234. * @param manager defines the manager
  78235. */
  78236. constructor(
  78237. /** defines the name */
  78238. name: string, manager: ISpriteManager);
  78239. /**
  78240. * Starts an animation
  78241. * @param from defines the initial key
  78242. * @param to defines the end key
  78243. * @param loop defines if the animation must loop
  78244. * @param delay defines the start delay (in ms)
  78245. * @param onAnimationEnd defines a callback to call when animation ends
  78246. */
  78247. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78248. /** Stops current animation (if any) */
  78249. stopAnimation(): void;
  78250. /** @hidden */
  78251. _animate(deltaTime: number): void;
  78252. /** Release associated resources */
  78253. dispose(): void;
  78254. }
  78255. }
  78256. declare module BABYLON {
  78257. /**
  78258. * Information about the result of picking within a scene
  78259. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78260. */
  78261. export class PickingInfo {
  78262. /** @hidden */
  78263. _pickingUnavailable: boolean;
  78264. /**
  78265. * If the pick collided with an object
  78266. */
  78267. hit: boolean;
  78268. /**
  78269. * Distance away where the pick collided
  78270. */
  78271. distance: number;
  78272. /**
  78273. * The location of pick collision
  78274. */
  78275. pickedPoint: Nullable<Vector3>;
  78276. /**
  78277. * The mesh corresponding the the pick collision
  78278. */
  78279. pickedMesh: Nullable<AbstractMesh>;
  78280. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78281. bu: number;
  78282. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78283. bv: number;
  78284. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78285. faceId: number;
  78286. /** Id of the the submesh that was picked */
  78287. subMeshId: number;
  78288. /** If a sprite was picked, this will be the sprite the pick collided with */
  78289. pickedSprite: Nullable<Sprite>;
  78290. /**
  78291. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78292. */
  78293. originMesh: Nullable<AbstractMesh>;
  78294. /**
  78295. * The ray that was used to perform the picking.
  78296. */
  78297. ray: Nullable<Ray>;
  78298. /**
  78299. * Gets the normal correspodning to the face the pick collided with
  78300. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78301. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78302. * @returns The normal correspodning to the face the pick collided with
  78303. */
  78304. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78305. /**
  78306. * Gets the texture coordinates of where the pick occured
  78307. * @returns the vector containing the coordnates of the texture
  78308. */
  78309. getTextureCoordinates(): Nullable<Vector2>;
  78310. }
  78311. }
  78312. declare module BABYLON {
  78313. /**
  78314. * Gather the list of pointer event types as constants.
  78315. */
  78316. export class PointerEventTypes {
  78317. /**
  78318. * 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.
  78319. */
  78320. static readonly POINTERDOWN: number;
  78321. /**
  78322. * The pointerup event is fired when a pointer is no longer active.
  78323. */
  78324. static readonly POINTERUP: number;
  78325. /**
  78326. * The pointermove event is fired when a pointer changes coordinates.
  78327. */
  78328. static readonly POINTERMOVE: number;
  78329. /**
  78330. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78331. */
  78332. static readonly POINTERWHEEL: number;
  78333. /**
  78334. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78335. */
  78336. static readonly POINTERPICK: number;
  78337. /**
  78338. * The pointertap event is fired when a the object has been touched and released without drag.
  78339. */
  78340. static readonly POINTERTAP: number;
  78341. /**
  78342. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78343. */
  78344. static readonly POINTERDOUBLETAP: number;
  78345. }
  78346. /**
  78347. * Base class of pointer info types.
  78348. */
  78349. export class PointerInfoBase {
  78350. /**
  78351. * Defines the type of event (PointerEventTypes)
  78352. */
  78353. type: number;
  78354. /**
  78355. * Defines the related dom event
  78356. */
  78357. event: PointerEvent | MouseWheelEvent;
  78358. /**
  78359. * Instantiates the base class of pointers info.
  78360. * @param type Defines the type of event (PointerEventTypes)
  78361. * @param event Defines the related dom event
  78362. */
  78363. constructor(
  78364. /**
  78365. * Defines the type of event (PointerEventTypes)
  78366. */
  78367. type: number,
  78368. /**
  78369. * Defines the related dom event
  78370. */
  78371. event: PointerEvent | MouseWheelEvent);
  78372. }
  78373. /**
  78374. * This class is used to store pointer related info for the onPrePointerObservable event.
  78375. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78376. */
  78377. export class PointerInfoPre extends PointerInfoBase {
  78378. /**
  78379. * Ray from a pointer if availible (eg. 6dof controller)
  78380. */
  78381. ray: Nullable<Ray>;
  78382. /**
  78383. * Defines the local position of the pointer on the canvas.
  78384. */
  78385. localPosition: Vector2;
  78386. /**
  78387. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78388. */
  78389. skipOnPointerObservable: boolean;
  78390. /**
  78391. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78392. * @param type Defines the type of event (PointerEventTypes)
  78393. * @param event Defines the related dom event
  78394. * @param localX Defines the local x coordinates of the pointer when the event occured
  78395. * @param localY Defines the local y coordinates of the pointer when the event occured
  78396. */
  78397. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78398. }
  78399. /**
  78400. * This type contains all the data related to a pointer event in Babylon.js.
  78401. * 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.
  78402. */
  78403. export class PointerInfo extends PointerInfoBase {
  78404. /**
  78405. * Defines the picking info associated to the info (if any)\
  78406. */
  78407. pickInfo: Nullable<PickingInfo>;
  78408. /**
  78409. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78410. * @param type Defines the type of event (PointerEventTypes)
  78411. * @param event Defines the related dom event
  78412. * @param pickInfo Defines the picking info associated to the info (if any)\
  78413. */
  78414. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78415. /**
  78416. * Defines the picking info associated to the info (if any)\
  78417. */
  78418. pickInfo: Nullable<PickingInfo>);
  78419. }
  78420. /**
  78421. * Data relating to a touch event on the screen.
  78422. */
  78423. export interface PointerTouch {
  78424. /**
  78425. * X coordinate of touch.
  78426. */
  78427. x: number;
  78428. /**
  78429. * Y coordinate of touch.
  78430. */
  78431. y: number;
  78432. /**
  78433. * Id of touch. Unique for each finger.
  78434. */
  78435. pointerId: number;
  78436. /**
  78437. * Event type passed from DOM.
  78438. */
  78439. type: any;
  78440. }
  78441. }
  78442. declare module BABYLON {
  78443. /**
  78444. * Manage the mouse inputs to control the movement of a free camera.
  78445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78446. */
  78447. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78448. /**
  78449. * Define if touch is enabled in the mouse input
  78450. */
  78451. touchEnabled: boolean;
  78452. /**
  78453. * Defines the camera the input is attached to.
  78454. */
  78455. camera: FreeCamera;
  78456. /**
  78457. * Defines the buttons associated with the input to handle camera move.
  78458. */
  78459. buttons: number[];
  78460. /**
  78461. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78462. */
  78463. angularSensibility: number;
  78464. private _pointerInput;
  78465. private _onMouseMove;
  78466. private _observer;
  78467. private previousPosition;
  78468. /**
  78469. * Observable for when a pointer move event occurs containing the move offset
  78470. */
  78471. onPointerMovedObservable: Observable<{
  78472. offsetX: number;
  78473. offsetY: number;
  78474. }>;
  78475. /**
  78476. * @hidden
  78477. * If the camera should be rotated automatically based on pointer movement
  78478. */
  78479. _allowCameraRotation: boolean;
  78480. /**
  78481. * Manage the mouse inputs to control the movement of a free camera.
  78482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78483. * @param touchEnabled Defines if touch is enabled or not
  78484. */
  78485. constructor(
  78486. /**
  78487. * Define if touch is enabled in the mouse input
  78488. */
  78489. touchEnabled?: boolean);
  78490. /**
  78491. * Attach the input controls to a specific dom element to get the input from.
  78492. * @param element Defines the element the controls should be listened from
  78493. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78494. */
  78495. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78496. /**
  78497. * Called on JS contextmenu event.
  78498. * Override this method to provide functionality.
  78499. */
  78500. protected onContextMenu(evt: PointerEvent): void;
  78501. /**
  78502. * Detach the current controls from the specified dom element.
  78503. * @param element Defines the element to stop listening the inputs from
  78504. */
  78505. detachControl(element: Nullable<HTMLElement>): void;
  78506. /**
  78507. * Gets the class name of the current intput.
  78508. * @returns the class name
  78509. */
  78510. getClassName(): string;
  78511. /**
  78512. * Get the friendly name associated with the input class.
  78513. * @returns the input friendly name
  78514. */
  78515. getSimpleName(): string;
  78516. }
  78517. }
  78518. declare module BABYLON {
  78519. /**
  78520. * Manage the touch inputs to control the movement of a free camera.
  78521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78522. */
  78523. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78524. /**
  78525. * Defines the camera the input is attached to.
  78526. */
  78527. camera: FreeCamera;
  78528. /**
  78529. * Defines the touch sensibility for rotation.
  78530. * The higher the faster.
  78531. */
  78532. touchAngularSensibility: number;
  78533. /**
  78534. * Defines the touch sensibility for move.
  78535. * The higher the faster.
  78536. */
  78537. touchMoveSensibility: number;
  78538. private _offsetX;
  78539. private _offsetY;
  78540. private _pointerPressed;
  78541. private _pointerInput;
  78542. private _observer;
  78543. private _onLostFocus;
  78544. /**
  78545. * Attach the input controls to a specific dom element to get the input from.
  78546. * @param element Defines the element the controls should be listened from
  78547. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78548. */
  78549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78550. /**
  78551. * Detach the current controls from the specified dom element.
  78552. * @param element Defines the element to stop listening the inputs from
  78553. */
  78554. detachControl(element: Nullable<HTMLElement>): void;
  78555. /**
  78556. * Update the current camera state depending on the inputs that have been used this frame.
  78557. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78558. */
  78559. checkInputs(): void;
  78560. /**
  78561. * Gets the class name of the current intput.
  78562. * @returns the class name
  78563. */
  78564. getClassName(): string;
  78565. /**
  78566. * Get the friendly name associated with the input class.
  78567. * @returns the input friendly name
  78568. */
  78569. getSimpleName(): string;
  78570. }
  78571. }
  78572. declare module BABYLON {
  78573. /**
  78574. * Default Inputs manager for the FreeCamera.
  78575. * It groups all the default supported inputs for ease of use.
  78576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78577. */
  78578. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78579. /**
  78580. * @hidden
  78581. */
  78582. _mouseInput: Nullable<FreeCameraMouseInput>;
  78583. /**
  78584. * Instantiates a new FreeCameraInputsManager.
  78585. * @param camera Defines the camera the inputs belong to
  78586. */
  78587. constructor(camera: FreeCamera);
  78588. /**
  78589. * Add keyboard input support to the input manager.
  78590. * @returns the current input manager
  78591. */
  78592. addKeyboard(): FreeCameraInputsManager;
  78593. /**
  78594. * Add mouse input support to the input manager.
  78595. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78596. * @returns the current input manager
  78597. */
  78598. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78599. /**
  78600. * Removes the mouse input support from the manager
  78601. * @returns the current input manager
  78602. */
  78603. removeMouse(): FreeCameraInputsManager;
  78604. /**
  78605. * Add touch input support to the input manager.
  78606. * @returns the current input manager
  78607. */
  78608. addTouch(): FreeCameraInputsManager;
  78609. /**
  78610. * Remove all attached input methods from a camera
  78611. */
  78612. clear(): void;
  78613. }
  78614. }
  78615. declare module BABYLON {
  78616. /**
  78617. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78618. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78619. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78620. */
  78621. export class FreeCamera extends TargetCamera {
  78622. /**
  78623. * Define the collision ellipsoid of the camera.
  78624. * This is helpful to simulate a camera body like the player body around the camera
  78625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78626. */
  78627. ellipsoid: Vector3;
  78628. /**
  78629. * Define an offset for the position of the ellipsoid around the camera.
  78630. * This can be helpful to determine the center of the body near the gravity center of the body
  78631. * instead of its head.
  78632. */
  78633. ellipsoidOffset: Vector3;
  78634. /**
  78635. * Enable or disable collisions of the camera with the rest of the scene objects.
  78636. */
  78637. checkCollisions: boolean;
  78638. /**
  78639. * Enable or disable gravity on the camera.
  78640. */
  78641. applyGravity: boolean;
  78642. /**
  78643. * Define the input manager associated to the camera.
  78644. */
  78645. inputs: FreeCameraInputsManager;
  78646. /**
  78647. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78648. * Higher values reduce sensitivity.
  78649. */
  78650. /**
  78651. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78652. * Higher values reduce sensitivity.
  78653. */
  78654. angularSensibility: number;
  78655. /**
  78656. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78657. */
  78658. keysUp: number[];
  78659. /**
  78660. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78661. */
  78662. keysDown: number[];
  78663. /**
  78664. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78665. */
  78666. keysLeft: number[];
  78667. /**
  78668. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78669. */
  78670. keysRight: number[];
  78671. /**
  78672. * Event raised when the camera collide with a mesh in the scene.
  78673. */
  78674. onCollide: (collidedMesh: AbstractMesh) => void;
  78675. private _collider;
  78676. private _needMoveForGravity;
  78677. private _oldPosition;
  78678. private _diffPosition;
  78679. private _newPosition;
  78680. /** @hidden */
  78681. _localDirection: Vector3;
  78682. /** @hidden */
  78683. _transformedDirection: Vector3;
  78684. /**
  78685. * Instantiates a Free Camera.
  78686. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78687. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78688. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78689. * @param name Define the name of the camera in the scene
  78690. * @param position Define the start position of the camera in the scene
  78691. * @param scene Define the scene the camera belongs to
  78692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78693. */
  78694. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78695. /**
  78696. * Attached controls to the current camera.
  78697. * @param element Defines the element the controls should be listened from
  78698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78699. */
  78700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78701. /**
  78702. * Detach the current controls from the camera.
  78703. * The camera will stop reacting to inputs.
  78704. * @param element Defines the element to stop listening the inputs from
  78705. */
  78706. detachControl(element: HTMLElement): void;
  78707. private _collisionMask;
  78708. /**
  78709. * Define a collision mask to limit the list of object the camera can collide with
  78710. */
  78711. collisionMask: number;
  78712. /** @hidden */
  78713. _collideWithWorld(displacement: Vector3): void;
  78714. private _onCollisionPositionChange;
  78715. /** @hidden */
  78716. _checkInputs(): void;
  78717. /** @hidden */
  78718. _decideIfNeedsToMove(): boolean;
  78719. /** @hidden */
  78720. _updatePosition(): void;
  78721. /**
  78722. * Destroy the camera and release the current resources hold by it.
  78723. */
  78724. dispose(): void;
  78725. /**
  78726. * Gets the current object class name.
  78727. * @return the class name
  78728. */
  78729. getClassName(): string;
  78730. }
  78731. }
  78732. declare module BABYLON {
  78733. /**
  78734. * Represents a gamepad control stick position
  78735. */
  78736. export class StickValues {
  78737. /**
  78738. * The x component of the control stick
  78739. */
  78740. x: number;
  78741. /**
  78742. * The y component of the control stick
  78743. */
  78744. y: number;
  78745. /**
  78746. * Initializes the gamepad x and y control stick values
  78747. * @param x The x component of the gamepad control stick value
  78748. * @param y The y component of the gamepad control stick value
  78749. */
  78750. constructor(
  78751. /**
  78752. * The x component of the control stick
  78753. */
  78754. x: number,
  78755. /**
  78756. * The y component of the control stick
  78757. */
  78758. y: number);
  78759. }
  78760. /**
  78761. * An interface which manages callbacks for gamepad button changes
  78762. */
  78763. export interface GamepadButtonChanges {
  78764. /**
  78765. * Called when a gamepad has been changed
  78766. */
  78767. changed: boolean;
  78768. /**
  78769. * Called when a gamepad press event has been triggered
  78770. */
  78771. pressChanged: boolean;
  78772. /**
  78773. * Called when a touch event has been triggered
  78774. */
  78775. touchChanged: boolean;
  78776. /**
  78777. * Called when a value has changed
  78778. */
  78779. valueChanged: boolean;
  78780. }
  78781. /**
  78782. * Represents a gamepad
  78783. */
  78784. export class Gamepad {
  78785. /**
  78786. * The id of the gamepad
  78787. */
  78788. id: string;
  78789. /**
  78790. * The index of the gamepad
  78791. */
  78792. index: number;
  78793. /**
  78794. * The browser gamepad
  78795. */
  78796. browserGamepad: any;
  78797. /**
  78798. * Specifies what type of gamepad this represents
  78799. */
  78800. type: number;
  78801. private _leftStick;
  78802. private _rightStick;
  78803. /** @hidden */
  78804. _isConnected: boolean;
  78805. private _leftStickAxisX;
  78806. private _leftStickAxisY;
  78807. private _rightStickAxisX;
  78808. private _rightStickAxisY;
  78809. /**
  78810. * Triggered when the left control stick has been changed
  78811. */
  78812. private _onleftstickchanged;
  78813. /**
  78814. * Triggered when the right control stick has been changed
  78815. */
  78816. private _onrightstickchanged;
  78817. /**
  78818. * Represents a gamepad controller
  78819. */
  78820. static GAMEPAD: number;
  78821. /**
  78822. * Represents a generic controller
  78823. */
  78824. static GENERIC: number;
  78825. /**
  78826. * Represents an XBox controller
  78827. */
  78828. static XBOX: number;
  78829. /**
  78830. * Represents a pose-enabled controller
  78831. */
  78832. static POSE_ENABLED: number;
  78833. /**
  78834. * Represents an Dual Shock controller
  78835. */
  78836. static DUALSHOCK: number;
  78837. /**
  78838. * Specifies whether the left control stick should be Y-inverted
  78839. */
  78840. protected _invertLeftStickY: boolean;
  78841. /**
  78842. * Specifies if the gamepad has been connected
  78843. */
  78844. readonly isConnected: boolean;
  78845. /**
  78846. * Initializes the gamepad
  78847. * @param id The id of the gamepad
  78848. * @param index The index of the gamepad
  78849. * @param browserGamepad The browser gamepad
  78850. * @param leftStickX The x component of the left joystick
  78851. * @param leftStickY The y component of the left joystick
  78852. * @param rightStickX The x component of the right joystick
  78853. * @param rightStickY The y component of the right joystick
  78854. */
  78855. constructor(
  78856. /**
  78857. * The id of the gamepad
  78858. */
  78859. id: string,
  78860. /**
  78861. * The index of the gamepad
  78862. */
  78863. index: number,
  78864. /**
  78865. * The browser gamepad
  78866. */
  78867. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78868. /**
  78869. * Callback triggered when the left joystick has changed
  78870. * @param callback
  78871. */
  78872. onleftstickchanged(callback: (values: StickValues) => void): void;
  78873. /**
  78874. * Callback triggered when the right joystick has changed
  78875. * @param callback
  78876. */
  78877. onrightstickchanged(callback: (values: StickValues) => void): void;
  78878. /**
  78879. * Gets the left joystick
  78880. */
  78881. /**
  78882. * Sets the left joystick values
  78883. */
  78884. leftStick: StickValues;
  78885. /**
  78886. * Gets the right joystick
  78887. */
  78888. /**
  78889. * Sets the right joystick value
  78890. */
  78891. rightStick: StickValues;
  78892. /**
  78893. * Updates the gamepad joystick positions
  78894. */
  78895. update(): void;
  78896. /**
  78897. * Disposes the gamepad
  78898. */
  78899. dispose(): void;
  78900. }
  78901. /**
  78902. * Represents a generic gamepad
  78903. */
  78904. export class GenericPad extends Gamepad {
  78905. private _buttons;
  78906. private _onbuttondown;
  78907. private _onbuttonup;
  78908. /**
  78909. * Observable triggered when a button has been pressed
  78910. */
  78911. onButtonDownObservable: Observable<number>;
  78912. /**
  78913. * Observable triggered when a button has been released
  78914. */
  78915. onButtonUpObservable: Observable<number>;
  78916. /**
  78917. * Callback triggered when a button has been pressed
  78918. * @param callback Called when a button has been pressed
  78919. */
  78920. onbuttondown(callback: (buttonPressed: number) => void): void;
  78921. /**
  78922. * Callback triggered when a button has been released
  78923. * @param callback Called when a button has been released
  78924. */
  78925. onbuttonup(callback: (buttonReleased: number) => void): void;
  78926. /**
  78927. * Initializes the generic gamepad
  78928. * @param id The id of the generic gamepad
  78929. * @param index The index of the generic gamepad
  78930. * @param browserGamepad The browser gamepad
  78931. */
  78932. constructor(id: string, index: number, browserGamepad: any);
  78933. private _setButtonValue;
  78934. /**
  78935. * Updates the generic gamepad
  78936. */
  78937. update(): void;
  78938. /**
  78939. * Disposes the generic gamepad
  78940. */
  78941. dispose(): void;
  78942. }
  78943. }
  78944. declare module BABYLON {
  78945. interface Engine {
  78946. /**
  78947. * Creates a raw texture
  78948. * @param data defines the data to store in the texture
  78949. * @param width defines the width of the texture
  78950. * @param height defines the height of the texture
  78951. * @param format defines the format of the data
  78952. * @param generateMipMaps defines if the engine should generate the mip levels
  78953. * @param invertY defines if data must be stored with Y axis inverted
  78954. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78955. * @param compression defines the compression used (null by default)
  78956. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78957. * @returns the raw texture inside an InternalTexture
  78958. */
  78959. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78960. /**
  78961. * Update a raw texture
  78962. * @param texture defines the texture to update
  78963. * @param data defines the data to store in the texture
  78964. * @param format defines the format of the data
  78965. * @param invertY defines if data must be stored with Y axis inverted
  78966. */
  78967. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78968. /**
  78969. * Update a raw texture
  78970. * @param texture defines the texture to update
  78971. * @param data defines the data to store in the texture
  78972. * @param format defines the format of the data
  78973. * @param invertY defines if data must be stored with Y axis inverted
  78974. * @param compression defines the compression used (null by default)
  78975. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78976. */
  78977. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78978. /**
  78979. * Creates a new raw cube texture
  78980. * @param data defines the array of data to use to create each face
  78981. * @param size defines the size of the textures
  78982. * @param format defines the format of the data
  78983. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78984. * @param generateMipMaps defines if the engine should generate the mip levels
  78985. * @param invertY defines if data must be stored with Y axis inverted
  78986. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78987. * @param compression defines the compression used (null by default)
  78988. * @returns the cube texture as an InternalTexture
  78989. */
  78990. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78991. /**
  78992. * Update a raw cube texture
  78993. * @param texture defines the texture to udpdate
  78994. * @param data defines the data to store
  78995. * @param format defines the data format
  78996. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78997. * @param invertY defines if data must be stored with Y axis inverted
  78998. */
  78999. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79000. /**
  79001. * Update a raw cube texture
  79002. * @param texture defines the texture to udpdate
  79003. * @param data defines the data to store
  79004. * @param format defines the data format
  79005. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79006. * @param invertY defines if data must be stored with Y axis inverted
  79007. * @param compression defines the compression used (null by default)
  79008. */
  79009. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79010. /**
  79011. * Update a raw cube texture
  79012. * @param texture defines the texture to udpdate
  79013. * @param data defines the data to store
  79014. * @param format defines the data format
  79015. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79016. * @param invertY defines if data must be stored with Y axis inverted
  79017. * @param compression defines the compression used (null by default)
  79018. * @param level defines which level of the texture to update
  79019. */
  79020. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79021. /**
  79022. * Creates a new raw cube texture from a specified url
  79023. * @param url defines the url where the data is located
  79024. * @param scene defines the current scene
  79025. * @param size defines the size of the textures
  79026. * @param format defines the format of the data
  79027. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79028. * @param noMipmap defines if the engine should avoid generating the mip levels
  79029. * @param callback defines a callback used to extract texture data from loaded data
  79030. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79031. * @param onLoad defines a callback called when texture is loaded
  79032. * @param onError defines a callback called if there is an error
  79033. * @returns the cube texture as an InternalTexture
  79034. */
  79035. 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;
  79036. /**
  79037. * Creates a new raw cube texture from a specified url
  79038. * @param url defines the url where the data is located
  79039. * @param scene defines the current scene
  79040. * @param size defines the size of the textures
  79041. * @param format defines the format of the data
  79042. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79043. * @param noMipmap defines if the engine should avoid generating the mip levels
  79044. * @param callback defines a callback used to extract texture data from loaded data
  79045. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79046. * @param onLoad defines a callback called when texture is loaded
  79047. * @param onError defines a callback called if there is an error
  79048. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79049. * @param invertY defines if data must be stored with Y axis inverted
  79050. * @returns the cube texture as an InternalTexture
  79051. */
  79052. 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;
  79053. /**
  79054. * Creates a new raw 3D texture
  79055. * @param data defines the data used to create the texture
  79056. * @param width defines the width of the texture
  79057. * @param height defines the height of the texture
  79058. * @param depth defines the depth of the texture
  79059. * @param format defines the format of the texture
  79060. * @param generateMipMaps defines if the engine must generate mip levels
  79061. * @param invertY defines if data must be stored with Y axis inverted
  79062. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79063. * @param compression defines the compressed used (can be null)
  79064. * @param textureType defines the compressed used (can be null)
  79065. * @returns a new raw 3D texture (stored in an InternalTexture)
  79066. */
  79067. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79068. /**
  79069. * Update a raw 3D texture
  79070. * @param texture defines the texture to update
  79071. * @param data defines the data to store
  79072. * @param format defines the data format
  79073. * @param invertY defines if data must be stored with Y axis inverted
  79074. */
  79075. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79076. /**
  79077. * Update a raw 3D texture
  79078. * @param texture defines the texture to update
  79079. * @param data defines the data to store
  79080. * @param format defines the data format
  79081. * @param invertY defines if data must be stored with Y axis inverted
  79082. * @param compression defines the used compression (can be null)
  79083. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79084. */
  79085. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79086. }
  79087. }
  79088. declare module BABYLON {
  79089. /**
  79090. * Raw texture can help creating a texture directly from an array of data.
  79091. * This can be super useful if you either get the data from an uncompressed source or
  79092. * if you wish to create your texture pixel by pixel.
  79093. */
  79094. export class RawTexture extends Texture {
  79095. /**
  79096. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79097. */
  79098. format: number;
  79099. private _engine;
  79100. /**
  79101. * Instantiates a new RawTexture.
  79102. * Raw texture can help creating a texture directly from an array of data.
  79103. * This can be super useful if you either get the data from an uncompressed source or
  79104. * if you wish to create your texture pixel by pixel.
  79105. * @param data define the array of data to use to create the texture
  79106. * @param width define the width of the texture
  79107. * @param height define the height of the texture
  79108. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79109. * @param scene define the scene the texture belongs to
  79110. * @param generateMipMaps define whether mip maps should be generated or not
  79111. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79112. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79113. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79114. */
  79115. constructor(data: ArrayBufferView, width: number, height: number,
  79116. /**
  79117. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79118. */
  79119. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79120. /**
  79121. * Updates the texture underlying data.
  79122. * @param data Define the new data of the texture
  79123. */
  79124. update(data: ArrayBufferView): void;
  79125. /**
  79126. * Creates a luminance texture from some data.
  79127. * @param data Define the texture data
  79128. * @param width Define the width of the texture
  79129. * @param height Define the height of the texture
  79130. * @param scene Define the scene the texture belongs to
  79131. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79132. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79133. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79134. * @returns the luminance texture
  79135. */
  79136. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79137. /**
  79138. * Creates a luminance alpha texture from some data.
  79139. * @param data Define the texture data
  79140. * @param width Define the width of the texture
  79141. * @param height Define the height of the texture
  79142. * @param scene Define the scene the texture belongs to
  79143. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79144. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79145. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79146. * @returns the luminance alpha texture
  79147. */
  79148. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79149. /**
  79150. * Creates an alpha texture from some data.
  79151. * @param data Define the texture data
  79152. * @param width Define the width of the texture
  79153. * @param height Define the height of the texture
  79154. * @param scene Define the scene the texture belongs to
  79155. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79156. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79157. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79158. * @returns the alpha texture
  79159. */
  79160. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79161. /**
  79162. * Creates a RGB texture from some data.
  79163. * @param data Define the texture data
  79164. * @param width Define the width of the texture
  79165. * @param height Define the height of the texture
  79166. * @param scene Define the scene the texture belongs to
  79167. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79168. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79169. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79170. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79171. * @returns the RGB alpha texture
  79172. */
  79173. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79174. /**
  79175. * Creates a RGBA texture from some data.
  79176. * @param data Define the texture data
  79177. * @param width Define the width of the texture
  79178. * @param height Define the height of the texture
  79179. * @param scene Define the scene the texture belongs to
  79180. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79181. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79182. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79183. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79184. * @returns the RGBA texture
  79185. */
  79186. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79187. /**
  79188. * Creates a R texture from some data.
  79189. * @param data Define the texture data
  79190. * @param width Define the width of the texture
  79191. * @param height Define the height of the texture
  79192. * @param scene Define the scene the texture belongs to
  79193. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79194. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79195. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79196. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79197. * @returns the R texture
  79198. */
  79199. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79200. }
  79201. }
  79202. declare module BABYLON {
  79203. /**
  79204. * Interface for the size containing width and height
  79205. */
  79206. export interface ISize {
  79207. /**
  79208. * Width
  79209. */
  79210. width: number;
  79211. /**
  79212. * Heighht
  79213. */
  79214. height: number;
  79215. }
  79216. /**
  79217. * Size containing widht and height
  79218. */
  79219. export class Size implements ISize {
  79220. /**
  79221. * Width
  79222. */
  79223. width: number;
  79224. /**
  79225. * Height
  79226. */
  79227. height: number;
  79228. /**
  79229. * Creates a Size object from the given width and height (floats).
  79230. * @param width width of the new size
  79231. * @param height height of the new size
  79232. */
  79233. constructor(width: number, height: number);
  79234. /**
  79235. * Returns a string with the Size width and height
  79236. * @returns a string with the Size width and height
  79237. */
  79238. toString(): string;
  79239. /**
  79240. * "Size"
  79241. * @returns the string "Size"
  79242. */
  79243. getClassName(): string;
  79244. /**
  79245. * Returns the Size hash code.
  79246. * @returns a hash code for a unique width and height
  79247. */
  79248. getHashCode(): number;
  79249. /**
  79250. * Updates the current size from the given one.
  79251. * @param src the given size
  79252. */
  79253. copyFrom(src: Size): void;
  79254. /**
  79255. * Updates in place the current Size from the given floats.
  79256. * @param width width of the new size
  79257. * @param height height of the new size
  79258. * @returns the updated Size.
  79259. */
  79260. copyFromFloats(width: number, height: number): Size;
  79261. /**
  79262. * Updates in place the current Size from the given floats.
  79263. * @param width width to set
  79264. * @param height height to set
  79265. * @returns the updated Size.
  79266. */
  79267. set(width: number, height: number): Size;
  79268. /**
  79269. * Multiplies the width and height by numbers
  79270. * @param w factor to multiple the width by
  79271. * @param h factor to multiple the height by
  79272. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79273. */
  79274. multiplyByFloats(w: number, h: number): Size;
  79275. /**
  79276. * Clones the size
  79277. * @returns a new Size copied from the given one.
  79278. */
  79279. clone(): Size;
  79280. /**
  79281. * True if the current Size and the given one width and height are strictly equal.
  79282. * @param other the other size to compare against
  79283. * @returns True if the current Size and the given one width and height are strictly equal.
  79284. */
  79285. equals(other: Size): boolean;
  79286. /**
  79287. * The surface of the Size : width * height (float).
  79288. */
  79289. readonly surface: number;
  79290. /**
  79291. * Create a new size of zero
  79292. * @returns a new Size set to (0.0, 0.0)
  79293. */
  79294. static Zero(): Size;
  79295. /**
  79296. * Sums the width and height of two sizes
  79297. * @param otherSize size to add to this size
  79298. * @returns a new Size set as the addition result of the current Size and the given one.
  79299. */
  79300. add(otherSize: Size): Size;
  79301. /**
  79302. * Subtracts the width and height of two
  79303. * @param otherSize size to subtract to this size
  79304. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79305. */
  79306. subtract(otherSize: Size): Size;
  79307. /**
  79308. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79309. * @param start starting size to lerp between
  79310. * @param end end size to lerp between
  79311. * @param amount amount to lerp between the start and end values
  79312. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79313. */
  79314. static Lerp(start: Size, end: Size, amount: number): Size;
  79315. }
  79316. }
  79317. declare module BABYLON {
  79318. /**
  79319. * Defines a runtime animation
  79320. */
  79321. export class RuntimeAnimation {
  79322. private _events;
  79323. /**
  79324. * The current frame of the runtime animation
  79325. */
  79326. private _currentFrame;
  79327. /**
  79328. * The animation used by the runtime animation
  79329. */
  79330. private _animation;
  79331. /**
  79332. * The target of the runtime animation
  79333. */
  79334. private _target;
  79335. /**
  79336. * The initiating animatable
  79337. */
  79338. private _host;
  79339. /**
  79340. * The original value of the runtime animation
  79341. */
  79342. private _originalValue;
  79343. /**
  79344. * The original blend value of the runtime animation
  79345. */
  79346. private _originalBlendValue;
  79347. /**
  79348. * The offsets cache of the runtime animation
  79349. */
  79350. private _offsetsCache;
  79351. /**
  79352. * The high limits cache of the runtime animation
  79353. */
  79354. private _highLimitsCache;
  79355. /**
  79356. * Specifies if the runtime animation has been stopped
  79357. */
  79358. private _stopped;
  79359. /**
  79360. * The blending factor of the runtime animation
  79361. */
  79362. private _blendingFactor;
  79363. /**
  79364. * The BabylonJS scene
  79365. */
  79366. private _scene;
  79367. /**
  79368. * The current value of the runtime animation
  79369. */
  79370. private _currentValue;
  79371. /** @hidden */
  79372. _animationState: _IAnimationState;
  79373. /**
  79374. * The active target of the runtime animation
  79375. */
  79376. private _activeTargets;
  79377. private _currentActiveTarget;
  79378. private _directTarget;
  79379. /**
  79380. * The target path of the runtime animation
  79381. */
  79382. private _targetPath;
  79383. /**
  79384. * The weight of the runtime animation
  79385. */
  79386. private _weight;
  79387. /**
  79388. * The ratio offset of the runtime animation
  79389. */
  79390. private _ratioOffset;
  79391. /**
  79392. * The previous delay of the runtime animation
  79393. */
  79394. private _previousDelay;
  79395. /**
  79396. * The previous ratio of the runtime animation
  79397. */
  79398. private _previousRatio;
  79399. private _enableBlending;
  79400. private _keys;
  79401. private _minFrame;
  79402. private _maxFrame;
  79403. private _minValue;
  79404. private _maxValue;
  79405. private _targetIsArray;
  79406. /**
  79407. * Gets the current frame of the runtime animation
  79408. */
  79409. readonly currentFrame: number;
  79410. /**
  79411. * Gets the weight of the runtime animation
  79412. */
  79413. readonly weight: number;
  79414. /**
  79415. * Gets the current value of the runtime animation
  79416. */
  79417. readonly currentValue: any;
  79418. /**
  79419. * Gets the target path of the runtime animation
  79420. */
  79421. readonly targetPath: string;
  79422. /**
  79423. * Gets the actual target of the runtime animation
  79424. */
  79425. readonly target: any;
  79426. /** @hidden */
  79427. _onLoop: () => void;
  79428. /**
  79429. * Create a new RuntimeAnimation object
  79430. * @param target defines the target of the animation
  79431. * @param animation defines the source animation object
  79432. * @param scene defines the hosting scene
  79433. * @param host defines the initiating Animatable
  79434. */
  79435. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79436. private _preparePath;
  79437. /**
  79438. * Gets the animation from the runtime animation
  79439. */
  79440. readonly animation: Animation;
  79441. /**
  79442. * Resets the runtime animation to the beginning
  79443. * @param restoreOriginal defines whether to restore the target property to the original value
  79444. */
  79445. reset(restoreOriginal?: boolean): void;
  79446. /**
  79447. * Specifies if the runtime animation is stopped
  79448. * @returns Boolean specifying if the runtime animation is stopped
  79449. */
  79450. isStopped(): boolean;
  79451. /**
  79452. * Disposes of the runtime animation
  79453. */
  79454. dispose(): void;
  79455. /**
  79456. * Apply the interpolated value to the target
  79457. * @param currentValue defines the value computed by the animation
  79458. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79459. */
  79460. setValue(currentValue: any, weight: number): void;
  79461. private _getOriginalValues;
  79462. private _setValue;
  79463. /**
  79464. * Gets the loop pmode of the runtime animation
  79465. * @returns Loop Mode
  79466. */
  79467. private _getCorrectLoopMode;
  79468. /**
  79469. * Move the current animation to a given frame
  79470. * @param frame defines the frame to move to
  79471. */
  79472. goToFrame(frame: number): void;
  79473. /**
  79474. * @hidden Internal use only
  79475. */
  79476. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79477. /**
  79478. * Execute the current animation
  79479. * @param delay defines the delay to add to the current frame
  79480. * @param from defines the lower bound of the animation range
  79481. * @param to defines the upper bound of the animation range
  79482. * @param loop defines if the current animation must loop
  79483. * @param speedRatio defines the current speed ratio
  79484. * @param weight defines the weight of the animation (default is -1 so no weight)
  79485. * @param onLoop optional callback called when animation loops
  79486. * @returns a boolean indicating if the animation is running
  79487. */
  79488. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79489. }
  79490. }
  79491. declare module BABYLON {
  79492. /**
  79493. * Class used to store an actual running animation
  79494. */
  79495. export class Animatable {
  79496. /** defines the target object */
  79497. target: any;
  79498. /** defines the starting frame number (default is 0) */
  79499. fromFrame: number;
  79500. /** defines the ending frame number (default is 100) */
  79501. toFrame: number;
  79502. /** defines if the animation must loop (default is false) */
  79503. loopAnimation: boolean;
  79504. /** defines a callback to call when animation ends if it is not looping */
  79505. onAnimationEnd?: (() => void) | null | undefined;
  79506. /** defines a callback to call when animation loops */
  79507. onAnimationLoop?: (() => void) | null | undefined;
  79508. private _localDelayOffset;
  79509. private _pausedDelay;
  79510. private _runtimeAnimations;
  79511. private _paused;
  79512. private _scene;
  79513. private _speedRatio;
  79514. private _weight;
  79515. private _syncRoot;
  79516. /**
  79517. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79518. * This will only apply for non looping animation (default is true)
  79519. */
  79520. disposeOnEnd: boolean;
  79521. /**
  79522. * Gets a boolean indicating if the animation has started
  79523. */
  79524. animationStarted: boolean;
  79525. /**
  79526. * Observer raised when the animation ends
  79527. */
  79528. onAnimationEndObservable: Observable<Animatable>;
  79529. /**
  79530. * Observer raised when the animation loops
  79531. */
  79532. onAnimationLoopObservable: Observable<Animatable>;
  79533. /**
  79534. * Gets the root Animatable used to synchronize and normalize animations
  79535. */
  79536. readonly syncRoot: Nullable<Animatable>;
  79537. /**
  79538. * Gets the current frame of the first RuntimeAnimation
  79539. * Used to synchronize Animatables
  79540. */
  79541. readonly masterFrame: number;
  79542. /**
  79543. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79544. */
  79545. weight: number;
  79546. /**
  79547. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79548. */
  79549. speedRatio: number;
  79550. /**
  79551. * Creates a new Animatable
  79552. * @param scene defines the hosting scene
  79553. * @param target defines the target object
  79554. * @param fromFrame defines the starting frame number (default is 0)
  79555. * @param toFrame defines the ending frame number (default is 100)
  79556. * @param loopAnimation defines if the animation must loop (default is false)
  79557. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79558. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79559. * @param animations defines a group of animation to add to the new Animatable
  79560. * @param onAnimationLoop defines a callback to call when animation loops
  79561. */
  79562. constructor(scene: Scene,
  79563. /** defines the target object */
  79564. target: any,
  79565. /** defines the starting frame number (default is 0) */
  79566. fromFrame?: number,
  79567. /** defines the ending frame number (default is 100) */
  79568. toFrame?: number,
  79569. /** defines if the animation must loop (default is false) */
  79570. loopAnimation?: boolean, speedRatio?: number,
  79571. /** defines a callback to call when animation ends if it is not looping */
  79572. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79573. /** defines a callback to call when animation loops */
  79574. onAnimationLoop?: (() => void) | null | undefined);
  79575. /**
  79576. * Synchronize and normalize current Animatable with a source Animatable
  79577. * This is useful when using animation weights and when animations are not of the same length
  79578. * @param root defines the root Animatable to synchronize with
  79579. * @returns the current Animatable
  79580. */
  79581. syncWith(root: Animatable): Animatable;
  79582. /**
  79583. * Gets the list of runtime animations
  79584. * @returns an array of RuntimeAnimation
  79585. */
  79586. getAnimations(): RuntimeAnimation[];
  79587. /**
  79588. * Adds more animations to the current animatable
  79589. * @param target defines the target of the animations
  79590. * @param animations defines the new animations to add
  79591. */
  79592. appendAnimations(target: any, animations: Animation[]): void;
  79593. /**
  79594. * Gets the source animation for a specific property
  79595. * @param property defines the propertyu to look for
  79596. * @returns null or the source animation for the given property
  79597. */
  79598. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79599. /**
  79600. * Gets the runtime animation for a specific property
  79601. * @param property defines the propertyu to look for
  79602. * @returns null or the runtime animation for the given property
  79603. */
  79604. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79605. /**
  79606. * Resets the animatable to its original state
  79607. */
  79608. reset(): void;
  79609. /**
  79610. * Allows the animatable to blend with current running animations
  79611. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79612. * @param blendingSpeed defines the blending speed to use
  79613. */
  79614. enableBlending(blendingSpeed: number): void;
  79615. /**
  79616. * Disable animation blending
  79617. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79618. */
  79619. disableBlending(): void;
  79620. /**
  79621. * Jump directly to a given frame
  79622. * @param frame defines the frame to jump to
  79623. */
  79624. goToFrame(frame: number): void;
  79625. /**
  79626. * Pause the animation
  79627. */
  79628. pause(): void;
  79629. /**
  79630. * Restart the animation
  79631. */
  79632. restart(): void;
  79633. private _raiseOnAnimationEnd;
  79634. /**
  79635. * Stop and delete the current animation
  79636. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79637. * @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)
  79638. */
  79639. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79640. /**
  79641. * Wait asynchronously for the animation to end
  79642. * @returns a promise which will be fullfilled when the animation ends
  79643. */
  79644. waitAsync(): Promise<Animatable>;
  79645. /** @hidden */
  79646. _animate(delay: number): boolean;
  79647. }
  79648. interface Scene {
  79649. /** @hidden */
  79650. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79651. /** @hidden */
  79652. _processLateAnimationBindingsForMatrices(holder: {
  79653. totalWeight: number;
  79654. animations: RuntimeAnimation[];
  79655. originalValue: Matrix;
  79656. }): any;
  79657. /** @hidden */
  79658. _processLateAnimationBindingsForQuaternions(holder: {
  79659. totalWeight: number;
  79660. animations: RuntimeAnimation[];
  79661. originalValue: Quaternion;
  79662. }, refQuaternion: Quaternion): Quaternion;
  79663. /** @hidden */
  79664. _processLateAnimationBindings(): void;
  79665. /**
  79666. * Will start the animation sequence of a given target
  79667. * @param target defines the target
  79668. * @param from defines from which frame should animation start
  79669. * @param to defines until which frame should animation run.
  79670. * @param weight defines the weight to apply to the animation (1.0 by default)
  79671. * @param loop defines if the animation loops
  79672. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79673. * @param onAnimationEnd defines the function to be executed when the animation ends
  79674. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79675. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79676. * @param onAnimationLoop defines the callback to call when an animation loops
  79677. * @returns the animatable object created for this animation
  79678. */
  79679. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79680. /**
  79681. * Will start the animation sequence of a given target
  79682. * @param target defines the target
  79683. * @param from defines from which frame should animation start
  79684. * @param to defines until which frame should animation run.
  79685. * @param loop defines if the animation loops
  79686. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79687. * @param onAnimationEnd defines the function to be executed when the animation ends
  79688. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79689. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79690. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79691. * @param onAnimationLoop defines the callback to call when an animation loops
  79692. * @returns the animatable object created for this animation
  79693. */
  79694. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79695. /**
  79696. * Will start the animation sequence of a given target and its hierarchy
  79697. * @param target defines the target
  79698. * @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.
  79699. * @param from defines from which frame should animation start
  79700. * @param to defines until which frame should animation run.
  79701. * @param loop defines if the animation loops
  79702. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79703. * @param onAnimationEnd defines the function to be executed when the animation ends
  79704. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79705. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79706. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79707. * @param onAnimationLoop defines the callback to call when an animation loops
  79708. * @returns the list of created animatables
  79709. */
  79710. 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[];
  79711. /**
  79712. * Begin a new animation on a given node
  79713. * @param target defines the target where the animation will take place
  79714. * @param animations defines the list of animations to start
  79715. * @param from defines the initial value
  79716. * @param to defines the final value
  79717. * @param loop defines if you want animation to loop (off by default)
  79718. * @param speedRatio defines the speed ratio to apply to all animations
  79719. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79720. * @param onAnimationLoop defines the callback to call when an animation loops
  79721. * @returns the list of created animatables
  79722. */
  79723. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79724. /**
  79725. * Begin a new animation on a given node and its hierarchy
  79726. * @param target defines the root node where the animation will take place
  79727. * @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.
  79728. * @param animations defines the list of animations to start
  79729. * @param from defines the initial value
  79730. * @param to defines the final value
  79731. * @param loop defines if you want animation to loop (off by default)
  79732. * @param speedRatio defines the speed ratio to apply to all animations
  79733. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79734. * @param onAnimationLoop defines the callback to call when an animation loops
  79735. * @returns the list of animatables created for all nodes
  79736. */
  79737. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79738. /**
  79739. * Gets the animatable associated with a specific target
  79740. * @param target defines the target of the animatable
  79741. * @returns the required animatable if found
  79742. */
  79743. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79744. /**
  79745. * Gets all animatables associated with a given target
  79746. * @param target defines the target to look animatables for
  79747. * @returns an array of Animatables
  79748. */
  79749. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79750. /**
  79751. * Stops and removes all animations that have been applied to the scene
  79752. */
  79753. stopAllAnimations(): void;
  79754. /**
  79755. * Gets the current delta time used by animation engine
  79756. */
  79757. deltaTime: number;
  79758. }
  79759. interface Bone {
  79760. /**
  79761. * Copy an animation range from another bone
  79762. * @param source defines the source bone
  79763. * @param rangeName defines the range name to copy
  79764. * @param frameOffset defines the frame offset
  79765. * @param rescaleAsRequired defines if rescaling must be applied if required
  79766. * @param skelDimensionsRatio defines the scaling ratio
  79767. * @returns true if operation was successful
  79768. */
  79769. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79770. }
  79771. }
  79772. declare module BABYLON {
  79773. /**
  79774. * Class used to override all child animations of a given target
  79775. */
  79776. export class AnimationPropertiesOverride {
  79777. /**
  79778. * Gets or sets a value indicating if animation blending must be used
  79779. */
  79780. enableBlending: boolean;
  79781. /**
  79782. * Gets or sets the blending speed to use when enableBlending is true
  79783. */
  79784. blendingSpeed: number;
  79785. /**
  79786. * Gets or sets the default loop mode to use
  79787. */
  79788. loopMode: number;
  79789. }
  79790. }
  79791. declare module BABYLON {
  79792. /**
  79793. * Class used to handle skinning animations
  79794. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79795. */
  79796. export class Skeleton implements IAnimatable {
  79797. /** defines the skeleton name */
  79798. name: string;
  79799. /** defines the skeleton Id */
  79800. id: string;
  79801. /**
  79802. * Defines the list of child bones
  79803. */
  79804. bones: Bone[];
  79805. /**
  79806. * Defines an estimate of the dimension of the skeleton at rest
  79807. */
  79808. dimensionsAtRest: Vector3;
  79809. /**
  79810. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79811. */
  79812. needInitialSkinMatrix: boolean;
  79813. /**
  79814. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79815. */
  79816. overrideMesh: Nullable<AbstractMesh>;
  79817. /**
  79818. * Gets the list of animations attached to this skeleton
  79819. */
  79820. animations: Array<Animation>;
  79821. private _scene;
  79822. private _isDirty;
  79823. private _transformMatrices;
  79824. private _transformMatrixTexture;
  79825. private _meshesWithPoseMatrix;
  79826. private _animatables;
  79827. private _identity;
  79828. private _synchronizedWithMesh;
  79829. private _ranges;
  79830. private _lastAbsoluteTransformsUpdateId;
  79831. private _canUseTextureForBones;
  79832. private _uniqueId;
  79833. /** @hidden */
  79834. _numBonesWithLinkedTransformNode: number;
  79835. /** @hidden */
  79836. _hasWaitingData: Nullable<boolean>;
  79837. /**
  79838. * Specifies if the skeleton should be serialized
  79839. */
  79840. doNotSerialize: boolean;
  79841. private _useTextureToStoreBoneMatrices;
  79842. /**
  79843. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79844. * Please note that this option is not available if the hardware does not support it
  79845. */
  79846. useTextureToStoreBoneMatrices: boolean;
  79847. private _animationPropertiesOverride;
  79848. /**
  79849. * Gets or sets the animation properties override
  79850. */
  79851. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79852. /**
  79853. * List of inspectable custom properties (used by the Inspector)
  79854. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79855. */
  79856. inspectableCustomProperties: IInspectable[];
  79857. /**
  79858. * An observable triggered before computing the skeleton's matrices
  79859. */
  79860. onBeforeComputeObservable: Observable<Skeleton>;
  79861. /**
  79862. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79863. */
  79864. readonly isUsingTextureForMatrices: boolean;
  79865. /**
  79866. * Gets the unique ID of this skeleton
  79867. */
  79868. readonly uniqueId: number;
  79869. /**
  79870. * Creates a new skeleton
  79871. * @param name defines the skeleton name
  79872. * @param id defines the skeleton Id
  79873. * @param scene defines the hosting scene
  79874. */
  79875. constructor(
  79876. /** defines the skeleton name */
  79877. name: string,
  79878. /** defines the skeleton Id */
  79879. id: string, scene: Scene);
  79880. /**
  79881. * Gets the current object class name.
  79882. * @return the class name
  79883. */
  79884. getClassName(): string;
  79885. /**
  79886. * Returns an array containing the root bones
  79887. * @returns an array containing the root bones
  79888. */
  79889. getChildren(): Array<Bone>;
  79890. /**
  79891. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79892. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79893. * @returns a Float32Array containing matrices data
  79894. */
  79895. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79896. /**
  79897. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79898. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79899. * @returns a raw texture containing the data
  79900. */
  79901. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79902. /**
  79903. * Gets the current hosting scene
  79904. * @returns a scene object
  79905. */
  79906. getScene(): Scene;
  79907. /**
  79908. * Gets a string representing the current skeleton data
  79909. * @param fullDetails defines a boolean indicating if we want a verbose version
  79910. * @returns a string representing the current skeleton data
  79911. */
  79912. toString(fullDetails?: boolean): string;
  79913. /**
  79914. * Get bone's index searching by name
  79915. * @param name defines bone's name to search for
  79916. * @return the indice of the bone. Returns -1 if not found
  79917. */
  79918. getBoneIndexByName(name: string): number;
  79919. /**
  79920. * Creater a new animation range
  79921. * @param name defines the name of the range
  79922. * @param from defines the start key
  79923. * @param to defines the end key
  79924. */
  79925. createAnimationRange(name: string, from: number, to: number): void;
  79926. /**
  79927. * Delete a specific animation range
  79928. * @param name defines the name of the range
  79929. * @param deleteFrames defines if frames must be removed as well
  79930. */
  79931. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79932. /**
  79933. * Gets a specific animation range
  79934. * @param name defines the name of the range to look for
  79935. * @returns the requested animation range or null if not found
  79936. */
  79937. getAnimationRange(name: string): Nullable<AnimationRange>;
  79938. /**
  79939. * Gets the list of all animation ranges defined on this skeleton
  79940. * @returns an array
  79941. */
  79942. getAnimationRanges(): Nullable<AnimationRange>[];
  79943. /**
  79944. * Copy animation range from a source skeleton.
  79945. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79946. * @param source defines the source skeleton
  79947. * @param name defines the name of the range to copy
  79948. * @param rescaleAsRequired defines if rescaling must be applied if required
  79949. * @returns true if operation was successful
  79950. */
  79951. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79952. /**
  79953. * Forces the skeleton to go to rest pose
  79954. */
  79955. returnToRest(): void;
  79956. private _getHighestAnimationFrame;
  79957. /**
  79958. * Begin a specific animation range
  79959. * @param name defines the name of the range to start
  79960. * @param loop defines if looping must be turned on (false by default)
  79961. * @param speedRatio defines the speed ratio to apply (1 by default)
  79962. * @param onAnimationEnd defines a callback which will be called when animation will end
  79963. * @returns a new animatable
  79964. */
  79965. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79966. /** @hidden */
  79967. _markAsDirty(): void;
  79968. /** @hidden */
  79969. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79970. /** @hidden */
  79971. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79972. private _computeTransformMatrices;
  79973. /**
  79974. * Build all resources required to render a skeleton
  79975. */
  79976. prepare(): void;
  79977. /**
  79978. * Gets the list of animatables currently running for this skeleton
  79979. * @returns an array of animatables
  79980. */
  79981. getAnimatables(): IAnimatable[];
  79982. /**
  79983. * Clone the current skeleton
  79984. * @param name defines the name of the new skeleton
  79985. * @param id defines the id of the new skeleton
  79986. * @returns the new skeleton
  79987. */
  79988. clone(name: string, id: string): Skeleton;
  79989. /**
  79990. * Enable animation blending for this skeleton
  79991. * @param blendingSpeed defines the blending speed to apply
  79992. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79993. */
  79994. enableBlending(blendingSpeed?: number): void;
  79995. /**
  79996. * Releases all resources associated with the current skeleton
  79997. */
  79998. dispose(): void;
  79999. /**
  80000. * Serialize the skeleton in a JSON object
  80001. * @returns a JSON object
  80002. */
  80003. serialize(): any;
  80004. /**
  80005. * Creates a new skeleton from serialized data
  80006. * @param parsedSkeleton defines the serialized data
  80007. * @param scene defines the hosting scene
  80008. * @returns a new skeleton
  80009. */
  80010. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80011. /**
  80012. * Compute all node absolute transforms
  80013. * @param forceUpdate defines if computation must be done even if cache is up to date
  80014. */
  80015. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80016. /**
  80017. * Gets the root pose matrix
  80018. * @returns a matrix
  80019. */
  80020. getPoseMatrix(): Nullable<Matrix>;
  80021. /**
  80022. * Sorts bones per internal index
  80023. */
  80024. sortBones(): void;
  80025. private _sortBones;
  80026. }
  80027. }
  80028. declare module BABYLON {
  80029. /**
  80030. * Class used to store bone information
  80031. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80032. */
  80033. export class Bone extends Node {
  80034. /**
  80035. * defines the bone name
  80036. */
  80037. name: string;
  80038. private static _tmpVecs;
  80039. private static _tmpQuat;
  80040. private static _tmpMats;
  80041. /**
  80042. * Gets the list of child bones
  80043. */
  80044. children: Bone[];
  80045. /** Gets the animations associated with this bone */
  80046. animations: Animation[];
  80047. /**
  80048. * Gets or sets bone length
  80049. */
  80050. length: number;
  80051. /**
  80052. * @hidden Internal only
  80053. * Set this value to map this bone to a different index in the transform matrices
  80054. * Set this value to -1 to exclude the bone from the transform matrices
  80055. */
  80056. _index: Nullable<number>;
  80057. private _skeleton;
  80058. private _localMatrix;
  80059. private _restPose;
  80060. private _baseMatrix;
  80061. private _absoluteTransform;
  80062. private _invertedAbsoluteTransform;
  80063. private _parent;
  80064. private _scalingDeterminant;
  80065. private _worldTransform;
  80066. private _localScaling;
  80067. private _localRotation;
  80068. private _localPosition;
  80069. private _needToDecompose;
  80070. private _needToCompose;
  80071. /** @hidden */
  80072. _linkedTransformNode: Nullable<TransformNode>;
  80073. /** @hidden */
  80074. _waitingTransformNodeId: Nullable<string>;
  80075. /** @hidden */
  80076. /** @hidden */
  80077. _matrix: Matrix;
  80078. /**
  80079. * Create a new bone
  80080. * @param name defines the bone name
  80081. * @param skeleton defines the parent skeleton
  80082. * @param parentBone defines the parent (can be null if the bone is the root)
  80083. * @param localMatrix defines the local matrix
  80084. * @param restPose defines the rest pose matrix
  80085. * @param baseMatrix defines the base matrix
  80086. * @param index defines index of the bone in the hiearchy
  80087. */
  80088. constructor(
  80089. /**
  80090. * defines the bone name
  80091. */
  80092. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80093. /**
  80094. * Gets the current object class name.
  80095. * @return the class name
  80096. */
  80097. getClassName(): string;
  80098. /**
  80099. * Gets the parent skeleton
  80100. * @returns a skeleton
  80101. */
  80102. getSkeleton(): Skeleton;
  80103. /**
  80104. * Gets parent bone
  80105. * @returns a bone or null if the bone is the root of the bone hierarchy
  80106. */
  80107. getParent(): Nullable<Bone>;
  80108. /**
  80109. * Returns an array containing the root bones
  80110. * @returns an array containing the root bones
  80111. */
  80112. getChildren(): Array<Bone>;
  80113. /**
  80114. * Sets the parent bone
  80115. * @param parent defines the parent (can be null if the bone is the root)
  80116. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80117. */
  80118. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80119. /**
  80120. * Gets the local matrix
  80121. * @returns a matrix
  80122. */
  80123. getLocalMatrix(): Matrix;
  80124. /**
  80125. * Gets the base matrix (initial matrix which remains unchanged)
  80126. * @returns a matrix
  80127. */
  80128. getBaseMatrix(): Matrix;
  80129. /**
  80130. * Gets the rest pose matrix
  80131. * @returns a matrix
  80132. */
  80133. getRestPose(): Matrix;
  80134. /**
  80135. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80136. */
  80137. getWorldMatrix(): Matrix;
  80138. /**
  80139. * Sets the local matrix to rest pose matrix
  80140. */
  80141. returnToRest(): void;
  80142. /**
  80143. * Gets the inverse of the absolute transform matrix.
  80144. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80145. * @returns a matrix
  80146. */
  80147. getInvertedAbsoluteTransform(): Matrix;
  80148. /**
  80149. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80150. * @returns a matrix
  80151. */
  80152. getAbsoluteTransform(): Matrix;
  80153. /**
  80154. * Links with the given transform node.
  80155. * The local matrix of this bone is copied from the transform node every frame.
  80156. * @param transformNode defines the transform node to link to
  80157. */
  80158. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80159. /**
  80160. * Gets the node used to drive the bone's transformation
  80161. * @returns a transform node or null
  80162. */
  80163. getTransformNode(): Nullable<TransformNode>;
  80164. /** Gets or sets current position (in local space) */
  80165. position: Vector3;
  80166. /** Gets or sets current rotation (in local space) */
  80167. rotation: Vector3;
  80168. /** Gets or sets current rotation quaternion (in local space) */
  80169. rotationQuaternion: Quaternion;
  80170. /** Gets or sets current scaling (in local space) */
  80171. scaling: Vector3;
  80172. /**
  80173. * Gets the animation properties override
  80174. */
  80175. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80176. private _decompose;
  80177. private _compose;
  80178. /**
  80179. * Update the base and local matrices
  80180. * @param matrix defines the new base or local matrix
  80181. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80182. * @param updateLocalMatrix defines if the local matrix should be updated
  80183. */
  80184. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80185. /** @hidden */
  80186. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80187. /**
  80188. * Flag the bone as dirty (Forcing it to update everything)
  80189. */
  80190. markAsDirty(): void;
  80191. /** @hidden */
  80192. _markAsDirtyAndCompose(): void;
  80193. private _markAsDirtyAndDecompose;
  80194. /**
  80195. * Translate the bone in local or world space
  80196. * @param vec The amount to translate the bone
  80197. * @param space The space that the translation is in
  80198. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80199. */
  80200. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80201. /**
  80202. * Set the postion of the bone in local or world space
  80203. * @param position The position to set the bone
  80204. * @param space The space that the position is in
  80205. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80206. */
  80207. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80208. /**
  80209. * Set the absolute position of the bone (world space)
  80210. * @param position The position to set the bone
  80211. * @param mesh The mesh that this bone is attached to
  80212. */
  80213. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80214. /**
  80215. * Scale the bone on the x, y and z axes (in local space)
  80216. * @param x The amount to scale the bone on the x axis
  80217. * @param y The amount to scale the bone on the y axis
  80218. * @param z The amount to scale the bone on the z axis
  80219. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80220. */
  80221. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80222. /**
  80223. * Set the bone scaling in local space
  80224. * @param scale defines the scaling vector
  80225. */
  80226. setScale(scale: Vector3): void;
  80227. /**
  80228. * Gets the current scaling in local space
  80229. * @returns the current scaling vector
  80230. */
  80231. getScale(): Vector3;
  80232. /**
  80233. * Gets the current scaling in local space and stores it in a target vector
  80234. * @param result defines the target vector
  80235. */
  80236. getScaleToRef(result: Vector3): void;
  80237. /**
  80238. * Set the yaw, pitch, and roll of the bone in local or world space
  80239. * @param yaw The rotation of the bone on the y axis
  80240. * @param pitch The rotation of the bone on the x axis
  80241. * @param roll The rotation of the bone on the z axis
  80242. * @param space The space that the axes of rotation are in
  80243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80244. */
  80245. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80246. /**
  80247. * Add a rotation to the bone on an axis in local or world space
  80248. * @param axis The axis to rotate the bone on
  80249. * @param amount The amount to rotate the bone
  80250. * @param space The space that the axis is in
  80251. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80252. */
  80253. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80254. /**
  80255. * Set the rotation of the bone to a particular axis angle in local or world space
  80256. * @param axis The axis to rotate the bone on
  80257. * @param angle The angle that the bone should be rotated to
  80258. * @param space The space that the axis is in
  80259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80260. */
  80261. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80262. /**
  80263. * Set the euler rotation of the bone in local of world space
  80264. * @param rotation The euler rotation that the bone should be set to
  80265. * @param space The space that the rotation is in
  80266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80267. */
  80268. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80269. /**
  80270. * Set the quaternion rotation of the bone in local of world space
  80271. * @param quat The quaternion rotation that the bone should be set to
  80272. * @param space The space that the rotation is in
  80273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80274. */
  80275. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80276. /**
  80277. * Set the rotation matrix of the bone in local of world space
  80278. * @param rotMat The rotation matrix that the bone should be set to
  80279. * @param space The space that the rotation is in
  80280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80281. */
  80282. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80283. private _rotateWithMatrix;
  80284. private _getNegativeRotationToRef;
  80285. /**
  80286. * Get the position of the bone in local or world space
  80287. * @param space The space that the returned position is in
  80288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80289. * @returns The position of the bone
  80290. */
  80291. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80292. /**
  80293. * Copy the position of the bone to a vector3 in local or world space
  80294. * @param space The space that the returned position is in
  80295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80296. * @param result The vector3 to copy the position to
  80297. */
  80298. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80299. /**
  80300. * Get the absolute position of the bone (world space)
  80301. * @param mesh The mesh that this bone is attached to
  80302. * @returns The absolute position of the bone
  80303. */
  80304. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80305. /**
  80306. * Copy the absolute position of the bone (world space) to the result param
  80307. * @param mesh The mesh that this bone is attached to
  80308. * @param result The vector3 to copy the absolute position to
  80309. */
  80310. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80311. /**
  80312. * Compute the absolute transforms of this bone and its children
  80313. */
  80314. computeAbsoluteTransforms(): void;
  80315. /**
  80316. * Get the world direction from an axis that is in the local space of the bone
  80317. * @param localAxis The local direction that is used to compute the world direction
  80318. * @param mesh The mesh that this bone is attached to
  80319. * @returns The world direction
  80320. */
  80321. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80322. /**
  80323. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80324. * @param localAxis The local direction that is used to compute the world direction
  80325. * @param mesh The mesh that this bone is attached to
  80326. * @param result The vector3 that the world direction will be copied to
  80327. */
  80328. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80329. /**
  80330. * Get the euler rotation of the bone in local or world space
  80331. * @param space The space that the rotation should be in
  80332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80333. * @returns The euler rotation
  80334. */
  80335. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80336. /**
  80337. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80338. * @param space The space that the rotation should be in
  80339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80340. * @param result The vector3 that the rotation should be copied to
  80341. */
  80342. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80343. /**
  80344. * Get the quaternion rotation of the bone in either local or world space
  80345. * @param space The space that the rotation should be in
  80346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80347. * @returns The quaternion rotation
  80348. */
  80349. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80350. /**
  80351. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80352. * @param space The space that the rotation should be in
  80353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80354. * @param result The quaternion that the rotation should be copied to
  80355. */
  80356. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80357. /**
  80358. * Get the rotation matrix of the bone in local or world space
  80359. * @param space The space that the rotation should be in
  80360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80361. * @returns The rotation matrix
  80362. */
  80363. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80364. /**
  80365. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80366. * @param space The space that the rotation should be in
  80367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80368. * @param result The quaternion that the rotation should be copied to
  80369. */
  80370. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80371. /**
  80372. * Get the world position of a point that is in the local space of the bone
  80373. * @param position The local position
  80374. * @param mesh The mesh that this bone is attached to
  80375. * @returns The world position
  80376. */
  80377. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80378. /**
  80379. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80380. * @param position The local position
  80381. * @param mesh The mesh that this bone is attached to
  80382. * @param result The vector3 that the world position should be copied to
  80383. */
  80384. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80385. /**
  80386. * Get the local position of a point that is in world space
  80387. * @param position The world position
  80388. * @param mesh The mesh that this bone is attached to
  80389. * @returns The local position
  80390. */
  80391. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80392. /**
  80393. * Get the local position of a point that is in world space and copy it to the result param
  80394. * @param position The world position
  80395. * @param mesh The mesh that this bone is attached to
  80396. * @param result The vector3 that the local position should be copied to
  80397. */
  80398. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80399. }
  80400. }
  80401. declare module BABYLON {
  80402. /**
  80403. * 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.
  80404. * @see https://doc.babylonjs.com/how_to/transformnode
  80405. */
  80406. export class TransformNode extends Node {
  80407. /**
  80408. * Object will not rotate to face the camera
  80409. */
  80410. static BILLBOARDMODE_NONE: number;
  80411. /**
  80412. * Object will rotate to face the camera but only on the x axis
  80413. */
  80414. static BILLBOARDMODE_X: number;
  80415. /**
  80416. * Object will rotate to face the camera but only on the y axis
  80417. */
  80418. static BILLBOARDMODE_Y: number;
  80419. /**
  80420. * Object will rotate to face the camera but only on the z axis
  80421. */
  80422. static BILLBOARDMODE_Z: number;
  80423. /**
  80424. * Object will rotate to face the camera
  80425. */
  80426. static BILLBOARDMODE_ALL: number;
  80427. /**
  80428. * Object will rotate to face the camera's position instead of orientation
  80429. */
  80430. static BILLBOARDMODE_USE_POSITION: number;
  80431. private _forward;
  80432. private _forwardInverted;
  80433. private _up;
  80434. private _right;
  80435. private _rightInverted;
  80436. private _position;
  80437. private _rotation;
  80438. private _rotationQuaternion;
  80439. protected _scaling: Vector3;
  80440. protected _isDirty: boolean;
  80441. private _transformToBoneReferal;
  80442. private _isAbsoluteSynced;
  80443. private _billboardMode;
  80444. /**
  80445. * Gets or sets the billboard mode. Default is 0.
  80446. *
  80447. * | Value | Type | Description |
  80448. * | --- | --- | --- |
  80449. * | 0 | BILLBOARDMODE_NONE | |
  80450. * | 1 | BILLBOARDMODE_X | |
  80451. * | 2 | BILLBOARDMODE_Y | |
  80452. * | 4 | BILLBOARDMODE_Z | |
  80453. * | 7 | BILLBOARDMODE_ALL | |
  80454. *
  80455. */
  80456. billboardMode: number;
  80457. private _preserveParentRotationForBillboard;
  80458. /**
  80459. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80460. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80461. */
  80462. preserveParentRotationForBillboard: boolean;
  80463. /**
  80464. * 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
  80465. */
  80466. scalingDeterminant: number;
  80467. private _infiniteDistance;
  80468. /**
  80469. * Gets or sets the distance of the object to max, often used by skybox
  80470. */
  80471. infiniteDistance: boolean;
  80472. /**
  80473. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80474. * By default the system will update normals to compensate
  80475. */
  80476. ignoreNonUniformScaling: boolean;
  80477. /**
  80478. * 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
  80479. */
  80480. reIntegrateRotationIntoRotationQuaternion: boolean;
  80481. /** @hidden */
  80482. _poseMatrix: Nullable<Matrix>;
  80483. /** @hidden */
  80484. _localMatrix: Matrix;
  80485. private _usePivotMatrix;
  80486. private _absolutePosition;
  80487. private _absoluteScaling;
  80488. private _absoluteRotationQuaternion;
  80489. private _pivotMatrix;
  80490. private _pivotMatrixInverse;
  80491. protected _postMultiplyPivotMatrix: boolean;
  80492. protected _isWorldMatrixFrozen: boolean;
  80493. /** @hidden */
  80494. _indexInSceneTransformNodesArray: number;
  80495. /**
  80496. * An event triggered after the world matrix is updated
  80497. */
  80498. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80499. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80500. /**
  80501. * Gets a string identifying the name of the class
  80502. * @returns "TransformNode" string
  80503. */
  80504. getClassName(): string;
  80505. /**
  80506. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80507. */
  80508. position: Vector3;
  80509. /**
  80510. * 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)).
  80511. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80512. */
  80513. rotation: Vector3;
  80514. /**
  80515. * 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)).
  80516. */
  80517. scaling: Vector3;
  80518. /**
  80519. * 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).
  80520. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80521. */
  80522. rotationQuaternion: Nullable<Quaternion>;
  80523. /**
  80524. * The forward direction of that transform in world space.
  80525. */
  80526. readonly forward: Vector3;
  80527. /**
  80528. * The up direction of that transform in world space.
  80529. */
  80530. readonly up: Vector3;
  80531. /**
  80532. * The right direction of that transform in world space.
  80533. */
  80534. readonly right: Vector3;
  80535. /**
  80536. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80537. * @param matrix the matrix to copy the pose from
  80538. * @returns this TransformNode.
  80539. */
  80540. updatePoseMatrix(matrix: Matrix): TransformNode;
  80541. /**
  80542. * Returns the mesh Pose matrix.
  80543. * @returns the pose matrix
  80544. */
  80545. getPoseMatrix(): Matrix;
  80546. /** @hidden */
  80547. _isSynchronized(): boolean;
  80548. /** @hidden */
  80549. _initCache(): void;
  80550. /**
  80551. * Flag the transform node as dirty (Forcing it to update everything)
  80552. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80553. * @returns this transform node
  80554. */
  80555. markAsDirty(property: string): TransformNode;
  80556. /**
  80557. * Returns the current mesh absolute position.
  80558. * Returns a Vector3.
  80559. */
  80560. readonly absolutePosition: Vector3;
  80561. /**
  80562. * Returns the current mesh absolute scaling.
  80563. * Returns a Vector3.
  80564. */
  80565. readonly absoluteScaling: Vector3;
  80566. /**
  80567. * Returns the current mesh absolute rotation.
  80568. * Returns a Quaternion.
  80569. */
  80570. readonly absoluteRotationQuaternion: Quaternion;
  80571. /**
  80572. * Sets a new matrix to apply before all other transformation
  80573. * @param matrix defines the transform matrix
  80574. * @returns the current TransformNode
  80575. */
  80576. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80577. /**
  80578. * Sets a new pivot matrix to the current node
  80579. * @param matrix defines the new pivot matrix to use
  80580. * @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
  80581. * @returns the current TransformNode
  80582. */
  80583. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80584. /**
  80585. * Returns the mesh pivot matrix.
  80586. * Default : Identity.
  80587. * @returns the matrix
  80588. */
  80589. getPivotMatrix(): Matrix;
  80590. /**
  80591. * Instantiate (when possible) or clone that node with its hierarchy
  80592. * @param newParent defines the new parent to use for the instance (or clone)
  80593. * @returns an instance (or a clone) of the current node with its hiearchy
  80594. */
  80595. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80596. /**
  80597. * Prevents the World matrix to be computed any longer
  80598. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80599. * @returns the TransformNode.
  80600. */
  80601. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80602. /**
  80603. * Allows back the World matrix computation.
  80604. * @returns the TransformNode.
  80605. */
  80606. unfreezeWorldMatrix(): this;
  80607. /**
  80608. * True if the World matrix has been frozen.
  80609. */
  80610. readonly isWorldMatrixFrozen: boolean;
  80611. /**
  80612. * Retuns the mesh absolute position in the World.
  80613. * @returns a Vector3.
  80614. */
  80615. getAbsolutePosition(): Vector3;
  80616. /**
  80617. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80618. * @param absolutePosition the absolute position to set
  80619. * @returns the TransformNode.
  80620. */
  80621. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80622. /**
  80623. * Sets the mesh position in its local space.
  80624. * @param vector3 the position to set in localspace
  80625. * @returns the TransformNode.
  80626. */
  80627. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80628. /**
  80629. * Returns the mesh position in the local space from the current World matrix values.
  80630. * @returns a new Vector3.
  80631. */
  80632. getPositionExpressedInLocalSpace(): Vector3;
  80633. /**
  80634. * Translates the mesh along the passed Vector3 in its local space.
  80635. * @param vector3 the distance to translate in localspace
  80636. * @returns the TransformNode.
  80637. */
  80638. locallyTranslate(vector3: Vector3): TransformNode;
  80639. private static _lookAtVectorCache;
  80640. /**
  80641. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80642. * @param targetPoint the position (must be in same space as current mesh) to look at
  80643. * @param yawCor optional yaw (y-axis) correction in radians
  80644. * @param pitchCor optional pitch (x-axis) correction in radians
  80645. * @param rollCor optional roll (z-axis) correction in radians
  80646. * @param space the choosen space of the target
  80647. * @returns the TransformNode.
  80648. */
  80649. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80650. /**
  80651. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80652. * This Vector3 is expressed in the World space.
  80653. * @param localAxis axis to rotate
  80654. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80655. */
  80656. getDirection(localAxis: Vector3): Vector3;
  80657. /**
  80658. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80659. * localAxis is expressed in the mesh local space.
  80660. * result is computed in the Wordl space from the mesh World matrix.
  80661. * @param localAxis axis to rotate
  80662. * @param result the resulting transformnode
  80663. * @returns this TransformNode.
  80664. */
  80665. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80666. /**
  80667. * Sets this transform node rotation to the given local axis.
  80668. * @param localAxis the axis in local space
  80669. * @param yawCor optional yaw (y-axis) correction in radians
  80670. * @param pitchCor optional pitch (x-axis) correction in radians
  80671. * @param rollCor optional roll (z-axis) correction in radians
  80672. * @returns this TransformNode
  80673. */
  80674. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80675. /**
  80676. * Sets a new pivot point to the current node
  80677. * @param point defines the new pivot point to use
  80678. * @param space defines if the point is in world or local space (local by default)
  80679. * @returns the current TransformNode
  80680. */
  80681. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80682. /**
  80683. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80684. * @returns the pivot point
  80685. */
  80686. getPivotPoint(): Vector3;
  80687. /**
  80688. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80689. * @param result the vector3 to store the result
  80690. * @returns this TransformNode.
  80691. */
  80692. getPivotPointToRef(result: Vector3): TransformNode;
  80693. /**
  80694. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80695. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80696. */
  80697. getAbsolutePivotPoint(): Vector3;
  80698. /**
  80699. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80700. * @param result vector3 to store the result
  80701. * @returns this TransformNode.
  80702. */
  80703. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80704. /**
  80705. * Defines the passed node as the parent of the current node.
  80706. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80707. * @see https://doc.babylonjs.com/how_to/parenting
  80708. * @param node the node ot set as the parent
  80709. * @returns this TransformNode.
  80710. */
  80711. setParent(node: Nullable<Node>): TransformNode;
  80712. private _nonUniformScaling;
  80713. /**
  80714. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80715. */
  80716. readonly nonUniformScaling: boolean;
  80717. /** @hidden */
  80718. _updateNonUniformScalingState(value: boolean): boolean;
  80719. /**
  80720. * Attach the current TransformNode to another TransformNode associated with a bone
  80721. * @param bone Bone affecting the TransformNode
  80722. * @param affectedTransformNode TransformNode associated with the bone
  80723. * @returns this object
  80724. */
  80725. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80726. /**
  80727. * Detach the transform node if its associated with a bone
  80728. * @returns this object
  80729. */
  80730. detachFromBone(): TransformNode;
  80731. private static _rotationAxisCache;
  80732. /**
  80733. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80734. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80735. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80736. * The passed axis is also normalized.
  80737. * @param axis the axis to rotate around
  80738. * @param amount the amount to rotate in radians
  80739. * @param space Space to rotate in (Default: local)
  80740. * @returns the TransformNode.
  80741. */
  80742. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80743. /**
  80744. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80745. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80746. * The passed axis is also normalized. .
  80747. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80748. * @param point the point to rotate around
  80749. * @param axis the axis to rotate around
  80750. * @param amount the amount to rotate in radians
  80751. * @returns the TransformNode
  80752. */
  80753. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80754. /**
  80755. * Translates the mesh along the axis vector for the passed distance in the given space.
  80756. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80757. * @param axis the axis to translate in
  80758. * @param distance the distance to translate
  80759. * @param space Space to rotate in (Default: local)
  80760. * @returns the TransformNode.
  80761. */
  80762. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80763. /**
  80764. * Adds a rotation step to the mesh current rotation.
  80765. * x, y, z are Euler angles expressed in radians.
  80766. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80767. * This means this rotation is made in the mesh local space only.
  80768. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80769. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80770. * ```javascript
  80771. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80772. * ```
  80773. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80774. * 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.
  80775. * @param x Rotation to add
  80776. * @param y Rotation to add
  80777. * @param z Rotation to add
  80778. * @returns the TransformNode.
  80779. */
  80780. addRotation(x: number, y: number, z: number): TransformNode;
  80781. /**
  80782. * @hidden
  80783. */
  80784. protected _getEffectiveParent(): Nullable<Node>;
  80785. /**
  80786. * Computes the world matrix of the node
  80787. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80788. * @returns the world matrix
  80789. */
  80790. computeWorldMatrix(force?: boolean): Matrix;
  80791. protected _afterComputeWorldMatrix(): void;
  80792. /**
  80793. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80794. * @param func callback function to add
  80795. *
  80796. * @returns the TransformNode.
  80797. */
  80798. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80799. /**
  80800. * Removes a registered callback function.
  80801. * @param func callback function to remove
  80802. * @returns the TransformNode.
  80803. */
  80804. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80805. /**
  80806. * Gets the position of the current mesh in camera space
  80807. * @param camera defines the camera to use
  80808. * @returns a position
  80809. */
  80810. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80811. /**
  80812. * Returns the distance from the mesh to the active camera
  80813. * @param camera defines the camera to use
  80814. * @returns the distance
  80815. */
  80816. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80817. /**
  80818. * Clone the current transform node
  80819. * @param name Name of the new clone
  80820. * @param newParent New parent for the clone
  80821. * @param doNotCloneChildren Do not clone children hierarchy
  80822. * @returns the new transform node
  80823. */
  80824. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80825. /**
  80826. * Serializes the objects information.
  80827. * @param currentSerializationObject defines the object to serialize in
  80828. * @returns the serialized object
  80829. */
  80830. serialize(currentSerializationObject?: any): any;
  80831. /**
  80832. * Returns a new TransformNode object parsed from the source provided.
  80833. * @param parsedTransformNode is the source.
  80834. * @param scene the scne the object belongs to
  80835. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80836. * @returns a new TransformNode object parsed from the source provided.
  80837. */
  80838. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80839. /**
  80840. * Get all child-transformNodes of this node
  80841. * @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
  80842. * @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
  80843. * @returns an array of TransformNode
  80844. */
  80845. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80846. /**
  80847. * Releases resources associated with this transform node.
  80848. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80849. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80850. */
  80851. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80852. /**
  80853. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80854. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80855. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80856. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80857. * @returns the current mesh
  80858. */
  80859. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80860. private _syncAbsoluteScalingAndRotation;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * Defines the types of pose enabled controllers that are supported
  80866. */
  80867. export enum PoseEnabledControllerType {
  80868. /**
  80869. * HTC Vive
  80870. */
  80871. VIVE = 0,
  80872. /**
  80873. * Oculus Rift
  80874. */
  80875. OCULUS = 1,
  80876. /**
  80877. * Windows mixed reality
  80878. */
  80879. WINDOWS = 2,
  80880. /**
  80881. * Samsung gear VR
  80882. */
  80883. GEAR_VR = 3,
  80884. /**
  80885. * Google Daydream
  80886. */
  80887. DAYDREAM = 4,
  80888. /**
  80889. * Generic
  80890. */
  80891. GENERIC = 5
  80892. }
  80893. /**
  80894. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80895. */
  80896. export interface MutableGamepadButton {
  80897. /**
  80898. * Value of the button/trigger
  80899. */
  80900. value: number;
  80901. /**
  80902. * If the button/trigger is currently touched
  80903. */
  80904. touched: boolean;
  80905. /**
  80906. * If the button/trigger is currently pressed
  80907. */
  80908. pressed: boolean;
  80909. }
  80910. /**
  80911. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80912. * @hidden
  80913. */
  80914. export interface ExtendedGamepadButton extends GamepadButton {
  80915. /**
  80916. * If the button/trigger is currently pressed
  80917. */
  80918. readonly pressed: boolean;
  80919. /**
  80920. * If the button/trigger is currently touched
  80921. */
  80922. readonly touched: boolean;
  80923. /**
  80924. * Value of the button/trigger
  80925. */
  80926. readonly value: number;
  80927. }
  80928. /** @hidden */
  80929. export interface _GamePadFactory {
  80930. /**
  80931. * Returns wether or not the current gamepad can be created for this type of controller.
  80932. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80933. * @returns true if it can be created, otherwise false
  80934. */
  80935. canCreate(gamepadInfo: any): boolean;
  80936. /**
  80937. * Creates a new instance of the Gamepad.
  80938. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80939. * @returns the new gamepad instance
  80940. */
  80941. create(gamepadInfo: any): Gamepad;
  80942. }
  80943. /**
  80944. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80945. */
  80946. export class PoseEnabledControllerHelper {
  80947. /** @hidden */
  80948. static _ControllerFactories: _GamePadFactory[];
  80949. /** @hidden */
  80950. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80951. /**
  80952. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80953. * @param vrGamepad the gamepad to initialized
  80954. * @returns a vr controller of the type the gamepad identified as
  80955. */
  80956. static InitiateController(vrGamepad: any): Gamepad;
  80957. }
  80958. /**
  80959. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80960. */
  80961. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80962. /**
  80963. * If the controller is used in a webXR session
  80964. */
  80965. isXR: boolean;
  80966. private _deviceRoomPosition;
  80967. private _deviceRoomRotationQuaternion;
  80968. /**
  80969. * The device position in babylon space
  80970. */
  80971. devicePosition: Vector3;
  80972. /**
  80973. * The device rotation in babylon space
  80974. */
  80975. deviceRotationQuaternion: Quaternion;
  80976. /**
  80977. * The scale factor of the device in babylon space
  80978. */
  80979. deviceScaleFactor: number;
  80980. /**
  80981. * (Likely devicePosition should be used instead) The device position in its room space
  80982. */
  80983. position: Vector3;
  80984. /**
  80985. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80986. */
  80987. rotationQuaternion: Quaternion;
  80988. /**
  80989. * The type of controller (Eg. Windows mixed reality)
  80990. */
  80991. controllerType: PoseEnabledControllerType;
  80992. protected _calculatedPosition: Vector3;
  80993. private _calculatedRotation;
  80994. /**
  80995. * The raw pose from the device
  80996. */
  80997. rawPose: DevicePose;
  80998. private _trackPosition;
  80999. private _maxRotationDistFromHeadset;
  81000. private _draggedRoomRotation;
  81001. /**
  81002. * @hidden
  81003. */
  81004. _disableTrackPosition(fixedPosition: Vector3): void;
  81005. /**
  81006. * Internal, the mesh attached to the controller
  81007. * @hidden
  81008. */
  81009. _mesh: Nullable<AbstractMesh>;
  81010. private _poseControlledCamera;
  81011. private _leftHandSystemQuaternion;
  81012. /**
  81013. * Internal, matrix used to convert room space to babylon space
  81014. * @hidden
  81015. */
  81016. _deviceToWorld: Matrix;
  81017. /**
  81018. * Node to be used when casting a ray from the controller
  81019. * @hidden
  81020. */
  81021. _pointingPoseNode: Nullable<TransformNode>;
  81022. /**
  81023. * Name of the child mesh that can be used to cast a ray from the controller
  81024. */
  81025. static readonly POINTING_POSE: string;
  81026. /**
  81027. * Creates a new PoseEnabledController from a gamepad
  81028. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81029. */
  81030. constructor(browserGamepad: any);
  81031. private _workingMatrix;
  81032. /**
  81033. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81034. */
  81035. update(): void;
  81036. /**
  81037. * Updates only the pose device and mesh without doing any button event checking
  81038. */
  81039. protected _updatePoseAndMesh(): void;
  81040. /**
  81041. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81042. * @param poseData raw pose fromthe device
  81043. */
  81044. updateFromDevice(poseData: DevicePose): void;
  81045. /**
  81046. * @hidden
  81047. */
  81048. _meshAttachedObservable: Observable<AbstractMesh>;
  81049. /**
  81050. * Attaches a mesh to the controller
  81051. * @param mesh the mesh to be attached
  81052. */
  81053. attachToMesh(mesh: AbstractMesh): void;
  81054. /**
  81055. * Attaches the controllers mesh to a camera
  81056. * @param camera the camera the mesh should be attached to
  81057. */
  81058. attachToPoseControlledCamera(camera: TargetCamera): void;
  81059. /**
  81060. * Disposes of the controller
  81061. */
  81062. dispose(): void;
  81063. /**
  81064. * The mesh that is attached to the controller
  81065. */
  81066. readonly mesh: Nullable<AbstractMesh>;
  81067. /**
  81068. * Gets the ray of the controller in the direction the controller is pointing
  81069. * @param length the length the resulting ray should be
  81070. * @returns a ray in the direction the controller is pointing
  81071. */
  81072. getForwardRay(length?: number): Ray;
  81073. }
  81074. }
  81075. declare module BABYLON {
  81076. /**
  81077. * Defines the WebVRController object that represents controllers tracked in 3D space
  81078. */
  81079. export abstract class WebVRController extends PoseEnabledController {
  81080. /**
  81081. * Internal, the default controller model for the controller
  81082. */
  81083. protected _defaultModel: Nullable<AbstractMesh>;
  81084. /**
  81085. * Fired when the trigger state has changed
  81086. */
  81087. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81088. /**
  81089. * Fired when the main button state has changed
  81090. */
  81091. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81092. /**
  81093. * Fired when the secondary button state has changed
  81094. */
  81095. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81096. /**
  81097. * Fired when the pad state has changed
  81098. */
  81099. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81100. /**
  81101. * Fired when controllers stick values have changed
  81102. */
  81103. onPadValuesChangedObservable: Observable<StickValues>;
  81104. /**
  81105. * Array of button availible on the controller
  81106. */
  81107. protected _buttons: Array<MutableGamepadButton>;
  81108. private _onButtonStateChange;
  81109. /**
  81110. * Fired when a controller button's state has changed
  81111. * @param callback the callback containing the button that was modified
  81112. */
  81113. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81114. /**
  81115. * X and Y axis corresponding to the controllers joystick
  81116. */
  81117. pad: StickValues;
  81118. /**
  81119. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81120. */
  81121. hand: string;
  81122. /**
  81123. * The default controller model for the controller
  81124. */
  81125. readonly defaultModel: Nullable<AbstractMesh>;
  81126. /**
  81127. * Creates a new WebVRController from a gamepad
  81128. * @param vrGamepad the gamepad that the WebVRController should be created from
  81129. */
  81130. constructor(vrGamepad: any);
  81131. /**
  81132. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81133. */
  81134. update(): void;
  81135. /**
  81136. * Function to be called when a button is modified
  81137. */
  81138. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81139. /**
  81140. * Loads a mesh and attaches it to the controller
  81141. * @param scene the scene the mesh should be added to
  81142. * @param meshLoaded callback for when the mesh has been loaded
  81143. */
  81144. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81145. private _setButtonValue;
  81146. private _changes;
  81147. private _checkChanges;
  81148. /**
  81149. * Disposes of th webVRCOntroller
  81150. */
  81151. dispose(): void;
  81152. }
  81153. }
  81154. declare module BABYLON {
  81155. /**
  81156. * The HemisphericLight simulates the ambient environment light,
  81157. * so the passed direction is the light reflection direction, not the incoming direction.
  81158. */
  81159. export class HemisphericLight extends Light {
  81160. /**
  81161. * The groundColor is the light in the opposite direction to the one specified during creation.
  81162. * 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.
  81163. */
  81164. groundColor: Color3;
  81165. /**
  81166. * The light reflection direction, not the incoming direction.
  81167. */
  81168. direction: Vector3;
  81169. /**
  81170. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81171. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81172. * The HemisphericLight can't cast shadows.
  81173. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81174. * @param name The friendly name of the light
  81175. * @param direction The direction of the light reflection
  81176. * @param scene The scene the light belongs to
  81177. */
  81178. constructor(name: string, direction: Vector3, scene: Scene);
  81179. protected _buildUniformLayout(): void;
  81180. /**
  81181. * Returns the string "HemisphericLight".
  81182. * @return The class name
  81183. */
  81184. getClassName(): string;
  81185. /**
  81186. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81187. * Returns the updated direction.
  81188. * @param target The target the direction should point to
  81189. * @return The computed direction
  81190. */
  81191. setDirectionToTarget(target: Vector3): Vector3;
  81192. /**
  81193. * Returns the shadow generator associated to the light.
  81194. * @returns Always null for hemispheric lights because it does not support shadows.
  81195. */
  81196. getShadowGenerator(): Nullable<IShadowGenerator>;
  81197. /**
  81198. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81199. * @param effect The effect to update
  81200. * @param lightIndex The index of the light in the effect to update
  81201. * @returns The hemispheric light
  81202. */
  81203. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81204. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81205. /**
  81206. * Computes the world matrix of the node
  81207. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81208. * @param useWasUpdatedFlag defines a reserved property
  81209. * @returns the world matrix
  81210. */
  81211. computeWorldMatrix(): Matrix;
  81212. /**
  81213. * Returns the integer 3.
  81214. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81215. */
  81216. getTypeID(): number;
  81217. /**
  81218. * Prepares the list of defines specific to the light type.
  81219. * @param defines the list of defines
  81220. * @param lightIndex defines the index of the light for the effect
  81221. */
  81222. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81223. }
  81224. }
  81225. declare module BABYLON {
  81226. /** @hidden */
  81227. export var vrMultiviewToSingleviewPixelShader: {
  81228. name: string;
  81229. shader: string;
  81230. };
  81231. }
  81232. declare module BABYLON {
  81233. /**
  81234. * Renders to multiple views with a single draw call
  81235. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81236. */
  81237. export class MultiviewRenderTarget extends RenderTargetTexture {
  81238. /**
  81239. * Creates a multiview render target
  81240. * @param scene scene used with the render target
  81241. * @param size the size of the render target (used for each view)
  81242. */
  81243. constructor(scene: Scene, size?: number | {
  81244. width: number;
  81245. height: number;
  81246. } | {
  81247. ratio: number;
  81248. });
  81249. /**
  81250. * @hidden
  81251. * @param faceIndex the face index, if its a cube texture
  81252. */
  81253. _bindFrameBuffer(faceIndex?: number): void;
  81254. /**
  81255. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81256. * @returns the view count
  81257. */
  81258. getViewCount(): number;
  81259. }
  81260. }
  81261. declare module BABYLON {
  81262. /**
  81263. * Represents a camera frustum
  81264. */
  81265. export class Frustum {
  81266. /**
  81267. * Gets the planes representing the frustum
  81268. * @param transform matrix to be applied to the returned planes
  81269. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81270. */
  81271. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81272. /**
  81273. * Gets the near frustum plane transformed by the transform matrix
  81274. * @param transform transformation matrix to be applied to the resulting frustum plane
  81275. * @param frustumPlane the resuling frustum plane
  81276. */
  81277. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81278. /**
  81279. * Gets the far frustum plane transformed by the transform matrix
  81280. * @param transform transformation matrix to be applied to the resulting frustum plane
  81281. * @param frustumPlane the resuling frustum plane
  81282. */
  81283. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81284. /**
  81285. * Gets the left frustum plane transformed by the transform matrix
  81286. * @param transform transformation matrix to be applied to the resulting frustum plane
  81287. * @param frustumPlane the resuling frustum plane
  81288. */
  81289. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81290. /**
  81291. * Gets the right frustum plane transformed by the transform matrix
  81292. * @param transform transformation matrix to be applied to the resulting frustum plane
  81293. * @param frustumPlane the resuling frustum plane
  81294. */
  81295. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81296. /**
  81297. * Gets the top frustum plane transformed by the transform matrix
  81298. * @param transform transformation matrix to be applied to the resulting frustum plane
  81299. * @param frustumPlane the resuling frustum plane
  81300. */
  81301. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81302. /**
  81303. * Gets the bottom frustum plane transformed by the transform matrix
  81304. * @param transform transformation matrix to be applied to the resulting frustum plane
  81305. * @param frustumPlane the resuling frustum plane
  81306. */
  81307. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81308. /**
  81309. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81310. * @param transform transformation matrix to be applied to the resulting frustum planes
  81311. * @param frustumPlanes the resuling frustum planes
  81312. */
  81313. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81314. }
  81315. }
  81316. declare module BABYLON {
  81317. interface Engine {
  81318. /**
  81319. * Creates a new multiview render target
  81320. * @param width defines the width of the texture
  81321. * @param height defines the height of the texture
  81322. * @returns the created multiview texture
  81323. */
  81324. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81325. /**
  81326. * Binds a multiview framebuffer to be drawn to
  81327. * @param multiviewTexture texture to bind
  81328. */
  81329. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81330. }
  81331. interface Camera {
  81332. /**
  81333. * @hidden
  81334. * 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)
  81335. */
  81336. _useMultiviewToSingleView: boolean;
  81337. /**
  81338. * @hidden
  81339. * 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)
  81340. */
  81341. _multiviewTexture: Nullable<RenderTargetTexture>;
  81342. /**
  81343. * @hidden
  81344. * ensures the multiview texture of the camera exists and has the specified width/height
  81345. * @param width height to set on the multiview texture
  81346. * @param height width to set on the multiview texture
  81347. */
  81348. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81349. }
  81350. interface Scene {
  81351. /** @hidden */
  81352. _transformMatrixR: Matrix;
  81353. /** @hidden */
  81354. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81355. /** @hidden */
  81356. _createMultiviewUbo(): void;
  81357. /** @hidden */
  81358. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81359. /** @hidden */
  81360. _renderMultiviewToSingleView(camera: Camera): void;
  81361. }
  81362. }
  81363. declare module BABYLON {
  81364. /**
  81365. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81366. * This will not be used for webXR as it supports displaying texture arrays directly
  81367. */
  81368. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81369. /**
  81370. * Initializes a VRMultiviewToSingleview
  81371. * @param name name of the post process
  81372. * @param camera camera to be applied to
  81373. * @param scaleFactor scaling factor to the size of the output texture
  81374. */
  81375. constructor(name: string, camera: Camera, scaleFactor: number);
  81376. }
  81377. }
  81378. declare module BABYLON {
  81379. interface Engine {
  81380. /** @hidden */
  81381. _vrDisplay: any;
  81382. /** @hidden */
  81383. _vrSupported: boolean;
  81384. /** @hidden */
  81385. _oldSize: Size;
  81386. /** @hidden */
  81387. _oldHardwareScaleFactor: number;
  81388. /** @hidden */
  81389. _vrExclusivePointerMode: boolean;
  81390. /** @hidden */
  81391. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81392. /** @hidden */
  81393. _onVRDisplayPointerRestricted: () => void;
  81394. /** @hidden */
  81395. _onVRDisplayPointerUnrestricted: () => void;
  81396. /** @hidden */
  81397. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81398. /** @hidden */
  81399. _onVrDisplayDisconnect: Nullable<() => void>;
  81400. /** @hidden */
  81401. _onVrDisplayPresentChange: Nullable<() => void>;
  81402. /**
  81403. * Observable signaled when VR display mode changes
  81404. */
  81405. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81406. /**
  81407. * Observable signaled when VR request present is complete
  81408. */
  81409. onVRRequestPresentComplete: Observable<boolean>;
  81410. /**
  81411. * Observable signaled when VR request present starts
  81412. */
  81413. onVRRequestPresentStart: Observable<Engine>;
  81414. /**
  81415. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81416. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81417. */
  81418. isInVRExclusivePointerMode: boolean;
  81419. /**
  81420. * Gets a boolean indicating if a webVR device was detected
  81421. * @returns true if a webVR device was detected
  81422. */
  81423. isVRDevicePresent(): boolean;
  81424. /**
  81425. * Gets the current webVR device
  81426. * @returns the current webVR device (or null)
  81427. */
  81428. getVRDevice(): any;
  81429. /**
  81430. * Initializes a webVR display and starts listening to display change events
  81431. * The onVRDisplayChangedObservable will be notified upon these changes
  81432. * @returns A promise containing a VRDisplay and if vr is supported
  81433. */
  81434. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81435. /** @hidden */
  81436. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81437. /**
  81438. * Call this function to switch to webVR mode
  81439. * Will do nothing if webVR is not supported or if there is no webVR device
  81440. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81441. */
  81442. enableVR(): void;
  81443. /** @hidden */
  81444. _onVRFullScreenTriggered(): void;
  81445. }
  81446. }
  81447. declare module BABYLON {
  81448. /**
  81449. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81450. * IMPORTANT!! The data is right-hand data.
  81451. * @export
  81452. * @interface DevicePose
  81453. */
  81454. export interface DevicePose {
  81455. /**
  81456. * The position of the device, values in array are [x,y,z].
  81457. */
  81458. readonly position: Nullable<Float32Array>;
  81459. /**
  81460. * The linearVelocity of the device, values in array are [x,y,z].
  81461. */
  81462. readonly linearVelocity: Nullable<Float32Array>;
  81463. /**
  81464. * The linearAcceleration of the device, values in array are [x,y,z].
  81465. */
  81466. readonly linearAcceleration: Nullable<Float32Array>;
  81467. /**
  81468. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81469. */
  81470. readonly orientation: Nullable<Float32Array>;
  81471. /**
  81472. * The angularVelocity of the device, values in array are [x,y,z].
  81473. */
  81474. readonly angularVelocity: Nullable<Float32Array>;
  81475. /**
  81476. * The angularAcceleration of the device, values in array are [x,y,z].
  81477. */
  81478. readonly angularAcceleration: Nullable<Float32Array>;
  81479. }
  81480. /**
  81481. * Interface representing a pose controlled object in Babylon.
  81482. * A pose controlled object has both regular pose values as well as pose values
  81483. * from an external device such as a VR head mounted display
  81484. */
  81485. export interface PoseControlled {
  81486. /**
  81487. * The position of the object in babylon space.
  81488. */
  81489. position: Vector3;
  81490. /**
  81491. * The rotation quaternion of the object in babylon space.
  81492. */
  81493. rotationQuaternion: Quaternion;
  81494. /**
  81495. * The position of the device in babylon space.
  81496. */
  81497. devicePosition?: Vector3;
  81498. /**
  81499. * The rotation quaternion of the device in babylon space.
  81500. */
  81501. deviceRotationQuaternion: Quaternion;
  81502. /**
  81503. * The raw pose coming from the device.
  81504. */
  81505. rawPose: Nullable<DevicePose>;
  81506. /**
  81507. * The scale of the device to be used when translating from device space to babylon space.
  81508. */
  81509. deviceScaleFactor: number;
  81510. /**
  81511. * Updates the poseControlled values based on the input device pose.
  81512. * @param poseData the pose data to update the object with
  81513. */
  81514. updateFromDevice(poseData: DevicePose): void;
  81515. }
  81516. /**
  81517. * Set of options to customize the webVRCamera
  81518. */
  81519. export interface WebVROptions {
  81520. /**
  81521. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81522. */
  81523. trackPosition?: boolean;
  81524. /**
  81525. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81526. */
  81527. positionScale?: number;
  81528. /**
  81529. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81530. */
  81531. displayName?: string;
  81532. /**
  81533. * Should the native controller meshes be initialized. (default: true)
  81534. */
  81535. controllerMeshes?: boolean;
  81536. /**
  81537. * Creating a default HemiLight only on controllers. (default: true)
  81538. */
  81539. defaultLightingOnControllers?: boolean;
  81540. /**
  81541. * If you don't want to use the default VR button of the helper. (default: false)
  81542. */
  81543. useCustomVRButton?: boolean;
  81544. /**
  81545. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81546. */
  81547. customVRButton?: HTMLButtonElement;
  81548. /**
  81549. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81550. */
  81551. rayLength?: number;
  81552. /**
  81553. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81554. */
  81555. defaultHeight?: number;
  81556. /**
  81557. * If multiview should be used if availible (default: false)
  81558. */
  81559. useMultiview?: boolean;
  81560. }
  81561. /**
  81562. * This represents a WebVR camera.
  81563. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81564. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81565. */
  81566. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81567. private webVROptions;
  81568. /**
  81569. * @hidden
  81570. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81571. */
  81572. _vrDevice: any;
  81573. /**
  81574. * The rawPose of the vrDevice.
  81575. */
  81576. rawPose: Nullable<DevicePose>;
  81577. private _onVREnabled;
  81578. private _specsVersion;
  81579. private _attached;
  81580. private _frameData;
  81581. protected _descendants: Array<Node>;
  81582. private _deviceRoomPosition;
  81583. /** @hidden */
  81584. _deviceRoomRotationQuaternion: Quaternion;
  81585. private _standingMatrix;
  81586. /**
  81587. * Represents device position in babylon space.
  81588. */
  81589. devicePosition: Vector3;
  81590. /**
  81591. * Represents device rotation in babylon space.
  81592. */
  81593. deviceRotationQuaternion: Quaternion;
  81594. /**
  81595. * The scale of the device to be used when translating from device space to babylon space.
  81596. */
  81597. deviceScaleFactor: number;
  81598. private _deviceToWorld;
  81599. private _worldToDevice;
  81600. /**
  81601. * References to the webVR controllers for the vrDevice.
  81602. */
  81603. controllers: Array<WebVRController>;
  81604. /**
  81605. * Emits an event when a controller is attached.
  81606. */
  81607. onControllersAttachedObservable: Observable<WebVRController[]>;
  81608. /**
  81609. * Emits an event when a controller's mesh has been loaded;
  81610. */
  81611. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81612. /**
  81613. * Emits an event when the HMD's pose has been updated.
  81614. */
  81615. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81616. private _poseSet;
  81617. /**
  81618. * If the rig cameras be used as parent instead of this camera.
  81619. */
  81620. rigParenting: boolean;
  81621. private _lightOnControllers;
  81622. private _defaultHeight?;
  81623. /**
  81624. * Instantiates a WebVRFreeCamera.
  81625. * @param name The name of the WebVRFreeCamera
  81626. * @param position The starting anchor position for the camera
  81627. * @param scene The scene the camera belongs to
  81628. * @param webVROptions a set of customizable options for the webVRCamera
  81629. */
  81630. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81631. /**
  81632. * Gets the device distance from the ground in meters.
  81633. * @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.
  81634. */
  81635. deviceDistanceToRoomGround(): number;
  81636. /**
  81637. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81638. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81639. */
  81640. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81641. /**
  81642. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81643. * @returns A promise with a boolean set to if the standing matrix is supported.
  81644. */
  81645. useStandingMatrixAsync(): Promise<boolean>;
  81646. /**
  81647. * Disposes the camera
  81648. */
  81649. dispose(): void;
  81650. /**
  81651. * Gets a vrController by name.
  81652. * @param name The name of the controller to retreive
  81653. * @returns the controller matching the name specified or null if not found
  81654. */
  81655. getControllerByName(name: string): Nullable<WebVRController>;
  81656. private _leftController;
  81657. /**
  81658. * The controller corresponding to the users left hand.
  81659. */
  81660. readonly leftController: Nullable<WebVRController>;
  81661. private _rightController;
  81662. /**
  81663. * The controller corresponding to the users right hand.
  81664. */
  81665. readonly rightController: Nullable<WebVRController>;
  81666. /**
  81667. * Casts a ray forward from the vrCamera's gaze.
  81668. * @param length Length of the ray (default: 100)
  81669. * @returns the ray corresponding to the gaze
  81670. */
  81671. getForwardRay(length?: number): Ray;
  81672. /**
  81673. * @hidden
  81674. * Updates the camera based on device's frame data
  81675. */
  81676. _checkInputs(): void;
  81677. /**
  81678. * Updates the poseControlled values based on the input device pose.
  81679. * @param poseData Pose coming from the device
  81680. */
  81681. updateFromDevice(poseData: DevicePose): void;
  81682. private _htmlElementAttached;
  81683. private _detachIfAttached;
  81684. /**
  81685. * WebVR's attach control will start broadcasting frames to the device.
  81686. * Note that in certain browsers (chrome for example) this function must be called
  81687. * within a user-interaction callback. Example:
  81688. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81689. *
  81690. * @param element html element to attach the vrDevice to
  81691. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81692. */
  81693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81694. /**
  81695. * Detaches the camera from the html element and disables VR
  81696. *
  81697. * @param element html element to detach from
  81698. */
  81699. detachControl(element: HTMLElement): void;
  81700. /**
  81701. * @returns the name of this class
  81702. */
  81703. getClassName(): string;
  81704. /**
  81705. * Calls resetPose on the vrDisplay
  81706. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81707. */
  81708. resetToCurrentRotation(): void;
  81709. /**
  81710. * @hidden
  81711. * Updates the rig cameras (left and right eye)
  81712. */
  81713. _updateRigCameras(): void;
  81714. private _workingVector;
  81715. private _oneVector;
  81716. private _workingMatrix;
  81717. private updateCacheCalled;
  81718. private _correctPositionIfNotTrackPosition;
  81719. /**
  81720. * @hidden
  81721. * Updates the cached values of the camera
  81722. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81723. */
  81724. _updateCache(ignoreParentClass?: boolean): void;
  81725. /**
  81726. * @hidden
  81727. * Get current device position in babylon world
  81728. */
  81729. _computeDevicePosition(): void;
  81730. /**
  81731. * Updates the current device position and rotation in the babylon world
  81732. */
  81733. update(): void;
  81734. /**
  81735. * @hidden
  81736. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81737. * @returns an identity matrix
  81738. */
  81739. _getViewMatrix(): Matrix;
  81740. private _tmpMatrix;
  81741. /**
  81742. * This function is called by the two RIG cameras.
  81743. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81744. * @hidden
  81745. */
  81746. _getWebVRViewMatrix(): Matrix;
  81747. /** @hidden */
  81748. _getWebVRProjectionMatrix(): Matrix;
  81749. private _onGamepadConnectedObserver;
  81750. private _onGamepadDisconnectedObserver;
  81751. private _updateCacheWhenTrackingDisabledObserver;
  81752. /**
  81753. * Initializes the controllers and their meshes
  81754. */
  81755. initControllers(): void;
  81756. }
  81757. }
  81758. declare module BABYLON {
  81759. /**
  81760. * Size options for a post process
  81761. */
  81762. export type PostProcessOptions = {
  81763. width: number;
  81764. height: number;
  81765. };
  81766. /**
  81767. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81768. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81769. */
  81770. export class PostProcess {
  81771. /** Name of the PostProcess. */
  81772. name: string;
  81773. /**
  81774. * Gets or sets the unique id of the post process
  81775. */
  81776. uniqueId: number;
  81777. /**
  81778. * Width of the texture to apply the post process on
  81779. */
  81780. width: number;
  81781. /**
  81782. * Height of the texture to apply the post process on
  81783. */
  81784. height: number;
  81785. /**
  81786. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81787. * @hidden
  81788. */
  81789. _outputTexture: Nullable<InternalTexture>;
  81790. /**
  81791. * Sampling mode used by the shader
  81792. * See https://doc.babylonjs.com/classes/3.1/texture
  81793. */
  81794. renderTargetSamplingMode: number;
  81795. /**
  81796. * Clear color to use when screen clearing
  81797. */
  81798. clearColor: Color4;
  81799. /**
  81800. * If the buffer needs to be cleared before applying the post process. (default: true)
  81801. * Should be set to false if shader will overwrite all previous pixels.
  81802. */
  81803. autoClear: boolean;
  81804. /**
  81805. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81806. */
  81807. alphaMode: number;
  81808. /**
  81809. * Sets the setAlphaBlendConstants of the babylon engine
  81810. */
  81811. alphaConstants: Color4;
  81812. /**
  81813. * Animations to be used for the post processing
  81814. */
  81815. animations: Animation[];
  81816. /**
  81817. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81818. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81819. */
  81820. enablePixelPerfectMode: boolean;
  81821. /**
  81822. * Force the postprocess to be applied without taking in account viewport
  81823. */
  81824. forceFullscreenViewport: boolean;
  81825. /**
  81826. * List of inspectable custom properties (used by the Inspector)
  81827. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81828. */
  81829. inspectableCustomProperties: IInspectable[];
  81830. /**
  81831. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81832. *
  81833. * | Value | Type | Description |
  81834. * | ----- | ----------------------------------- | ----------- |
  81835. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81836. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81837. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81838. *
  81839. */
  81840. scaleMode: number;
  81841. /**
  81842. * Force textures to be a power of two (default: false)
  81843. */
  81844. alwaysForcePOT: boolean;
  81845. private _samples;
  81846. /**
  81847. * Number of sample textures (default: 1)
  81848. */
  81849. samples: number;
  81850. /**
  81851. * Modify the scale of the post process to be the same as the viewport (default: false)
  81852. */
  81853. adaptScaleToCurrentViewport: boolean;
  81854. private _camera;
  81855. private _scene;
  81856. private _engine;
  81857. private _options;
  81858. private _reusable;
  81859. private _textureType;
  81860. /**
  81861. * Smart array of input and output textures for the post process.
  81862. * @hidden
  81863. */
  81864. _textures: SmartArray<InternalTexture>;
  81865. /**
  81866. * The index in _textures that corresponds to the output texture.
  81867. * @hidden
  81868. */
  81869. _currentRenderTextureInd: number;
  81870. private _effect;
  81871. private _samplers;
  81872. private _fragmentUrl;
  81873. private _vertexUrl;
  81874. private _parameters;
  81875. private _scaleRatio;
  81876. protected _indexParameters: any;
  81877. private _shareOutputWithPostProcess;
  81878. private _texelSize;
  81879. private _forcedOutputTexture;
  81880. /**
  81881. * Returns the fragment url or shader name used in the post process.
  81882. * @returns the fragment url or name in the shader store.
  81883. */
  81884. getEffectName(): string;
  81885. /**
  81886. * An event triggered when the postprocess is activated.
  81887. */
  81888. onActivateObservable: Observable<Camera>;
  81889. private _onActivateObserver;
  81890. /**
  81891. * A function that is added to the onActivateObservable
  81892. */
  81893. onActivate: Nullable<(camera: Camera) => void>;
  81894. /**
  81895. * An event triggered when the postprocess changes its size.
  81896. */
  81897. onSizeChangedObservable: Observable<PostProcess>;
  81898. private _onSizeChangedObserver;
  81899. /**
  81900. * A function that is added to the onSizeChangedObservable
  81901. */
  81902. onSizeChanged: (postProcess: PostProcess) => void;
  81903. /**
  81904. * An event triggered when the postprocess applies its effect.
  81905. */
  81906. onApplyObservable: Observable<Effect>;
  81907. private _onApplyObserver;
  81908. /**
  81909. * A function that is added to the onApplyObservable
  81910. */
  81911. onApply: (effect: Effect) => void;
  81912. /**
  81913. * An event triggered before rendering the postprocess
  81914. */
  81915. onBeforeRenderObservable: Observable<Effect>;
  81916. private _onBeforeRenderObserver;
  81917. /**
  81918. * A function that is added to the onBeforeRenderObservable
  81919. */
  81920. onBeforeRender: (effect: Effect) => void;
  81921. /**
  81922. * An event triggered after rendering the postprocess
  81923. */
  81924. onAfterRenderObservable: Observable<Effect>;
  81925. private _onAfterRenderObserver;
  81926. /**
  81927. * A function that is added to the onAfterRenderObservable
  81928. */
  81929. onAfterRender: (efect: Effect) => void;
  81930. /**
  81931. * 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
  81932. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81933. */
  81934. inputTexture: InternalTexture;
  81935. /**
  81936. * Gets the camera which post process is applied to.
  81937. * @returns The camera the post process is applied to.
  81938. */
  81939. getCamera(): Camera;
  81940. /**
  81941. * Gets the texel size of the postprocess.
  81942. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81943. */
  81944. readonly texelSize: Vector2;
  81945. /**
  81946. * Creates a new instance PostProcess
  81947. * @param name The name of the PostProcess.
  81948. * @param fragmentUrl The url of the fragment shader to be used.
  81949. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81950. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81951. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81952. * @param camera The camera to apply the render pass to.
  81953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81954. * @param engine The engine which the post process will be applied. (default: current engine)
  81955. * @param reusable If the post process can be reused on the same frame. (default: false)
  81956. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81957. * @param textureType Type of textures used when performing the post process. (default: 0)
  81958. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81959. * @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
  81960. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81961. */
  81962. constructor(
  81963. /** Name of the PostProcess. */
  81964. 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);
  81965. /**
  81966. * Gets a string idenfifying the name of the class
  81967. * @returns "PostProcess" string
  81968. */
  81969. getClassName(): string;
  81970. /**
  81971. * Gets the engine which this post process belongs to.
  81972. * @returns The engine the post process was enabled with.
  81973. */
  81974. getEngine(): Engine;
  81975. /**
  81976. * The effect that is created when initializing the post process.
  81977. * @returns The created effect corresponding the the postprocess.
  81978. */
  81979. getEffect(): Effect;
  81980. /**
  81981. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81982. * @param postProcess The post process to share the output with.
  81983. * @returns This post process.
  81984. */
  81985. shareOutputWith(postProcess: PostProcess): PostProcess;
  81986. /**
  81987. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81988. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81989. */
  81990. useOwnOutput(): void;
  81991. /**
  81992. * Updates the effect with the current post process compile time values and recompiles the shader.
  81993. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81994. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81995. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81996. * @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
  81997. * @param onCompiled Called when the shader has been compiled.
  81998. * @param onError Called if there is an error when compiling a shader.
  81999. */
  82000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82001. /**
  82002. * The post process is reusable if it can be used multiple times within one frame.
  82003. * @returns If the post process is reusable
  82004. */
  82005. isReusable(): boolean;
  82006. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82007. markTextureDirty(): void;
  82008. /**
  82009. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82010. * 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.
  82011. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82012. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82013. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82014. * @returns The target texture that was bound to be written to.
  82015. */
  82016. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82017. /**
  82018. * If the post process is supported.
  82019. */
  82020. readonly isSupported: boolean;
  82021. /**
  82022. * The aspect ratio of the output texture.
  82023. */
  82024. readonly aspectRatio: number;
  82025. /**
  82026. * Get a value indicating if the post-process is ready to be used
  82027. * @returns true if the post-process is ready (shader is compiled)
  82028. */
  82029. isReady(): boolean;
  82030. /**
  82031. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82032. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82033. */
  82034. apply(): Nullable<Effect>;
  82035. private _disposeTextures;
  82036. /**
  82037. * Disposes the post process.
  82038. * @param camera The camera to dispose the post process on.
  82039. */
  82040. dispose(camera?: Camera): void;
  82041. }
  82042. }
  82043. declare module BABYLON {
  82044. /** @hidden */
  82045. export var kernelBlurVaryingDeclaration: {
  82046. name: string;
  82047. shader: string;
  82048. };
  82049. }
  82050. declare module BABYLON {
  82051. /** @hidden */
  82052. export var kernelBlurFragment: {
  82053. name: string;
  82054. shader: string;
  82055. };
  82056. }
  82057. declare module BABYLON {
  82058. /** @hidden */
  82059. export var kernelBlurFragment2: {
  82060. name: string;
  82061. shader: string;
  82062. };
  82063. }
  82064. declare module BABYLON {
  82065. /** @hidden */
  82066. export var kernelBlurPixelShader: {
  82067. name: string;
  82068. shader: string;
  82069. };
  82070. }
  82071. declare module BABYLON {
  82072. /** @hidden */
  82073. export var kernelBlurVertex: {
  82074. name: string;
  82075. shader: string;
  82076. };
  82077. }
  82078. declare module BABYLON {
  82079. /** @hidden */
  82080. export var kernelBlurVertexShader: {
  82081. name: string;
  82082. shader: string;
  82083. };
  82084. }
  82085. declare module BABYLON {
  82086. /**
  82087. * The Blur Post Process which blurs an image based on a kernel and direction.
  82088. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82089. */
  82090. export class BlurPostProcess extends PostProcess {
  82091. /** The direction in which to blur the image. */
  82092. direction: Vector2;
  82093. private blockCompilation;
  82094. protected _kernel: number;
  82095. protected _idealKernel: number;
  82096. protected _packedFloat: boolean;
  82097. private _staticDefines;
  82098. /**
  82099. * Sets the length in pixels of the blur sample region
  82100. */
  82101. /**
  82102. * Gets the length in pixels of the blur sample region
  82103. */
  82104. kernel: number;
  82105. /**
  82106. * Sets wether or not the blur needs to unpack/repack floats
  82107. */
  82108. /**
  82109. * Gets wether or not the blur is unpacking/repacking floats
  82110. */
  82111. packedFloat: boolean;
  82112. /**
  82113. * Creates a new instance BlurPostProcess
  82114. * @param name The name of the effect.
  82115. * @param direction The direction in which to blur the image.
  82116. * @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.
  82117. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82118. * @param camera The camera to apply the render pass to.
  82119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82120. * @param engine The engine which the post process will be applied. (default: current engine)
  82121. * @param reusable If the post process can be reused on the same frame. (default: false)
  82122. * @param textureType Type of textures used when performing the post process. (default: 0)
  82123. * @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)
  82124. */
  82125. constructor(name: string,
  82126. /** The direction in which to blur the image. */
  82127. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82128. /**
  82129. * Updates the effect with the current post process compile time values and recompiles the shader.
  82130. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82131. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82132. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82133. * @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
  82134. * @param onCompiled Called when the shader has been compiled.
  82135. * @param onError Called if there is an error when compiling a shader.
  82136. */
  82137. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82138. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82139. /**
  82140. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82141. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82142. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82143. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82144. * The gaps between physical kernels are compensated for in the weighting of the samples
  82145. * @param idealKernel Ideal blur kernel.
  82146. * @return Nearest best kernel.
  82147. */
  82148. protected _nearestBestKernel(idealKernel: number): number;
  82149. /**
  82150. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82151. * @param x The point on the Gaussian distribution to sample.
  82152. * @return the value of the Gaussian function at x.
  82153. */
  82154. protected _gaussianWeight(x: number): number;
  82155. /**
  82156. * Generates a string that can be used as a floating point number in GLSL.
  82157. * @param x Value to print.
  82158. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82159. * @return GLSL float string.
  82160. */
  82161. protected _glslFloat(x: number, decimalFigures?: number): string;
  82162. }
  82163. }
  82164. declare module BABYLON {
  82165. /**
  82166. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82167. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82168. * You can then easily use it as a reflectionTexture on a flat surface.
  82169. * In case the surface is not a plane, please consider relying on reflection probes.
  82170. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82171. */
  82172. export class MirrorTexture extends RenderTargetTexture {
  82173. private scene;
  82174. /**
  82175. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82176. * 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.
  82177. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82178. */
  82179. mirrorPlane: Plane;
  82180. /**
  82181. * Define the blur ratio used to blur the reflection if needed.
  82182. */
  82183. blurRatio: number;
  82184. /**
  82185. * Define the adaptive blur kernel used to blur the reflection if needed.
  82186. * This will autocompute the closest best match for the `blurKernel`
  82187. */
  82188. adaptiveBlurKernel: number;
  82189. /**
  82190. * Define the blur kernel used to blur the reflection if needed.
  82191. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82192. */
  82193. blurKernel: number;
  82194. /**
  82195. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82196. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82197. */
  82198. blurKernelX: number;
  82199. /**
  82200. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82201. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82202. */
  82203. blurKernelY: number;
  82204. private _autoComputeBlurKernel;
  82205. protected _onRatioRescale(): void;
  82206. private _updateGammaSpace;
  82207. private _imageProcessingConfigChangeObserver;
  82208. private _transformMatrix;
  82209. private _mirrorMatrix;
  82210. private _savedViewMatrix;
  82211. private _blurX;
  82212. private _blurY;
  82213. private _adaptiveBlurKernel;
  82214. private _blurKernelX;
  82215. private _blurKernelY;
  82216. private _blurRatio;
  82217. /**
  82218. * Instantiates a Mirror Texture.
  82219. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82220. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82221. * You can then easily use it as a reflectionTexture on a flat surface.
  82222. * In case the surface is not a plane, please consider relying on reflection probes.
  82223. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82224. * @param name
  82225. * @param size
  82226. * @param scene
  82227. * @param generateMipMaps
  82228. * @param type
  82229. * @param samplingMode
  82230. * @param generateDepthBuffer
  82231. */
  82232. constructor(name: string, size: number | {
  82233. width: number;
  82234. height: number;
  82235. } | {
  82236. ratio: number;
  82237. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82238. private _preparePostProcesses;
  82239. /**
  82240. * Clone the mirror texture.
  82241. * @returns the cloned texture
  82242. */
  82243. clone(): MirrorTexture;
  82244. /**
  82245. * Serialize the texture to a JSON representation you could use in Parse later on
  82246. * @returns the serialized JSON representation
  82247. */
  82248. serialize(): any;
  82249. /**
  82250. * Dispose the texture and release its associated resources.
  82251. */
  82252. dispose(): void;
  82253. }
  82254. }
  82255. declare module BABYLON {
  82256. /**
  82257. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82258. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82259. */
  82260. export class Texture extends BaseTexture {
  82261. /**
  82262. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82263. */
  82264. static SerializeBuffers: boolean;
  82265. /** @hidden */
  82266. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82267. /** @hidden */
  82268. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82269. /** @hidden */
  82270. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82271. /** nearest is mag = nearest and min = nearest and mip = linear */
  82272. static readonly NEAREST_SAMPLINGMODE: number;
  82273. /** nearest is mag = nearest and min = nearest and mip = linear */
  82274. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82275. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82276. static readonly BILINEAR_SAMPLINGMODE: number;
  82277. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82278. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82279. /** Trilinear is mag = linear and min = linear and mip = linear */
  82280. static readonly TRILINEAR_SAMPLINGMODE: number;
  82281. /** Trilinear is mag = linear and min = linear and mip = linear */
  82282. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82283. /** mag = nearest and min = nearest and mip = nearest */
  82284. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82285. /** mag = nearest and min = linear and mip = nearest */
  82286. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82287. /** mag = nearest and min = linear and mip = linear */
  82288. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82289. /** mag = nearest and min = linear and mip = none */
  82290. static readonly NEAREST_LINEAR: number;
  82291. /** mag = nearest and min = nearest and mip = none */
  82292. static readonly NEAREST_NEAREST: number;
  82293. /** mag = linear and min = nearest and mip = nearest */
  82294. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82295. /** mag = linear and min = nearest and mip = linear */
  82296. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82297. /** mag = linear and min = linear and mip = none */
  82298. static readonly LINEAR_LINEAR: number;
  82299. /** mag = linear and min = nearest and mip = none */
  82300. static readonly LINEAR_NEAREST: number;
  82301. /** Explicit coordinates mode */
  82302. static readonly EXPLICIT_MODE: number;
  82303. /** Spherical coordinates mode */
  82304. static readonly SPHERICAL_MODE: number;
  82305. /** Planar coordinates mode */
  82306. static readonly PLANAR_MODE: number;
  82307. /** Cubic coordinates mode */
  82308. static readonly CUBIC_MODE: number;
  82309. /** Projection coordinates mode */
  82310. static readonly PROJECTION_MODE: number;
  82311. /** Inverse Cubic coordinates mode */
  82312. static readonly SKYBOX_MODE: number;
  82313. /** Inverse Cubic coordinates mode */
  82314. static readonly INVCUBIC_MODE: number;
  82315. /** Equirectangular coordinates mode */
  82316. static readonly EQUIRECTANGULAR_MODE: number;
  82317. /** Equirectangular Fixed coordinates mode */
  82318. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82319. /** Equirectangular Fixed Mirrored coordinates mode */
  82320. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82321. /** Texture is not repeating outside of 0..1 UVs */
  82322. static readonly CLAMP_ADDRESSMODE: number;
  82323. /** Texture is repeating outside of 0..1 UVs */
  82324. static readonly WRAP_ADDRESSMODE: number;
  82325. /** Texture is repeating and mirrored */
  82326. static readonly MIRROR_ADDRESSMODE: number;
  82327. /**
  82328. * 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
  82329. */
  82330. static UseSerializedUrlIfAny: boolean;
  82331. /**
  82332. * Define the url of the texture.
  82333. */
  82334. url: Nullable<string>;
  82335. /**
  82336. * Define an offset on the texture to offset the u coordinates of the UVs
  82337. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82338. */
  82339. uOffset: number;
  82340. /**
  82341. * Define an offset on the texture to offset the v coordinates of the UVs
  82342. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82343. */
  82344. vOffset: number;
  82345. /**
  82346. * Define an offset on the texture to scale the u coordinates of the UVs
  82347. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82348. */
  82349. uScale: number;
  82350. /**
  82351. * Define an offset on the texture to scale the v coordinates of the UVs
  82352. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82353. */
  82354. vScale: number;
  82355. /**
  82356. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82357. * @see http://doc.babylonjs.com/how_to/more_materials
  82358. */
  82359. uAng: number;
  82360. /**
  82361. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82362. * @see http://doc.babylonjs.com/how_to/more_materials
  82363. */
  82364. vAng: number;
  82365. /**
  82366. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82367. * @see http://doc.babylonjs.com/how_to/more_materials
  82368. */
  82369. wAng: number;
  82370. /**
  82371. * Defines the center of rotation (U)
  82372. */
  82373. uRotationCenter: number;
  82374. /**
  82375. * Defines the center of rotation (V)
  82376. */
  82377. vRotationCenter: number;
  82378. /**
  82379. * Defines the center of rotation (W)
  82380. */
  82381. wRotationCenter: number;
  82382. /**
  82383. * Are mip maps generated for this texture or not.
  82384. */
  82385. readonly noMipmap: boolean;
  82386. /**
  82387. * List of inspectable custom properties (used by the Inspector)
  82388. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82389. */
  82390. inspectableCustomProperties: Nullable<IInspectable[]>;
  82391. private _noMipmap;
  82392. /** @hidden */
  82393. _invertY: boolean;
  82394. private _rowGenerationMatrix;
  82395. private _cachedTextureMatrix;
  82396. private _projectionModeMatrix;
  82397. private _t0;
  82398. private _t1;
  82399. private _t2;
  82400. private _cachedUOffset;
  82401. private _cachedVOffset;
  82402. private _cachedUScale;
  82403. private _cachedVScale;
  82404. private _cachedUAng;
  82405. private _cachedVAng;
  82406. private _cachedWAng;
  82407. private _cachedProjectionMatrixId;
  82408. private _cachedCoordinatesMode;
  82409. /** @hidden */
  82410. protected _initialSamplingMode: number;
  82411. /** @hidden */
  82412. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82413. private _deleteBuffer;
  82414. protected _format: Nullable<number>;
  82415. private _delayedOnLoad;
  82416. private _delayedOnError;
  82417. /**
  82418. * Observable triggered once the texture has been loaded.
  82419. */
  82420. onLoadObservable: Observable<Texture>;
  82421. protected _isBlocking: boolean;
  82422. /**
  82423. * Is the texture preventing material to render while loading.
  82424. * If false, a default texture will be used instead of the loading one during the preparation step.
  82425. */
  82426. isBlocking: boolean;
  82427. /**
  82428. * Get the current sampling mode associated with the texture.
  82429. */
  82430. readonly samplingMode: number;
  82431. /**
  82432. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82433. */
  82434. readonly invertY: boolean;
  82435. /**
  82436. * Instantiates a new texture.
  82437. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82438. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82439. * @param url define the url of the picture to load as a texture
  82440. * @param scene define the scene or engine the texture will belong to
  82441. * @param noMipmap define if the texture will require mip maps or not
  82442. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82443. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82444. * @param onLoad define a callback triggered when the texture has been loaded
  82445. * @param onError define a callback triggered when an error occurred during the loading session
  82446. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82447. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82448. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82449. */
  82450. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  82451. /**
  82452. * Update the url (and optional buffer) of this texture if url was null during construction.
  82453. * @param url the url of the texture
  82454. * @param buffer the buffer of the texture (defaults to null)
  82455. * @param onLoad callback called when the texture is loaded (defaults to null)
  82456. */
  82457. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82458. /**
  82459. * Finish the loading sequence of a texture flagged as delayed load.
  82460. * @hidden
  82461. */
  82462. delayLoad(): void;
  82463. private _prepareRowForTextureGeneration;
  82464. /**
  82465. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82466. * @returns the transform matrix of the texture.
  82467. */
  82468. getTextureMatrix(): Matrix;
  82469. /**
  82470. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82471. * @returns The reflection texture transform
  82472. */
  82473. getReflectionTextureMatrix(): Matrix;
  82474. /**
  82475. * Clones the texture.
  82476. * @returns the cloned texture
  82477. */
  82478. clone(): Texture;
  82479. /**
  82480. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82481. * @returns The JSON representation of the texture
  82482. */
  82483. serialize(): any;
  82484. /**
  82485. * Get the current class name of the texture useful for serialization or dynamic coding.
  82486. * @returns "Texture"
  82487. */
  82488. getClassName(): string;
  82489. /**
  82490. * Dispose the texture and release its associated resources.
  82491. */
  82492. dispose(): void;
  82493. /**
  82494. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82495. * @param parsedTexture Define the JSON representation of the texture
  82496. * @param scene Define the scene the parsed texture should be instantiated in
  82497. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82498. * @returns The parsed texture if successful
  82499. */
  82500. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82501. /**
  82502. * Creates a texture from its base 64 representation.
  82503. * @param data Define the base64 payload without the data: prefix
  82504. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82505. * @param scene Define the scene the texture should belong to
  82506. * @param noMipmap Forces the texture to not create mip map information if true
  82507. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82508. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82509. * @param onLoad define a callback triggered when the texture has been loaded
  82510. * @param onError define a callback triggered when an error occurred during the loading session
  82511. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82512. * @returns the created texture
  82513. */
  82514. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82515. /**
  82516. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82517. * @param data Define the base64 payload without the data: prefix
  82518. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82519. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82520. * @param scene Define the scene the texture should belong to
  82521. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82522. * @param noMipmap Forces the texture to not create mip map information if true
  82523. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82524. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82525. * @param onLoad define a callback triggered when the texture has been loaded
  82526. * @param onError define a callback triggered when an error occurred during the loading session
  82527. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82528. * @returns the created texture
  82529. */
  82530. 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;
  82531. }
  82532. }
  82533. declare module BABYLON {
  82534. /**
  82535. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82536. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82537. */
  82538. export class PostProcessManager {
  82539. private _scene;
  82540. private _indexBuffer;
  82541. private _vertexBuffers;
  82542. /**
  82543. * Creates a new instance PostProcess
  82544. * @param scene The scene that the post process is associated with.
  82545. */
  82546. constructor(scene: Scene);
  82547. private _prepareBuffers;
  82548. private _buildIndexBuffer;
  82549. /**
  82550. * Rebuilds the vertex buffers of the manager.
  82551. * @hidden
  82552. */
  82553. _rebuild(): void;
  82554. /**
  82555. * Prepares a frame to be run through a post process.
  82556. * @param sourceTexture The input texture to the post procesess. (default: null)
  82557. * @param postProcesses An array of post processes to be run. (default: null)
  82558. * @returns True if the post processes were able to be run.
  82559. * @hidden
  82560. */
  82561. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82562. /**
  82563. * Manually render a set of post processes to a texture.
  82564. * @param postProcesses An array of post processes to be run.
  82565. * @param targetTexture The target texture to render to.
  82566. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82567. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82568. * @param lodLevel defines which lod of the texture to render to
  82569. */
  82570. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82571. /**
  82572. * Finalize the result of the output of the postprocesses.
  82573. * @param doNotPresent If true the result will not be displayed to the screen.
  82574. * @param targetTexture The target texture to render to.
  82575. * @param faceIndex The index of the face to bind the target texture to.
  82576. * @param postProcesses The array of post processes to render.
  82577. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82578. * @hidden
  82579. */
  82580. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82581. /**
  82582. * Disposes of the post process manager.
  82583. */
  82584. dispose(): void;
  82585. }
  82586. }
  82587. declare module BABYLON {
  82588. /** Interface used by value gradients (color, factor, ...) */
  82589. export interface IValueGradient {
  82590. /**
  82591. * Gets or sets the gradient value (between 0 and 1)
  82592. */
  82593. gradient: number;
  82594. }
  82595. /** Class used to store color4 gradient */
  82596. export class ColorGradient implements IValueGradient {
  82597. /**
  82598. * Gets or sets the gradient value (between 0 and 1)
  82599. */
  82600. gradient: number;
  82601. /**
  82602. * Gets or sets first associated color
  82603. */
  82604. color1: Color4;
  82605. /**
  82606. * Gets or sets second associated color
  82607. */
  82608. color2?: Color4;
  82609. /**
  82610. * Will get a color picked randomly between color1 and color2.
  82611. * If color2 is undefined then color1 will be used
  82612. * @param result defines the target Color4 to store the result in
  82613. */
  82614. getColorToRef(result: Color4): void;
  82615. }
  82616. /** Class used to store color 3 gradient */
  82617. export class Color3Gradient implements IValueGradient {
  82618. /**
  82619. * Gets or sets the gradient value (between 0 and 1)
  82620. */
  82621. gradient: number;
  82622. /**
  82623. * Gets or sets the associated color
  82624. */
  82625. color: Color3;
  82626. }
  82627. /** Class used to store factor gradient */
  82628. export class FactorGradient implements IValueGradient {
  82629. /**
  82630. * Gets or sets the gradient value (between 0 and 1)
  82631. */
  82632. gradient: number;
  82633. /**
  82634. * Gets or sets first associated factor
  82635. */
  82636. factor1: number;
  82637. /**
  82638. * Gets or sets second associated factor
  82639. */
  82640. factor2?: number;
  82641. /**
  82642. * Will get a number picked randomly between factor1 and factor2.
  82643. * If factor2 is undefined then factor1 will be used
  82644. * @returns the picked number
  82645. */
  82646. getFactor(): number;
  82647. }
  82648. /**
  82649. * Helper used to simplify some generic gradient tasks
  82650. */
  82651. export class GradientHelper {
  82652. /**
  82653. * Gets the current gradient from an array of IValueGradient
  82654. * @param ratio defines the current ratio to get
  82655. * @param gradients defines the array of IValueGradient
  82656. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82657. */
  82658. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82659. }
  82660. }
  82661. declare module BABYLON {
  82662. interface ThinEngine {
  82663. /**
  82664. * Creates a dynamic texture
  82665. * @param width defines the width of the texture
  82666. * @param height defines the height of the texture
  82667. * @param generateMipMaps defines if the engine should generate the mip levels
  82668. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82669. * @returns the dynamic texture inside an InternalTexture
  82670. */
  82671. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82672. /**
  82673. * Update the content of a dynamic texture
  82674. * @param texture defines the texture to update
  82675. * @param canvas defines the canvas containing the source
  82676. * @param invertY defines if data must be stored with Y axis inverted
  82677. * @param premulAlpha defines if alpha is stored as premultiplied
  82678. * @param format defines the format of the data
  82679. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82680. */
  82681. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82682. }
  82683. }
  82684. declare module BABYLON {
  82685. /**
  82686. * A class extending Texture allowing drawing on a texture
  82687. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82688. */
  82689. export class DynamicTexture extends Texture {
  82690. private _generateMipMaps;
  82691. private _canvas;
  82692. private _context;
  82693. private _engine;
  82694. /**
  82695. * Creates a DynamicTexture
  82696. * @param name defines the name of the texture
  82697. * @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
  82698. * @param scene defines the scene where you want the texture
  82699. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82700. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82701. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82702. */
  82703. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82704. /**
  82705. * Get the current class name of the texture useful for serialization or dynamic coding.
  82706. * @returns "DynamicTexture"
  82707. */
  82708. getClassName(): string;
  82709. /**
  82710. * Gets the current state of canRescale
  82711. */
  82712. readonly canRescale: boolean;
  82713. private _recreate;
  82714. /**
  82715. * Scales the texture
  82716. * @param ratio the scale factor to apply to both width and height
  82717. */
  82718. scale(ratio: number): void;
  82719. /**
  82720. * Resizes the texture
  82721. * @param width the new width
  82722. * @param height the new height
  82723. */
  82724. scaleTo(width: number, height: number): void;
  82725. /**
  82726. * Gets the context of the canvas used by the texture
  82727. * @returns the canvas context of the dynamic texture
  82728. */
  82729. getContext(): CanvasRenderingContext2D;
  82730. /**
  82731. * Clears the texture
  82732. */
  82733. clear(): void;
  82734. /**
  82735. * Updates the texture
  82736. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82737. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82738. */
  82739. update(invertY?: boolean, premulAlpha?: boolean): void;
  82740. /**
  82741. * Draws text onto the texture
  82742. * @param text defines the text to be drawn
  82743. * @param x defines the placement of the text from the left
  82744. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82745. * @param font defines the font to be used with font-style, font-size, font-name
  82746. * @param color defines the color used for the text
  82747. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82748. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82749. * @param update defines whether texture is immediately update (default is true)
  82750. */
  82751. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82752. /**
  82753. * Clones the texture
  82754. * @returns the clone of the texture.
  82755. */
  82756. clone(): DynamicTexture;
  82757. /**
  82758. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82759. * @returns a serialized dynamic texture object
  82760. */
  82761. serialize(): any;
  82762. /** @hidden */
  82763. _rebuild(): void;
  82764. }
  82765. }
  82766. declare module BABYLON {
  82767. interface AbstractScene {
  82768. /**
  82769. * The list of procedural textures added to the scene
  82770. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82771. */
  82772. proceduralTextures: Array<ProceduralTexture>;
  82773. }
  82774. /**
  82775. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82776. * in a given scene.
  82777. */
  82778. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82779. /**
  82780. * The component name helpfull to identify the component in the list of scene components.
  82781. */
  82782. readonly name: string;
  82783. /**
  82784. * The scene the component belongs to.
  82785. */
  82786. scene: Scene;
  82787. /**
  82788. * Creates a new instance of the component for the given scene
  82789. * @param scene Defines the scene to register the component in
  82790. */
  82791. constructor(scene: Scene);
  82792. /**
  82793. * Registers the component in a given scene
  82794. */
  82795. register(): void;
  82796. /**
  82797. * Rebuilds the elements related to this component in case of
  82798. * context lost for instance.
  82799. */
  82800. rebuild(): void;
  82801. /**
  82802. * Disposes the component and the associated ressources.
  82803. */
  82804. dispose(): void;
  82805. private _beforeClear;
  82806. }
  82807. }
  82808. declare module BABYLON {
  82809. interface ThinEngine {
  82810. /**
  82811. * Creates a new render target cube texture
  82812. * @param size defines the size of the texture
  82813. * @param options defines the options used to create the texture
  82814. * @returns a new render target cube texture stored in an InternalTexture
  82815. */
  82816. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82817. }
  82818. }
  82819. declare module BABYLON {
  82820. /** @hidden */
  82821. export var proceduralVertexShader: {
  82822. name: string;
  82823. shader: string;
  82824. };
  82825. }
  82826. declare module BABYLON {
  82827. /**
  82828. * 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.
  82829. * This is the base class of any Procedural texture and contains most of the shareable code.
  82830. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82831. */
  82832. export class ProceduralTexture extends Texture {
  82833. isCube: boolean;
  82834. /**
  82835. * Define if the texture is enabled or not (disabled texture will not render)
  82836. */
  82837. isEnabled: boolean;
  82838. /**
  82839. * Define if the texture must be cleared before rendering (default is true)
  82840. */
  82841. autoClear: boolean;
  82842. /**
  82843. * Callback called when the texture is generated
  82844. */
  82845. onGenerated: () => void;
  82846. /**
  82847. * Event raised when the texture is generated
  82848. */
  82849. onGeneratedObservable: Observable<ProceduralTexture>;
  82850. /** @hidden */
  82851. _generateMipMaps: boolean;
  82852. /** @hidden **/
  82853. _effect: Effect;
  82854. /** @hidden */
  82855. _textures: {
  82856. [key: string]: Texture;
  82857. };
  82858. private _size;
  82859. private _currentRefreshId;
  82860. private _refreshRate;
  82861. private _vertexBuffers;
  82862. private _indexBuffer;
  82863. private _uniforms;
  82864. private _samplers;
  82865. private _fragment;
  82866. private _floats;
  82867. private _ints;
  82868. private _floatsArrays;
  82869. private _colors3;
  82870. private _colors4;
  82871. private _vectors2;
  82872. private _vectors3;
  82873. private _matrices;
  82874. private _fallbackTexture;
  82875. private _fallbackTextureUsed;
  82876. private _engine;
  82877. private _cachedDefines;
  82878. private _contentUpdateId;
  82879. private _contentData;
  82880. /**
  82881. * Instantiates a new procedural texture.
  82882. * 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.
  82883. * This is the base class of any Procedural texture and contains most of the shareable code.
  82884. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82885. * @param name Define the name of the texture
  82886. * @param size Define the size of the texture to create
  82887. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82888. * @param scene Define the scene the texture belongs to
  82889. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82890. * @param generateMipMaps Define if the texture should creates mip maps or not
  82891. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82892. */
  82893. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82894. /**
  82895. * The effect that is created when initializing the post process.
  82896. * @returns The created effect corresponding the the postprocess.
  82897. */
  82898. getEffect(): Effect;
  82899. /**
  82900. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82901. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82902. */
  82903. getContent(): Nullable<ArrayBufferView>;
  82904. private _createIndexBuffer;
  82905. /** @hidden */
  82906. _rebuild(): void;
  82907. /**
  82908. * Resets the texture in order to recreate its associated resources.
  82909. * This can be called in case of context loss
  82910. */
  82911. reset(): void;
  82912. protected _getDefines(): string;
  82913. /**
  82914. * Is the texture ready to be used ? (rendered at least once)
  82915. * @returns true if ready, otherwise, false.
  82916. */
  82917. isReady(): boolean;
  82918. /**
  82919. * Resets the refresh counter of the texture and start bak from scratch.
  82920. * Could be useful to regenerate the texture if it is setup to render only once.
  82921. */
  82922. resetRefreshCounter(): void;
  82923. /**
  82924. * Set the fragment shader to use in order to render the texture.
  82925. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82926. */
  82927. setFragment(fragment: any): void;
  82928. /**
  82929. * Define the refresh rate of the texture or the rendering frequency.
  82930. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82931. */
  82932. refreshRate: number;
  82933. /** @hidden */
  82934. _shouldRender(): boolean;
  82935. /**
  82936. * Get the size the texture is rendering at.
  82937. * @returns the size (texture is always squared)
  82938. */
  82939. getRenderSize(): number;
  82940. /**
  82941. * Resize the texture to new value.
  82942. * @param size Define the new size the texture should have
  82943. * @param generateMipMaps Define whether the new texture should create mip maps
  82944. */
  82945. resize(size: number, generateMipMaps: boolean): void;
  82946. private _checkUniform;
  82947. /**
  82948. * Set a texture in the shader program used to render.
  82949. * @param name Define the name of the uniform samplers as defined in the shader
  82950. * @param texture Define the texture to bind to this sampler
  82951. * @return the texture itself allowing "fluent" like uniform updates
  82952. */
  82953. setTexture(name: string, texture: Texture): ProceduralTexture;
  82954. /**
  82955. * Set a float in the shader.
  82956. * @param name Define the name of the uniform as defined in the shader
  82957. * @param value Define the value to give to the uniform
  82958. * @return the texture itself allowing "fluent" like uniform updates
  82959. */
  82960. setFloat(name: string, value: number): ProceduralTexture;
  82961. /**
  82962. * Set a int in the shader.
  82963. * @param name Define the name of the uniform as defined in the shader
  82964. * @param value Define the value to give to the uniform
  82965. * @return the texture itself allowing "fluent" like uniform updates
  82966. */
  82967. setInt(name: string, value: number): ProceduralTexture;
  82968. /**
  82969. * Set an array of floats in the shader.
  82970. * @param name Define the name of the uniform as defined in the shader
  82971. * @param value Define the value to give to the uniform
  82972. * @return the texture itself allowing "fluent" like uniform updates
  82973. */
  82974. setFloats(name: string, value: number[]): ProceduralTexture;
  82975. /**
  82976. * Set a vec3 in the shader from a Color3.
  82977. * @param name Define the name of the uniform as defined in the shader
  82978. * @param value Define the value to give to the uniform
  82979. * @return the texture itself allowing "fluent" like uniform updates
  82980. */
  82981. setColor3(name: string, value: Color3): ProceduralTexture;
  82982. /**
  82983. * Set a vec4 in the shader from a Color4.
  82984. * @param name Define the name of the uniform as defined in the shader
  82985. * @param value Define the value to give to the uniform
  82986. * @return the texture itself allowing "fluent" like uniform updates
  82987. */
  82988. setColor4(name: string, value: Color4): ProceduralTexture;
  82989. /**
  82990. * Set a vec2 in the shader from a Vector2.
  82991. * @param name Define the name of the uniform as defined in the shader
  82992. * @param value Define the value to give to the uniform
  82993. * @return the texture itself allowing "fluent" like uniform updates
  82994. */
  82995. setVector2(name: string, value: Vector2): ProceduralTexture;
  82996. /**
  82997. * Set a vec3 in the shader from a Vector3.
  82998. * @param name Define the name of the uniform as defined in the shader
  82999. * @param value Define the value to give to the uniform
  83000. * @return the texture itself allowing "fluent" like uniform updates
  83001. */
  83002. setVector3(name: string, value: Vector3): ProceduralTexture;
  83003. /**
  83004. * Set a mat4 in the shader from a MAtrix.
  83005. * @param name Define the name of the uniform as defined in the shader
  83006. * @param value Define the value to give to the uniform
  83007. * @return the texture itself allowing "fluent" like uniform updates
  83008. */
  83009. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83010. /**
  83011. * Render the texture to its associated render target.
  83012. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83013. */
  83014. render(useCameraPostProcess?: boolean): void;
  83015. /**
  83016. * Clone the texture.
  83017. * @returns the cloned texture
  83018. */
  83019. clone(): ProceduralTexture;
  83020. /**
  83021. * Dispose the texture and release its asoociated resources.
  83022. */
  83023. dispose(): void;
  83024. }
  83025. }
  83026. declare module BABYLON {
  83027. /**
  83028. * This represents the base class for particle system in Babylon.
  83029. * 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.
  83030. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83031. * @example https://doc.babylonjs.com/babylon101/particles
  83032. */
  83033. export class BaseParticleSystem {
  83034. /**
  83035. * Source color is added to the destination color without alpha affecting the result
  83036. */
  83037. static BLENDMODE_ONEONE: number;
  83038. /**
  83039. * Blend current color and particle color using particle’s alpha
  83040. */
  83041. static BLENDMODE_STANDARD: number;
  83042. /**
  83043. * Add current color and particle color multiplied by particle’s alpha
  83044. */
  83045. static BLENDMODE_ADD: number;
  83046. /**
  83047. * Multiply current color with particle color
  83048. */
  83049. static BLENDMODE_MULTIPLY: number;
  83050. /**
  83051. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83052. */
  83053. static BLENDMODE_MULTIPLYADD: number;
  83054. /**
  83055. * List of animations used by the particle system.
  83056. */
  83057. animations: Animation[];
  83058. /**
  83059. * The id of the Particle system.
  83060. */
  83061. id: string;
  83062. /**
  83063. * The friendly name of the Particle system.
  83064. */
  83065. name: string;
  83066. /**
  83067. * The rendering group used by the Particle system to chose when to render.
  83068. */
  83069. renderingGroupId: number;
  83070. /**
  83071. * The emitter represents the Mesh or position we are attaching the particle system to.
  83072. */
  83073. emitter: Nullable<AbstractMesh | Vector3>;
  83074. /**
  83075. * The maximum number of particles to emit per frame
  83076. */
  83077. emitRate: number;
  83078. /**
  83079. * If you want to launch only a few particles at once, that can be done, as well.
  83080. */
  83081. manualEmitCount: number;
  83082. /**
  83083. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83084. */
  83085. updateSpeed: number;
  83086. /**
  83087. * The amount of time the particle system is running (depends of the overall update speed).
  83088. */
  83089. targetStopDuration: number;
  83090. /**
  83091. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83092. */
  83093. disposeOnStop: boolean;
  83094. /**
  83095. * Minimum power of emitting particles.
  83096. */
  83097. minEmitPower: number;
  83098. /**
  83099. * Maximum power of emitting particles.
  83100. */
  83101. maxEmitPower: number;
  83102. /**
  83103. * Minimum life time of emitting particles.
  83104. */
  83105. minLifeTime: number;
  83106. /**
  83107. * Maximum life time of emitting particles.
  83108. */
  83109. maxLifeTime: number;
  83110. /**
  83111. * Minimum Size of emitting particles.
  83112. */
  83113. minSize: number;
  83114. /**
  83115. * Maximum Size of emitting particles.
  83116. */
  83117. maxSize: number;
  83118. /**
  83119. * Minimum scale of emitting particles on X axis.
  83120. */
  83121. minScaleX: number;
  83122. /**
  83123. * Maximum scale of emitting particles on X axis.
  83124. */
  83125. maxScaleX: number;
  83126. /**
  83127. * Minimum scale of emitting particles on Y axis.
  83128. */
  83129. minScaleY: number;
  83130. /**
  83131. * Maximum scale of emitting particles on Y axis.
  83132. */
  83133. maxScaleY: number;
  83134. /**
  83135. * Gets or sets the minimal initial rotation in radians.
  83136. */
  83137. minInitialRotation: number;
  83138. /**
  83139. * Gets or sets the maximal initial rotation in radians.
  83140. */
  83141. maxInitialRotation: number;
  83142. /**
  83143. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83144. */
  83145. minAngularSpeed: number;
  83146. /**
  83147. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83148. */
  83149. maxAngularSpeed: number;
  83150. /**
  83151. * The texture used to render each particle. (this can be a spritesheet)
  83152. */
  83153. particleTexture: Nullable<Texture>;
  83154. /**
  83155. * The layer mask we are rendering the particles through.
  83156. */
  83157. layerMask: number;
  83158. /**
  83159. * This can help using your own shader to render the particle system.
  83160. * The according effect will be created
  83161. */
  83162. customShader: any;
  83163. /**
  83164. * By default particle system starts as soon as they are created. This prevents the
  83165. * automatic start to happen and let you decide when to start emitting particles.
  83166. */
  83167. preventAutoStart: boolean;
  83168. private _noiseTexture;
  83169. /**
  83170. * Gets or sets a texture used to add random noise to particle positions
  83171. */
  83172. noiseTexture: Nullable<ProceduralTexture>;
  83173. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83174. noiseStrength: Vector3;
  83175. /**
  83176. * Callback triggered when the particle animation is ending.
  83177. */
  83178. onAnimationEnd: Nullable<() => void>;
  83179. /**
  83180. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83181. */
  83182. blendMode: number;
  83183. /**
  83184. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83185. * to override the particles.
  83186. */
  83187. forceDepthWrite: boolean;
  83188. /** 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 */
  83189. preWarmCycles: number;
  83190. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83191. preWarmStepOffset: number;
  83192. /**
  83193. * 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)
  83194. */
  83195. spriteCellChangeSpeed: number;
  83196. /**
  83197. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83198. */
  83199. startSpriteCellID: number;
  83200. /**
  83201. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83202. */
  83203. endSpriteCellID: number;
  83204. /**
  83205. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83206. */
  83207. spriteCellWidth: number;
  83208. /**
  83209. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83210. */
  83211. spriteCellHeight: number;
  83212. /**
  83213. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83214. */
  83215. spriteRandomStartCell: boolean;
  83216. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83217. translationPivot: Vector2;
  83218. /** @hidden */
  83219. protected _isAnimationSheetEnabled: boolean;
  83220. /**
  83221. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83222. */
  83223. beginAnimationOnStart: boolean;
  83224. /**
  83225. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83226. */
  83227. beginAnimationFrom: number;
  83228. /**
  83229. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83230. */
  83231. beginAnimationTo: number;
  83232. /**
  83233. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83234. */
  83235. beginAnimationLoop: boolean;
  83236. /**
  83237. * Gets or sets a world offset applied to all particles
  83238. */
  83239. worldOffset: Vector3;
  83240. /**
  83241. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83242. */
  83243. isAnimationSheetEnabled: boolean;
  83244. /**
  83245. * Get hosting scene
  83246. * @returns the scene
  83247. */
  83248. getScene(): Scene;
  83249. /**
  83250. * You can use gravity if you want to give an orientation to your particles.
  83251. */
  83252. gravity: Vector3;
  83253. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83254. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83255. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83256. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83257. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83258. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83259. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83260. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83261. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83262. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83263. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83264. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83265. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83266. /**
  83267. * Defines the delay in milliseconds before starting the system (0 by default)
  83268. */
  83269. startDelay: number;
  83270. /**
  83271. * Gets the current list of drag gradients.
  83272. * You must use addDragGradient and removeDragGradient to udpate this list
  83273. * @returns the list of drag gradients
  83274. */
  83275. getDragGradients(): Nullable<Array<FactorGradient>>;
  83276. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83277. limitVelocityDamping: number;
  83278. /**
  83279. * Gets the current list of limit velocity gradients.
  83280. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83281. * @returns the list of limit velocity gradients
  83282. */
  83283. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83284. /**
  83285. * Gets the current list of color gradients.
  83286. * You must use addColorGradient and removeColorGradient to udpate this list
  83287. * @returns the list of color gradients
  83288. */
  83289. getColorGradients(): Nullable<Array<ColorGradient>>;
  83290. /**
  83291. * Gets the current list of size gradients.
  83292. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83293. * @returns the list of size gradients
  83294. */
  83295. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83296. /**
  83297. * Gets the current list of color remap gradients.
  83298. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83299. * @returns the list of color remap gradients
  83300. */
  83301. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83302. /**
  83303. * Gets the current list of alpha remap gradients.
  83304. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83305. * @returns the list of alpha remap gradients
  83306. */
  83307. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83308. /**
  83309. * Gets the current list of life time gradients.
  83310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83311. * @returns the list of life time gradients
  83312. */
  83313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83314. /**
  83315. * Gets the current list of angular speed gradients.
  83316. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83317. * @returns the list of angular speed gradients
  83318. */
  83319. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83320. /**
  83321. * Gets the current list of velocity gradients.
  83322. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83323. * @returns the list of velocity gradients
  83324. */
  83325. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83326. /**
  83327. * Gets the current list of start size gradients.
  83328. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83329. * @returns the list of start size gradients
  83330. */
  83331. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83332. /**
  83333. * Gets the current list of emit rate gradients.
  83334. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83335. * @returns the list of emit rate gradients
  83336. */
  83337. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83338. /**
  83339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83340. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83341. */
  83342. direction1: Vector3;
  83343. /**
  83344. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83345. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83346. */
  83347. direction2: Vector3;
  83348. /**
  83349. * 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.
  83350. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83351. */
  83352. minEmitBox: Vector3;
  83353. /**
  83354. * 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.
  83355. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83356. */
  83357. maxEmitBox: Vector3;
  83358. /**
  83359. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83360. */
  83361. color1: Color4;
  83362. /**
  83363. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83364. */
  83365. color2: Color4;
  83366. /**
  83367. * Color the particle will have at the end of its lifetime
  83368. */
  83369. colorDead: Color4;
  83370. /**
  83371. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83372. */
  83373. textureMask: Color4;
  83374. /**
  83375. * The particle emitter type defines the emitter used by the particle system.
  83376. * It can be for example box, sphere, or cone...
  83377. */
  83378. particleEmitterType: IParticleEmitterType;
  83379. /** @hidden */
  83380. _isSubEmitter: boolean;
  83381. /**
  83382. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83383. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83384. */
  83385. billboardMode: number;
  83386. protected _isBillboardBased: boolean;
  83387. /**
  83388. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83389. */
  83390. isBillboardBased: boolean;
  83391. /**
  83392. * The scene the particle system belongs to.
  83393. */
  83394. protected _scene: Scene;
  83395. /**
  83396. * Local cache of defines for image processing.
  83397. */
  83398. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83399. /**
  83400. * Default configuration related to image processing available in the standard Material.
  83401. */
  83402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83403. /**
  83404. * Gets the image processing configuration used either in this material.
  83405. */
  83406. /**
  83407. * Sets the Default image processing configuration used either in the this material.
  83408. *
  83409. * If sets to null, the scene one is in use.
  83410. */
  83411. imageProcessingConfiguration: ImageProcessingConfiguration;
  83412. /**
  83413. * Attaches a new image processing configuration to the Standard Material.
  83414. * @param configuration
  83415. */
  83416. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83417. /** @hidden */
  83418. protected _reset(): void;
  83419. /** @hidden */
  83420. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83421. /**
  83422. * Instantiates a particle system.
  83423. * 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.
  83424. * @param name The name of the particle system
  83425. */
  83426. constructor(name: string);
  83427. /**
  83428. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83429. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83430. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83431. * @returns the emitter
  83432. */
  83433. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83434. /**
  83435. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83436. * @param radius The radius of the hemisphere to emit from
  83437. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83438. * @returns the emitter
  83439. */
  83440. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83441. /**
  83442. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83443. * @param radius The radius of the sphere to emit from
  83444. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83445. * @returns the emitter
  83446. */
  83447. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83448. /**
  83449. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83450. * @param radius The radius of the sphere to emit from
  83451. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83452. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83453. * @returns the emitter
  83454. */
  83455. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83456. /**
  83457. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83458. * @param radius The radius of the emission cylinder
  83459. * @param height The height of the emission cylinder
  83460. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83461. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83462. * @returns the emitter
  83463. */
  83464. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83465. /**
  83466. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83467. * @param radius The radius of the cylinder to emit from
  83468. * @param height The height of the emission cylinder
  83469. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83470. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83471. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83472. * @returns the emitter
  83473. */
  83474. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83475. /**
  83476. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83477. * @param radius The radius of the cone to emit from
  83478. * @param angle The base angle of the cone
  83479. * @returns the emitter
  83480. */
  83481. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83482. /**
  83483. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83484. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83485. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83486. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83487. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83488. * @returns the emitter
  83489. */
  83490. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83491. }
  83492. }
  83493. declare module BABYLON {
  83494. /**
  83495. * Type of sub emitter
  83496. */
  83497. export enum SubEmitterType {
  83498. /**
  83499. * Attached to the particle over it's lifetime
  83500. */
  83501. ATTACHED = 0,
  83502. /**
  83503. * Created when the particle dies
  83504. */
  83505. END = 1
  83506. }
  83507. /**
  83508. * Sub emitter class used to emit particles from an existing particle
  83509. */
  83510. export class SubEmitter {
  83511. /**
  83512. * the particle system to be used by the sub emitter
  83513. */
  83514. particleSystem: ParticleSystem;
  83515. /**
  83516. * Type of the submitter (Default: END)
  83517. */
  83518. type: SubEmitterType;
  83519. /**
  83520. * 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)
  83521. * Note: This only is supported when using an emitter of type Mesh
  83522. */
  83523. inheritDirection: boolean;
  83524. /**
  83525. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83526. */
  83527. inheritedVelocityAmount: number;
  83528. /**
  83529. * Creates a sub emitter
  83530. * @param particleSystem the particle system to be used by the sub emitter
  83531. */
  83532. constructor(
  83533. /**
  83534. * the particle system to be used by the sub emitter
  83535. */
  83536. particleSystem: ParticleSystem);
  83537. /**
  83538. * Clones the sub emitter
  83539. * @returns the cloned sub emitter
  83540. */
  83541. clone(): SubEmitter;
  83542. /**
  83543. * Serialize current object to a JSON object
  83544. * @returns the serialized object
  83545. */
  83546. serialize(): any;
  83547. /** @hidden */
  83548. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83549. /**
  83550. * Creates a new SubEmitter from a serialized JSON version
  83551. * @param serializationObject defines the JSON object to read from
  83552. * @param scene defines the hosting scene
  83553. * @param rootUrl defines the rootUrl for data loading
  83554. * @returns a new SubEmitter
  83555. */
  83556. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83557. /** Release associated resources */
  83558. dispose(): void;
  83559. }
  83560. }
  83561. declare module BABYLON {
  83562. /** @hidden */
  83563. export var clipPlaneFragmentDeclaration: {
  83564. name: string;
  83565. shader: string;
  83566. };
  83567. }
  83568. declare module BABYLON {
  83569. /** @hidden */
  83570. export var imageProcessingDeclaration: {
  83571. name: string;
  83572. shader: string;
  83573. };
  83574. }
  83575. declare module BABYLON {
  83576. /** @hidden */
  83577. export var imageProcessingFunctions: {
  83578. name: string;
  83579. shader: string;
  83580. };
  83581. }
  83582. declare module BABYLON {
  83583. /** @hidden */
  83584. export var clipPlaneFragment: {
  83585. name: string;
  83586. shader: string;
  83587. };
  83588. }
  83589. declare module BABYLON {
  83590. /** @hidden */
  83591. export var particlesPixelShader: {
  83592. name: string;
  83593. shader: string;
  83594. };
  83595. }
  83596. declare module BABYLON {
  83597. /** @hidden */
  83598. export var clipPlaneVertexDeclaration: {
  83599. name: string;
  83600. shader: string;
  83601. };
  83602. }
  83603. declare module BABYLON {
  83604. /** @hidden */
  83605. export var clipPlaneVertex: {
  83606. name: string;
  83607. shader: string;
  83608. };
  83609. }
  83610. declare module BABYLON {
  83611. /** @hidden */
  83612. export var particlesVertexShader: {
  83613. name: string;
  83614. shader: string;
  83615. };
  83616. }
  83617. declare module BABYLON {
  83618. /**
  83619. * This represents a particle system in Babylon.
  83620. * 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.
  83621. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83622. * @example https://doc.babylonjs.com/babylon101/particles
  83623. */
  83624. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83625. /**
  83626. * Billboard mode will only apply to Y axis
  83627. */
  83628. static readonly BILLBOARDMODE_Y: number;
  83629. /**
  83630. * Billboard mode will apply to all axes
  83631. */
  83632. static readonly BILLBOARDMODE_ALL: number;
  83633. /**
  83634. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83635. */
  83636. static readonly BILLBOARDMODE_STRETCHED: number;
  83637. /**
  83638. * This function can be defined to provide custom update for active particles.
  83639. * This function will be called instead of regular update (age, position, color, etc.).
  83640. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83641. */
  83642. updateFunction: (particles: Particle[]) => void;
  83643. private _emitterWorldMatrix;
  83644. /**
  83645. * This function can be defined to specify initial direction for every new particle.
  83646. * It by default use the emitterType defined function
  83647. */
  83648. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83649. /**
  83650. * This function can be defined to specify initial position for every new particle.
  83651. * It by default use the emitterType defined function
  83652. */
  83653. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83654. /**
  83655. * @hidden
  83656. */
  83657. _inheritedVelocityOffset: Vector3;
  83658. /**
  83659. * An event triggered when the system is disposed
  83660. */
  83661. onDisposeObservable: Observable<ParticleSystem>;
  83662. private _onDisposeObserver;
  83663. /**
  83664. * Sets a callback that will be triggered when the system is disposed
  83665. */
  83666. onDispose: () => void;
  83667. private _particles;
  83668. private _epsilon;
  83669. private _capacity;
  83670. private _stockParticles;
  83671. private _newPartsExcess;
  83672. private _vertexData;
  83673. private _vertexBuffer;
  83674. private _vertexBuffers;
  83675. private _spriteBuffer;
  83676. private _indexBuffer;
  83677. private _effect;
  83678. private _customEffect;
  83679. private _cachedDefines;
  83680. private _scaledColorStep;
  83681. private _colorDiff;
  83682. private _scaledDirection;
  83683. private _scaledGravity;
  83684. private _currentRenderId;
  83685. private _alive;
  83686. private _useInstancing;
  83687. private _started;
  83688. private _stopped;
  83689. private _actualFrame;
  83690. private _scaledUpdateSpeed;
  83691. private _vertexBufferSize;
  83692. /** @hidden */
  83693. _currentEmitRateGradient: Nullable<FactorGradient>;
  83694. /** @hidden */
  83695. _currentEmitRate1: number;
  83696. /** @hidden */
  83697. _currentEmitRate2: number;
  83698. /** @hidden */
  83699. _currentStartSizeGradient: Nullable<FactorGradient>;
  83700. /** @hidden */
  83701. _currentStartSize1: number;
  83702. /** @hidden */
  83703. _currentStartSize2: number;
  83704. private readonly _rawTextureWidth;
  83705. private _rampGradientsTexture;
  83706. private _useRampGradients;
  83707. /** Gets or sets a boolean indicating that ramp gradients must be used
  83708. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83709. */
  83710. useRampGradients: boolean;
  83711. /**
  83712. * 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.
  83713. * 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: [])
  83714. */
  83715. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83716. private _subEmitters;
  83717. /**
  83718. * @hidden
  83719. * If the particle systems emitter should be disposed when the particle system is disposed
  83720. */
  83721. _disposeEmitterOnDispose: boolean;
  83722. /**
  83723. * The current active Sub-systems, this property is used by the root particle system only.
  83724. */
  83725. activeSubSystems: Array<ParticleSystem>;
  83726. private _rootParticleSystem;
  83727. /**
  83728. * Gets the current list of active particles
  83729. */
  83730. readonly particles: Particle[];
  83731. /**
  83732. * Returns the string "ParticleSystem"
  83733. * @returns a string containing the class name
  83734. */
  83735. getClassName(): string;
  83736. /**
  83737. * Instantiates a particle system.
  83738. * 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.
  83739. * @param name The name of the particle system
  83740. * @param capacity The max number of particles alive at the same time
  83741. * @param scene The scene the particle system belongs to
  83742. * @param customEffect a custom effect used to change the way particles are rendered by default
  83743. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83744. * @param epsilon Offset used to render the particles
  83745. */
  83746. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83747. private _addFactorGradient;
  83748. private _removeFactorGradient;
  83749. /**
  83750. * Adds a new life time gradient
  83751. * @param gradient defines the gradient to use (between 0 and 1)
  83752. * @param factor defines the life time factor to affect to the specified gradient
  83753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83754. * @returns the current particle system
  83755. */
  83756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83757. /**
  83758. * Remove a specific life time gradient
  83759. * @param gradient defines the gradient to remove
  83760. * @returns the current particle system
  83761. */
  83762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83763. /**
  83764. * Adds a new size gradient
  83765. * @param gradient defines the gradient to use (between 0 and 1)
  83766. * @param factor defines the size factor to affect to the specified gradient
  83767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83768. * @returns the current particle system
  83769. */
  83770. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83771. /**
  83772. * Remove a specific size gradient
  83773. * @param gradient defines the gradient to remove
  83774. * @returns the current particle system
  83775. */
  83776. removeSizeGradient(gradient: number): IParticleSystem;
  83777. /**
  83778. * Adds a new color remap gradient
  83779. * @param gradient defines the gradient to use (between 0 and 1)
  83780. * @param min defines the color remap minimal range
  83781. * @param max defines the color remap maximal range
  83782. * @returns the current particle system
  83783. */
  83784. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83785. /**
  83786. * Remove a specific color remap gradient
  83787. * @param gradient defines the gradient to remove
  83788. * @returns the current particle system
  83789. */
  83790. removeColorRemapGradient(gradient: number): IParticleSystem;
  83791. /**
  83792. * Adds a new alpha remap gradient
  83793. * @param gradient defines the gradient to use (between 0 and 1)
  83794. * @param min defines the alpha remap minimal range
  83795. * @param max defines the alpha remap maximal range
  83796. * @returns the current particle system
  83797. */
  83798. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83799. /**
  83800. * Remove a specific alpha remap gradient
  83801. * @param gradient defines the gradient to remove
  83802. * @returns the current particle system
  83803. */
  83804. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83805. /**
  83806. * Adds a new angular speed gradient
  83807. * @param gradient defines the gradient to use (between 0 and 1)
  83808. * @param factor defines the angular speed to affect to the specified gradient
  83809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83810. * @returns the current particle system
  83811. */
  83812. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83813. /**
  83814. * Remove a specific angular speed gradient
  83815. * @param gradient defines the gradient to remove
  83816. * @returns the current particle system
  83817. */
  83818. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83819. /**
  83820. * Adds a new velocity gradient
  83821. * @param gradient defines the gradient to use (between 0 and 1)
  83822. * @param factor defines the velocity to affect to the specified gradient
  83823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83824. * @returns the current particle system
  83825. */
  83826. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83827. /**
  83828. * Remove a specific velocity gradient
  83829. * @param gradient defines the gradient to remove
  83830. * @returns the current particle system
  83831. */
  83832. removeVelocityGradient(gradient: number): IParticleSystem;
  83833. /**
  83834. * Adds a new limit velocity gradient
  83835. * @param gradient defines the gradient to use (between 0 and 1)
  83836. * @param factor defines the limit velocity value to affect to the specified gradient
  83837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83838. * @returns the current particle system
  83839. */
  83840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83841. /**
  83842. * Remove a specific limit velocity gradient
  83843. * @param gradient defines the gradient to remove
  83844. * @returns the current particle system
  83845. */
  83846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83847. /**
  83848. * Adds a new drag gradient
  83849. * @param gradient defines the gradient to use (between 0 and 1)
  83850. * @param factor defines the drag value to affect to the specified gradient
  83851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83852. * @returns the current particle system
  83853. */
  83854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83855. /**
  83856. * Remove a specific drag gradient
  83857. * @param gradient defines the gradient to remove
  83858. * @returns the current particle system
  83859. */
  83860. removeDragGradient(gradient: number): IParticleSystem;
  83861. /**
  83862. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83863. * @param gradient defines the gradient to use (between 0 and 1)
  83864. * @param factor defines the emit rate value to affect to the specified gradient
  83865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83866. * @returns the current particle system
  83867. */
  83868. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83869. /**
  83870. * Remove a specific emit rate gradient
  83871. * @param gradient defines the gradient to remove
  83872. * @returns the current particle system
  83873. */
  83874. removeEmitRateGradient(gradient: number): IParticleSystem;
  83875. /**
  83876. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83877. * @param gradient defines the gradient to use (between 0 and 1)
  83878. * @param factor defines the start size value to affect to the specified gradient
  83879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83880. * @returns the current particle system
  83881. */
  83882. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83883. /**
  83884. * Remove a specific start size gradient
  83885. * @param gradient defines the gradient to remove
  83886. * @returns the current particle system
  83887. */
  83888. removeStartSizeGradient(gradient: number): IParticleSystem;
  83889. private _createRampGradientTexture;
  83890. /**
  83891. * Gets the current list of ramp gradients.
  83892. * You must use addRampGradient and removeRampGradient to udpate this list
  83893. * @returns the list of ramp gradients
  83894. */
  83895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83896. /**
  83897. * Adds a new ramp gradient used to remap particle colors
  83898. * @param gradient defines the gradient to use (between 0 and 1)
  83899. * @param color defines the color to affect to the specified gradient
  83900. * @returns the current particle system
  83901. */
  83902. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83903. /**
  83904. * Remove a specific ramp gradient
  83905. * @param gradient defines the gradient to remove
  83906. * @returns the current particle system
  83907. */
  83908. removeRampGradient(gradient: number): ParticleSystem;
  83909. /**
  83910. * Adds a new color gradient
  83911. * @param gradient defines the gradient to use (between 0 and 1)
  83912. * @param color1 defines the color to affect to the specified gradient
  83913. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83914. * @returns this particle system
  83915. */
  83916. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83917. /**
  83918. * Remove a specific color gradient
  83919. * @param gradient defines the gradient to remove
  83920. * @returns this particle system
  83921. */
  83922. removeColorGradient(gradient: number): IParticleSystem;
  83923. private _fetchR;
  83924. protected _reset(): void;
  83925. private _resetEffect;
  83926. private _createVertexBuffers;
  83927. private _createIndexBuffer;
  83928. /**
  83929. * Gets the maximum number of particles active at the same time.
  83930. * @returns The max number of active particles.
  83931. */
  83932. getCapacity(): number;
  83933. /**
  83934. * Gets whether there are still active particles in the system.
  83935. * @returns True if it is alive, otherwise false.
  83936. */
  83937. isAlive(): boolean;
  83938. /**
  83939. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83940. * @returns True if it has been started, otherwise false.
  83941. */
  83942. isStarted(): boolean;
  83943. private _prepareSubEmitterInternalArray;
  83944. /**
  83945. * Starts the particle system and begins to emit
  83946. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83947. */
  83948. start(delay?: number): void;
  83949. /**
  83950. * Stops the particle system.
  83951. * @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.
  83952. */
  83953. stop(stopSubEmitters?: boolean): void;
  83954. /**
  83955. * Remove all active particles
  83956. */
  83957. reset(): void;
  83958. /**
  83959. * @hidden (for internal use only)
  83960. */
  83961. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83962. /**
  83963. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83964. * Its lifetime will start back at 0.
  83965. */
  83966. recycleParticle: (particle: Particle) => void;
  83967. private _stopSubEmitters;
  83968. private _createParticle;
  83969. private _removeFromRoot;
  83970. private _emitFromParticle;
  83971. private _update;
  83972. /** @hidden */
  83973. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83974. /** @hidden */
  83975. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83976. /** @hidden */
  83977. private _getEffect;
  83978. /**
  83979. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83980. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83981. */
  83982. animate(preWarmOnly?: boolean): void;
  83983. private _appendParticleVertices;
  83984. /**
  83985. * Rebuilds the particle system.
  83986. */
  83987. rebuild(): void;
  83988. /**
  83989. * Is this system ready to be used/rendered
  83990. * @return true if the system is ready
  83991. */
  83992. isReady(): boolean;
  83993. private _render;
  83994. /**
  83995. * Renders the particle system in its current state.
  83996. * @returns the current number of particles
  83997. */
  83998. render(): number;
  83999. /**
  84000. * Disposes the particle system and free the associated resources
  84001. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84002. */
  84003. dispose(disposeTexture?: boolean): void;
  84004. /**
  84005. * Clones the particle system.
  84006. * @param name The name of the cloned object
  84007. * @param newEmitter The new emitter to use
  84008. * @returns the cloned particle system
  84009. */
  84010. clone(name: string, newEmitter: any): ParticleSystem;
  84011. /**
  84012. * Serializes the particle system to a JSON object.
  84013. * @returns the JSON object
  84014. */
  84015. serialize(): any;
  84016. /** @hidden */
  84017. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84018. /** @hidden */
  84019. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84020. /**
  84021. * Parses a JSON object to create a particle system.
  84022. * @param parsedParticleSystem The JSON object to parse
  84023. * @param scene The scene to create the particle system in
  84024. * @param rootUrl The root url to use to load external dependencies like texture
  84025. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84026. * @returns the Parsed particle system
  84027. */
  84028. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84029. }
  84030. }
  84031. declare module BABYLON {
  84032. /**
  84033. * A particle represents one of the element emitted by a particle system.
  84034. * This is mainly define by its coordinates, direction, velocity and age.
  84035. */
  84036. export class Particle {
  84037. /**
  84038. * The particle system the particle belongs to.
  84039. */
  84040. particleSystem: ParticleSystem;
  84041. private static _Count;
  84042. /**
  84043. * Unique ID of the particle
  84044. */
  84045. id: number;
  84046. /**
  84047. * The world position of the particle in the scene.
  84048. */
  84049. position: Vector3;
  84050. /**
  84051. * The world direction of the particle in the scene.
  84052. */
  84053. direction: Vector3;
  84054. /**
  84055. * The color of the particle.
  84056. */
  84057. color: Color4;
  84058. /**
  84059. * The color change of the particle per step.
  84060. */
  84061. colorStep: Color4;
  84062. /**
  84063. * Defines how long will the life of the particle be.
  84064. */
  84065. lifeTime: number;
  84066. /**
  84067. * The current age of the particle.
  84068. */
  84069. age: number;
  84070. /**
  84071. * The current size of the particle.
  84072. */
  84073. size: number;
  84074. /**
  84075. * The current scale of the particle.
  84076. */
  84077. scale: Vector2;
  84078. /**
  84079. * The current angle of the particle.
  84080. */
  84081. angle: number;
  84082. /**
  84083. * Defines how fast is the angle changing.
  84084. */
  84085. angularSpeed: number;
  84086. /**
  84087. * Defines the cell index used by the particle to be rendered from a sprite.
  84088. */
  84089. cellIndex: number;
  84090. /**
  84091. * The information required to support color remapping
  84092. */
  84093. remapData: Vector4;
  84094. /** @hidden */
  84095. _randomCellOffset?: number;
  84096. /** @hidden */
  84097. _initialDirection: Nullable<Vector3>;
  84098. /** @hidden */
  84099. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84100. /** @hidden */
  84101. _initialStartSpriteCellID: number;
  84102. /** @hidden */
  84103. _initialEndSpriteCellID: number;
  84104. /** @hidden */
  84105. _currentColorGradient: Nullable<ColorGradient>;
  84106. /** @hidden */
  84107. _currentColor1: Color4;
  84108. /** @hidden */
  84109. _currentColor2: Color4;
  84110. /** @hidden */
  84111. _currentSizeGradient: Nullable<FactorGradient>;
  84112. /** @hidden */
  84113. _currentSize1: number;
  84114. /** @hidden */
  84115. _currentSize2: number;
  84116. /** @hidden */
  84117. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84118. /** @hidden */
  84119. _currentAngularSpeed1: number;
  84120. /** @hidden */
  84121. _currentAngularSpeed2: number;
  84122. /** @hidden */
  84123. _currentVelocityGradient: Nullable<FactorGradient>;
  84124. /** @hidden */
  84125. _currentVelocity1: number;
  84126. /** @hidden */
  84127. _currentVelocity2: number;
  84128. /** @hidden */
  84129. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84130. /** @hidden */
  84131. _currentLimitVelocity1: number;
  84132. /** @hidden */
  84133. _currentLimitVelocity2: number;
  84134. /** @hidden */
  84135. _currentDragGradient: Nullable<FactorGradient>;
  84136. /** @hidden */
  84137. _currentDrag1: number;
  84138. /** @hidden */
  84139. _currentDrag2: number;
  84140. /** @hidden */
  84141. _randomNoiseCoordinates1: Vector3;
  84142. /** @hidden */
  84143. _randomNoiseCoordinates2: Vector3;
  84144. /**
  84145. * Creates a new instance Particle
  84146. * @param particleSystem the particle system the particle belongs to
  84147. */
  84148. constructor(
  84149. /**
  84150. * The particle system the particle belongs to.
  84151. */
  84152. particleSystem: ParticleSystem);
  84153. private updateCellInfoFromSystem;
  84154. /**
  84155. * Defines how the sprite cell index is updated for the particle
  84156. */
  84157. updateCellIndex(): void;
  84158. /** @hidden */
  84159. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84160. /** @hidden */
  84161. _inheritParticleInfoToSubEmitters(): void;
  84162. /** @hidden */
  84163. _reset(): void;
  84164. /**
  84165. * Copy the properties of particle to another one.
  84166. * @param other the particle to copy the information to.
  84167. */
  84168. copyTo(other: Particle): void;
  84169. }
  84170. }
  84171. declare module BABYLON {
  84172. /**
  84173. * Particle emitter represents a volume emitting particles.
  84174. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84175. */
  84176. export interface IParticleEmitterType {
  84177. /**
  84178. * Called by the particle System when the direction is computed for the created particle.
  84179. * @param worldMatrix is the world matrix of the particle system
  84180. * @param directionToUpdate is the direction vector to update with the result
  84181. * @param particle is the particle we are computed the direction for
  84182. */
  84183. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84184. /**
  84185. * Called by the particle System when the position is computed for the created particle.
  84186. * @param worldMatrix is the world matrix of the particle system
  84187. * @param positionToUpdate is the position vector to update with the result
  84188. * @param particle is the particle we are computed the position for
  84189. */
  84190. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84191. /**
  84192. * Clones the current emitter and returns a copy of it
  84193. * @returns the new emitter
  84194. */
  84195. clone(): IParticleEmitterType;
  84196. /**
  84197. * Called by the GPUParticleSystem to setup the update shader
  84198. * @param effect defines the update shader
  84199. */
  84200. applyToShader(effect: Effect): void;
  84201. /**
  84202. * Returns a string to use to update the GPU particles update shader
  84203. * @returns the effect defines string
  84204. */
  84205. getEffectDefines(): string;
  84206. /**
  84207. * Returns a string representing the class name
  84208. * @returns a string containing the class name
  84209. */
  84210. getClassName(): string;
  84211. /**
  84212. * Serializes the particle system to a JSON object.
  84213. * @returns the JSON object
  84214. */
  84215. serialize(): any;
  84216. /**
  84217. * Parse properties from a JSON object
  84218. * @param serializationObject defines the JSON object
  84219. */
  84220. parse(serializationObject: any): void;
  84221. }
  84222. }
  84223. declare module BABYLON {
  84224. /**
  84225. * Particle emitter emitting particles from the inside of a box.
  84226. * It emits the particles randomly between 2 given directions.
  84227. */
  84228. export class BoxParticleEmitter implements IParticleEmitterType {
  84229. /**
  84230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84231. */
  84232. direction1: Vector3;
  84233. /**
  84234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84235. */
  84236. direction2: Vector3;
  84237. /**
  84238. * 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.
  84239. */
  84240. minEmitBox: Vector3;
  84241. /**
  84242. * 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.
  84243. */
  84244. maxEmitBox: Vector3;
  84245. /**
  84246. * Creates a new instance BoxParticleEmitter
  84247. */
  84248. constructor();
  84249. /**
  84250. * Called by the particle System when the direction is computed for the created particle.
  84251. * @param worldMatrix is the world matrix of the particle system
  84252. * @param directionToUpdate is the direction vector to update with the result
  84253. * @param particle is the particle we are computed the direction for
  84254. */
  84255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84256. /**
  84257. * Called by the particle System when the position is computed for the created particle.
  84258. * @param worldMatrix is the world matrix of the particle system
  84259. * @param positionToUpdate is the position vector to update with the result
  84260. * @param particle is the particle we are computed the position for
  84261. */
  84262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84263. /**
  84264. * Clones the current emitter and returns a copy of it
  84265. * @returns the new emitter
  84266. */
  84267. clone(): BoxParticleEmitter;
  84268. /**
  84269. * Called by the GPUParticleSystem to setup the update shader
  84270. * @param effect defines the update shader
  84271. */
  84272. applyToShader(effect: Effect): void;
  84273. /**
  84274. * Returns a string to use to update the GPU particles update shader
  84275. * @returns a string containng the defines string
  84276. */
  84277. getEffectDefines(): string;
  84278. /**
  84279. * Returns the string "BoxParticleEmitter"
  84280. * @returns a string containing the class name
  84281. */
  84282. getClassName(): string;
  84283. /**
  84284. * Serializes the particle system to a JSON object.
  84285. * @returns the JSON object
  84286. */
  84287. serialize(): any;
  84288. /**
  84289. * Parse properties from a JSON object
  84290. * @param serializationObject defines the JSON object
  84291. */
  84292. parse(serializationObject: any): void;
  84293. }
  84294. }
  84295. declare module BABYLON {
  84296. /**
  84297. * Particle emitter emitting particles from the inside of a cone.
  84298. * It emits the particles alongside the cone volume from the base to the particle.
  84299. * The emission direction might be randomized.
  84300. */
  84301. export class ConeParticleEmitter implements IParticleEmitterType {
  84302. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84303. directionRandomizer: number;
  84304. private _radius;
  84305. private _angle;
  84306. private _height;
  84307. /**
  84308. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84309. */
  84310. radiusRange: number;
  84311. /**
  84312. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84313. */
  84314. heightRange: number;
  84315. /**
  84316. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84317. */
  84318. emitFromSpawnPointOnly: boolean;
  84319. /**
  84320. * Gets or sets the radius of the emission cone
  84321. */
  84322. radius: number;
  84323. /**
  84324. * Gets or sets the angle of the emission cone
  84325. */
  84326. angle: number;
  84327. private _buildHeight;
  84328. /**
  84329. * Creates a new instance ConeParticleEmitter
  84330. * @param radius the radius of the emission cone (1 by default)
  84331. * @param angle the cone base angle (PI by default)
  84332. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84333. */
  84334. constructor(radius?: number, angle?: number,
  84335. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84336. directionRandomizer?: number);
  84337. /**
  84338. * Called by the particle System when the direction is computed for the created particle.
  84339. * @param worldMatrix is the world matrix of the particle system
  84340. * @param directionToUpdate is the direction vector to update with the result
  84341. * @param particle is the particle we are computed the direction for
  84342. */
  84343. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84344. /**
  84345. * Called by the particle System when the position is computed for the created particle.
  84346. * @param worldMatrix is the world matrix of the particle system
  84347. * @param positionToUpdate is the position vector to update with the result
  84348. * @param particle is the particle we are computed the position for
  84349. */
  84350. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84351. /**
  84352. * Clones the current emitter and returns a copy of it
  84353. * @returns the new emitter
  84354. */
  84355. clone(): ConeParticleEmitter;
  84356. /**
  84357. * Called by the GPUParticleSystem to setup the update shader
  84358. * @param effect defines the update shader
  84359. */
  84360. applyToShader(effect: Effect): void;
  84361. /**
  84362. * Returns a string to use to update the GPU particles update shader
  84363. * @returns a string containng the defines string
  84364. */
  84365. getEffectDefines(): string;
  84366. /**
  84367. * Returns the string "ConeParticleEmitter"
  84368. * @returns a string containing the class name
  84369. */
  84370. getClassName(): string;
  84371. /**
  84372. * Serializes the particle system to a JSON object.
  84373. * @returns the JSON object
  84374. */
  84375. serialize(): any;
  84376. /**
  84377. * Parse properties from a JSON object
  84378. * @param serializationObject defines the JSON object
  84379. */
  84380. parse(serializationObject: any): void;
  84381. }
  84382. }
  84383. declare module BABYLON {
  84384. /**
  84385. * Particle emitter emitting particles from the inside of a cylinder.
  84386. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84387. */
  84388. export class CylinderParticleEmitter implements IParticleEmitterType {
  84389. /**
  84390. * The radius of the emission cylinder.
  84391. */
  84392. radius: number;
  84393. /**
  84394. * The height of the emission cylinder.
  84395. */
  84396. height: number;
  84397. /**
  84398. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84399. */
  84400. radiusRange: number;
  84401. /**
  84402. * How much to randomize the particle direction [0-1].
  84403. */
  84404. directionRandomizer: number;
  84405. /**
  84406. * Creates a new instance CylinderParticleEmitter
  84407. * @param radius the radius of the emission cylinder (1 by default)
  84408. * @param height the height of the emission cylinder (1 by default)
  84409. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84410. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84411. */
  84412. constructor(
  84413. /**
  84414. * The radius of the emission cylinder.
  84415. */
  84416. radius?: number,
  84417. /**
  84418. * The height of the emission cylinder.
  84419. */
  84420. height?: number,
  84421. /**
  84422. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84423. */
  84424. radiusRange?: number,
  84425. /**
  84426. * How much to randomize the particle direction [0-1].
  84427. */
  84428. directionRandomizer?: number);
  84429. /**
  84430. * Called by the particle System when the direction is computed for the created particle.
  84431. * @param worldMatrix is the world matrix of the particle system
  84432. * @param directionToUpdate is the direction vector to update with the result
  84433. * @param particle is the particle we are computed the direction for
  84434. */
  84435. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84436. /**
  84437. * Called by the particle System when the position is computed for the created particle.
  84438. * @param worldMatrix is the world matrix of the particle system
  84439. * @param positionToUpdate is the position vector to update with the result
  84440. * @param particle is the particle we are computed the position for
  84441. */
  84442. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84443. /**
  84444. * Clones the current emitter and returns a copy of it
  84445. * @returns the new emitter
  84446. */
  84447. clone(): CylinderParticleEmitter;
  84448. /**
  84449. * Called by the GPUParticleSystem to setup the update shader
  84450. * @param effect defines the update shader
  84451. */
  84452. applyToShader(effect: Effect): void;
  84453. /**
  84454. * Returns a string to use to update the GPU particles update shader
  84455. * @returns a string containng the defines string
  84456. */
  84457. getEffectDefines(): string;
  84458. /**
  84459. * Returns the string "CylinderParticleEmitter"
  84460. * @returns a string containing the class name
  84461. */
  84462. getClassName(): string;
  84463. /**
  84464. * Serializes the particle system to a JSON object.
  84465. * @returns the JSON object
  84466. */
  84467. serialize(): any;
  84468. /**
  84469. * Parse properties from a JSON object
  84470. * @param serializationObject defines the JSON object
  84471. */
  84472. parse(serializationObject: any): void;
  84473. }
  84474. /**
  84475. * Particle emitter emitting particles from the inside of a cylinder.
  84476. * It emits the particles randomly between two vectors.
  84477. */
  84478. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84479. /**
  84480. * The min limit of the emission direction.
  84481. */
  84482. direction1: Vector3;
  84483. /**
  84484. * The max limit of the emission direction.
  84485. */
  84486. direction2: Vector3;
  84487. /**
  84488. * Creates a new instance CylinderDirectedParticleEmitter
  84489. * @param radius the radius of the emission cylinder (1 by default)
  84490. * @param height the height of the emission cylinder (1 by default)
  84491. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84492. * @param direction1 the min limit of the emission direction (up vector by default)
  84493. * @param direction2 the max limit of the emission direction (up vector by default)
  84494. */
  84495. constructor(radius?: number, height?: number, radiusRange?: number,
  84496. /**
  84497. * The min limit of the emission direction.
  84498. */
  84499. direction1?: Vector3,
  84500. /**
  84501. * The max limit of the emission direction.
  84502. */
  84503. direction2?: Vector3);
  84504. /**
  84505. * Called by the particle System when the direction is computed for the created particle.
  84506. * @param worldMatrix is the world matrix of the particle system
  84507. * @param directionToUpdate is the direction vector to update with the result
  84508. * @param particle is the particle we are computed the direction for
  84509. */
  84510. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84511. /**
  84512. * Clones the current emitter and returns a copy of it
  84513. * @returns the new emitter
  84514. */
  84515. clone(): CylinderDirectedParticleEmitter;
  84516. /**
  84517. * Called by the GPUParticleSystem to setup the update shader
  84518. * @param effect defines the update shader
  84519. */
  84520. applyToShader(effect: Effect): void;
  84521. /**
  84522. * Returns a string to use to update the GPU particles update shader
  84523. * @returns a string containng the defines string
  84524. */
  84525. getEffectDefines(): string;
  84526. /**
  84527. * Returns the string "CylinderDirectedParticleEmitter"
  84528. * @returns a string containing the class name
  84529. */
  84530. getClassName(): string;
  84531. /**
  84532. * Serializes the particle system to a JSON object.
  84533. * @returns the JSON object
  84534. */
  84535. serialize(): any;
  84536. /**
  84537. * Parse properties from a JSON object
  84538. * @param serializationObject defines the JSON object
  84539. */
  84540. parse(serializationObject: any): void;
  84541. }
  84542. }
  84543. declare module BABYLON {
  84544. /**
  84545. * Particle emitter emitting particles from the inside of a hemisphere.
  84546. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84547. */
  84548. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84549. /**
  84550. * The radius of the emission hemisphere.
  84551. */
  84552. radius: number;
  84553. /**
  84554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84555. */
  84556. radiusRange: number;
  84557. /**
  84558. * How much to randomize the particle direction [0-1].
  84559. */
  84560. directionRandomizer: number;
  84561. /**
  84562. * Creates a new instance HemisphericParticleEmitter
  84563. * @param radius the radius of the emission hemisphere (1 by default)
  84564. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84565. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84566. */
  84567. constructor(
  84568. /**
  84569. * The radius of the emission hemisphere.
  84570. */
  84571. radius?: number,
  84572. /**
  84573. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84574. */
  84575. radiusRange?: number,
  84576. /**
  84577. * How much to randomize the particle direction [0-1].
  84578. */
  84579. directionRandomizer?: number);
  84580. /**
  84581. * Called by the particle System when the direction is computed for the created particle.
  84582. * @param worldMatrix is the world matrix of the particle system
  84583. * @param directionToUpdate is the direction vector to update with the result
  84584. * @param particle is the particle we are computed the direction for
  84585. */
  84586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84587. /**
  84588. * Called by the particle System when the position is computed for the created particle.
  84589. * @param worldMatrix is the world matrix of the particle system
  84590. * @param positionToUpdate is the position vector to update with the result
  84591. * @param particle is the particle we are computed the position for
  84592. */
  84593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84594. /**
  84595. * Clones the current emitter and returns a copy of it
  84596. * @returns the new emitter
  84597. */
  84598. clone(): HemisphericParticleEmitter;
  84599. /**
  84600. * Called by the GPUParticleSystem to setup the update shader
  84601. * @param effect defines the update shader
  84602. */
  84603. applyToShader(effect: Effect): void;
  84604. /**
  84605. * Returns a string to use to update the GPU particles update shader
  84606. * @returns a string containng the defines string
  84607. */
  84608. getEffectDefines(): string;
  84609. /**
  84610. * Returns the string "HemisphericParticleEmitter"
  84611. * @returns a string containing the class name
  84612. */
  84613. getClassName(): string;
  84614. /**
  84615. * Serializes the particle system to a JSON object.
  84616. * @returns the JSON object
  84617. */
  84618. serialize(): any;
  84619. /**
  84620. * Parse properties from a JSON object
  84621. * @param serializationObject defines the JSON object
  84622. */
  84623. parse(serializationObject: any): void;
  84624. }
  84625. }
  84626. declare module BABYLON {
  84627. /**
  84628. * Particle emitter emitting particles from a point.
  84629. * It emits the particles randomly between 2 given directions.
  84630. */
  84631. export class PointParticleEmitter implements IParticleEmitterType {
  84632. /**
  84633. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84634. */
  84635. direction1: Vector3;
  84636. /**
  84637. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84638. */
  84639. direction2: Vector3;
  84640. /**
  84641. * Creates a new instance PointParticleEmitter
  84642. */
  84643. constructor();
  84644. /**
  84645. * Called by the particle System when the direction is computed for the created particle.
  84646. * @param worldMatrix is the world matrix of the particle system
  84647. * @param directionToUpdate is the direction vector to update with the result
  84648. * @param particle is the particle we are computed the direction for
  84649. */
  84650. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84651. /**
  84652. * Called by the particle System when the position is computed for the created particle.
  84653. * @param worldMatrix is the world matrix of the particle system
  84654. * @param positionToUpdate is the position vector to update with the result
  84655. * @param particle is the particle we are computed the position for
  84656. */
  84657. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84658. /**
  84659. * Clones the current emitter and returns a copy of it
  84660. * @returns the new emitter
  84661. */
  84662. clone(): PointParticleEmitter;
  84663. /**
  84664. * Called by the GPUParticleSystem to setup the update shader
  84665. * @param effect defines the update shader
  84666. */
  84667. applyToShader(effect: Effect): void;
  84668. /**
  84669. * Returns a string to use to update the GPU particles update shader
  84670. * @returns a string containng the defines string
  84671. */
  84672. getEffectDefines(): string;
  84673. /**
  84674. * Returns the string "PointParticleEmitter"
  84675. * @returns a string containing the class name
  84676. */
  84677. getClassName(): string;
  84678. /**
  84679. * Serializes the particle system to a JSON object.
  84680. * @returns the JSON object
  84681. */
  84682. serialize(): any;
  84683. /**
  84684. * Parse properties from a JSON object
  84685. * @param serializationObject defines the JSON object
  84686. */
  84687. parse(serializationObject: any): void;
  84688. }
  84689. }
  84690. declare module BABYLON {
  84691. /**
  84692. * Particle emitter emitting particles from the inside of a sphere.
  84693. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84694. */
  84695. export class SphereParticleEmitter implements IParticleEmitterType {
  84696. /**
  84697. * The radius of the emission sphere.
  84698. */
  84699. radius: number;
  84700. /**
  84701. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84702. */
  84703. radiusRange: number;
  84704. /**
  84705. * How much to randomize the particle direction [0-1].
  84706. */
  84707. directionRandomizer: number;
  84708. /**
  84709. * Creates a new instance SphereParticleEmitter
  84710. * @param radius the radius of the emission sphere (1 by default)
  84711. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84712. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84713. */
  84714. constructor(
  84715. /**
  84716. * The radius of the emission sphere.
  84717. */
  84718. radius?: number,
  84719. /**
  84720. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84721. */
  84722. radiusRange?: number,
  84723. /**
  84724. * How much to randomize the particle direction [0-1].
  84725. */
  84726. directionRandomizer?: number);
  84727. /**
  84728. * Called by the particle System when the direction is computed for the created particle.
  84729. * @param worldMatrix is the world matrix of the particle system
  84730. * @param directionToUpdate is the direction vector to update with the result
  84731. * @param particle is the particle we are computed the direction for
  84732. */
  84733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84734. /**
  84735. * Called by the particle System when the position is computed for the created particle.
  84736. * @param worldMatrix is the world matrix of the particle system
  84737. * @param positionToUpdate is the position vector to update with the result
  84738. * @param particle is the particle we are computed the position for
  84739. */
  84740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84741. /**
  84742. * Clones the current emitter and returns a copy of it
  84743. * @returns the new emitter
  84744. */
  84745. clone(): SphereParticleEmitter;
  84746. /**
  84747. * Called by the GPUParticleSystem to setup the update shader
  84748. * @param effect defines the update shader
  84749. */
  84750. applyToShader(effect: Effect): void;
  84751. /**
  84752. * Returns a string to use to update the GPU particles update shader
  84753. * @returns a string containng the defines string
  84754. */
  84755. getEffectDefines(): string;
  84756. /**
  84757. * Returns the string "SphereParticleEmitter"
  84758. * @returns a string containing the class name
  84759. */
  84760. getClassName(): string;
  84761. /**
  84762. * Serializes the particle system to a JSON object.
  84763. * @returns the JSON object
  84764. */
  84765. serialize(): any;
  84766. /**
  84767. * Parse properties from a JSON object
  84768. * @param serializationObject defines the JSON object
  84769. */
  84770. parse(serializationObject: any): void;
  84771. }
  84772. /**
  84773. * Particle emitter emitting particles from the inside of a sphere.
  84774. * It emits the particles randomly between two vectors.
  84775. */
  84776. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84777. /**
  84778. * The min limit of the emission direction.
  84779. */
  84780. direction1: Vector3;
  84781. /**
  84782. * The max limit of the emission direction.
  84783. */
  84784. direction2: Vector3;
  84785. /**
  84786. * Creates a new instance SphereDirectedParticleEmitter
  84787. * @param radius the radius of the emission sphere (1 by default)
  84788. * @param direction1 the min limit of the emission direction (up vector by default)
  84789. * @param direction2 the max limit of the emission direction (up vector by default)
  84790. */
  84791. constructor(radius?: number,
  84792. /**
  84793. * The min limit of the emission direction.
  84794. */
  84795. direction1?: Vector3,
  84796. /**
  84797. * The max limit of the emission direction.
  84798. */
  84799. direction2?: Vector3);
  84800. /**
  84801. * Called by the particle System when the direction is computed for the created particle.
  84802. * @param worldMatrix is the world matrix of the particle system
  84803. * @param directionToUpdate is the direction vector to update with the result
  84804. * @param particle is the particle we are computed the direction for
  84805. */
  84806. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84807. /**
  84808. * Clones the current emitter and returns a copy of it
  84809. * @returns the new emitter
  84810. */
  84811. clone(): SphereDirectedParticleEmitter;
  84812. /**
  84813. * Called by the GPUParticleSystem to setup the update shader
  84814. * @param effect defines the update shader
  84815. */
  84816. applyToShader(effect: Effect): void;
  84817. /**
  84818. * Returns a string to use to update the GPU particles update shader
  84819. * @returns a string containng the defines string
  84820. */
  84821. getEffectDefines(): string;
  84822. /**
  84823. * Returns the string "SphereDirectedParticleEmitter"
  84824. * @returns a string containing the class name
  84825. */
  84826. getClassName(): string;
  84827. /**
  84828. * Serializes the particle system to a JSON object.
  84829. * @returns the JSON object
  84830. */
  84831. serialize(): any;
  84832. /**
  84833. * Parse properties from a JSON object
  84834. * @param serializationObject defines the JSON object
  84835. */
  84836. parse(serializationObject: any): void;
  84837. }
  84838. }
  84839. declare module BABYLON {
  84840. /**
  84841. * Interface representing a particle system in Babylon.js.
  84842. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84843. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84844. */
  84845. export interface IParticleSystem {
  84846. /**
  84847. * List of animations used by the particle system.
  84848. */
  84849. animations: Animation[];
  84850. /**
  84851. * The id of the Particle system.
  84852. */
  84853. id: string;
  84854. /**
  84855. * The name of the Particle system.
  84856. */
  84857. name: string;
  84858. /**
  84859. * The emitter represents the Mesh or position we are attaching the particle system to.
  84860. */
  84861. emitter: Nullable<AbstractMesh | Vector3>;
  84862. /**
  84863. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84864. */
  84865. isBillboardBased: boolean;
  84866. /**
  84867. * The rendering group used by the Particle system to chose when to render.
  84868. */
  84869. renderingGroupId: number;
  84870. /**
  84871. * The layer mask we are rendering the particles through.
  84872. */
  84873. layerMask: number;
  84874. /**
  84875. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84876. */
  84877. updateSpeed: number;
  84878. /**
  84879. * The amount of time the particle system is running (depends of the overall update speed).
  84880. */
  84881. targetStopDuration: number;
  84882. /**
  84883. * The texture used to render each particle. (this can be a spritesheet)
  84884. */
  84885. particleTexture: Nullable<Texture>;
  84886. /**
  84887. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84888. */
  84889. blendMode: number;
  84890. /**
  84891. * Minimum life time of emitting particles.
  84892. */
  84893. minLifeTime: number;
  84894. /**
  84895. * Maximum life time of emitting particles.
  84896. */
  84897. maxLifeTime: number;
  84898. /**
  84899. * Minimum Size of emitting particles.
  84900. */
  84901. minSize: number;
  84902. /**
  84903. * Maximum Size of emitting particles.
  84904. */
  84905. maxSize: number;
  84906. /**
  84907. * Minimum scale of emitting particles on X axis.
  84908. */
  84909. minScaleX: number;
  84910. /**
  84911. * Maximum scale of emitting particles on X axis.
  84912. */
  84913. maxScaleX: number;
  84914. /**
  84915. * Minimum scale of emitting particles on Y axis.
  84916. */
  84917. minScaleY: number;
  84918. /**
  84919. * Maximum scale of emitting particles on Y axis.
  84920. */
  84921. maxScaleY: number;
  84922. /**
  84923. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84924. */
  84925. color1: Color4;
  84926. /**
  84927. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84928. */
  84929. color2: Color4;
  84930. /**
  84931. * Color the particle will have at the end of its lifetime.
  84932. */
  84933. colorDead: Color4;
  84934. /**
  84935. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84936. */
  84937. emitRate: number;
  84938. /**
  84939. * You can use gravity if you want to give an orientation to your particles.
  84940. */
  84941. gravity: Vector3;
  84942. /**
  84943. * Minimum power of emitting particles.
  84944. */
  84945. minEmitPower: number;
  84946. /**
  84947. * Maximum power of emitting particles.
  84948. */
  84949. maxEmitPower: number;
  84950. /**
  84951. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84952. */
  84953. minAngularSpeed: number;
  84954. /**
  84955. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84956. */
  84957. maxAngularSpeed: number;
  84958. /**
  84959. * Gets or sets the minimal initial rotation in radians.
  84960. */
  84961. minInitialRotation: number;
  84962. /**
  84963. * Gets or sets the maximal initial rotation in radians.
  84964. */
  84965. maxInitialRotation: number;
  84966. /**
  84967. * The particle emitter type defines the emitter used by the particle system.
  84968. * It can be for example box, sphere, or cone...
  84969. */
  84970. particleEmitterType: Nullable<IParticleEmitterType>;
  84971. /**
  84972. * Defines the delay in milliseconds before starting the system (0 by default)
  84973. */
  84974. startDelay: number;
  84975. /**
  84976. * 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
  84977. */
  84978. preWarmCycles: number;
  84979. /**
  84980. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84981. */
  84982. preWarmStepOffset: number;
  84983. /**
  84984. * 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)
  84985. */
  84986. spriteCellChangeSpeed: number;
  84987. /**
  84988. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84989. */
  84990. startSpriteCellID: number;
  84991. /**
  84992. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84993. */
  84994. endSpriteCellID: number;
  84995. /**
  84996. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84997. */
  84998. spriteCellWidth: number;
  84999. /**
  85000. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85001. */
  85002. spriteCellHeight: number;
  85003. /**
  85004. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85005. */
  85006. spriteRandomStartCell: boolean;
  85007. /**
  85008. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85009. */
  85010. isAnimationSheetEnabled: boolean;
  85011. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85012. translationPivot: Vector2;
  85013. /**
  85014. * Gets or sets a texture used to add random noise to particle positions
  85015. */
  85016. noiseTexture: Nullable<BaseTexture>;
  85017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85018. noiseStrength: Vector3;
  85019. /**
  85020. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85021. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85022. */
  85023. billboardMode: number;
  85024. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85025. limitVelocityDamping: number;
  85026. /**
  85027. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85028. */
  85029. beginAnimationOnStart: boolean;
  85030. /**
  85031. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85032. */
  85033. beginAnimationFrom: number;
  85034. /**
  85035. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85036. */
  85037. beginAnimationTo: number;
  85038. /**
  85039. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85040. */
  85041. beginAnimationLoop: boolean;
  85042. /**
  85043. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85044. */
  85045. disposeOnStop: boolean;
  85046. /**
  85047. * Gets the maximum number of particles active at the same time.
  85048. * @returns The max number of active particles.
  85049. */
  85050. getCapacity(): number;
  85051. /**
  85052. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85053. * @returns True if it has been started, otherwise false.
  85054. */
  85055. isStarted(): boolean;
  85056. /**
  85057. * Animates the particle system for this frame.
  85058. */
  85059. animate(): void;
  85060. /**
  85061. * Renders the particle system in its current state.
  85062. * @returns the current number of particles
  85063. */
  85064. render(): number;
  85065. /**
  85066. * Dispose the particle system and frees its associated resources.
  85067. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85068. */
  85069. dispose(disposeTexture?: boolean): void;
  85070. /**
  85071. * Clones the particle system.
  85072. * @param name The name of the cloned object
  85073. * @param newEmitter The new emitter to use
  85074. * @returns the cloned particle system
  85075. */
  85076. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85077. /**
  85078. * Serializes the particle system to a JSON object.
  85079. * @returns the JSON object
  85080. */
  85081. serialize(): any;
  85082. /**
  85083. * Rebuild the particle system
  85084. */
  85085. rebuild(): void;
  85086. /**
  85087. * Starts the particle system and begins to emit
  85088. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85089. */
  85090. start(delay?: number): void;
  85091. /**
  85092. * Stops the particle system.
  85093. */
  85094. stop(): void;
  85095. /**
  85096. * Remove all active particles
  85097. */
  85098. reset(): void;
  85099. /**
  85100. * Is this system ready to be used/rendered
  85101. * @return true if the system is ready
  85102. */
  85103. isReady(): boolean;
  85104. /**
  85105. * Adds a new color gradient
  85106. * @param gradient defines the gradient to use (between 0 and 1)
  85107. * @param color1 defines the color to affect to the specified gradient
  85108. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85109. * @returns the current particle system
  85110. */
  85111. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85112. /**
  85113. * Remove a specific color gradient
  85114. * @param gradient defines the gradient to remove
  85115. * @returns the current particle system
  85116. */
  85117. removeColorGradient(gradient: number): IParticleSystem;
  85118. /**
  85119. * Adds a new size gradient
  85120. * @param gradient defines the gradient to use (between 0 and 1)
  85121. * @param factor defines the size factor to affect to the specified gradient
  85122. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85123. * @returns the current particle system
  85124. */
  85125. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85126. /**
  85127. * Remove a specific size gradient
  85128. * @param gradient defines the gradient to remove
  85129. * @returns the current particle system
  85130. */
  85131. removeSizeGradient(gradient: number): IParticleSystem;
  85132. /**
  85133. * Gets the current list of color gradients.
  85134. * You must use addColorGradient and removeColorGradient to udpate this list
  85135. * @returns the list of color gradients
  85136. */
  85137. getColorGradients(): Nullable<Array<ColorGradient>>;
  85138. /**
  85139. * Gets the current list of size gradients.
  85140. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85141. * @returns the list of size gradients
  85142. */
  85143. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85144. /**
  85145. * Gets the current list of angular speed gradients.
  85146. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85147. * @returns the list of angular speed gradients
  85148. */
  85149. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85150. /**
  85151. * Adds a new angular speed gradient
  85152. * @param gradient defines the gradient to use (between 0 and 1)
  85153. * @param factor defines the angular speed to affect to the specified gradient
  85154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85155. * @returns the current particle system
  85156. */
  85157. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85158. /**
  85159. * Remove a specific angular speed gradient
  85160. * @param gradient defines the gradient to remove
  85161. * @returns the current particle system
  85162. */
  85163. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85164. /**
  85165. * Gets the current list of velocity gradients.
  85166. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85167. * @returns the list of velocity gradients
  85168. */
  85169. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85170. /**
  85171. * Adds a new velocity gradient
  85172. * @param gradient defines the gradient to use (between 0 and 1)
  85173. * @param factor defines the velocity to affect to the specified gradient
  85174. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85175. * @returns the current particle system
  85176. */
  85177. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85178. /**
  85179. * Remove a specific velocity gradient
  85180. * @param gradient defines the gradient to remove
  85181. * @returns the current particle system
  85182. */
  85183. removeVelocityGradient(gradient: number): IParticleSystem;
  85184. /**
  85185. * Gets the current list of limit velocity gradients.
  85186. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85187. * @returns the list of limit velocity gradients
  85188. */
  85189. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85190. /**
  85191. * Adds a new limit velocity gradient
  85192. * @param gradient defines the gradient to use (between 0 and 1)
  85193. * @param factor defines the limit velocity to affect to the specified gradient
  85194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85195. * @returns the current particle system
  85196. */
  85197. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85198. /**
  85199. * Remove a specific limit velocity gradient
  85200. * @param gradient defines the gradient to remove
  85201. * @returns the current particle system
  85202. */
  85203. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85204. /**
  85205. * Adds a new drag gradient
  85206. * @param gradient defines the gradient to use (between 0 and 1)
  85207. * @param factor defines the drag to affect to the specified gradient
  85208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85209. * @returns the current particle system
  85210. */
  85211. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85212. /**
  85213. * Remove a specific drag gradient
  85214. * @param gradient defines the gradient to remove
  85215. * @returns the current particle system
  85216. */
  85217. removeDragGradient(gradient: number): IParticleSystem;
  85218. /**
  85219. * Gets the current list of drag gradients.
  85220. * You must use addDragGradient and removeDragGradient to udpate this list
  85221. * @returns the list of drag gradients
  85222. */
  85223. getDragGradients(): Nullable<Array<FactorGradient>>;
  85224. /**
  85225. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85226. * @param gradient defines the gradient to use (between 0 and 1)
  85227. * @param factor defines the emit rate to affect to the specified gradient
  85228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85229. * @returns the current particle system
  85230. */
  85231. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85232. /**
  85233. * Remove a specific emit rate gradient
  85234. * @param gradient defines the gradient to remove
  85235. * @returns the current particle system
  85236. */
  85237. removeEmitRateGradient(gradient: number): IParticleSystem;
  85238. /**
  85239. * Gets the current list of emit rate gradients.
  85240. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85241. * @returns the list of emit rate gradients
  85242. */
  85243. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85244. /**
  85245. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85246. * @param gradient defines the gradient to use (between 0 and 1)
  85247. * @param factor defines the start size to affect to the specified gradient
  85248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85249. * @returns the current particle system
  85250. */
  85251. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85252. /**
  85253. * Remove a specific start size gradient
  85254. * @param gradient defines the gradient to remove
  85255. * @returns the current particle system
  85256. */
  85257. removeStartSizeGradient(gradient: number): IParticleSystem;
  85258. /**
  85259. * Gets the current list of start size gradients.
  85260. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85261. * @returns the list of start size gradients
  85262. */
  85263. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85264. /**
  85265. * Adds a new life time gradient
  85266. * @param gradient defines the gradient to use (between 0 and 1)
  85267. * @param factor defines the life time factor to affect to the specified gradient
  85268. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85269. * @returns the current particle system
  85270. */
  85271. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85272. /**
  85273. * Remove a specific life time gradient
  85274. * @param gradient defines the gradient to remove
  85275. * @returns the current particle system
  85276. */
  85277. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85278. /**
  85279. * Gets the current list of life time gradients.
  85280. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85281. * @returns the list of life time gradients
  85282. */
  85283. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85284. /**
  85285. * Gets the current list of color gradients.
  85286. * You must use addColorGradient and removeColorGradient to udpate this list
  85287. * @returns the list of color gradients
  85288. */
  85289. getColorGradients(): Nullable<Array<ColorGradient>>;
  85290. /**
  85291. * Adds a new ramp gradient used to remap particle colors
  85292. * @param gradient defines the gradient to use (between 0 and 1)
  85293. * @param color defines the color to affect to the specified gradient
  85294. * @returns the current particle system
  85295. */
  85296. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85297. /**
  85298. * Gets the current list of ramp gradients.
  85299. * You must use addRampGradient and removeRampGradient to udpate this list
  85300. * @returns the list of ramp gradients
  85301. */
  85302. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85303. /** Gets or sets a boolean indicating that ramp gradients must be used
  85304. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85305. */
  85306. useRampGradients: boolean;
  85307. /**
  85308. * Adds a new color remap gradient
  85309. * @param gradient defines the gradient to use (between 0 and 1)
  85310. * @param min defines the color remap minimal range
  85311. * @param max defines the color remap maximal range
  85312. * @returns the current particle system
  85313. */
  85314. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85315. /**
  85316. * Gets the current list of color remap gradients.
  85317. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85318. * @returns the list of color remap gradients
  85319. */
  85320. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85321. /**
  85322. * Adds a new alpha remap gradient
  85323. * @param gradient defines the gradient to use (between 0 and 1)
  85324. * @param min defines the alpha remap minimal range
  85325. * @param max defines the alpha remap maximal range
  85326. * @returns the current particle system
  85327. */
  85328. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85329. /**
  85330. * Gets the current list of alpha remap gradients.
  85331. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85332. * @returns the list of alpha remap gradients
  85333. */
  85334. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85335. /**
  85336. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85337. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85338. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85339. * @returns the emitter
  85340. */
  85341. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85342. /**
  85343. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85344. * @param radius The radius of the hemisphere to emit from
  85345. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85346. * @returns the emitter
  85347. */
  85348. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85349. /**
  85350. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85351. * @param radius The radius of the sphere to emit from
  85352. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85353. * @returns the emitter
  85354. */
  85355. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85356. /**
  85357. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85358. * @param radius The radius of the sphere to emit from
  85359. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85360. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85361. * @returns the emitter
  85362. */
  85363. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85364. /**
  85365. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85366. * @param radius The radius of the emission cylinder
  85367. * @param height The height of the emission cylinder
  85368. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85369. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85370. * @returns the emitter
  85371. */
  85372. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85373. /**
  85374. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85375. * @param radius The radius of the cylinder to emit from
  85376. * @param height The height of the emission cylinder
  85377. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85378. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85379. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85380. * @returns the emitter
  85381. */
  85382. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85383. /**
  85384. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85385. * @param radius The radius of the cone to emit from
  85386. * @param angle The base angle of the cone
  85387. * @returns the emitter
  85388. */
  85389. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85390. /**
  85391. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85392. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85393. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85394. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85395. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85396. * @returns the emitter
  85397. */
  85398. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85399. /**
  85400. * Get hosting scene
  85401. * @returns the scene
  85402. */
  85403. getScene(): Scene;
  85404. }
  85405. }
  85406. declare module BABYLON {
  85407. /**
  85408. * Creates an instance based on a source mesh.
  85409. */
  85410. export class InstancedMesh extends AbstractMesh {
  85411. private _sourceMesh;
  85412. private _currentLOD;
  85413. /** @hidden */
  85414. _indexInSourceMeshInstanceArray: number;
  85415. constructor(name: string, source: Mesh);
  85416. /**
  85417. * Returns the string "InstancedMesh".
  85418. */
  85419. getClassName(): string;
  85420. /** Gets the list of lights affecting that mesh */
  85421. readonly lightSources: Light[];
  85422. _resyncLightSources(): void;
  85423. _resyncLighSource(light: Light): void;
  85424. _removeLightSource(light: Light, dispose: boolean): void;
  85425. /**
  85426. * If the source mesh receives shadows
  85427. */
  85428. readonly receiveShadows: boolean;
  85429. /**
  85430. * The material of the source mesh
  85431. */
  85432. readonly material: Nullable<Material>;
  85433. /**
  85434. * Visibility of the source mesh
  85435. */
  85436. readonly visibility: number;
  85437. /**
  85438. * Skeleton of the source mesh
  85439. */
  85440. readonly skeleton: Nullable<Skeleton>;
  85441. /**
  85442. * Rendering ground id of the source mesh
  85443. */
  85444. renderingGroupId: number;
  85445. /**
  85446. * Returns the total number of vertices (integer).
  85447. */
  85448. getTotalVertices(): number;
  85449. /**
  85450. * Returns a positive integer : the total number of indices in this mesh geometry.
  85451. * @returns the numner of indices or zero if the mesh has no geometry.
  85452. */
  85453. getTotalIndices(): number;
  85454. /**
  85455. * The source mesh of the instance
  85456. */
  85457. readonly sourceMesh: Mesh;
  85458. /**
  85459. * Is this node ready to be used/rendered
  85460. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85461. * @return {boolean} is it ready
  85462. */
  85463. isReady(completeCheck?: boolean): boolean;
  85464. /**
  85465. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85466. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85467. * @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.
  85468. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85469. */
  85470. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85471. /**
  85472. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85473. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85474. * The `data` are either a numeric array either a Float32Array.
  85475. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85476. * 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).
  85477. * Note that a new underlying VertexBuffer object is created each call.
  85478. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85479. *
  85480. * Possible `kind` values :
  85481. * - VertexBuffer.PositionKind
  85482. * - VertexBuffer.UVKind
  85483. * - VertexBuffer.UV2Kind
  85484. * - VertexBuffer.UV3Kind
  85485. * - VertexBuffer.UV4Kind
  85486. * - VertexBuffer.UV5Kind
  85487. * - VertexBuffer.UV6Kind
  85488. * - VertexBuffer.ColorKind
  85489. * - VertexBuffer.MatricesIndicesKind
  85490. * - VertexBuffer.MatricesIndicesExtraKind
  85491. * - VertexBuffer.MatricesWeightsKind
  85492. * - VertexBuffer.MatricesWeightsExtraKind
  85493. *
  85494. * Returns the Mesh.
  85495. */
  85496. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85497. /**
  85498. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85499. * If the mesh has no geometry, it is simply returned as it is.
  85500. * The `data` are either a numeric array either a Float32Array.
  85501. * No new underlying VertexBuffer object is created.
  85502. * 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.
  85503. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85504. *
  85505. * Possible `kind` values :
  85506. * - VertexBuffer.PositionKind
  85507. * - VertexBuffer.UVKind
  85508. * - VertexBuffer.UV2Kind
  85509. * - VertexBuffer.UV3Kind
  85510. * - VertexBuffer.UV4Kind
  85511. * - VertexBuffer.UV5Kind
  85512. * - VertexBuffer.UV6Kind
  85513. * - VertexBuffer.ColorKind
  85514. * - VertexBuffer.MatricesIndicesKind
  85515. * - VertexBuffer.MatricesIndicesExtraKind
  85516. * - VertexBuffer.MatricesWeightsKind
  85517. * - VertexBuffer.MatricesWeightsExtraKind
  85518. *
  85519. * Returns the Mesh.
  85520. */
  85521. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85522. /**
  85523. * Sets the mesh indices.
  85524. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85525. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85526. * This method creates a new index buffer each call.
  85527. * Returns the Mesh.
  85528. */
  85529. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85530. /**
  85531. * Boolean : True if the mesh owns the requested kind of data.
  85532. */
  85533. isVerticesDataPresent(kind: string): boolean;
  85534. /**
  85535. * Returns an array of indices (IndicesArray).
  85536. */
  85537. getIndices(): Nullable<IndicesArray>;
  85538. readonly _positions: Nullable<Vector3[]>;
  85539. /**
  85540. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85541. * This means the mesh underlying bounding box and sphere are recomputed.
  85542. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85543. * @returns the current mesh
  85544. */
  85545. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85546. /** @hidden */
  85547. _preActivate(): InstancedMesh;
  85548. /** @hidden */
  85549. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85550. /** @hidden */
  85551. _postActivate(): void;
  85552. getWorldMatrix(): Matrix;
  85553. readonly isAnInstance: boolean;
  85554. /**
  85555. * Returns the current associated LOD AbstractMesh.
  85556. */
  85557. getLOD(camera: Camera): AbstractMesh;
  85558. /** @hidden */
  85559. _syncSubMeshes(): InstancedMesh;
  85560. /** @hidden */
  85561. _generatePointsArray(): boolean;
  85562. /**
  85563. * Creates a new InstancedMesh from the current mesh.
  85564. * - name (string) : the cloned mesh name
  85565. * - newParent (optional Node) : the optional Node to parent the clone to.
  85566. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85567. *
  85568. * Returns the clone.
  85569. */
  85570. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85571. /**
  85572. * Disposes the InstancedMesh.
  85573. * Returns nothing.
  85574. */
  85575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85576. }
  85577. }
  85578. declare module BABYLON {
  85579. /**
  85580. * Defines the options associated with the creation of a shader material.
  85581. */
  85582. export interface IShaderMaterialOptions {
  85583. /**
  85584. * Does the material work in alpha blend mode
  85585. */
  85586. needAlphaBlending: boolean;
  85587. /**
  85588. * Does the material work in alpha test mode
  85589. */
  85590. needAlphaTesting: boolean;
  85591. /**
  85592. * The list of attribute names used in the shader
  85593. */
  85594. attributes: string[];
  85595. /**
  85596. * The list of unifrom names used in the shader
  85597. */
  85598. uniforms: string[];
  85599. /**
  85600. * The list of UBO names used in the shader
  85601. */
  85602. uniformBuffers: string[];
  85603. /**
  85604. * The list of sampler names used in the shader
  85605. */
  85606. samplers: string[];
  85607. /**
  85608. * The list of defines used in the shader
  85609. */
  85610. defines: string[];
  85611. }
  85612. /**
  85613. * 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.
  85614. *
  85615. * This returned material effects how the mesh will look based on the code in the shaders.
  85616. *
  85617. * @see http://doc.babylonjs.com/how_to/shader_material
  85618. */
  85619. export class ShaderMaterial extends Material {
  85620. private _shaderPath;
  85621. private _options;
  85622. private _textures;
  85623. private _textureArrays;
  85624. private _floats;
  85625. private _ints;
  85626. private _floatsArrays;
  85627. private _colors3;
  85628. private _colors3Arrays;
  85629. private _colors4;
  85630. private _colors4Arrays;
  85631. private _vectors2;
  85632. private _vectors3;
  85633. private _vectors4;
  85634. private _matrices;
  85635. private _matrices3x3;
  85636. private _matrices2x2;
  85637. private _vectors2Arrays;
  85638. private _vectors3Arrays;
  85639. private _vectors4Arrays;
  85640. private _cachedWorldViewMatrix;
  85641. private _cachedWorldViewProjectionMatrix;
  85642. private _renderId;
  85643. /**
  85644. * Instantiate a new shader material.
  85645. * 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.
  85646. * This returned material effects how the mesh will look based on the code in the shaders.
  85647. * @see http://doc.babylonjs.com/how_to/shader_material
  85648. * @param name Define the name of the material in the scene
  85649. * @param scene Define the scene the material belongs to
  85650. * @param shaderPath Defines the route to the shader code in one of three ways:
  85651. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85652. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85653. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85654. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85655. * @param options Define the options used to create the shader
  85656. */
  85657. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85658. /**
  85659. * Gets the options used to compile the shader.
  85660. * They can be modified to trigger a new compilation
  85661. */
  85662. readonly options: IShaderMaterialOptions;
  85663. /**
  85664. * Gets the current class name of the material e.g. "ShaderMaterial"
  85665. * Mainly use in serialization.
  85666. * @returns the class name
  85667. */
  85668. getClassName(): string;
  85669. /**
  85670. * Specifies if the material will require alpha blending
  85671. * @returns a boolean specifying if alpha blending is needed
  85672. */
  85673. needAlphaBlending(): boolean;
  85674. /**
  85675. * Specifies if this material should be rendered in alpha test mode
  85676. * @returns a boolean specifying if an alpha test is needed.
  85677. */
  85678. needAlphaTesting(): boolean;
  85679. private _checkUniform;
  85680. /**
  85681. * Set a texture in the shader.
  85682. * @param name Define the name of the uniform samplers as defined in the shader
  85683. * @param texture Define the texture to bind to this sampler
  85684. * @return the material itself allowing "fluent" like uniform updates
  85685. */
  85686. setTexture(name: string, texture: Texture): ShaderMaterial;
  85687. /**
  85688. * Set a texture array in the shader.
  85689. * @param name Define the name of the uniform sampler array as defined in the shader
  85690. * @param textures Define the list of textures to bind to this sampler
  85691. * @return the material itself allowing "fluent" like uniform updates
  85692. */
  85693. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85694. /**
  85695. * Set a float in the shader.
  85696. * @param name Define the name of the uniform as defined in the shader
  85697. * @param value Define the value to give to the uniform
  85698. * @return the material itself allowing "fluent" like uniform updates
  85699. */
  85700. setFloat(name: string, value: number): ShaderMaterial;
  85701. /**
  85702. * Set a int in the shader.
  85703. * @param name Define the name of the uniform as defined in the shader
  85704. * @param value Define the value to give to the uniform
  85705. * @return the material itself allowing "fluent" like uniform updates
  85706. */
  85707. setInt(name: string, value: number): ShaderMaterial;
  85708. /**
  85709. * Set an array of floats in the shader.
  85710. * @param name Define the name of the uniform as defined in the shader
  85711. * @param value Define the value to give to the uniform
  85712. * @return the material itself allowing "fluent" like uniform updates
  85713. */
  85714. setFloats(name: string, value: number[]): ShaderMaterial;
  85715. /**
  85716. * Set a vec3 in the shader from a Color3.
  85717. * @param name Define the name of the uniform as defined in the shader
  85718. * @param value Define the value to give to the uniform
  85719. * @return the material itself allowing "fluent" like uniform updates
  85720. */
  85721. setColor3(name: string, value: Color3): ShaderMaterial;
  85722. /**
  85723. * Set a vec3 array in the shader from a Color3 array.
  85724. * @param name Define the name of the uniform as defined in the shader
  85725. * @param value Define the value to give to the uniform
  85726. * @return the material itself allowing "fluent" like uniform updates
  85727. */
  85728. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85729. /**
  85730. * Set a vec4 in the shader from a Color4.
  85731. * @param name Define the name of the uniform as defined in the shader
  85732. * @param value Define the value to give to the uniform
  85733. * @return the material itself allowing "fluent" like uniform updates
  85734. */
  85735. setColor4(name: string, value: Color4): ShaderMaterial;
  85736. /**
  85737. * Set a vec4 array in the shader from a Color4 array.
  85738. * @param name Define the name of the uniform as defined in the shader
  85739. * @param value Define the value to give to the uniform
  85740. * @return the material itself allowing "fluent" like uniform updates
  85741. */
  85742. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85743. /**
  85744. * Set a vec2 in the shader from a Vector2.
  85745. * @param name Define the name of the uniform as defined in the shader
  85746. * @param value Define the value to give to the uniform
  85747. * @return the material itself allowing "fluent" like uniform updates
  85748. */
  85749. setVector2(name: string, value: Vector2): ShaderMaterial;
  85750. /**
  85751. * Set a vec3 in the shader from a Vector3.
  85752. * @param name Define the name of the uniform as defined in the shader
  85753. * @param value Define the value to give to the uniform
  85754. * @return the material itself allowing "fluent" like uniform updates
  85755. */
  85756. setVector3(name: string, value: Vector3): ShaderMaterial;
  85757. /**
  85758. * Set a vec4 in the shader from a Vector4.
  85759. * @param name Define the name of the uniform as defined in the shader
  85760. * @param value Define the value to give to the uniform
  85761. * @return the material itself allowing "fluent" like uniform updates
  85762. */
  85763. setVector4(name: string, value: Vector4): ShaderMaterial;
  85764. /**
  85765. * Set a mat4 in the shader from a Matrix.
  85766. * @param name Define the name of the uniform as defined in the shader
  85767. * @param value Define the value to give to the uniform
  85768. * @return the material itself allowing "fluent" like uniform updates
  85769. */
  85770. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85771. /**
  85772. * Set a mat3 in the shader from a Float32Array.
  85773. * @param name Define the name of the uniform as defined in the shader
  85774. * @param value Define the value to give to the uniform
  85775. * @return the material itself allowing "fluent" like uniform updates
  85776. */
  85777. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85778. /**
  85779. * Set a mat2 in the shader from a Float32Array.
  85780. * @param name Define the name of the uniform as defined in the shader
  85781. * @param value Define the value to give to the uniform
  85782. * @return the material itself allowing "fluent" like uniform updates
  85783. */
  85784. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85785. /**
  85786. * Set a vec2 array in the shader from a number array.
  85787. * @param name Define the name of the uniform as defined in the shader
  85788. * @param value Define the value to give to the uniform
  85789. * @return the material itself allowing "fluent" like uniform updates
  85790. */
  85791. setArray2(name: string, value: number[]): ShaderMaterial;
  85792. /**
  85793. * Set a vec3 array in the shader from a number array.
  85794. * @param name Define the name of the uniform as defined in the shader
  85795. * @param value Define the value to give to the uniform
  85796. * @return the material itself allowing "fluent" like uniform updates
  85797. */
  85798. setArray3(name: string, value: number[]): ShaderMaterial;
  85799. /**
  85800. * Set a vec4 array in the shader from a number array.
  85801. * @param name Define the name of the uniform as defined in the shader
  85802. * @param value Define the value to give to the uniform
  85803. * @return the material itself allowing "fluent" like uniform updates
  85804. */
  85805. setArray4(name: string, value: number[]): ShaderMaterial;
  85806. private _checkCache;
  85807. /**
  85808. * Specifies that the submesh is ready to be used
  85809. * @param mesh defines the mesh to check
  85810. * @param subMesh defines which submesh to check
  85811. * @param useInstances specifies that instances should be used
  85812. * @returns a boolean indicating that the submesh is ready or not
  85813. */
  85814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85815. /**
  85816. * Checks if the material is ready to render the requested mesh
  85817. * @param mesh Define the mesh to render
  85818. * @param useInstances Define whether or not the material is used with instances
  85819. * @returns true if ready, otherwise false
  85820. */
  85821. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85822. /**
  85823. * Binds the world matrix to the material
  85824. * @param world defines the world transformation matrix
  85825. */
  85826. bindOnlyWorldMatrix(world: Matrix): void;
  85827. /**
  85828. * Binds the material to the mesh
  85829. * @param world defines the world transformation matrix
  85830. * @param mesh defines the mesh to bind the material to
  85831. */
  85832. bind(world: Matrix, mesh?: Mesh): void;
  85833. /**
  85834. * Gets the active textures from the material
  85835. * @returns an array of textures
  85836. */
  85837. getActiveTextures(): BaseTexture[];
  85838. /**
  85839. * Specifies if the material uses a texture
  85840. * @param texture defines the texture to check against the material
  85841. * @returns a boolean specifying if the material uses the texture
  85842. */
  85843. hasTexture(texture: BaseTexture): boolean;
  85844. /**
  85845. * Makes a duplicate of the material, and gives it a new name
  85846. * @param name defines the new name for the duplicated material
  85847. * @returns the cloned material
  85848. */
  85849. clone(name: string): ShaderMaterial;
  85850. /**
  85851. * Disposes the material
  85852. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85853. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85854. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85855. */
  85856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85857. /**
  85858. * Serializes this material in a JSON representation
  85859. * @returns the serialized material object
  85860. */
  85861. serialize(): any;
  85862. /**
  85863. * Creates a shader material from parsed shader material data
  85864. * @param source defines the JSON represnetation of the material
  85865. * @param scene defines the hosting scene
  85866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85867. * @returns a new material
  85868. */
  85869. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85870. }
  85871. }
  85872. declare module BABYLON {
  85873. /** @hidden */
  85874. export var colorPixelShader: {
  85875. name: string;
  85876. shader: string;
  85877. };
  85878. }
  85879. declare module BABYLON {
  85880. /** @hidden */
  85881. export var colorVertexShader: {
  85882. name: string;
  85883. shader: string;
  85884. };
  85885. }
  85886. declare module BABYLON {
  85887. /**
  85888. * Line mesh
  85889. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85890. */
  85891. export class LinesMesh extends Mesh {
  85892. /**
  85893. * If vertex color should be applied to the mesh
  85894. */
  85895. readonly useVertexColor?: boolean | undefined;
  85896. /**
  85897. * If vertex alpha should be applied to the mesh
  85898. */
  85899. readonly useVertexAlpha?: boolean | undefined;
  85900. /**
  85901. * Color of the line (Default: White)
  85902. */
  85903. color: Color3;
  85904. /**
  85905. * Alpha of the line (Default: 1)
  85906. */
  85907. alpha: number;
  85908. /**
  85909. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85910. * This margin is expressed in world space coordinates, so its value may vary.
  85911. * Default value is 0.1
  85912. */
  85913. intersectionThreshold: number;
  85914. private _colorShader;
  85915. private color4;
  85916. /**
  85917. * Creates a new LinesMesh
  85918. * @param name defines the name
  85919. * @param scene defines the hosting scene
  85920. * @param parent defines the parent mesh if any
  85921. * @param source defines the optional source LinesMesh used to clone data from
  85922. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85923. * When false, achieved by calling a clone(), also passing False.
  85924. * This will make creation of children, recursive.
  85925. * @param useVertexColor defines if this LinesMesh supports vertex color
  85926. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85927. */
  85928. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85929. /**
  85930. * If vertex color should be applied to the mesh
  85931. */
  85932. useVertexColor?: boolean | undefined,
  85933. /**
  85934. * If vertex alpha should be applied to the mesh
  85935. */
  85936. useVertexAlpha?: boolean | undefined);
  85937. private _addClipPlaneDefine;
  85938. private _removeClipPlaneDefine;
  85939. isReady(): boolean;
  85940. /**
  85941. * Returns the string "LineMesh"
  85942. */
  85943. getClassName(): string;
  85944. /**
  85945. * @hidden
  85946. */
  85947. /**
  85948. * @hidden
  85949. */
  85950. material: Material;
  85951. /**
  85952. * @hidden
  85953. */
  85954. readonly checkCollisions: boolean;
  85955. /** @hidden */
  85956. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85957. /** @hidden */
  85958. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85959. /**
  85960. * Disposes of the line mesh
  85961. * @param doNotRecurse If children should be disposed
  85962. */
  85963. dispose(doNotRecurse?: boolean): void;
  85964. /**
  85965. * Returns a new LineMesh object cloned from the current one.
  85966. */
  85967. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85968. /**
  85969. * Creates a new InstancedLinesMesh object from the mesh model.
  85970. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85971. * @param name defines the name of the new instance
  85972. * @returns a new InstancedLinesMesh
  85973. */
  85974. createInstance(name: string): InstancedLinesMesh;
  85975. }
  85976. /**
  85977. * Creates an instance based on a source LinesMesh
  85978. */
  85979. export class InstancedLinesMesh extends InstancedMesh {
  85980. /**
  85981. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85982. * This margin is expressed in world space coordinates, so its value may vary.
  85983. * Initilized with the intersectionThreshold value of the source LinesMesh
  85984. */
  85985. intersectionThreshold: number;
  85986. constructor(name: string, source: LinesMesh);
  85987. /**
  85988. * Returns the string "InstancedLinesMesh".
  85989. */
  85990. getClassName(): string;
  85991. }
  85992. }
  85993. declare module BABYLON {
  85994. /** @hidden */
  85995. export var linePixelShader: {
  85996. name: string;
  85997. shader: string;
  85998. };
  85999. }
  86000. declare module BABYLON {
  86001. /** @hidden */
  86002. export var lineVertexShader: {
  86003. name: string;
  86004. shader: string;
  86005. };
  86006. }
  86007. declare module BABYLON {
  86008. interface AbstractMesh {
  86009. /**
  86010. * Gets the edgesRenderer associated with the mesh
  86011. */
  86012. edgesRenderer: Nullable<EdgesRenderer>;
  86013. }
  86014. interface LinesMesh {
  86015. /**
  86016. * Enables the edge rendering mode on the mesh.
  86017. * This mode makes the mesh edges visible
  86018. * @param epsilon defines the maximal distance between two angles to detect a face
  86019. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86020. * @returns the currentAbstractMesh
  86021. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86022. */
  86023. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86024. }
  86025. interface InstancedLinesMesh {
  86026. /**
  86027. * Enables the edge rendering mode on the mesh.
  86028. * This mode makes the mesh edges visible
  86029. * @param epsilon defines the maximal distance between two angles to detect a face
  86030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86031. * @returns the current InstancedLinesMesh
  86032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86033. */
  86034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86035. }
  86036. /**
  86037. * Defines the minimum contract an Edges renderer should follow.
  86038. */
  86039. export interface IEdgesRenderer extends IDisposable {
  86040. /**
  86041. * Gets or sets a boolean indicating if the edgesRenderer is active
  86042. */
  86043. isEnabled: boolean;
  86044. /**
  86045. * Renders the edges of the attached mesh,
  86046. */
  86047. render(): void;
  86048. /**
  86049. * Checks wether or not the edges renderer is ready to render.
  86050. * @return true if ready, otherwise false.
  86051. */
  86052. isReady(): boolean;
  86053. }
  86054. /**
  86055. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86056. */
  86057. export class EdgesRenderer implements IEdgesRenderer {
  86058. /**
  86059. * Define the size of the edges with an orthographic camera
  86060. */
  86061. edgesWidthScalerForOrthographic: number;
  86062. /**
  86063. * Define the size of the edges with a perspective camera
  86064. */
  86065. edgesWidthScalerForPerspective: number;
  86066. protected _source: AbstractMesh;
  86067. protected _linesPositions: number[];
  86068. protected _linesNormals: number[];
  86069. protected _linesIndices: number[];
  86070. protected _epsilon: number;
  86071. protected _indicesCount: number;
  86072. protected _lineShader: ShaderMaterial;
  86073. protected _ib: DataBuffer;
  86074. protected _buffers: {
  86075. [key: string]: Nullable<VertexBuffer>;
  86076. };
  86077. protected _checkVerticesInsteadOfIndices: boolean;
  86078. private _meshRebuildObserver;
  86079. private _meshDisposeObserver;
  86080. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86081. isEnabled: boolean;
  86082. /**
  86083. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86084. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86085. * @param source Mesh used to create edges
  86086. * @param epsilon sum of angles in adjacency to check for edge
  86087. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86088. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86089. */
  86090. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86091. protected _prepareRessources(): void;
  86092. /** @hidden */
  86093. _rebuild(): void;
  86094. /**
  86095. * Releases the required resources for the edges renderer
  86096. */
  86097. dispose(): void;
  86098. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86099. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86100. /**
  86101. * Checks if the pair of p0 and p1 is en edge
  86102. * @param faceIndex
  86103. * @param edge
  86104. * @param faceNormals
  86105. * @param p0
  86106. * @param p1
  86107. * @private
  86108. */
  86109. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86110. /**
  86111. * push line into the position, normal and index buffer
  86112. * @protected
  86113. */
  86114. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86115. /**
  86116. * Generates lines edges from adjacencjes
  86117. * @private
  86118. */
  86119. _generateEdgesLines(): void;
  86120. /**
  86121. * Checks wether or not the edges renderer is ready to render.
  86122. * @return true if ready, otherwise false.
  86123. */
  86124. isReady(): boolean;
  86125. /**
  86126. * Renders the edges of the attached mesh,
  86127. */
  86128. render(): void;
  86129. }
  86130. /**
  86131. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86132. */
  86133. export class LineEdgesRenderer extends EdgesRenderer {
  86134. /**
  86135. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86136. * @param source LineMesh used to generate edges
  86137. * @param epsilon not important (specified angle for edge detection)
  86138. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86139. */
  86140. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86141. /**
  86142. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86143. */
  86144. _generateEdgesLines(): void;
  86145. }
  86146. }
  86147. declare module BABYLON {
  86148. /**
  86149. * This represents the object necessary to create a rendering group.
  86150. * This is exclusively used and created by the rendering manager.
  86151. * To modify the behavior, you use the available helpers in your scene or meshes.
  86152. * @hidden
  86153. */
  86154. export class RenderingGroup {
  86155. index: number;
  86156. private static _zeroVector;
  86157. private _scene;
  86158. private _opaqueSubMeshes;
  86159. private _transparentSubMeshes;
  86160. private _alphaTestSubMeshes;
  86161. private _depthOnlySubMeshes;
  86162. private _particleSystems;
  86163. private _spriteManagers;
  86164. private _opaqueSortCompareFn;
  86165. private _alphaTestSortCompareFn;
  86166. private _transparentSortCompareFn;
  86167. private _renderOpaque;
  86168. private _renderAlphaTest;
  86169. private _renderTransparent;
  86170. /** @hidden */
  86171. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86172. onBeforeTransparentRendering: () => void;
  86173. /**
  86174. * Set the opaque sort comparison function.
  86175. * If null the sub meshes will be render in the order they were created
  86176. */
  86177. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86178. /**
  86179. * Set the alpha test sort comparison function.
  86180. * If null the sub meshes will be render in the order they were created
  86181. */
  86182. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86183. /**
  86184. * Set the transparent sort comparison function.
  86185. * If null the sub meshes will be render in the order they were created
  86186. */
  86187. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86188. /**
  86189. * Creates a new rendering group.
  86190. * @param index The rendering group index
  86191. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86192. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86193. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86194. */
  86195. 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>);
  86196. /**
  86197. * Render all the sub meshes contained in the group.
  86198. * @param customRenderFunction Used to override the default render behaviour of the group.
  86199. * @returns true if rendered some submeshes.
  86200. */
  86201. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86202. /**
  86203. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86204. * @param subMeshes The submeshes to render
  86205. */
  86206. private renderOpaqueSorted;
  86207. /**
  86208. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86209. * @param subMeshes The submeshes to render
  86210. */
  86211. private renderAlphaTestSorted;
  86212. /**
  86213. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86214. * @param subMeshes The submeshes to render
  86215. */
  86216. private renderTransparentSorted;
  86217. /**
  86218. * Renders the submeshes in a specified order.
  86219. * @param subMeshes The submeshes to sort before render
  86220. * @param sortCompareFn The comparison function use to sort
  86221. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86222. * @param transparent Specifies to activate blending if true
  86223. */
  86224. private static renderSorted;
  86225. /**
  86226. * Renders the submeshes in the order they were dispatched (no sort applied).
  86227. * @param subMeshes The submeshes to render
  86228. */
  86229. private static renderUnsorted;
  86230. /**
  86231. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86232. * are rendered back to front if in the same alpha index.
  86233. *
  86234. * @param a The first submesh
  86235. * @param b The second submesh
  86236. * @returns The result of the comparison
  86237. */
  86238. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86239. /**
  86240. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86241. * are rendered back to front.
  86242. *
  86243. * @param a The first submesh
  86244. * @param b The second submesh
  86245. * @returns The result of the comparison
  86246. */
  86247. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86248. /**
  86249. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86250. * are rendered front to back (prevent overdraw).
  86251. *
  86252. * @param a The first submesh
  86253. * @param b The second submesh
  86254. * @returns The result of the comparison
  86255. */
  86256. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86257. /**
  86258. * Resets the different lists of submeshes to prepare a new frame.
  86259. */
  86260. prepare(): void;
  86261. dispose(): void;
  86262. /**
  86263. * Inserts the submesh in its correct queue depending on its material.
  86264. * @param subMesh The submesh to dispatch
  86265. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86266. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86267. */
  86268. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86269. dispatchSprites(spriteManager: ISpriteManager): void;
  86270. dispatchParticles(particleSystem: IParticleSystem): void;
  86271. private _renderParticles;
  86272. private _renderSprites;
  86273. }
  86274. }
  86275. declare module BABYLON {
  86276. /**
  86277. * Interface describing the different options available in the rendering manager
  86278. * regarding Auto Clear between groups.
  86279. */
  86280. export interface IRenderingManagerAutoClearSetup {
  86281. /**
  86282. * Defines whether or not autoclear is enable.
  86283. */
  86284. autoClear: boolean;
  86285. /**
  86286. * Defines whether or not to autoclear the depth buffer.
  86287. */
  86288. depth: boolean;
  86289. /**
  86290. * Defines whether or not to autoclear the stencil buffer.
  86291. */
  86292. stencil: boolean;
  86293. }
  86294. /**
  86295. * This class is used by the onRenderingGroupObservable
  86296. */
  86297. export class RenderingGroupInfo {
  86298. /**
  86299. * The Scene that being rendered
  86300. */
  86301. scene: Scene;
  86302. /**
  86303. * The camera currently used for the rendering pass
  86304. */
  86305. camera: Nullable<Camera>;
  86306. /**
  86307. * The ID of the renderingGroup being processed
  86308. */
  86309. renderingGroupId: number;
  86310. }
  86311. /**
  86312. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86313. * It is enable to manage the different groups as well as the different necessary sort functions.
  86314. * This should not be used directly aside of the few static configurations
  86315. */
  86316. export class RenderingManager {
  86317. /**
  86318. * The max id used for rendering groups (not included)
  86319. */
  86320. static MAX_RENDERINGGROUPS: number;
  86321. /**
  86322. * The min id used for rendering groups (included)
  86323. */
  86324. static MIN_RENDERINGGROUPS: number;
  86325. /**
  86326. * Used to globally prevent autoclearing scenes.
  86327. */
  86328. static AUTOCLEAR: boolean;
  86329. /**
  86330. * @hidden
  86331. */
  86332. _useSceneAutoClearSetup: boolean;
  86333. private _scene;
  86334. private _renderingGroups;
  86335. private _depthStencilBufferAlreadyCleaned;
  86336. private _autoClearDepthStencil;
  86337. private _customOpaqueSortCompareFn;
  86338. private _customAlphaTestSortCompareFn;
  86339. private _customTransparentSortCompareFn;
  86340. private _renderingGroupInfo;
  86341. /**
  86342. * Instantiates a new rendering group for a particular scene
  86343. * @param scene Defines the scene the groups belongs to
  86344. */
  86345. constructor(scene: Scene);
  86346. private _clearDepthStencilBuffer;
  86347. /**
  86348. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86349. * @hidden
  86350. */
  86351. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86352. /**
  86353. * Resets the different information of the group to prepare a new frame
  86354. * @hidden
  86355. */
  86356. reset(): void;
  86357. /**
  86358. * Dispose and release the group and its associated resources.
  86359. * @hidden
  86360. */
  86361. dispose(): void;
  86362. /**
  86363. * Clear the info related to rendering groups preventing retention points during dispose.
  86364. */
  86365. freeRenderingGroups(): void;
  86366. private _prepareRenderingGroup;
  86367. /**
  86368. * Add a sprite manager to the rendering manager in order to render it this frame.
  86369. * @param spriteManager Define the sprite manager to render
  86370. */
  86371. dispatchSprites(spriteManager: ISpriteManager): void;
  86372. /**
  86373. * Add a particle system to the rendering manager in order to render it this frame.
  86374. * @param particleSystem Define the particle system to render
  86375. */
  86376. dispatchParticles(particleSystem: IParticleSystem): void;
  86377. /**
  86378. * Add a submesh to the manager in order to render it this frame
  86379. * @param subMesh The submesh to dispatch
  86380. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86381. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86382. */
  86383. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86384. /**
  86385. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86386. * This allowed control for front to back rendering or reversly depending of the special needs.
  86387. *
  86388. * @param renderingGroupId The rendering group id corresponding to its index
  86389. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86390. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86391. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86392. */
  86393. 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;
  86394. /**
  86395. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86396. *
  86397. * @param renderingGroupId The rendering group id corresponding to its index
  86398. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86399. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86400. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86401. */
  86402. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86403. /**
  86404. * Gets the current auto clear configuration for one rendering group of the rendering
  86405. * manager.
  86406. * @param index the rendering group index to get the information for
  86407. * @returns The auto clear setup for the requested rendering group
  86408. */
  86409. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86410. }
  86411. }
  86412. declare module BABYLON {
  86413. /**
  86414. * This Helps creating a texture that will be created from a camera in your scene.
  86415. * It is basically a dynamic texture that could be used to create special effects for instance.
  86416. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86417. */
  86418. export class RenderTargetTexture extends Texture {
  86419. isCube: boolean;
  86420. /**
  86421. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86422. */
  86423. static readonly REFRESHRATE_RENDER_ONCE: number;
  86424. /**
  86425. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86426. */
  86427. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86428. /**
  86429. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86430. * the central point of your effect and can save a lot of performances.
  86431. */
  86432. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86433. /**
  86434. * Use this predicate to dynamically define the list of mesh you want to render.
  86435. * If set, the renderList property will be overwritten.
  86436. */
  86437. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86438. private _renderList;
  86439. /**
  86440. * Use this list to define the list of mesh you want to render.
  86441. */
  86442. renderList: Nullable<Array<AbstractMesh>>;
  86443. private _hookArray;
  86444. /**
  86445. * Define if particles should be rendered in your texture.
  86446. */
  86447. renderParticles: boolean;
  86448. /**
  86449. * Define if sprites should be rendered in your texture.
  86450. */
  86451. renderSprites: boolean;
  86452. /**
  86453. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86454. */
  86455. coordinatesMode: number;
  86456. /**
  86457. * Define the camera used to render the texture.
  86458. */
  86459. activeCamera: Nullable<Camera>;
  86460. /**
  86461. * Override the render function of the texture with your own one.
  86462. */
  86463. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86464. /**
  86465. * Define if camera post processes should be use while rendering the texture.
  86466. */
  86467. useCameraPostProcesses: boolean;
  86468. /**
  86469. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86470. */
  86471. ignoreCameraViewport: boolean;
  86472. private _postProcessManager;
  86473. private _postProcesses;
  86474. private _resizeObserver;
  86475. /**
  86476. * An event triggered when the texture is unbind.
  86477. */
  86478. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86479. /**
  86480. * An event triggered when the texture is unbind.
  86481. */
  86482. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86483. private _onAfterUnbindObserver;
  86484. /**
  86485. * Set a after unbind callback in the texture.
  86486. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86487. */
  86488. onAfterUnbind: () => void;
  86489. /**
  86490. * An event triggered before rendering the texture
  86491. */
  86492. onBeforeRenderObservable: Observable<number>;
  86493. private _onBeforeRenderObserver;
  86494. /**
  86495. * Set a before render callback in the texture.
  86496. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86497. */
  86498. onBeforeRender: (faceIndex: number) => void;
  86499. /**
  86500. * An event triggered after rendering the texture
  86501. */
  86502. onAfterRenderObservable: Observable<number>;
  86503. private _onAfterRenderObserver;
  86504. /**
  86505. * Set a after render callback in the texture.
  86506. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86507. */
  86508. onAfterRender: (faceIndex: number) => void;
  86509. /**
  86510. * An event triggered after the texture clear
  86511. */
  86512. onClearObservable: Observable<Engine>;
  86513. private _onClearObserver;
  86514. /**
  86515. * Set a clear callback in the texture.
  86516. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86517. */
  86518. onClear: (Engine: Engine) => void;
  86519. /**
  86520. * An event triggered when the texture is resized.
  86521. */
  86522. onResizeObservable: Observable<RenderTargetTexture>;
  86523. /**
  86524. * Define the clear color of the Render Target if it should be different from the scene.
  86525. */
  86526. clearColor: Color4;
  86527. protected _size: number | {
  86528. width: number;
  86529. height: number;
  86530. };
  86531. protected _initialSizeParameter: number | {
  86532. width: number;
  86533. height: number;
  86534. } | {
  86535. ratio: number;
  86536. };
  86537. protected _sizeRatio: Nullable<number>;
  86538. /** @hidden */
  86539. _generateMipMaps: boolean;
  86540. protected _renderingManager: RenderingManager;
  86541. /** @hidden */
  86542. _waitingRenderList: string[];
  86543. protected _doNotChangeAspectRatio: boolean;
  86544. protected _currentRefreshId: number;
  86545. protected _refreshRate: number;
  86546. protected _textureMatrix: Matrix;
  86547. protected _samples: number;
  86548. protected _renderTargetOptions: RenderTargetCreationOptions;
  86549. /**
  86550. * Gets render target creation options that were used.
  86551. */
  86552. readonly renderTargetOptions: RenderTargetCreationOptions;
  86553. protected _engine: Engine;
  86554. protected _onRatioRescale(): void;
  86555. /**
  86556. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86557. * It must define where the camera used to render the texture is set
  86558. */
  86559. boundingBoxPosition: Vector3;
  86560. private _boundingBoxSize;
  86561. /**
  86562. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86563. * When defined, the cubemap will switch to local mode
  86564. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86565. * @example https://www.babylonjs-playground.com/#RNASML
  86566. */
  86567. boundingBoxSize: Vector3;
  86568. /**
  86569. * In case the RTT has been created with a depth texture, get the associated
  86570. * depth texture.
  86571. * Otherwise, return null.
  86572. */
  86573. depthStencilTexture: Nullable<InternalTexture>;
  86574. /**
  86575. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86576. * or used a shadow, depth texture...
  86577. * @param name The friendly name of the texture
  86578. * @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)
  86579. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86580. * @param generateMipMaps True if mip maps need to be generated after render.
  86581. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86582. * @param type The type of the buffer in the RTT (int, half float, float...)
  86583. * @param isCube True if a cube texture needs to be created
  86584. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86585. * @param generateDepthBuffer True to generate a depth buffer
  86586. * @param generateStencilBuffer True to generate a stencil buffer
  86587. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86588. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86589. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86590. */
  86591. constructor(name: string, size: number | {
  86592. width: number;
  86593. height: number;
  86594. } | {
  86595. ratio: number;
  86596. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86597. /**
  86598. * Creates a depth stencil texture.
  86599. * This is only available in WebGL 2 or with the depth texture extension available.
  86600. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86601. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86602. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86603. */
  86604. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86605. private _processSizeParameter;
  86606. /**
  86607. * Define the number of samples to use in case of MSAA.
  86608. * It defaults to one meaning no MSAA has been enabled.
  86609. */
  86610. samples: number;
  86611. /**
  86612. * Resets the refresh counter of the texture and start bak from scratch.
  86613. * Could be useful to regenerate the texture if it is setup to render only once.
  86614. */
  86615. resetRefreshCounter(): void;
  86616. /**
  86617. * Define the refresh rate of the texture or the rendering frequency.
  86618. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86619. */
  86620. refreshRate: number;
  86621. /**
  86622. * Adds a post process to the render target rendering passes.
  86623. * @param postProcess define the post process to add
  86624. */
  86625. addPostProcess(postProcess: PostProcess): void;
  86626. /**
  86627. * Clear all the post processes attached to the render target
  86628. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86629. */
  86630. clearPostProcesses(dispose?: boolean): void;
  86631. /**
  86632. * Remove one of the post process from the list of attached post processes to the texture
  86633. * @param postProcess define the post process to remove from the list
  86634. */
  86635. removePostProcess(postProcess: PostProcess): void;
  86636. /** @hidden */
  86637. _shouldRender(): boolean;
  86638. /**
  86639. * Gets the actual render size of the texture.
  86640. * @returns the width of the render size
  86641. */
  86642. getRenderSize(): number;
  86643. /**
  86644. * Gets the actual render width of the texture.
  86645. * @returns the width of the render size
  86646. */
  86647. getRenderWidth(): number;
  86648. /**
  86649. * Gets the actual render height of the texture.
  86650. * @returns the height of the render size
  86651. */
  86652. getRenderHeight(): number;
  86653. /**
  86654. * Get if the texture can be rescaled or not.
  86655. */
  86656. readonly canRescale: boolean;
  86657. /**
  86658. * Resize the texture using a ratio.
  86659. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86660. */
  86661. scale(ratio: number): void;
  86662. /**
  86663. * Get the texture reflection matrix used to rotate/transform the reflection.
  86664. * @returns the reflection matrix
  86665. */
  86666. getReflectionTextureMatrix(): Matrix;
  86667. /**
  86668. * Resize the texture to a new desired size.
  86669. * Be carrefull as it will recreate all the data in the new texture.
  86670. * @param size Define the new size. It can be:
  86671. * - a number for squared texture,
  86672. * - an object containing { width: number, height: number }
  86673. * - or an object containing a ratio { ratio: number }
  86674. */
  86675. resize(size: number | {
  86676. width: number;
  86677. height: number;
  86678. } | {
  86679. ratio: number;
  86680. }): void;
  86681. /**
  86682. * Renders all the objects from the render list into the texture.
  86683. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86684. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86685. */
  86686. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86687. private _bestReflectionRenderTargetDimension;
  86688. /**
  86689. * @hidden
  86690. * @param faceIndex face index to bind to if this is a cubetexture
  86691. */
  86692. _bindFrameBuffer(faceIndex?: number): void;
  86693. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86694. private renderToTarget;
  86695. /**
  86696. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86697. * This allowed control for front to back rendering or reversly depending of the special needs.
  86698. *
  86699. * @param renderingGroupId The rendering group id corresponding to its index
  86700. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86701. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86702. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86703. */
  86704. 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;
  86705. /**
  86706. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86707. *
  86708. * @param renderingGroupId The rendering group id corresponding to its index
  86709. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86710. */
  86711. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86712. /**
  86713. * Clones the texture.
  86714. * @returns the cloned texture
  86715. */
  86716. clone(): RenderTargetTexture;
  86717. /**
  86718. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86719. * @returns The JSON representation of the texture
  86720. */
  86721. serialize(): any;
  86722. /**
  86723. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86724. */
  86725. disposeFramebufferObjects(): void;
  86726. /**
  86727. * Dispose the texture and release its associated resources.
  86728. */
  86729. dispose(): void;
  86730. /** @hidden */
  86731. _rebuild(): void;
  86732. /**
  86733. * Clear the info related to rendering groups preventing retention point in material dispose.
  86734. */
  86735. freeRenderingGroups(): void;
  86736. /**
  86737. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86738. * @returns the view count
  86739. */
  86740. getViewCount(): number;
  86741. }
  86742. }
  86743. declare module BABYLON {
  86744. /**
  86745. * Base class for the main features of a material in Babylon.js
  86746. */
  86747. export class Material implements IAnimatable {
  86748. /**
  86749. * Returns the triangle fill mode
  86750. */
  86751. static readonly TriangleFillMode: number;
  86752. /**
  86753. * Returns the wireframe mode
  86754. */
  86755. static readonly WireFrameFillMode: number;
  86756. /**
  86757. * Returns the point fill mode
  86758. */
  86759. static readonly PointFillMode: number;
  86760. /**
  86761. * Returns the point list draw mode
  86762. */
  86763. static readonly PointListDrawMode: number;
  86764. /**
  86765. * Returns the line list draw mode
  86766. */
  86767. static readonly LineListDrawMode: number;
  86768. /**
  86769. * Returns the line loop draw mode
  86770. */
  86771. static readonly LineLoopDrawMode: number;
  86772. /**
  86773. * Returns the line strip draw mode
  86774. */
  86775. static readonly LineStripDrawMode: number;
  86776. /**
  86777. * Returns the triangle strip draw mode
  86778. */
  86779. static readonly TriangleStripDrawMode: number;
  86780. /**
  86781. * Returns the triangle fan draw mode
  86782. */
  86783. static readonly TriangleFanDrawMode: number;
  86784. /**
  86785. * Stores the clock-wise side orientation
  86786. */
  86787. static readonly ClockWiseSideOrientation: number;
  86788. /**
  86789. * Stores the counter clock-wise side orientation
  86790. */
  86791. static readonly CounterClockWiseSideOrientation: number;
  86792. /**
  86793. * The dirty texture flag value
  86794. */
  86795. static readonly TextureDirtyFlag: number;
  86796. /**
  86797. * The dirty light flag value
  86798. */
  86799. static readonly LightDirtyFlag: number;
  86800. /**
  86801. * The dirty fresnel flag value
  86802. */
  86803. static readonly FresnelDirtyFlag: number;
  86804. /**
  86805. * The dirty attribute flag value
  86806. */
  86807. static readonly AttributesDirtyFlag: number;
  86808. /**
  86809. * The dirty misc flag value
  86810. */
  86811. static readonly MiscDirtyFlag: number;
  86812. /**
  86813. * The all dirty flag value
  86814. */
  86815. static readonly AllDirtyFlag: number;
  86816. /**
  86817. * The ID of the material
  86818. */
  86819. id: string;
  86820. /**
  86821. * Gets or sets the unique id of the material
  86822. */
  86823. uniqueId: number;
  86824. /**
  86825. * The name of the material
  86826. */
  86827. name: string;
  86828. /**
  86829. * Gets or sets user defined metadata
  86830. */
  86831. metadata: any;
  86832. /**
  86833. * For internal use only. Please do not use.
  86834. */
  86835. reservedDataStore: any;
  86836. /**
  86837. * Specifies if the ready state should be checked on each call
  86838. */
  86839. checkReadyOnEveryCall: boolean;
  86840. /**
  86841. * Specifies if the ready state should be checked once
  86842. */
  86843. checkReadyOnlyOnce: boolean;
  86844. /**
  86845. * The state of the material
  86846. */
  86847. state: string;
  86848. /**
  86849. * The alpha value of the material
  86850. */
  86851. protected _alpha: number;
  86852. /**
  86853. * List of inspectable custom properties (used by the Inspector)
  86854. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86855. */
  86856. inspectableCustomProperties: IInspectable[];
  86857. /**
  86858. * Sets the alpha value of the material
  86859. */
  86860. /**
  86861. * Gets the alpha value of the material
  86862. */
  86863. alpha: number;
  86864. /**
  86865. * Specifies if back face culling is enabled
  86866. */
  86867. protected _backFaceCulling: boolean;
  86868. /**
  86869. * Sets the back-face culling state
  86870. */
  86871. /**
  86872. * Gets the back-face culling state
  86873. */
  86874. backFaceCulling: boolean;
  86875. /**
  86876. * Stores the value for side orientation
  86877. */
  86878. sideOrientation: number;
  86879. /**
  86880. * Callback triggered when the material is compiled
  86881. */
  86882. onCompiled: Nullable<(effect: Effect) => void>;
  86883. /**
  86884. * Callback triggered when an error occurs
  86885. */
  86886. onError: Nullable<(effect: Effect, errors: string) => void>;
  86887. /**
  86888. * Callback triggered to get the render target textures
  86889. */
  86890. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86891. /**
  86892. * Gets a boolean indicating that current material needs to register RTT
  86893. */
  86894. readonly hasRenderTargetTextures: boolean;
  86895. /**
  86896. * Specifies if the material should be serialized
  86897. */
  86898. doNotSerialize: boolean;
  86899. /**
  86900. * @hidden
  86901. */
  86902. _storeEffectOnSubMeshes: boolean;
  86903. /**
  86904. * Stores the animations for the material
  86905. */
  86906. animations: Nullable<Array<Animation>>;
  86907. /**
  86908. * An event triggered when the material is disposed
  86909. */
  86910. onDisposeObservable: Observable<Material>;
  86911. /**
  86912. * An observer which watches for dispose events
  86913. */
  86914. private _onDisposeObserver;
  86915. private _onUnBindObservable;
  86916. /**
  86917. * Called during a dispose event
  86918. */
  86919. onDispose: () => void;
  86920. private _onBindObservable;
  86921. /**
  86922. * An event triggered when the material is bound
  86923. */
  86924. readonly onBindObservable: Observable<AbstractMesh>;
  86925. /**
  86926. * An observer which watches for bind events
  86927. */
  86928. private _onBindObserver;
  86929. /**
  86930. * Called during a bind event
  86931. */
  86932. onBind: (Mesh: AbstractMesh) => void;
  86933. /**
  86934. * An event triggered when the material is unbound
  86935. */
  86936. readonly onUnBindObservable: Observable<Material>;
  86937. /**
  86938. * Stores the value of the alpha mode
  86939. */
  86940. private _alphaMode;
  86941. /**
  86942. * Sets the value of the alpha mode.
  86943. *
  86944. * | Value | Type | Description |
  86945. * | --- | --- | --- |
  86946. * | 0 | ALPHA_DISABLE | |
  86947. * | 1 | ALPHA_ADD | |
  86948. * | 2 | ALPHA_COMBINE | |
  86949. * | 3 | ALPHA_SUBTRACT | |
  86950. * | 4 | ALPHA_MULTIPLY | |
  86951. * | 5 | ALPHA_MAXIMIZED | |
  86952. * | 6 | ALPHA_ONEONE | |
  86953. * | 7 | ALPHA_PREMULTIPLIED | |
  86954. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86955. * | 9 | ALPHA_INTERPOLATE | |
  86956. * | 10 | ALPHA_SCREENMODE | |
  86957. *
  86958. */
  86959. /**
  86960. * Gets the value of the alpha mode
  86961. */
  86962. alphaMode: number;
  86963. /**
  86964. * Stores the state of the need depth pre-pass value
  86965. */
  86966. private _needDepthPrePass;
  86967. /**
  86968. * Sets the need depth pre-pass value
  86969. */
  86970. /**
  86971. * Gets the depth pre-pass value
  86972. */
  86973. needDepthPrePass: boolean;
  86974. /**
  86975. * Specifies if depth writing should be disabled
  86976. */
  86977. disableDepthWrite: boolean;
  86978. /**
  86979. * Specifies if depth writing should be forced
  86980. */
  86981. forceDepthWrite: boolean;
  86982. /**
  86983. * Specifies if there should be a separate pass for culling
  86984. */
  86985. separateCullingPass: boolean;
  86986. /**
  86987. * Stores the state specifing if fog should be enabled
  86988. */
  86989. private _fogEnabled;
  86990. /**
  86991. * Sets the state for enabling fog
  86992. */
  86993. /**
  86994. * Gets the value of the fog enabled state
  86995. */
  86996. fogEnabled: boolean;
  86997. /**
  86998. * Stores the size of points
  86999. */
  87000. pointSize: number;
  87001. /**
  87002. * Stores the z offset value
  87003. */
  87004. zOffset: number;
  87005. /**
  87006. * Gets a value specifying if wireframe mode is enabled
  87007. */
  87008. /**
  87009. * Sets the state of wireframe mode
  87010. */
  87011. wireframe: boolean;
  87012. /**
  87013. * Gets the value specifying if point clouds are enabled
  87014. */
  87015. /**
  87016. * Sets the state of point cloud mode
  87017. */
  87018. pointsCloud: boolean;
  87019. /**
  87020. * Gets the material fill mode
  87021. */
  87022. /**
  87023. * Sets the material fill mode
  87024. */
  87025. fillMode: number;
  87026. /**
  87027. * @hidden
  87028. * Stores the effects for the material
  87029. */
  87030. _effect: Nullable<Effect>;
  87031. /**
  87032. * @hidden
  87033. * Specifies if the material was previously ready
  87034. */
  87035. _wasPreviouslyReady: boolean;
  87036. /**
  87037. * Specifies if uniform buffers should be used
  87038. */
  87039. private _useUBO;
  87040. /**
  87041. * Stores a reference to the scene
  87042. */
  87043. private _scene;
  87044. /**
  87045. * Stores the fill mode state
  87046. */
  87047. private _fillMode;
  87048. /**
  87049. * Specifies if the depth write state should be cached
  87050. */
  87051. private _cachedDepthWriteState;
  87052. /**
  87053. * Stores the uniform buffer
  87054. */
  87055. protected _uniformBuffer: UniformBuffer;
  87056. /** @hidden */
  87057. _indexInSceneMaterialArray: number;
  87058. /** @hidden */
  87059. meshMap: Nullable<{
  87060. [id: string]: AbstractMesh | undefined;
  87061. }>;
  87062. /**
  87063. * Creates a material instance
  87064. * @param name defines the name of the material
  87065. * @param scene defines the scene to reference
  87066. * @param doNotAdd specifies if the material should be added to the scene
  87067. */
  87068. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87069. /**
  87070. * Returns a string representation of the current material
  87071. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87072. * @returns a string with material information
  87073. */
  87074. toString(fullDetails?: boolean): string;
  87075. /**
  87076. * Gets the class name of the material
  87077. * @returns a string with the class name of the material
  87078. */
  87079. getClassName(): string;
  87080. /**
  87081. * Specifies if updates for the material been locked
  87082. */
  87083. readonly isFrozen: boolean;
  87084. /**
  87085. * Locks updates for the material
  87086. */
  87087. freeze(): void;
  87088. /**
  87089. * Unlocks updates for the material
  87090. */
  87091. unfreeze(): void;
  87092. /**
  87093. * Specifies if the material is ready to be used
  87094. * @param mesh defines the mesh to check
  87095. * @param useInstances specifies if instances should be used
  87096. * @returns a boolean indicating if the material is ready to be used
  87097. */
  87098. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87099. /**
  87100. * Specifies that the submesh is ready to be used
  87101. * @param mesh defines the mesh to check
  87102. * @param subMesh defines which submesh to check
  87103. * @param useInstances specifies that instances should be used
  87104. * @returns a boolean indicating that the submesh is ready or not
  87105. */
  87106. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87107. /**
  87108. * Returns the material effect
  87109. * @returns the effect associated with the material
  87110. */
  87111. getEffect(): Nullable<Effect>;
  87112. /**
  87113. * Returns the current scene
  87114. * @returns a Scene
  87115. */
  87116. getScene(): Scene;
  87117. /**
  87118. * Specifies if the material will require alpha blending
  87119. * @returns a boolean specifying if alpha blending is needed
  87120. */
  87121. needAlphaBlending(): boolean;
  87122. /**
  87123. * Specifies if the mesh will require alpha blending
  87124. * @param mesh defines the mesh to check
  87125. * @returns a boolean specifying if alpha blending is needed for the mesh
  87126. */
  87127. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87128. /**
  87129. * Specifies if this material should be rendered in alpha test mode
  87130. * @returns a boolean specifying if an alpha test is needed.
  87131. */
  87132. needAlphaTesting(): boolean;
  87133. /**
  87134. * Gets the texture used for the alpha test
  87135. * @returns the texture to use for alpha testing
  87136. */
  87137. getAlphaTestTexture(): Nullable<BaseTexture>;
  87138. /**
  87139. * Marks the material to indicate that it needs to be re-calculated
  87140. */
  87141. markDirty(): void;
  87142. /** @hidden */
  87143. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87144. /**
  87145. * Binds the material to the mesh
  87146. * @param world defines the world transformation matrix
  87147. * @param mesh defines the mesh to bind the material to
  87148. */
  87149. bind(world: Matrix, mesh?: Mesh): void;
  87150. /**
  87151. * Binds the submesh to the material
  87152. * @param world defines the world transformation matrix
  87153. * @param mesh defines the mesh containing the submesh
  87154. * @param subMesh defines the submesh to bind the material to
  87155. */
  87156. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87157. /**
  87158. * Binds the world matrix to the material
  87159. * @param world defines the world transformation matrix
  87160. */
  87161. bindOnlyWorldMatrix(world: Matrix): void;
  87162. /**
  87163. * Binds the scene's uniform buffer to the effect.
  87164. * @param effect defines the effect to bind to the scene uniform buffer
  87165. * @param sceneUbo defines the uniform buffer storing scene data
  87166. */
  87167. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87168. /**
  87169. * Binds the view matrix to the effect
  87170. * @param effect defines the effect to bind the view matrix to
  87171. */
  87172. bindView(effect: Effect): void;
  87173. /**
  87174. * Binds the view projection matrix to the effect
  87175. * @param effect defines the effect to bind the view projection matrix to
  87176. */
  87177. bindViewProjection(effect: Effect): void;
  87178. /**
  87179. * Specifies if material alpha testing should be turned on for the mesh
  87180. * @param mesh defines the mesh to check
  87181. */
  87182. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87183. /**
  87184. * Processes to execute after binding the material to a mesh
  87185. * @param mesh defines the rendered mesh
  87186. */
  87187. protected _afterBind(mesh?: Mesh): void;
  87188. /**
  87189. * Unbinds the material from the mesh
  87190. */
  87191. unbind(): void;
  87192. /**
  87193. * Gets the active textures from the material
  87194. * @returns an array of textures
  87195. */
  87196. getActiveTextures(): BaseTexture[];
  87197. /**
  87198. * Specifies if the material uses a texture
  87199. * @param texture defines the texture to check against the material
  87200. * @returns a boolean specifying if the material uses the texture
  87201. */
  87202. hasTexture(texture: BaseTexture): boolean;
  87203. /**
  87204. * Makes a duplicate of the material, and gives it a new name
  87205. * @param name defines the new name for the duplicated material
  87206. * @returns the cloned material
  87207. */
  87208. clone(name: string): Nullable<Material>;
  87209. /**
  87210. * Gets the meshes bound to the material
  87211. * @returns an array of meshes bound to the material
  87212. */
  87213. getBindedMeshes(): AbstractMesh[];
  87214. /**
  87215. * Force shader compilation
  87216. * @param mesh defines the mesh associated with this material
  87217. * @param onCompiled defines a function to execute once the material is compiled
  87218. * @param options defines the options to configure the compilation
  87219. */
  87220. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87221. clipPlane: boolean;
  87222. }>): void;
  87223. /**
  87224. * Force shader compilation
  87225. * @param mesh defines the mesh that will use this material
  87226. * @param options defines additional options for compiling the shaders
  87227. * @returns a promise that resolves when the compilation completes
  87228. */
  87229. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87230. clipPlane: boolean;
  87231. }>): Promise<void>;
  87232. private static readonly _AllDirtyCallBack;
  87233. private static readonly _ImageProcessingDirtyCallBack;
  87234. private static readonly _TextureDirtyCallBack;
  87235. private static readonly _FresnelDirtyCallBack;
  87236. private static readonly _MiscDirtyCallBack;
  87237. private static readonly _LightsDirtyCallBack;
  87238. private static readonly _AttributeDirtyCallBack;
  87239. private static _FresnelAndMiscDirtyCallBack;
  87240. private static _TextureAndMiscDirtyCallBack;
  87241. private static readonly _DirtyCallbackArray;
  87242. private static readonly _RunDirtyCallBacks;
  87243. /**
  87244. * Marks a define in the material to indicate that it needs to be re-computed
  87245. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87246. */
  87247. markAsDirty(flag: number): void;
  87248. /**
  87249. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87250. * @param func defines a function which checks material defines against the submeshes
  87251. */
  87252. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87253. /**
  87254. * Indicates that we need to re-calculated for all submeshes
  87255. */
  87256. protected _markAllSubMeshesAsAllDirty(): void;
  87257. /**
  87258. * Indicates that image processing needs to be re-calculated for all submeshes
  87259. */
  87260. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87261. /**
  87262. * Indicates that textures need to be re-calculated for all submeshes
  87263. */
  87264. protected _markAllSubMeshesAsTexturesDirty(): void;
  87265. /**
  87266. * Indicates that fresnel needs to be re-calculated for all submeshes
  87267. */
  87268. protected _markAllSubMeshesAsFresnelDirty(): void;
  87269. /**
  87270. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87271. */
  87272. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87273. /**
  87274. * Indicates that lights need to be re-calculated for all submeshes
  87275. */
  87276. protected _markAllSubMeshesAsLightsDirty(): void;
  87277. /**
  87278. * Indicates that attributes need to be re-calculated for all submeshes
  87279. */
  87280. protected _markAllSubMeshesAsAttributesDirty(): void;
  87281. /**
  87282. * Indicates that misc needs to be re-calculated for all submeshes
  87283. */
  87284. protected _markAllSubMeshesAsMiscDirty(): void;
  87285. /**
  87286. * Indicates that textures and misc need to be re-calculated for all submeshes
  87287. */
  87288. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87289. /**
  87290. * Disposes the material
  87291. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87292. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87293. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87294. */
  87295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87296. /** @hidden */
  87297. private releaseVertexArrayObject;
  87298. /**
  87299. * Serializes this material
  87300. * @returns the serialized material object
  87301. */
  87302. serialize(): any;
  87303. /**
  87304. * Creates a material from parsed material data
  87305. * @param parsedMaterial defines parsed material data
  87306. * @param scene defines the hosting scene
  87307. * @param rootUrl defines the root URL to use to load textures
  87308. * @returns a new material
  87309. */
  87310. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87311. }
  87312. }
  87313. declare module BABYLON {
  87314. /**
  87315. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87316. * separate meshes. This can be use to improve performances.
  87317. * @see http://doc.babylonjs.com/how_to/multi_materials
  87318. */
  87319. export class MultiMaterial extends Material {
  87320. private _subMaterials;
  87321. /**
  87322. * Gets or Sets the list of Materials used within the multi material.
  87323. * They need to be ordered according to the submeshes order in the associated mesh
  87324. */
  87325. subMaterials: Nullable<Material>[];
  87326. /**
  87327. * Function used to align with Node.getChildren()
  87328. * @returns the list of Materials used within the multi material
  87329. */
  87330. getChildren(): Nullable<Material>[];
  87331. /**
  87332. * Instantiates a new Multi Material
  87333. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87334. * separate meshes. This can be use to improve performances.
  87335. * @see http://doc.babylonjs.com/how_to/multi_materials
  87336. * @param name Define the name in the scene
  87337. * @param scene Define the scene the material belongs to
  87338. */
  87339. constructor(name: string, scene: Scene);
  87340. private _hookArray;
  87341. /**
  87342. * Get one of the submaterial by its index in the submaterials array
  87343. * @param index The index to look the sub material at
  87344. * @returns The Material if the index has been defined
  87345. */
  87346. getSubMaterial(index: number): Nullable<Material>;
  87347. /**
  87348. * Get the list of active textures for the whole sub materials list.
  87349. * @returns All the textures that will be used during the rendering
  87350. */
  87351. getActiveTextures(): BaseTexture[];
  87352. /**
  87353. * Gets the current class name of the material e.g. "MultiMaterial"
  87354. * Mainly use in serialization.
  87355. * @returns the class name
  87356. */
  87357. getClassName(): string;
  87358. /**
  87359. * Checks if the material is ready to render the requested sub mesh
  87360. * @param mesh Define the mesh the submesh belongs to
  87361. * @param subMesh Define the sub mesh to look readyness for
  87362. * @param useInstances Define whether or not the material is used with instances
  87363. * @returns true if ready, otherwise false
  87364. */
  87365. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87366. /**
  87367. * Clones the current material and its related sub materials
  87368. * @param name Define the name of the newly cloned material
  87369. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87370. * @returns the cloned material
  87371. */
  87372. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87373. /**
  87374. * Serializes the materials into a JSON representation.
  87375. * @returns the JSON representation
  87376. */
  87377. serialize(): any;
  87378. /**
  87379. * Dispose the material and release its associated resources
  87380. * @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)
  87381. * @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)
  87382. * @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)
  87383. */
  87384. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87385. /**
  87386. * Creates a MultiMaterial from parsed MultiMaterial data.
  87387. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87388. * @param scene defines the hosting scene
  87389. * @returns a new MultiMaterial
  87390. */
  87391. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87392. }
  87393. }
  87394. declare module BABYLON {
  87395. /**
  87396. * Base class for submeshes
  87397. */
  87398. export class BaseSubMesh {
  87399. /** @hidden */
  87400. _materialDefines: Nullable<MaterialDefines>;
  87401. /** @hidden */
  87402. _materialEffect: Nullable<Effect>;
  87403. /**
  87404. * Gets associated effect
  87405. */
  87406. readonly effect: Nullable<Effect>;
  87407. /**
  87408. * Sets associated effect (effect used to render this submesh)
  87409. * @param effect defines the effect to associate with
  87410. * @param defines defines the set of defines used to compile this effect
  87411. */
  87412. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87413. }
  87414. /**
  87415. * Defines a subdivision inside a mesh
  87416. */
  87417. export class SubMesh extends BaseSubMesh implements ICullable {
  87418. /** the material index to use */
  87419. materialIndex: number;
  87420. /** vertex index start */
  87421. verticesStart: number;
  87422. /** vertices count */
  87423. verticesCount: number;
  87424. /** index start */
  87425. indexStart: number;
  87426. /** indices count */
  87427. indexCount: number;
  87428. /** @hidden */
  87429. _linesIndexCount: number;
  87430. private _mesh;
  87431. private _renderingMesh;
  87432. private _boundingInfo;
  87433. private _linesIndexBuffer;
  87434. /** @hidden */
  87435. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87436. /** @hidden */
  87437. _trianglePlanes: Plane[];
  87438. /** @hidden */
  87439. _lastColliderTransformMatrix: Nullable<Matrix>;
  87440. /** @hidden */
  87441. _renderId: number;
  87442. /** @hidden */
  87443. _alphaIndex: number;
  87444. /** @hidden */
  87445. _distanceToCamera: number;
  87446. /** @hidden */
  87447. _id: number;
  87448. private _currentMaterial;
  87449. /**
  87450. * Add a new submesh to a mesh
  87451. * @param materialIndex defines the material index to use
  87452. * @param verticesStart defines vertex index start
  87453. * @param verticesCount defines vertices count
  87454. * @param indexStart defines index start
  87455. * @param indexCount defines indices count
  87456. * @param mesh defines the parent mesh
  87457. * @param renderingMesh defines an optional rendering mesh
  87458. * @param createBoundingBox defines if bounding box should be created for this submesh
  87459. * @returns the new submesh
  87460. */
  87461. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87462. /**
  87463. * Creates a new submesh
  87464. * @param materialIndex defines the material index to use
  87465. * @param verticesStart defines vertex index start
  87466. * @param verticesCount defines vertices count
  87467. * @param indexStart defines index start
  87468. * @param indexCount defines indices count
  87469. * @param mesh defines the parent mesh
  87470. * @param renderingMesh defines an optional rendering mesh
  87471. * @param createBoundingBox defines if bounding box should be created for this submesh
  87472. */
  87473. constructor(
  87474. /** the material index to use */
  87475. materialIndex: number,
  87476. /** vertex index start */
  87477. verticesStart: number,
  87478. /** vertices count */
  87479. verticesCount: number,
  87480. /** index start */
  87481. indexStart: number,
  87482. /** indices count */
  87483. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87484. /**
  87485. * Returns true if this submesh covers the entire parent mesh
  87486. * @ignorenaming
  87487. */
  87488. readonly IsGlobal: boolean;
  87489. /**
  87490. * Returns the submesh BoudingInfo object
  87491. * @returns current bounding info (or mesh's one if the submesh is global)
  87492. */
  87493. getBoundingInfo(): BoundingInfo;
  87494. /**
  87495. * Sets the submesh BoundingInfo
  87496. * @param boundingInfo defines the new bounding info to use
  87497. * @returns the SubMesh
  87498. */
  87499. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87500. /**
  87501. * Returns the mesh of the current submesh
  87502. * @return the parent mesh
  87503. */
  87504. getMesh(): AbstractMesh;
  87505. /**
  87506. * Returns the rendering mesh of the submesh
  87507. * @returns the rendering mesh (could be different from parent mesh)
  87508. */
  87509. getRenderingMesh(): Mesh;
  87510. /**
  87511. * Returns the submesh material
  87512. * @returns null or the current material
  87513. */
  87514. getMaterial(): Nullable<Material>;
  87515. /**
  87516. * Sets a new updated BoundingInfo object to the submesh
  87517. * @param data defines an optional position array to use to determine the bounding info
  87518. * @returns the SubMesh
  87519. */
  87520. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87521. /** @hidden */
  87522. _checkCollision(collider: Collider): boolean;
  87523. /**
  87524. * Updates the submesh BoundingInfo
  87525. * @param world defines the world matrix to use to update the bounding info
  87526. * @returns the submesh
  87527. */
  87528. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87529. /**
  87530. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87531. * @param frustumPlanes defines the frustum planes
  87532. * @returns true if the submesh is intersecting with the frustum
  87533. */
  87534. isInFrustum(frustumPlanes: Plane[]): boolean;
  87535. /**
  87536. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87537. * @param frustumPlanes defines the frustum planes
  87538. * @returns true if the submesh is inside the frustum
  87539. */
  87540. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87541. /**
  87542. * Renders the submesh
  87543. * @param enableAlphaMode defines if alpha needs to be used
  87544. * @returns the submesh
  87545. */
  87546. render(enableAlphaMode: boolean): SubMesh;
  87547. /**
  87548. * @hidden
  87549. */
  87550. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87551. /**
  87552. * Checks if the submesh intersects with a ray
  87553. * @param ray defines the ray to test
  87554. * @returns true is the passed ray intersects the submesh bounding box
  87555. */
  87556. canIntersects(ray: Ray): boolean;
  87557. /**
  87558. * Intersects current submesh with a ray
  87559. * @param ray defines the ray to test
  87560. * @param positions defines mesh's positions array
  87561. * @param indices defines mesh's indices array
  87562. * @param fastCheck defines if only bounding info should be used
  87563. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87564. * @returns intersection info or null if no intersection
  87565. */
  87566. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87567. /** @hidden */
  87568. private _intersectLines;
  87569. /** @hidden */
  87570. private _intersectUnIndexedLines;
  87571. /** @hidden */
  87572. private _intersectTriangles;
  87573. /** @hidden */
  87574. private _intersectUnIndexedTriangles;
  87575. /** @hidden */
  87576. _rebuild(): void;
  87577. /**
  87578. * Creates a new submesh from the passed mesh
  87579. * @param newMesh defines the new hosting mesh
  87580. * @param newRenderingMesh defines an optional rendering mesh
  87581. * @returns the new submesh
  87582. */
  87583. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87584. /**
  87585. * Release associated resources
  87586. */
  87587. dispose(): void;
  87588. /**
  87589. * Gets the class name
  87590. * @returns the string "SubMesh".
  87591. */
  87592. getClassName(): string;
  87593. /**
  87594. * Creates a new submesh from indices data
  87595. * @param materialIndex the index of the main mesh material
  87596. * @param startIndex the index where to start the copy in the mesh indices array
  87597. * @param indexCount the number of indices to copy then from the startIndex
  87598. * @param mesh the main mesh to create the submesh from
  87599. * @param renderingMesh the optional rendering mesh
  87600. * @returns a new submesh
  87601. */
  87602. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87603. }
  87604. }
  87605. declare module BABYLON {
  87606. /**
  87607. * Class used to represent data loading progression
  87608. */
  87609. export class SceneLoaderFlags {
  87610. private static _ForceFullSceneLoadingForIncremental;
  87611. private static _ShowLoadingScreen;
  87612. private static _CleanBoneMatrixWeights;
  87613. private static _loggingLevel;
  87614. /**
  87615. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87616. */
  87617. static ForceFullSceneLoadingForIncremental: boolean;
  87618. /**
  87619. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87620. */
  87621. static ShowLoadingScreen: boolean;
  87622. /**
  87623. * Defines the current logging level (while loading the scene)
  87624. * @ignorenaming
  87625. */
  87626. static loggingLevel: number;
  87627. /**
  87628. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87629. */
  87630. static CleanBoneMatrixWeights: boolean;
  87631. }
  87632. }
  87633. declare module BABYLON {
  87634. /**
  87635. * Class used to store geometry data (vertex buffers + index buffer)
  87636. */
  87637. export class Geometry implements IGetSetVerticesData {
  87638. /**
  87639. * Gets or sets the ID of the geometry
  87640. */
  87641. id: string;
  87642. /**
  87643. * Gets or sets the unique ID of the geometry
  87644. */
  87645. uniqueId: number;
  87646. /**
  87647. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87648. */
  87649. delayLoadState: number;
  87650. /**
  87651. * Gets the file containing the data to load when running in delay load state
  87652. */
  87653. delayLoadingFile: Nullable<string>;
  87654. /**
  87655. * Callback called when the geometry is updated
  87656. */
  87657. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87658. private _scene;
  87659. private _engine;
  87660. private _meshes;
  87661. private _totalVertices;
  87662. /** @hidden */
  87663. _indices: IndicesArray;
  87664. /** @hidden */
  87665. _vertexBuffers: {
  87666. [key: string]: VertexBuffer;
  87667. };
  87668. private _isDisposed;
  87669. private _extend;
  87670. private _boundingBias;
  87671. /** @hidden */
  87672. _delayInfo: Array<string>;
  87673. private _indexBuffer;
  87674. private _indexBufferIsUpdatable;
  87675. /** @hidden */
  87676. _boundingInfo: Nullable<BoundingInfo>;
  87677. /** @hidden */
  87678. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87679. /** @hidden */
  87680. _softwareSkinningFrameId: number;
  87681. private _vertexArrayObjects;
  87682. private _updatable;
  87683. /** @hidden */
  87684. _positions: Nullable<Vector3[]>;
  87685. /**
  87686. * 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
  87687. */
  87688. /**
  87689. * 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
  87690. */
  87691. boundingBias: Vector2;
  87692. /**
  87693. * Static function used to attach a new empty geometry to a mesh
  87694. * @param mesh defines the mesh to attach the geometry to
  87695. * @returns the new Geometry
  87696. */
  87697. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87698. /**
  87699. * Creates a new geometry
  87700. * @param id defines the unique ID
  87701. * @param scene defines the hosting scene
  87702. * @param vertexData defines the VertexData used to get geometry data
  87703. * @param updatable defines if geometry must be updatable (false by default)
  87704. * @param mesh defines the mesh that will be associated with the geometry
  87705. */
  87706. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87707. /**
  87708. * Gets the current extend of the geometry
  87709. */
  87710. readonly extend: {
  87711. minimum: Vector3;
  87712. maximum: Vector3;
  87713. };
  87714. /**
  87715. * Gets the hosting scene
  87716. * @returns the hosting Scene
  87717. */
  87718. getScene(): Scene;
  87719. /**
  87720. * Gets the hosting engine
  87721. * @returns the hosting Engine
  87722. */
  87723. getEngine(): Engine;
  87724. /**
  87725. * Defines if the geometry is ready to use
  87726. * @returns true if the geometry is ready to be used
  87727. */
  87728. isReady(): boolean;
  87729. /**
  87730. * Gets a value indicating that the geometry should not be serialized
  87731. */
  87732. readonly doNotSerialize: boolean;
  87733. /** @hidden */
  87734. _rebuild(): void;
  87735. /**
  87736. * Affects all geometry data in one call
  87737. * @param vertexData defines the geometry data
  87738. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87739. */
  87740. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87741. /**
  87742. * Set specific vertex data
  87743. * @param kind defines the data kind (Position, normal, etc...)
  87744. * @param data defines the vertex data to use
  87745. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87746. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87747. */
  87748. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87749. /**
  87750. * Removes a specific vertex data
  87751. * @param kind defines the data kind (Position, normal, etc...)
  87752. */
  87753. removeVerticesData(kind: string): void;
  87754. /**
  87755. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87756. * @param buffer defines the vertex buffer to use
  87757. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87758. */
  87759. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87760. /**
  87761. * Update a specific vertex buffer
  87762. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87763. * It will do nothing if the buffer is not updatable
  87764. * @param kind defines the data kind (Position, normal, etc...)
  87765. * @param data defines the data to use
  87766. * @param offset defines the offset in the target buffer where to store the data
  87767. * @param useBytes set to true if the offset is in bytes
  87768. */
  87769. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87770. /**
  87771. * Update a specific vertex buffer
  87772. * This function will create a new buffer if the current one is not updatable
  87773. * @param kind defines the data kind (Position, normal, etc...)
  87774. * @param data defines the data to use
  87775. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87776. */
  87777. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87778. private _updateBoundingInfo;
  87779. /** @hidden */
  87780. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87781. /**
  87782. * Gets total number of vertices
  87783. * @returns the total number of vertices
  87784. */
  87785. getTotalVertices(): number;
  87786. /**
  87787. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87788. * @param kind defines the data kind (Position, normal, etc...)
  87789. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87790. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87791. * @returns a float array containing vertex data
  87792. */
  87793. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87794. /**
  87795. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87796. * @param kind defines the data kind (Position, normal, etc...)
  87797. * @returns true if the vertex buffer with the specified kind is updatable
  87798. */
  87799. isVertexBufferUpdatable(kind: string): boolean;
  87800. /**
  87801. * Gets a specific vertex buffer
  87802. * @param kind defines the data kind (Position, normal, etc...)
  87803. * @returns a VertexBuffer
  87804. */
  87805. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87806. /**
  87807. * Returns all vertex buffers
  87808. * @return an object holding all vertex buffers indexed by kind
  87809. */
  87810. getVertexBuffers(): Nullable<{
  87811. [key: string]: VertexBuffer;
  87812. }>;
  87813. /**
  87814. * Gets a boolean indicating if specific vertex buffer is present
  87815. * @param kind defines the data kind (Position, normal, etc...)
  87816. * @returns true if data is present
  87817. */
  87818. isVerticesDataPresent(kind: string): boolean;
  87819. /**
  87820. * Gets a list of all attached data kinds (Position, normal, etc...)
  87821. * @returns a list of string containing all kinds
  87822. */
  87823. getVerticesDataKinds(): string[];
  87824. /**
  87825. * Update index buffer
  87826. * @param indices defines the indices to store in the index buffer
  87827. * @param offset defines the offset in the target buffer where to store the data
  87828. * @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)
  87829. */
  87830. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87831. /**
  87832. * Creates a new index buffer
  87833. * @param indices defines the indices to store in the index buffer
  87834. * @param totalVertices defines the total number of vertices (could be null)
  87835. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87836. */
  87837. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87838. /**
  87839. * Return the total number of indices
  87840. * @returns the total number of indices
  87841. */
  87842. getTotalIndices(): number;
  87843. /**
  87844. * Gets the index buffer array
  87845. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87846. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87847. * @returns the index buffer array
  87848. */
  87849. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87850. /**
  87851. * Gets the index buffer
  87852. * @return the index buffer
  87853. */
  87854. getIndexBuffer(): Nullable<DataBuffer>;
  87855. /** @hidden */
  87856. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87857. /**
  87858. * Release the associated resources for a specific mesh
  87859. * @param mesh defines the source mesh
  87860. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87861. */
  87862. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87863. /**
  87864. * Apply current geometry to a given mesh
  87865. * @param mesh defines the mesh to apply geometry to
  87866. */
  87867. applyToMesh(mesh: Mesh): void;
  87868. private _updateExtend;
  87869. private _applyToMesh;
  87870. private notifyUpdate;
  87871. /**
  87872. * Load the geometry if it was flagged as delay loaded
  87873. * @param scene defines the hosting scene
  87874. * @param onLoaded defines a callback called when the geometry is loaded
  87875. */
  87876. load(scene: Scene, onLoaded?: () => void): void;
  87877. private _queueLoad;
  87878. /**
  87879. * Invert the geometry to move from a right handed system to a left handed one.
  87880. */
  87881. toLeftHanded(): void;
  87882. /** @hidden */
  87883. _resetPointsArrayCache(): void;
  87884. /** @hidden */
  87885. _generatePointsArray(): boolean;
  87886. /**
  87887. * Gets a value indicating if the geometry is disposed
  87888. * @returns true if the geometry was disposed
  87889. */
  87890. isDisposed(): boolean;
  87891. private _disposeVertexArrayObjects;
  87892. /**
  87893. * Free all associated resources
  87894. */
  87895. dispose(): void;
  87896. /**
  87897. * Clone the current geometry into a new geometry
  87898. * @param id defines the unique ID of the new geometry
  87899. * @returns a new geometry object
  87900. */
  87901. copy(id: string): Geometry;
  87902. /**
  87903. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87904. * @return a JSON representation of the current geometry data (without the vertices data)
  87905. */
  87906. serialize(): any;
  87907. private toNumberArray;
  87908. /**
  87909. * Serialize all vertices data into a JSON oject
  87910. * @returns a JSON representation of the current geometry data
  87911. */
  87912. serializeVerticeData(): any;
  87913. /**
  87914. * Extracts a clone of a mesh geometry
  87915. * @param mesh defines the source mesh
  87916. * @param id defines the unique ID of the new geometry object
  87917. * @returns the new geometry object
  87918. */
  87919. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87920. /**
  87921. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87922. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87923. * Be aware Math.random() could cause collisions, but:
  87924. * "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"
  87925. * @returns a string containing a new GUID
  87926. */
  87927. static RandomId(): string;
  87928. /** @hidden */
  87929. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87930. private static _CleanMatricesWeights;
  87931. /**
  87932. * Create a new geometry from persisted data (Using .babylon file format)
  87933. * @param parsedVertexData defines the persisted data
  87934. * @param scene defines the hosting scene
  87935. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87936. * @returns the new geometry object
  87937. */
  87938. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87939. }
  87940. }
  87941. declare module BABYLON {
  87942. /**
  87943. * Define an interface for all classes that will get and set the data on vertices
  87944. */
  87945. export interface IGetSetVerticesData {
  87946. /**
  87947. * Gets a boolean indicating if specific vertex data is present
  87948. * @param kind defines the vertex data kind to use
  87949. * @returns true is data kind is present
  87950. */
  87951. isVerticesDataPresent(kind: string): boolean;
  87952. /**
  87953. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87954. * @param kind defines the data kind (Position, normal, etc...)
  87955. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87956. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87957. * @returns a float array containing vertex data
  87958. */
  87959. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87960. /**
  87961. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87962. * @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.
  87963. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87964. * @returns the indices array or an empty array if the mesh has no geometry
  87965. */
  87966. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87967. /**
  87968. * Set specific vertex data
  87969. * @param kind defines the data kind (Position, normal, etc...)
  87970. * @param data defines the vertex data to use
  87971. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87972. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87973. */
  87974. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87975. /**
  87976. * Update a specific associated vertex buffer
  87977. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87978. * - VertexBuffer.PositionKind
  87979. * - VertexBuffer.UVKind
  87980. * - VertexBuffer.UV2Kind
  87981. * - VertexBuffer.UV3Kind
  87982. * - VertexBuffer.UV4Kind
  87983. * - VertexBuffer.UV5Kind
  87984. * - VertexBuffer.UV6Kind
  87985. * - VertexBuffer.ColorKind
  87986. * - VertexBuffer.MatricesIndicesKind
  87987. * - VertexBuffer.MatricesIndicesExtraKind
  87988. * - VertexBuffer.MatricesWeightsKind
  87989. * - VertexBuffer.MatricesWeightsExtraKind
  87990. * @param data defines the data source
  87991. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87992. * @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)
  87993. */
  87994. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87995. /**
  87996. * Creates a new index buffer
  87997. * @param indices defines the indices to store in the index buffer
  87998. * @param totalVertices defines the total number of vertices (could be null)
  87999. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88000. */
  88001. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88002. }
  88003. /**
  88004. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88005. */
  88006. export class VertexData {
  88007. /**
  88008. * Mesh side orientation : usually the external or front surface
  88009. */
  88010. static readonly FRONTSIDE: number;
  88011. /**
  88012. * Mesh side orientation : usually the internal or back surface
  88013. */
  88014. static readonly BACKSIDE: number;
  88015. /**
  88016. * Mesh side orientation : both internal and external or front and back surfaces
  88017. */
  88018. static readonly DOUBLESIDE: number;
  88019. /**
  88020. * Mesh side orientation : by default, `FRONTSIDE`
  88021. */
  88022. static readonly DEFAULTSIDE: number;
  88023. /**
  88024. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88025. */
  88026. positions: Nullable<FloatArray>;
  88027. /**
  88028. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88029. */
  88030. normals: Nullable<FloatArray>;
  88031. /**
  88032. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88033. */
  88034. tangents: Nullable<FloatArray>;
  88035. /**
  88036. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88037. */
  88038. uvs: Nullable<FloatArray>;
  88039. /**
  88040. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88041. */
  88042. uvs2: Nullable<FloatArray>;
  88043. /**
  88044. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88045. */
  88046. uvs3: Nullable<FloatArray>;
  88047. /**
  88048. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88049. */
  88050. uvs4: Nullable<FloatArray>;
  88051. /**
  88052. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88053. */
  88054. uvs5: Nullable<FloatArray>;
  88055. /**
  88056. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88057. */
  88058. uvs6: Nullable<FloatArray>;
  88059. /**
  88060. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88061. */
  88062. colors: Nullable<FloatArray>;
  88063. /**
  88064. * 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).
  88065. */
  88066. matricesIndices: Nullable<FloatArray>;
  88067. /**
  88068. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88069. */
  88070. matricesWeights: Nullable<FloatArray>;
  88071. /**
  88072. * An array extending the number of possible indices
  88073. */
  88074. matricesIndicesExtra: Nullable<FloatArray>;
  88075. /**
  88076. * An array extending the number of possible weights when the number of indices is extended
  88077. */
  88078. matricesWeightsExtra: Nullable<FloatArray>;
  88079. /**
  88080. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88081. */
  88082. indices: Nullable<IndicesArray>;
  88083. /**
  88084. * Uses the passed data array to set the set the values for the specified kind of data
  88085. * @param data a linear array of floating numbers
  88086. * @param kind the type of data that is being set, eg positions, colors etc
  88087. */
  88088. set(data: FloatArray, kind: string): void;
  88089. /**
  88090. * Associates the vertexData to the passed Mesh.
  88091. * Sets it as updatable or not (default `false`)
  88092. * @param mesh the mesh the vertexData is applied to
  88093. * @param updatable when used and having the value true allows new data to update the vertexData
  88094. * @returns the VertexData
  88095. */
  88096. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88097. /**
  88098. * Associates the vertexData to the passed Geometry.
  88099. * Sets it as updatable or not (default `false`)
  88100. * @param geometry the geometry the vertexData is applied to
  88101. * @param updatable when used and having the value true allows new data to update the vertexData
  88102. * @returns VertexData
  88103. */
  88104. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88105. /**
  88106. * Updates the associated mesh
  88107. * @param mesh the mesh to be updated
  88108. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88109. * @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
  88110. * @returns VertexData
  88111. */
  88112. updateMesh(mesh: Mesh): VertexData;
  88113. /**
  88114. * Updates the associated geometry
  88115. * @param geometry the geometry to be updated
  88116. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88117. * @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
  88118. * @returns VertexData.
  88119. */
  88120. updateGeometry(geometry: Geometry): VertexData;
  88121. private _applyTo;
  88122. private _update;
  88123. /**
  88124. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88125. * @param matrix the transforming matrix
  88126. * @returns the VertexData
  88127. */
  88128. transform(matrix: Matrix): VertexData;
  88129. /**
  88130. * Merges the passed VertexData into the current one
  88131. * @param other the VertexData to be merged into the current one
  88132. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88133. * @returns the modified VertexData
  88134. */
  88135. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88136. private _mergeElement;
  88137. private _validate;
  88138. /**
  88139. * Serializes the VertexData
  88140. * @returns a serialized object
  88141. */
  88142. serialize(): any;
  88143. /**
  88144. * Extracts the vertexData from a mesh
  88145. * @param mesh the mesh from which to extract the VertexData
  88146. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88147. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88148. * @returns the object VertexData associated to the passed mesh
  88149. */
  88150. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88151. /**
  88152. * Extracts the vertexData from the geometry
  88153. * @param geometry the geometry from which to extract the VertexData
  88154. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88155. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88156. * @returns the object VertexData associated to the passed mesh
  88157. */
  88158. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88159. private static _ExtractFrom;
  88160. /**
  88161. * Creates the VertexData for a Ribbon
  88162. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88163. * * pathArray array of paths, each of which an array of successive Vector3
  88164. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88165. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88166. * * 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
  88167. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88168. * * 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)
  88169. * * 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)
  88170. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88171. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88172. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88173. * @returns the VertexData of the ribbon
  88174. */
  88175. static CreateRibbon(options: {
  88176. pathArray: Vector3[][];
  88177. closeArray?: boolean;
  88178. closePath?: boolean;
  88179. offset?: number;
  88180. sideOrientation?: number;
  88181. frontUVs?: Vector4;
  88182. backUVs?: Vector4;
  88183. invertUV?: boolean;
  88184. uvs?: Vector2[];
  88185. colors?: Color4[];
  88186. }): VertexData;
  88187. /**
  88188. * Creates the VertexData for a box
  88189. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88190. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88191. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88192. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88193. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88194. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88195. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88196. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88197. * * 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)
  88198. * * 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)
  88199. * @returns the VertexData of the box
  88200. */
  88201. static CreateBox(options: {
  88202. size?: number;
  88203. width?: number;
  88204. height?: number;
  88205. depth?: number;
  88206. faceUV?: Vector4[];
  88207. faceColors?: Color4[];
  88208. sideOrientation?: number;
  88209. frontUVs?: Vector4;
  88210. backUVs?: Vector4;
  88211. }): VertexData;
  88212. /**
  88213. * Creates the VertexData for a tiled box
  88214. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88215. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88216. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88217. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88219. * @returns the VertexData of the box
  88220. */
  88221. static CreateTiledBox(options: {
  88222. pattern?: number;
  88223. width?: number;
  88224. height?: number;
  88225. depth?: number;
  88226. tileSize?: number;
  88227. tileWidth?: number;
  88228. tileHeight?: number;
  88229. alignHorizontal?: number;
  88230. alignVertical?: number;
  88231. faceUV?: Vector4[];
  88232. faceColors?: Color4[];
  88233. sideOrientation?: number;
  88234. }): VertexData;
  88235. /**
  88236. * Creates the VertexData for a tiled plane
  88237. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88238. * * pattern a limited pattern arrangement depending on the number
  88239. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88240. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88241. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88243. * * 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)
  88244. * * 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)
  88245. * @returns the VertexData of the tiled plane
  88246. */
  88247. static CreateTiledPlane(options: {
  88248. pattern?: number;
  88249. tileSize?: number;
  88250. tileWidth?: number;
  88251. tileHeight?: number;
  88252. size?: number;
  88253. width?: number;
  88254. height?: number;
  88255. alignHorizontal?: number;
  88256. alignVertical?: number;
  88257. sideOrientation?: number;
  88258. frontUVs?: Vector4;
  88259. backUVs?: Vector4;
  88260. }): VertexData;
  88261. /**
  88262. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88264. * * segments sets the number of horizontal strips optional, default 32
  88265. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88266. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88267. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88268. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88269. * * 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
  88270. * * 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
  88271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88272. * * 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)
  88273. * * 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)
  88274. * @returns the VertexData of the ellipsoid
  88275. */
  88276. static CreateSphere(options: {
  88277. segments?: number;
  88278. diameter?: number;
  88279. diameterX?: number;
  88280. diameterY?: number;
  88281. diameterZ?: number;
  88282. arc?: number;
  88283. slice?: number;
  88284. sideOrientation?: number;
  88285. frontUVs?: Vector4;
  88286. backUVs?: Vector4;
  88287. }): VertexData;
  88288. /**
  88289. * Creates the VertexData for a cylinder, cone or prism
  88290. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88291. * * height sets the height (y direction) of the cylinder, optional, default 2
  88292. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88293. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88294. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88295. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88296. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88297. * * 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
  88298. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88299. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88300. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88301. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88302. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88303. * * 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)
  88304. * * 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)
  88305. * @returns the VertexData of the cylinder, cone or prism
  88306. */
  88307. static CreateCylinder(options: {
  88308. height?: number;
  88309. diameterTop?: number;
  88310. diameterBottom?: number;
  88311. diameter?: number;
  88312. tessellation?: number;
  88313. subdivisions?: number;
  88314. arc?: number;
  88315. faceColors?: Color4[];
  88316. faceUV?: Vector4[];
  88317. hasRings?: boolean;
  88318. enclose?: boolean;
  88319. sideOrientation?: number;
  88320. frontUVs?: Vector4;
  88321. backUVs?: Vector4;
  88322. }): VertexData;
  88323. /**
  88324. * Creates the VertexData for a torus
  88325. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88326. * * diameter the diameter of the torus, optional default 1
  88327. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88328. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88329. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88330. * * 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)
  88331. * * 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)
  88332. * @returns the VertexData of the torus
  88333. */
  88334. static CreateTorus(options: {
  88335. diameter?: number;
  88336. thickness?: number;
  88337. tessellation?: number;
  88338. sideOrientation?: number;
  88339. frontUVs?: Vector4;
  88340. backUVs?: Vector4;
  88341. }): VertexData;
  88342. /**
  88343. * Creates the VertexData of the LineSystem
  88344. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88345. * - lines an array of lines, each line being an array of successive Vector3
  88346. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88347. * @returns the VertexData of the LineSystem
  88348. */
  88349. static CreateLineSystem(options: {
  88350. lines: Vector3[][];
  88351. colors?: Nullable<Color4[][]>;
  88352. }): VertexData;
  88353. /**
  88354. * Create the VertexData for a DashedLines
  88355. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88356. * - points an array successive Vector3
  88357. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88358. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88359. * - dashNb the intended total number of dashes, optional, default 200
  88360. * @returns the VertexData for the DashedLines
  88361. */
  88362. static CreateDashedLines(options: {
  88363. points: Vector3[];
  88364. dashSize?: number;
  88365. gapSize?: number;
  88366. dashNb?: number;
  88367. }): VertexData;
  88368. /**
  88369. * Creates the VertexData for a Ground
  88370. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88371. * - width the width (x direction) of the ground, optional, default 1
  88372. * - height the height (z direction) of the ground, optional, default 1
  88373. * - subdivisions the number of subdivisions per side, optional, default 1
  88374. * @returns the VertexData of the Ground
  88375. */
  88376. static CreateGround(options: {
  88377. width?: number;
  88378. height?: number;
  88379. subdivisions?: number;
  88380. subdivisionsX?: number;
  88381. subdivisionsY?: number;
  88382. }): VertexData;
  88383. /**
  88384. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88385. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88386. * * xmin the ground minimum X coordinate, optional, default -1
  88387. * * zmin the ground minimum Z coordinate, optional, default -1
  88388. * * xmax the ground maximum X coordinate, optional, default 1
  88389. * * zmax the ground maximum Z coordinate, optional, default 1
  88390. * * 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}
  88391. * * 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}
  88392. * @returns the VertexData of the TiledGround
  88393. */
  88394. static CreateTiledGround(options: {
  88395. xmin: number;
  88396. zmin: number;
  88397. xmax: number;
  88398. zmax: number;
  88399. subdivisions?: {
  88400. w: number;
  88401. h: number;
  88402. };
  88403. precision?: {
  88404. w: number;
  88405. h: number;
  88406. };
  88407. }): VertexData;
  88408. /**
  88409. * Creates the VertexData of the Ground designed from a heightmap
  88410. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88411. * * width the width (x direction) of the ground
  88412. * * height the height (z direction) of the ground
  88413. * * subdivisions the number of subdivisions per side
  88414. * * minHeight the minimum altitude on the ground, optional, default 0
  88415. * * maxHeight the maximum altitude on the ground, optional default 1
  88416. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88417. * * buffer the array holding the image color data
  88418. * * bufferWidth the width of image
  88419. * * bufferHeight the height of image
  88420. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88421. * @returns the VertexData of the Ground designed from a heightmap
  88422. */
  88423. static CreateGroundFromHeightMap(options: {
  88424. width: number;
  88425. height: number;
  88426. subdivisions: number;
  88427. minHeight: number;
  88428. maxHeight: number;
  88429. colorFilter: Color3;
  88430. buffer: Uint8Array;
  88431. bufferWidth: number;
  88432. bufferHeight: number;
  88433. alphaFilter: number;
  88434. }): VertexData;
  88435. /**
  88436. * Creates the VertexData for a Plane
  88437. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88438. * * size sets the width and height of the plane to the value of size, optional default 1
  88439. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88440. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88441. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88442. * * 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)
  88443. * * 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)
  88444. * @returns the VertexData of the box
  88445. */
  88446. static CreatePlane(options: {
  88447. size?: number;
  88448. width?: number;
  88449. height?: number;
  88450. sideOrientation?: number;
  88451. frontUVs?: Vector4;
  88452. backUVs?: Vector4;
  88453. }): VertexData;
  88454. /**
  88455. * Creates the VertexData of the Disc or regular Polygon
  88456. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88457. * * radius the radius of the disc, optional default 0.5
  88458. * * tessellation the number of polygon sides, optional, default 64
  88459. * * 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
  88460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88461. * * 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)
  88462. * * 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)
  88463. * @returns the VertexData of the box
  88464. */
  88465. static CreateDisc(options: {
  88466. radius?: number;
  88467. tessellation?: number;
  88468. arc?: number;
  88469. sideOrientation?: number;
  88470. frontUVs?: Vector4;
  88471. backUVs?: Vector4;
  88472. }): VertexData;
  88473. /**
  88474. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88475. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88476. * @param polygon a mesh built from polygonTriangulation.build()
  88477. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88478. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88479. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88480. * @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)
  88481. * @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)
  88482. * @returns the VertexData of the Polygon
  88483. */
  88484. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88485. /**
  88486. * Creates the VertexData of the IcoSphere
  88487. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88488. * * radius the radius of the IcoSphere, optional default 1
  88489. * * radiusX allows stretching in the x direction, optional, default radius
  88490. * * radiusY allows stretching in the y direction, optional, default radius
  88491. * * radiusZ allows stretching in the z direction, optional, default radius
  88492. * * flat when true creates a flat shaded mesh, optional, default true
  88493. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88495. * * 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)
  88496. * * 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)
  88497. * @returns the VertexData of the IcoSphere
  88498. */
  88499. static CreateIcoSphere(options: {
  88500. radius?: number;
  88501. radiusX?: number;
  88502. radiusY?: number;
  88503. radiusZ?: number;
  88504. flat?: boolean;
  88505. subdivisions?: number;
  88506. sideOrientation?: number;
  88507. frontUVs?: Vector4;
  88508. backUVs?: Vector4;
  88509. }): VertexData;
  88510. /**
  88511. * Creates the VertexData for a Polyhedron
  88512. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88513. * * type provided types are:
  88514. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88515. * * 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)
  88516. * * size the size of the IcoSphere, optional default 1
  88517. * * sizeX allows stretching in the x direction, optional, default size
  88518. * * sizeY allows stretching in the y direction, optional, default size
  88519. * * sizeZ allows stretching in the z direction, optional, default size
  88520. * * 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
  88521. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88522. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88523. * * flat when true creates a flat shaded mesh, optional, default true
  88524. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88526. * * 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)
  88527. * * 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)
  88528. * @returns the VertexData of the Polyhedron
  88529. */
  88530. static CreatePolyhedron(options: {
  88531. type?: number;
  88532. size?: number;
  88533. sizeX?: number;
  88534. sizeY?: number;
  88535. sizeZ?: number;
  88536. custom?: any;
  88537. faceUV?: Vector4[];
  88538. faceColors?: Color4[];
  88539. flat?: boolean;
  88540. sideOrientation?: number;
  88541. frontUVs?: Vector4;
  88542. backUVs?: Vector4;
  88543. }): VertexData;
  88544. /**
  88545. * Creates the VertexData for a TorusKnot
  88546. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88547. * * radius the radius of the torus knot, optional, default 2
  88548. * * tube the thickness of the tube, optional, default 0.5
  88549. * * radialSegments the number of sides on each tube segments, optional, default 32
  88550. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88551. * * p the number of windings around the z axis, optional, default 2
  88552. * * q the number of windings around the x axis, optional, default 3
  88553. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88554. * * 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)
  88555. * * 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)
  88556. * @returns the VertexData of the Torus Knot
  88557. */
  88558. static CreateTorusKnot(options: {
  88559. radius?: number;
  88560. tube?: number;
  88561. radialSegments?: number;
  88562. tubularSegments?: number;
  88563. p?: number;
  88564. q?: number;
  88565. sideOrientation?: number;
  88566. frontUVs?: Vector4;
  88567. backUVs?: Vector4;
  88568. }): VertexData;
  88569. /**
  88570. * Compute normals for given positions and indices
  88571. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88572. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88573. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88574. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88575. * * facetNormals : optional array of facet normals (vector3)
  88576. * * facetPositions : optional array of facet positions (vector3)
  88577. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88578. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88579. * * bInfo : optional bounding info, required for facetPartitioning computation
  88580. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88581. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88582. * * useRightHandedSystem: optional boolean to for right handed system computation
  88583. * * depthSort : optional boolean to enable the facet depth sort computation
  88584. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88585. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88586. */
  88587. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88588. facetNormals?: any;
  88589. facetPositions?: any;
  88590. facetPartitioning?: any;
  88591. ratio?: number;
  88592. bInfo?: any;
  88593. bbSize?: Vector3;
  88594. subDiv?: any;
  88595. useRightHandedSystem?: boolean;
  88596. depthSort?: boolean;
  88597. distanceTo?: Vector3;
  88598. depthSortedFacets?: any;
  88599. }): void;
  88600. /** @hidden */
  88601. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88602. /**
  88603. * Applies VertexData created from the imported parameters to the geometry
  88604. * @param parsedVertexData the parsed data from an imported file
  88605. * @param geometry the geometry to apply the VertexData to
  88606. */
  88607. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88608. }
  88609. }
  88610. declare module BABYLON {
  88611. /**
  88612. * Defines a target to use with MorphTargetManager
  88613. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88614. */
  88615. export class MorphTarget implements IAnimatable {
  88616. /** defines the name of the target */
  88617. name: string;
  88618. /**
  88619. * Gets or sets the list of animations
  88620. */
  88621. animations: Animation[];
  88622. private _scene;
  88623. private _positions;
  88624. private _normals;
  88625. private _tangents;
  88626. private _uvs;
  88627. private _influence;
  88628. /**
  88629. * Observable raised when the influence changes
  88630. */
  88631. onInfluenceChanged: Observable<boolean>;
  88632. /** @hidden */
  88633. _onDataLayoutChanged: Observable<void>;
  88634. /**
  88635. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88636. */
  88637. influence: number;
  88638. /**
  88639. * Gets or sets the id of the morph Target
  88640. */
  88641. id: string;
  88642. private _animationPropertiesOverride;
  88643. /**
  88644. * Gets or sets the animation properties override
  88645. */
  88646. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88647. /**
  88648. * Creates a new MorphTarget
  88649. * @param name defines the name of the target
  88650. * @param influence defines the influence to use
  88651. * @param scene defines the scene the morphtarget belongs to
  88652. */
  88653. constructor(
  88654. /** defines the name of the target */
  88655. name: string, influence?: number, scene?: Nullable<Scene>);
  88656. /**
  88657. * Gets a boolean defining if the target contains position data
  88658. */
  88659. readonly hasPositions: boolean;
  88660. /**
  88661. * Gets a boolean defining if the target contains normal data
  88662. */
  88663. readonly hasNormals: boolean;
  88664. /**
  88665. * Gets a boolean defining if the target contains tangent data
  88666. */
  88667. readonly hasTangents: boolean;
  88668. /**
  88669. * Gets a boolean defining if the target contains texture coordinates data
  88670. */
  88671. readonly hasUVs: boolean;
  88672. /**
  88673. * Affects position data to this target
  88674. * @param data defines the position data to use
  88675. */
  88676. setPositions(data: Nullable<FloatArray>): void;
  88677. /**
  88678. * Gets the position data stored in this target
  88679. * @returns a FloatArray containing the position data (or null if not present)
  88680. */
  88681. getPositions(): Nullable<FloatArray>;
  88682. /**
  88683. * Affects normal data to this target
  88684. * @param data defines the normal data to use
  88685. */
  88686. setNormals(data: Nullable<FloatArray>): void;
  88687. /**
  88688. * Gets the normal data stored in this target
  88689. * @returns a FloatArray containing the normal data (or null if not present)
  88690. */
  88691. getNormals(): Nullable<FloatArray>;
  88692. /**
  88693. * Affects tangent data to this target
  88694. * @param data defines the tangent data to use
  88695. */
  88696. setTangents(data: Nullable<FloatArray>): void;
  88697. /**
  88698. * Gets the tangent data stored in this target
  88699. * @returns a FloatArray containing the tangent data (or null if not present)
  88700. */
  88701. getTangents(): Nullable<FloatArray>;
  88702. /**
  88703. * Affects texture coordinates data to this target
  88704. * @param data defines the texture coordinates data to use
  88705. */
  88706. setUVs(data: Nullable<FloatArray>): void;
  88707. /**
  88708. * Gets the texture coordinates data stored in this target
  88709. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88710. */
  88711. getUVs(): Nullable<FloatArray>;
  88712. /**
  88713. * Serializes the current target into a Serialization object
  88714. * @returns the serialized object
  88715. */
  88716. serialize(): any;
  88717. /**
  88718. * Returns the string "MorphTarget"
  88719. * @returns "MorphTarget"
  88720. */
  88721. getClassName(): string;
  88722. /**
  88723. * Creates a new target from serialized data
  88724. * @param serializationObject defines the serialized data to use
  88725. * @returns a new MorphTarget
  88726. */
  88727. static Parse(serializationObject: any): MorphTarget;
  88728. /**
  88729. * Creates a MorphTarget from mesh data
  88730. * @param mesh defines the source mesh
  88731. * @param name defines the name to use for the new target
  88732. * @param influence defines the influence to attach to the target
  88733. * @returns a new MorphTarget
  88734. */
  88735. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88736. }
  88737. }
  88738. declare module BABYLON {
  88739. /**
  88740. * This class is used to deform meshes using morphing between different targets
  88741. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88742. */
  88743. export class MorphTargetManager {
  88744. private _targets;
  88745. private _targetInfluenceChangedObservers;
  88746. private _targetDataLayoutChangedObservers;
  88747. private _activeTargets;
  88748. private _scene;
  88749. private _influences;
  88750. private _supportsNormals;
  88751. private _supportsTangents;
  88752. private _supportsUVs;
  88753. private _vertexCount;
  88754. private _uniqueId;
  88755. private _tempInfluences;
  88756. /**
  88757. * Gets or sets a boolean indicating if normals must be morphed
  88758. */
  88759. enableNormalMorphing: boolean;
  88760. /**
  88761. * Gets or sets a boolean indicating if tangents must be morphed
  88762. */
  88763. enableTangentMorphing: boolean;
  88764. /**
  88765. * Gets or sets a boolean indicating if UV must be morphed
  88766. */
  88767. enableUVMorphing: boolean;
  88768. /**
  88769. * Creates a new MorphTargetManager
  88770. * @param scene defines the current scene
  88771. */
  88772. constructor(scene?: Nullable<Scene>);
  88773. /**
  88774. * Gets the unique ID of this manager
  88775. */
  88776. readonly uniqueId: number;
  88777. /**
  88778. * Gets the number of vertices handled by this manager
  88779. */
  88780. readonly vertexCount: number;
  88781. /**
  88782. * Gets a boolean indicating if this manager supports morphing of normals
  88783. */
  88784. readonly supportsNormals: boolean;
  88785. /**
  88786. * Gets a boolean indicating if this manager supports morphing of tangents
  88787. */
  88788. readonly supportsTangents: boolean;
  88789. /**
  88790. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88791. */
  88792. readonly supportsUVs: boolean;
  88793. /**
  88794. * Gets the number of targets stored in this manager
  88795. */
  88796. readonly numTargets: number;
  88797. /**
  88798. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88799. */
  88800. readonly numInfluencers: number;
  88801. /**
  88802. * Gets the list of influences (one per target)
  88803. */
  88804. readonly influences: Float32Array;
  88805. /**
  88806. * Gets the active target at specified index. An active target is a target with an influence > 0
  88807. * @param index defines the index to check
  88808. * @returns the requested target
  88809. */
  88810. getActiveTarget(index: number): MorphTarget;
  88811. /**
  88812. * Gets the target at specified index
  88813. * @param index defines the index to check
  88814. * @returns the requested target
  88815. */
  88816. getTarget(index: number): MorphTarget;
  88817. /**
  88818. * Add a new target to this manager
  88819. * @param target defines the target to add
  88820. */
  88821. addTarget(target: MorphTarget): void;
  88822. /**
  88823. * Removes a target from the manager
  88824. * @param target defines the target to remove
  88825. */
  88826. removeTarget(target: MorphTarget): void;
  88827. /**
  88828. * Serializes the current manager into a Serialization object
  88829. * @returns the serialized object
  88830. */
  88831. serialize(): any;
  88832. private _syncActiveTargets;
  88833. /**
  88834. * Syncrhonize the targets with all the meshes using this morph target manager
  88835. */
  88836. synchronize(): void;
  88837. /**
  88838. * Creates a new MorphTargetManager from serialized data
  88839. * @param serializationObject defines the serialized data
  88840. * @param scene defines the hosting scene
  88841. * @returns the new MorphTargetManager
  88842. */
  88843. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88844. }
  88845. }
  88846. declare module BABYLON {
  88847. /**
  88848. * Class used to represent a specific level of detail of a mesh
  88849. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88850. */
  88851. export class MeshLODLevel {
  88852. /** Defines the distance where this level should start being displayed */
  88853. distance: number;
  88854. /** Defines the mesh to use to render this level */
  88855. mesh: Nullable<Mesh>;
  88856. /**
  88857. * Creates a new LOD level
  88858. * @param distance defines the distance where this level should star being displayed
  88859. * @param mesh defines the mesh to use to render this level
  88860. */
  88861. constructor(
  88862. /** Defines the distance where this level should start being displayed */
  88863. distance: number,
  88864. /** Defines the mesh to use to render this level */
  88865. mesh: Nullable<Mesh>);
  88866. }
  88867. }
  88868. declare module BABYLON {
  88869. /**
  88870. * Mesh representing the gorund
  88871. */
  88872. export class GroundMesh extends Mesh {
  88873. /** If octree should be generated */
  88874. generateOctree: boolean;
  88875. private _heightQuads;
  88876. /** @hidden */
  88877. _subdivisionsX: number;
  88878. /** @hidden */
  88879. _subdivisionsY: number;
  88880. /** @hidden */
  88881. _width: number;
  88882. /** @hidden */
  88883. _height: number;
  88884. /** @hidden */
  88885. _minX: number;
  88886. /** @hidden */
  88887. _maxX: number;
  88888. /** @hidden */
  88889. _minZ: number;
  88890. /** @hidden */
  88891. _maxZ: number;
  88892. constructor(name: string, scene: Scene);
  88893. /**
  88894. * "GroundMesh"
  88895. * @returns "GroundMesh"
  88896. */
  88897. getClassName(): string;
  88898. /**
  88899. * The minimum of x and y subdivisions
  88900. */
  88901. readonly subdivisions: number;
  88902. /**
  88903. * X subdivisions
  88904. */
  88905. readonly subdivisionsX: number;
  88906. /**
  88907. * Y subdivisions
  88908. */
  88909. readonly subdivisionsY: number;
  88910. /**
  88911. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88912. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88913. * @param chunksCount the number of subdivisions for x and y
  88914. * @param octreeBlocksSize (Default: 32)
  88915. */
  88916. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88917. /**
  88918. * Returns a height (y) value in the Worl system :
  88919. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88920. * @param x x coordinate
  88921. * @param z z coordinate
  88922. * @returns the ground y position if (x, z) are outside the ground surface.
  88923. */
  88924. getHeightAtCoordinates(x: number, z: number): number;
  88925. /**
  88926. * Returns a normalized vector (Vector3) orthogonal to the ground
  88927. * at the ground coordinates (x, z) expressed in the World system.
  88928. * @param x x coordinate
  88929. * @param z z coordinate
  88930. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88931. */
  88932. getNormalAtCoordinates(x: number, z: number): Vector3;
  88933. /**
  88934. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88935. * at the ground coordinates (x, z) expressed in the World system.
  88936. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88937. * @param x x coordinate
  88938. * @param z z coordinate
  88939. * @param ref vector to store the result
  88940. * @returns the GroundMesh.
  88941. */
  88942. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88943. /**
  88944. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88945. * if the ground has been updated.
  88946. * This can be used in the render loop.
  88947. * @returns the GroundMesh.
  88948. */
  88949. updateCoordinateHeights(): GroundMesh;
  88950. private _getFacetAt;
  88951. private _initHeightQuads;
  88952. private _computeHeightQuads;
  88953. /**
  88954. * Serializes this ground mesh
  88955. * @param serializationObject object to write serialization to
  88956. */
  88957. serialize(serializationObject: any): void;
  88958. /**
  88959. * Parses a serialized ground mesh
  88960. * @param parsedMesh the serialized mesh
  88961. * @param scene the scene to create the ground mesh in
  88962. * @returns the created ground mesh
  88963. */
  88964. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88965. }
  88966. }
  88967. declare module BABYLON {
  88968. /**
  88969. * Interface for Physics-Joint data
  88970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88971. */
  88972. export interface PhysicsJointData {
  88973. /**
  88974. * The main pivot of the joint
  88975. */
  88976. mainPivot?: Vector3;
  88977. /**
  88978. * The connected pivot of the joint
  88979. */
  88980. connectedPivot?: Vector3;
  88981. /**
  88982. * The main axis of the joint
  88983. */
  88984. mainAxis?: Vector3;
  88985. /**
  88986. * The connected axis of the joint
  88987. */
  88988. connectedAxis?: Vector3;
  88989. /**
  88990. * The collision of the joint
  88991. */
  88992. collision?: boolean;
  88993. /**
  88994. * Native Oimo/Cannon/Energy data
  88995. */
  88996. nativeParams?: any;
  88997. }
  88998. /**
  88999. * This is a holder class for the physics joint created by the physics plugin
  89000. * It holds a set of functions to control the underlying joint
  89001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89002. */
  89003. export class PhysicsJoint {
  89004. /**
  89005. * The type of the physics joint
  89006. */
  89007. type: number;
  89008. /**
  89009. * The data for the physics joint
  89010. */
  89011. jointData: PhysicsJointData;
  89012. private _physicsJoint;
  89013. protected _physicsPlugin: IPhysicsEnginePlugin;
  89014. /**
  89015. * Initializes the physics joint
  89016. * @param type The type of the physics joint
  89017. * @param jointData The data for the physics joint
  89018. */
  89019. constructor(
  89020. /**
  89021. * The type of the physics joint
  89022. */
  89023. type: number,
  89024. /**
  89025. * The data for the physics joint
  89026. */
  89027. jointData: PhysicsJointData);
  89028. /**
  89029. * Gets the physics joint
  89030. */
  89031. /**
  89032. * Sets the physics joint
  89033. */
  89034. physicsJoint: any;
  89035. /**
  89036. * Sets the physics plugin
  89037. */
  89038. physicsPlugin: IPhysicsEnginePlugin;
  89039. /**
  89040. * Execute a function that is physics-plugin specific.
  89041. * @param {Function} func the function that will be executed.
  89042. * It accepts two parameters: the physics world and the physics joint
  89043. */
  89044. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89045. /**
  89046. * Distance-Joint type
  89047. */
  89048. static DistanceJoint: number;
  89049. /**
  89050. * Hinge-Joint type
  89051. */
  89052. static HingeJoint: number;
  89053. /**
  89054. * Ball-and-Socket joint type
  89055. */
  89056. static BallAndSocketJoint: number;
  89057. /**
  89058. * Wheel-Joint type
  89059. */
  89060. static WheelJoint: number;
  89061. /**
  89062. * Slider-Joint type
  89063. */
  89064. static SliderJoint: number;
  89065. /**
  89066. * Prismatic-Joint type
  89067. */
  89068. static PrismaticJoint: number;
  89069. /**
  89070. * Universal-Joint type
  89071. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89072. */
  89073. static UniversalJoint: number;
  89074. /**
  89075. * Hinge-Joint 2 type
  89076. */
  89077. static Hinge2Joint: number;
  89078. /**
  89079. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89080. */
  89081. static PointToPointJoint: number;
  89082. /**
  89083. * Spring-Joint type
  89084. */
  89085. static SpringJoint: number;
  89086. /**
  89087. * Lock-Joint type
  89088. */
  89089. static LockJoint: number;
  89090. }
  89091. /**
  89092. * A class representing a physics distance joint
  89093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89094. */
  89095. export class DistanceJoint extends PhysicsJoint {
  89096. /**
  89097. *
  89098. * @param jointData The data for the Distance-Joint
  89099. */
  89100. constructor(jointData: DistanceJointData);
  89101. /**
  89102. * Update the predefined distance.
  89103. * @param maxDistance The maximum preferred distance
  89104. * @param minDistance The minimum preferred distance
  89105. */
  89106. updateDistance(maxDistance: number, minDistance?: number): void;
  89107. }
  89108. /**
  89109. * Represents a Motor-Enabled Joint
  89110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89111. */
  89112. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89113. /**
  89114. * Initializes the Motor-Enabled Joint
  89115. * @param type The type of the joint
  89116. * @param jointData The physica joint data for the joint
  89117. */
  89118. constructor(type: number, jointData: PhysicsJointData);
  89119. /**
  89120. * Set the motor values.
  89121. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89122. * @param force the force to apply
  89123. * @param maxForce max force for this motor.
  89124. */
  89125. setMotor(force?: number, maxForce?: number): void;
  89126. /**
  89127. * Set the motor's limits.
  89128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89129. * @param upperLimit The upper limit of the motor
  89130. * @param lowerLimit The lower limit of the motor
  89131. */
  89132. setLimit(upperLimit: number, lowerLimit?: number): void;
  89133. }
  89134. /**
  89135. * This class represents a single physics Hinge-Joint
  89136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89137. */
  89138. export class HingeJoint extends MotorEnabledJoint {
  89139. /**
  89140. * Initializes the Hinge-Joint
  89141. * @param jointData The joint data for the Hinge-Joint
  89142. */
  89143. constructor(jointData: PhysicsJointData);
  89144. /**
  89145. * Set the motor values.
  89146. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89147. * @param {number} force the force to apply
  89148. * @param {number} maxForce max force for this motor.
  89149. */
  89150. setMotor(force?: number, maxForce?: number): void;
  89151. /**
  89152. * Set the motor's limits.
  89153. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89154. * @param upperLimit The upper limit of the motor
  89155. * @param lowerLimit The lower limit of the motor
  89156. */
  89157. setLimit(upperLimit: number, lowerLimit?: number): void;
  89158. }
  89159. /**
  89160. * This class represents a dual hinge physics joint (same as wheel joint)
  89161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89162. */
  89163. export class Hinge2Joint extends MotorEnabledJoint {
  89164. /**
  89165. * Initializes the Hinge2-Joint
  89166. * @param jointData The joint data for the Hinge2-Joint
  89167. */
  89168. constructor(jointData: PhysicsJointData);
  89169. /**
  89170. * Set the motor values.
  89171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89172. * @param {number} targetSpeed the speed the motor is to reach
  89173. * @param {number} maxForce max force for this motor.
  89174. * @param {motorIndex} the motor's index, 0 or 1.
  89175. */
  89176. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89177. /**
  89178. * Set the motor limits.
  89179. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89180. * @param {number} upperLimit the upper limit
  89181. * @param {number} lowerLimit lower limit
  89182. * @param {motorIndex} the motor's index, 0 or 1.
  89183. */
  89184. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89185. }
  89186. /**
  89187. * Interface for a motor enabled joint
  89188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89189. */
  89190. export interface IMotorEnabledJoint {
  89191. /**
  89192. * Physics joint
  89193. */
  89194. physicsJoint: any;
  89195. /**
  89196. * Sets the motor of the motor-enabled joint
  89197. * @param force The force of the motor
  89198. * @param maxForce The maximum force of the motor
  89199. * @param motorIndex The index of the motor
  89200. */
  89201. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89202. /**
  89203. * Sets the limit of the motor
  89204. * @param upperLimit The upper limit of the motor
  89205. * @param lowerLimit The lower limit of the motor
  89206. * @param motorIndex The index of the motor
  89207. */
  89208. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89209. }
  89210. /**
  89211. * Joint data for a Distance-Joint
  89212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89213. */
  89214. export interface DistanceJointData extends PhysicsJointData {
  89215. /**
  89216. * Max distance the 2 joint objects can be apart
  89217. */
  89218. maxDistance: number;
  89219. }
  89220. /**
  89221. * Joint data from a spring joint
  89222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89223. */
  89224. export interface SpringJointData extends PhysicsJointData {
  89225. /**
  89226. * Length of the spring
  89227. */
  89228. length: number;
  89229. /**
  89230. * Stiffness of the spring
  89231. */
  89232. stiffness: number;
  89233. /**
  89234. * Damping of the spring
  89235. */
  89236. damping: number;
  89237. /** this callback will be called when applying the force to the impostors. */
  89238. forceApplicationCallback: () => void;
  89239. }
  89240. }
  89241. declare module BABYLON {
  89242. /**
  89243. * Holds the data for the raycast result
  89244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89245. */
  89246. export class PhysicsRaycastResult {
  89247. private _hasHit;
  89248. private _hitDistance;
  89249. private _hitNormalWorld;
  89250. private _hitPointWorld;
  89251. private _rayFromWorld;
  89252. private _rayToWorld;
  89253. /**
  89254. * Gets if there was a hit
  89255. */
  89256. readonly hasHit: boolean;
  89257. /**
  89258. * Gets the distance from the hit
  89259. */
  89260. readonly hitDistance: number;
  89261. /**
  89262. * Gets the hit normal/direction in the world
  89263. */
  89264. readonly hitNormalWorld: Vector3;
  89265. /**
  89266. * Gets the hit point in the world
  89267. */
  89268. readonly hitPointWorld: Vector3;
  89269. /**
  89270. * Gets the ray "start point" of the ray in the world
  89271. */
  89272. readonly rayFromWorld: Vector3;
  89273. /**
  89274. * Gets the ray "end point" of the ray in the world
  89275. */
  89276. readonly rayToWorld: Vector3;
  89277. /**
  89278. * Sets the hit data (normal & point in world space)
  89279. * @param hitNormalWorld defines the normal in world space
  89280. * @param hitPointWorld defines the point in world space
  89281. */
  89282. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89283. /**
  89284. * Sets the distance from the start point to the hit point
  89285. * @param distance
  89286. */
  89287. setHitDistance(distance: number): void;
  89288. /**
  89289. * Calculates the distance manually
  89290. */
  89291. calculateHitDistance(): void;
  89292. /**
  89293. * Resets all the values to default
  89294. * @param from The from point on world space
  89295. * @param to The to point on world space
  89296. */
  89297. reset(from?: Vector3, to?: Vector3): void;
  89298. }
  89299. /**
  89300. * Interface for the size containing width and height
  89301. */
  89302. interface IXYZ {
  89303. /**
  89304. * X
  89305. */
  89306. x: number;
  89307. /**
  89308. * Y
  89309. */
  89310. y: number;
  89311. /**
  89312. * Z
  89313. */
  89314. z: number;
  89315. }
  89316. }
  89317. declare module BABYLON {
  89318. /**
  89319. * Interface used to describe a physics joint
  89320. */
  89321. export interface PhysicsImpostorJoint {
  89322. /** Defines the main impostor to which the joint is linked */
  89323. mainImpostor: PhysicsImpostor;
  89324. /** Defines the impostor that is connected to the main impostor using this joint */
  89325. connectedImpostor: PhysicsImpostor;
  89326. /** Defines the joint itself */
  89327. joint: PhysicsJoint;
  89328. }
  89329. /** @hidden */
  89330. export interface IPhysicsEnginePlugin {
  89331. world: any;
  89332. name: string;
  89333. setGravity(gravity: Vector3): void;
  89334. setTimeStep(timeStep: number): void;
  89335. getTimeStep(): number;
  89336. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89337. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89339. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89340. removePhysicsBody(impostor: PhysicsImpostor): void;
  89341. generateJoint(joint: PhysicsImpostorJoint): void;
  89342. removeJoint(joint: PhysicsImpostorJoint): void;
  89343. isSupported(): boolean;
  89344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89351. getBodyMass(impostor: PhysicsImpostor): number;
  89352. getBodyFriction(impostor: PhysicsImpostor): number;
  89353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89354. getBodyRestitution(impostor: PhysicsImpostor): number;
  89355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89356. getBodyPressure?(impostor: PhysicsImpostor): number;
  89357. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89358. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89359. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89360. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89361. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89362. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89363. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89364. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89365. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89366. sleepBody(impostor: PhysicsImpostor): void;
  89367. wakeUpBody(impostor: PhysicsImpostor): void;
  89368. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89370. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89372. getRadius(impostor: PhysicsImpostor): number;
  89373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89375. dispose(): void;
  89376. }
  89377. /**
  89378. * Interface used to define a physics engine
  89379. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89380. */
  89381. export interface IPhysicsEngine {
  89382. /**
  89383. * Gets the gravity vector used by the simulation
  89384. */
  89385. gravity: Vector3;
  89386. /**
  89387. * Sets the gravity vector used by the simulation
  89388. * @param gravity defines the gravity vector to use
  89389. */
  89390. setGravity(gravity: Vector3): void;
  89391. /**
  89392. * Set the time step of the physics engine.
  89393. * Default is 1/60.
  89394. * To slow it down, enter 1/600 for example.
  89395. * To speed it up, 1/30
  89396. * @param newTimeStep the new timestep to apply to this world.
  89397. */
  89398. setTimeStep(newTimeStep: number): void;
  89399. /**
  89400. * Get the time step of the physics engine.
  89401. * @returns the current time step
  89402. */
  89403. getTimeStep(): number;
  89404. /**
  89405. * Release all resources
  89406. */
  89407. dispose(): void;
  89408. /**
  89409. * Gets the name of the current physics plugin
  89410. * @returns the name of the plugin
  89411. */
  89412. getPhysicsPluginName(): string;
  89413. /**
  89414. * Adding a new impostor for the impostor tracking.
  89415. * This will be done by the impostor itself.
  89416. * @param impostor the impostor to add
  89417. */
  89418. addImpostor(impostor: PhysicsImpostor): void;
  89419. /**
  89420. * Remove an impostor from the engine.
  89421. * This impostor and its mesh will not longer be updated by the physics engine.
  89422. * @param impostor the impostor to remove
  89423. */
  89424. removeImpostor(impostor: PhysicsImpostor): void;
  89425. /**
  89426. * Add a joint to the physics engine
  89427. * @param mainImpostor defines the main impostor to which the joint is added.
  89428. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89429. * @param joint defines the joint that will connect both impostors.
  89430. */
  89431. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89432. /**
  89433. * Removes a joint from the simulation
  89434. * @param mainImpostor defines the impostor used with the joint
  89435. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89436. * @param joint defines the joint to remove
  89437. */
  89438. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89439. /**
  89440. * Gets the current plugin used to run the simulation
  89441. * @returns current plugin
  89442. */
  89443. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89444. /**
  89445. * Gets the list of physic impostors
  89446. * @returns an array of PhysicsImpostor
  89447. */
  89448. getImpostors(): Array<PhysicsImpostor>;
  89449. /**
  89450. * Gets the impostor for a physics enabled object
  89451. * @param object defines the object impersonated by the impostor
  89452. * @returns the PhysicsImpostor or null if not found
  89453. */
  89454. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89455. /**
  89456. * Gets the impostor for a physics body object
  89457. * @param body defines physics body used by the impostor
  89458. * @returns the PhysicsImpostor or null if not found
  89459. */
  89460. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89461. /**
  89462. * Does a raycast in the physics world
  89463. * @param from when should the ray start?
  89464. * @param to when should the ray end?
  89465. * @returns PhysicsRaycastResult
  89466. */
  89467. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89468. /**
  89469. * Called by the scene. No need to call it.
  89470. * @param delta defines the timespam between frames
  89471. */
  89472. _step(delta: number): void;
  89473. }
  89474. }
  89475. declare module BABYLON {
  89476. /**
  89477. * The interface for the physics imposter parameters
  89478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89479. */
  89480. export interface PhysicsImpostorParameters {
  89481. /**
  89482. * The mass of the physics imposter
  89483. */
  89484. mass: number;
  89485. /**
  89486. * The friction of the physics imposter
  89487. */
  89488. friction?: number;
  89489. /**
  89490. * The coefficient of restitution of the physics imposter
  89491. */
  89492. restitution?: number;
  89493. /**
  89494. * The native options of the physics imposter
  89495. */
  89496. nativeOptions?: any;
  89497. /**
  89498. * Specifies if the parent should be ignored
  89499. */
  89500. ignoreParent?: boolean;
  89501. /**
  89502. * Specifies if bi-directional transformations should be disabled
  89503. */
  89504. disableBidirectionalTransformation?: boolean;
  89505. /**
  89506. * The pressure inside the physics imposter, soft object only
  89507. */
  89508. pressure?: number;
  89509. /**
  89510. * The stiffness the physics imposter, soft object only
  89511. */
  89512. stiffness?: number;
  89513. /**
  89514. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89515. */
  89516. velocityIterations?: number;
  89517. /**
  89518. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89519. */
  89520. positionIterations?: number;
  89521. /**
  89522. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89523. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89524. * Add to fix multiple points
  89525. */
  89526. fixedPoints?: number;
  89527. /**
  89528. * The collision margin around a soft object
  89529. */
  89530. margin?: number;
  89531. /**
  89532. * The collision margin around a soft object
  89533. */
  89534. damping?: number;
  89535. /**
  89536. * The path for a rope based on an extrusion
  89537. */
  89538. path?: any;
  89539. /**
  89540. * The shape of an extrusion used for a rope based on an extrusion
  89541. */
  89542. shape?: any;
  89543. }
  89544. /**
  89545. * Interface for a physics-enabled object
  89546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89547. */
  89548. export interface IPhysicsEnabledObject {
  89549. /**
  89550. * The position of the physics-enabled object
  89551. */
  89552. position: Vector3;
  89553. /**
  89554. * The rotation of the physics-enabled object
  89555. */
  89556. rotationQuaternion: Nullable<Quaternion>;
  89557. /**
  89558. * The scale of the physics-enabled object
  89559. */
  89560. scaling: Vector3;
  89561. /**
  89562. * The rotation of the physics-enabled object
  89563. */
  89564. rotation?: Vector3;
  89565. /**
  89566. * The parent of the physics-enabled object
  89567. */
  89568. parent?: any;
  89569. /**
  89570. * The bounding info of the physics-enabled object
  89571. * @returns The bounding info of the physics-enabled object
  89572. */
  89573. getBoundingInfo(): BoundingInfo;
  89574. /**
  89575. * Computes the world matrix
  89576. * @param force Specifies if the world matrix should be computed by force
  89577. * @returns A world matrix
  89578. */
  89579. computeWorldMatrix(force: boolean): Matrix;
  89580. /**
  89581. * Gets the world matrix
  89582. * @returns A world matrix
  89583. */
  89584. getWorldMatrix?(): Matrix;
  89585. /**
  89586. * Gets the child meshes
  89587. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89588. * @returns An array of abstract meshes
  89589. */
  89590. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89591. /**
  89592. * Gets the vertex data
  89593. * @param kind The type of vertex data
  89594. * @returns A nullable array of numbers, or a float32 array
  89595. */
  89596. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89597. /**
  89598. * Gets the indices from the mesh
  89599. * @returns A nullable array of index arrays
  89600. */
  89601. getIndices?(): Nullable<IndicesArray>;
  89602. /**
  89603. * Gets the scene from the mesh
  89604. * @returns the indices array or null
  89605. */
  89606. getScene?(): Scene;
  89607. /**
  89608. * Gets the absolute position from the mesh
  89609. * @returns the absolute position
  89610. */
  89611. getAbsolutePosition(): Vector3;
  89612. /**
  89613. * Gets the absolute pivot point from the mesh
  89614. * @returns the absolute pivot point
  89615. */
  89616. getAbsolutePivotPoint(): Vector3;
  89617. /**
  89618. * Rotates the mesh
  89619. * @param axis The axis of rotation
  89620. * @param amount The amount of rotation
  89621. * @param space The space of the rotation
  89622. * @returns The rotation transform node
  89623. */
  89624. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89625. /**
  89626. * Translates the mesh
  89627. * @param axis The axis of translation
  89628. * @param distance The distance of translation
  89629. * @param space The space of the translation
  89630. * @returns The transform node
  89631. */
  89632. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89633. /**
  89634. * Sets the absolute position of the mesh
  89635. * @param absolutePosition The absolute position of the mesh
  89636. * @returns The transform node
  89637. */
  89638. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89639. /**
  89640. * Gets the class name of the mesh
  89641. * @returns The class name
  89642. */
  89643. getClassName(): string;
  89644. }
  89645. /**
  89646. * Represents a physics imposter
  89647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89648. */
  89649. export class PhysicsImpostor {
  89650. /**
  89651. * The physics-enabled object used as the physics imposter
  89652. */
  89653. object: IPhysicsEnabledObject;
  89654. /**
  89655. * The type of the physics imposter
  89656. */
  89657. type: number;
  89658. private _options;
  89659. private _scene?;
  89660. /**
  89661. * The default object size of the imposter
  89662. */
  89663. static DEFAULT_OBJECT_SIZE: Vector3;
  89664. /**
  89665. * The identity quaternion of the imposter
  89666. */
  89667. static IDENTITY_QUATERNION: Quaternion;
  89668. /** @hidden */
  89669. _pluginData: any;
  89670. private _physicsEngine;
  89671. private _physicsBody;
  89672. private _bodyUpdateRequired;
  89673. private _onBeforePhysicsStepCallbacks;
  89674. private _onAfterPhysicsStepCallbacks;
  89675. /** @hidden */
  89676. _onPhysicsCollideCallbacks: Array<{
  89677. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89678. otherImpostors: Array<PhysicsImpostor>;
  89679. }>;
  89680. private _deltaPosition;
  89681. private _deltaRotation;
  89682. private _deltaRotationConjugated;
  89683. /** @hidden */
  89684. _isFromLine: boolean;
  89685. private _parent;
  89686. private _isDisposed;
  89687. private static _tmpVecs;
  89688. private static _tmpQuat;
  89689. /**
  89690. * Specifies if the physics imposter is disposed
  89691. */
  89692. readonly isDisposed: boolean;
  89693. /**
  89694. * Gets the mass of the physics imposter
  89695. */
  89696. mass: number;
  89697. /**
  89698. * Gets the coefficient of friction
  89699. */
  89700. /**
  89701. * Sets the coefficient of friction
  89702. */
  89703. friction: number;
  89704. /**
  89705. * Gets the coefficient of restitution
  89706. */
  89707. /**
  89708. * Sets the coefficient of restitution
  89709. */
  89710. restitution: number;
  89711. /**
  89712. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89713. */
  89714. /**
  89715. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89716. */
  89717. pressure: number;
  89718. /**
  89719. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89720. */
  89721. /**
  89722. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89723. */
  89724. stiffness: number;
  89725. /**
  89726. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89727. */
  89728. /**
  89729. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89730. */
  89731. velocityIterations: number;
  89732. /**
  89733. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89734. */
  89735. /**
  89736. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89737. */
  89738. positionIterations: number;
  89739. /**
  89740. * The unique id of the physics imposter
  89741. * set by the physics engine when adding this impostor to the array
  89742. */
  89743. uniqueId: number;
  89744. /**
  89745. * @hidden
  89746. */
  89747. soft: boolean;
  89748. /**
  89749. * @hidden
  89750. */
  89751. segments: number;
  89752. private _joints;
  89753. /**
  89754. * Initializes the physics imposter
  89755. * @param object The physics-enabled object used as the physics imposter
  89756. * @param type The type of the physics imposter
  89757. * @param _options The options for the physics imposter
  89758. * @param _scene The Babylon scene
  89759. */
  89760. constructor(
  89761. /**
  89762. * The physics-enabled object used as the physics imposter
  89763. */
  89764. object: IPhysicsEnabledObject,
  89765. /**
  89766. * The type of the physics imposter
  89767. */
  89768. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89769. /**
  89770. * This function will completly initialize this impostor.
  89771. * It will create a new body - but only if this mesh has no parent.
  89772. * If it has, this impostor will not be used other than to define the impostor
  89773. * of the child mesh.
  89774. * @hidden
  89775. */
  89776. _init(): void;
  89777. private _getPhysicsParent;
  89778. /**
  89779. * Should a new body be generated.
  89780. * @returns boolean specifying if body initialization is required
  89781. */
  89782. isBodyInitRequired(): boolean;
  89783. /**
  89784. * Sets the updated scaling
  89785. * @param updated Specifies if the scaling is updated
  89786. */
  89787. setScalingUpdated(): void;
  89788. /**
  89789. * Force a regeneration of this or the parent's impostor's body.
  89790. * Use under cautious - This will remove all joints already implemented.
  89791. */
  89792. forceUpdate(): void;
  89793. /**
  89794. * Gets the body that holds this impostor. Either its own, or its parent.
  89795. */
  89796. /**
  89797. * Set the physics body. Used mainly by the physics engine/plugin
  89798. */
  89799. physicsBody: any;
  89800. /**
  89801. * Get the parent of the physics imposter
  89802. * @returns Physics imposter or null
  89803. */
  89804. /**
  89805. * Sets the parent of the physics imposter
  89806. */
  89807. parent: Nullable<PhysicsImpostor>;
  89808. /**
  89809. * Resets the update flags
  89810. */
  89811. resetUpdateFlags(): void;
  89812. /**
  89813. * Gets the object extend size
  89814. * @returns the object extend size
  89815. */
  89816. getObjectExtendSize(): Vector3;
  89817. /**
  89818. * Gets the object center
  89819. * @returns The object center
  89820. */
  89821. getObjectCenter(): Vector3;
  89822. /**
  89823. * Get a specific parametes from the options parameter
  89824. * @param paramName The object parameter name
  89825. * @returns The object parameter
  89826. */
  89827. getParam(paramName: string): any;
  89828. /**
  89829. * Sets a specific parameter in the options given to the physics plugin
  89830. * @param paramName The parameter name
  89831. * @param value The value of the parameter
  89832. */
  89833. setParam(paramName: string, value: number): void;
  89834. /**
  89835. * Specifically change the body's mass option. Won't recreate the physics body object
  89836. * @param mass The mass of the physics imposter
  89837. */
  89838. setMass(mass: number): void;
  89839. /**
  89840. * Gets the linear velocity
  89841. * @returns linear velocity or null
  89842. */
  89843. getLinearVelocity(): Nullable<Vector3>;
  89844. /**
  89845. * Sets the linear velocity
  89846. * @param velocity linear velocity or null
  89847. */
  89848. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89849. /**
  89850. * Gets the angular velocity
  89851. * @returns angular velocity or null
  89852. */
  89853. getAngularVelocity(): Nullable<Vector3>;
  89854. /**
  89855. * Sets the angular velocity
  89856. * @param velocity The velocity or null
  89857. */
  89858. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89859. /**
  89860. * Execute a function with the physics plugin native code
  89861. * Provide a function the will have two variables - the world object and the physics body object
  89862. * @param func The function to execute with the physics plugin native code
  89863. */
  89864. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89865. /**
  89866. * Register a function that will be executed before the physics world is stepping forward
  89867. * @param func The function to execute before the physics world is stepped forward
  89868. */
  89869. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89870. /**
  89871. * Unregister a function that will be executed before the physics world is stepping forward
  89872. * @param func The function to execute before the physics world is stepped forward
  89873. */
  89874. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89875. /**
  89876. * Register a function that will be executed after the physics step
  89877. * @param func The function to execute after physics step
  89878. */
  89879. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89880. /**
  89881. * Unregisters a function that will be executed after the physics step
  89882. * @param func The function to execute after physics step
  89883. */
  89884. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89885. /**
  89886. * register a function that will be executed when this impostor collides against a different body
  89887. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89888. * @param func Callback that is executed on collision
  89889. */
  89890. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89891. /**
  89892. * Unregisters the physics imposter on contact
  89893. * @param collideAgainst The physics object to collide against
  89894. * @param func Callback to execute on collision
  89895. */
  89896. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89897. private _tmpQuat;
  89898. private _tmpQuat2;
  89899. /**
  89900. * Get the parent rotation
  89901. * @returns The parent rotation
  89902. */
  89903. getParentsRotation(): Quaternion;
  89904. /**
  89905. * this function is executed by the physics engine.
  89906. */
  89907. beforeStep: () => void;
  89908. /**
  89909. * this function is executed by the physics engine
  89910. */
  89911. afterStep: () => void;
  89912. /**
  89913. * Legacy collision detection event support
  89914. */
  89915. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89916. /**
  89917. * event and body object due to cannon's event-based architecture.
  89918. */
  89919. onCollide: (e: {
  89920. body: any;
  89921. }) => void;
  89922. /**
  89923. * Apply a force
  89924. * @param force The force to apply
  89925. * @param contactPoint The contact point for the force
  89926. * @returns The physics imposter
  89927. */
  89928. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89929. /**
  89930. * Apply an impulse
  89931. * @param force The impulse force
  89932. * @param contactPoint The contact point for the impulse force
  89933. * @returns The physics imposter
  89934. */
  89935. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89936. /**
  89937. * A help function to create a joint
  89938. * @param otherImpostor A physics imposter used to create a joint
  89939. * @param jointType The type of joint
  89940. * @param jointData The data for the joint
  89941. * @returns The physics imposter
  89942. */
  89943. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89944. /**
  89945. * Add a joint to this impostor with a different impostor
  89946. * @param otherImpostor A physics imposter used to add a joint
  89947. * @param joint The joint to add
  89948. * @returns The physics imposter
  89949. */
  89950. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89951. /**
  89952. * Add an anchor to a cloth impostor
  89953. * @param otherImpostor rigid impostor to anchor to
  89954. * @param width ratio across width from 0 to 1
  89955. * @param height ratio up height from 0 to 1
  89956. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89957. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89958. * @returns impostor the soft imposter
  89959. */
  89960. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89961. /**
  89962. * Add a hook to a rope impostor
  89963. * @param otherImpostor rigid impostor to anchor to
  89964. * @param length ratio across rope from 0 to 1
  89965. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89966. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89967. * @returns impostor the rope imposter
  89968. */
  89969. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89970. /**
  89971. * Will keep this body still, in a sleep mode.
  89972. * @returns the physics imposter
  89973. */
  89974. sleep(): PhysicsImpostor;
  89975. /**
  89976. * Wake the body up.
  89977. * @returns The physics imposter
  89978. */
  89979. wakeUp(): PhysicsImpostor;
  89980. /**
  89981. * Clones the physics imposter
  89982. * @param newObject The physics imposter clones to this physics-enabled object
  89983. * @returns A nullable physics imposter
  89984. */
  89985. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89986. /**
  89987. * Disposes the physics imposter
  89988. */
  89989. dispose(): void;
  89990. /**
  89991. * Sets the delta position
  89992. * @param position The delta position amount
  89993. */
  89994. setDeltaPosition(position: Vector3): void;
  89995. /**
  89996. * Sets the delta rotation
  89997. * @param rotation The delta rotation amount
  89998. */
  89999. setDeltaRotation(rotation: Quaternion): void;
  90000. /**
  90001. * Gets the box size of the physics imposter and stores the result in the input parameter
  90002. * @param result Stores the box size
  90003. * @returns The physics imposter
  90004. */
  90005. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90006. /**
  90007. * Gets the radius of the physics imposter
  90008. * @returns Radius of the physics imposter
  90009. */
  90010. getRadius(): number;
  90011. /**
  90012. * Sync a bone with this impostor
  90013. * @param bone The bone to sync to the impostor.
  90014. * @param boneMesh The mesh that the bone is influencing.
  90015. * @param jointPivot The pivot of the joint / bone in local space.
  90016. * @param distToJoint Optional distance from the impostor to the joint.
  90017. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90018. */
  90019. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90020. /**
  90021. * Sync impostor to a bone
  90022. * @param bone The bone that the impostor will be synced to.
  90023. * @param boneMesh The mesh that the bone is influencing.
  90024. * @param jointPivot The pivot of the joint / bone in local space.
  90025. * @param distToJoint Optional distance from the impostor to the joint.
  90026. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90027. * @param boneAxis Optional vector3 axis the bone is aligned with
  90028. */
  90029. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90030. /**
  90031. * No-Imposter type
  90032. */
  90033. static NoImpostor: number;
  90034. /**
  90035. * Sphere-Imposter type
  90036. */
  90037. static SphereImpostor: number;
  90038. /**
  90039. * Box-Imposter type
  90040. */
  90041. static BoxImpostor: number;
  90042. /**
  90043. * Plane-Imposter type
  90044. */
  90045. static PlaneImpostor: number;
  90046. /**
  90047. * Mesh-imposter type
  90048. */
  90049. static MeshImpostor: number;
  90050. /**
  90051. * Capsule-Impostor type (Ammo.js plugin only)
  90052. */
  90053. static CapsuleImpostor: number;
  90054. /**
  90055. * Cylinder-Imposter type
  90056. */
  90057. static CylinderImpostor: number;
  90058. /**
  90059. * Particle-Imposter type
  90060. */
  90061. static ParticleImpostor: number;
  90062. /**
  90063. * Heightmap-Imposter type
  90064. */
  90065. static HeightmapImpostor: number;
  90066. /**
  90067. * ConvexHull-Impostor type (Ammo.js plugin only)
  90068. */
  90069. static ConvexHullImpostor: number;
  90070. /**
  90071. * Rope-Imposter type
  90072. */
  90073. static RopeImpostor: number;
  90074. /**
  90075. * Cloth-Imposter type
  90076. */
  90077. static ClothImpostor: number;
  90078. /**
  90079. * Softbody-Imposter type
  90080. */
  90081. static SoftbodyImpostor: number;
  90082. }
  90083. }
  90084. declare module BABYLON {
  90085. /**
  90086. * @hidden
  90087. **/
  90088. export class _CreationDataStorage {
  90089. closePath?: boolean;
  90090. closeArray?: boolean;
  90091. idx: number[];
  90092. dashSize: number;
  90093. gapSize: number;
  90094. path3D: Path3D;
  90095. pathArray: Vector3[][];
  90096. arc: number;
  90097. radius: number;
  90098. cap: number;
  90099. tessellation: number;
  90100. }
  90101. /**
  90102. * @hidden
  90103. **/
  90104. class _InstanceDataStorage {
  90105. visibleInstances: any;
  90106. batchCache: _InstancesBatch;
  90107. instancesBufferSize: number;
  90108. instancesBuffer: Nullable<Buffer>;
  90109. instancesData: Float32Array;
  90110. overridenInstanceCount: number;
  90111. isFrozen: boolean;
  90112. previousBatch: Nullable<_InstancesBatch>;
  90113. hardwareInstancedRendering: boolean;
  90114. sideOrientation: number;
  90115. }
  90116. /**
  90117. * @hidden
  90118. **/
  90119. export class _InstancesBatch {
  90120. mustReturn: boolean;
  90121. visibleInstances: Nullable<InstancedMesh[]>[];
  90122. renderSelf: boolean[];
  90123. hardwareInstancedRendering: boolean[];
  90124. }
  90125. /**
  90126. * Class used to represent renderable models
  90127. */
  90128. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90129. /**
  90130. * Mesh side orientation : usually the external or front surface
  90131. */
  90132. static readonly FRONTSIDE: number;
  90133. /**
  90134. * Mesh side orientation : usually the internal or back surface
  90135. */
  90136. static readonly BACKSIDE: number;
  90137. /**
  90138. * Mesh side orientation : both internal and external or front and back surfaces
  90139. */
  90140. static readonly DOUBLESIDE: number;
  90141. /**
  90142. * Mesh side orientation : by default, `FRONTSIDE`
  90143. */
  90144. static readonly DEFAULTSIDE: number;
  90145. /**
  90146. * Mesh cap setting : no cap
  90147. */
  90148. static readonly NO_CAP: number;
  90149. /**
  90150. * Mesh cap setting : one cap at the beginning of the mesh
  90151. */
  90152. static readonly CAP_START: number;
  90153. /**
  90154. * Mesh cap setting : one cap at the end of the mesh
  90155. */
  90156. static readonly CAP_END: number;
  90157. /**
  90158. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90159. */
  90160. static readonly CAP_ALL: number;
  90161. /**
  90162. * Mesh pattern setting : no flip or rotate
  90163. */
  90164. static readonly NO_FLIP: number;
  90165. /**
  90166. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90167. */
  90168. static readonly FLIP_TILE: number;
  90169. /**
  90170. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90171. */
  90172. static readonly ROTATE_TILE: number;
  90173. /**
  90174. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90175. */
  90176. static readonly FLIP_ROW: number;
  90177. /**
  90178. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90179. */
  90180. static readonly ROTATE_ROW: number;
  90181. /**
  90182. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90183. */
  90184. static readonly FLIP_N_ROTATE_TILE: number;
  90185. /**
  90186. * Mesh pattern setting : rotate pattern and rotate
  90187. */
  90188. static readonly FLIP_N_ROTATE_ROW: number;
  90189. /**
  90190. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90191. */
  90192. static readonly CENTER: number;
  90193. /**
  90194. * Mesh tile positioning : part tiles on left
  90195. */
  90196. static readonly LEFT: number;
  90197. /**
  90198. * Mesh tile positioning : part tiles on right
  90199. */
  90200. static readonly RIGHT: number;
  90201. /**
  90202. * Mesh tile positioning : part tiles on top
  90203. */
  90204. static readonly TOP: number;
  90205. /**
  90206. * Mesh tile positioning : part tiles on bottom
  90207. */
  90208. static readonly BOTTOM: number;
  90209. /**
  90210. * Gets the default side orientation.
  90211. * @param orientation the orientation to value to attempt to get
  90212. * @returns the default orientation
  90213. * @hidden
  90214. */
  90215. static _GetDefaultSideOrientation(orientation?: number): number;
  90216. private _internalMeshDataInfo;
  90217. /**
  90218. * An event triggered before rendering the mesh
  90219. */
  90220. readonly onBeforeRenderObservable: Observable<Mesh>;
  90221. /**
  90222. * An event triggered before binding the mesh
  90223. */
  90224. readonly onBeforeBindObservable: Observable<Mesh>;
  90225. /**
  90226. * An event triggered after rendering the mesh
  90227. */
  90228. readonly onAfterRenderObservable: Observable<Mesh>;
  90229. /**
  90230. * An event triggered before drawing the mesh
  90231. */
  90232. readonly onBeforeDrawObservable: Observable<Mesh>;
  90233. private _onBeforeDrawObserver;
  90234. /**
  90235. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90236. */
  90237. onBeforeDraw: () => void;
  90238. readonly hasInstances: boolean;
  90239. /**
  90240. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90241. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90242. */
  90243. delayLoadState: number;
  90244. /**
  90245. * Gets the list of instances created from this mesh
  90246. * it is not supposed to be modified manually.
  90247. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90248. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90249. */
  90250. instances: InstancedMesh[];
  90251. /**
  90252. * Gets the file containing delay loading data for this mesh
  90253. */
  90254. delayLoadingFile: string;
  90255. /** @hidden */
  90256. _binaryInfo: any;
  90257. /**
  90258. * User defined function used to change how LOD level selection is done
  90259. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90260. */
  90261. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90262. /**
  90263. * Gets or sets the morph target manager
  90264. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90265. */
  90266. morphTargetManager: Nullable<MorphTargetManager>;
  90267. /** @hidden */
  90268. _creationDataStorage: Nullable<_CreationDataStorage>;
  90269. /** @hidden */
  90270. _geometry: Nullable<Geometry>;
  90271. /** @hidden */
  90272. _delayInfo: Array<string>;
  90273. /** @hidden */
  90274. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90275. /** @hidden */
  90276. _instanceDataStorage: _InstanceDataStorage;
  90277. private _effectiveMaterial;
  90278. /** @hidden */
  90279. _shouldGenerateFlatShading: boolean;
  90280. /** @hidden */
  90281. _originalBuilderSideOrientation: number;
  90282. /**
  90283. * Use this property to change the original side orientation defined at construction time
  90284. */
  90285. overrideMaterialSideOrientation: Nullable<number>;
  90286. /**
  90287. * Gets the source mesh (the one used to clone this one from)
  90288. */
  90289. readonly source: Nullable<Mesh>;
  90290. /**
  90291. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90292. */
  90293. isUnIndexed: boolean;
  90294. /**
  90295. * @constructor
  90296. * @param name The value used by scene.getMeshByName() to do a lookup.
  90297. * @param scene The scene to add this mesh to.
  90298. * @param parent The parent of this mesh, if it has one
  90299. * @param source An optional Mesh from which geometry is shared, cloned.
  90300. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90301. * When false, achieved by calling a clone(), also passing False.
  90302. * This will make creation of children, recursive.
  90303. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90304. */
  90305. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90306. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90307. /**
  90308. * Gets the class name
  90309. * @returns the string "Mesh".
  90310. */
  90311. getClassName(): string;
  90312. /** @hidden */
  90313. readonly _isMesh: boolean;
  90314. /**
  90315. * Returns a description of this mesh
  90316. * @param fullDetails define if full details about this mesh must be used
  90317. * @returns a descriptive string representing this mesh
  90318. */
  90319. toString(fullDetails?: boolean): string;
  90320. /** @hidden */
  90321. _unBindEffect(): void;
  90322. /**
  90323. * Gets a boolean indicating if this mesh has LOD
  90324. */
  90325. readonly hasLODLevels: boolean;
  90326. /**
  90327. * Gets the list of MeshLODLevel associated with the current mesh
  90328. * @returns an array of MeshLODLevel
  90329. */
  90330. getLODLevels(): MeshLODLevel[];
  90331. private _sortLODLevels;
  90332. /**
  90333. * Add a mesh as LOD level triggered at the given distance.
  90334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90335. * @param distance The distance from the center of the object to show this level
  90336. * @param mesh The mesh to be added as LOD level (can be null)
  90337. * @return This mesh (for chaining)
  90338. */
  90339. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90340. /**
  90341. * Returns the LOD level mesh at the passed distance or null if not found.
  90342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90343. * @param distance The distance from the center of the object to show this level
  90344. * @returns a Mesh or `null`
  90345. */
  90346. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90347. /**
  90348. * Remove a mesh from the LOD array
  90349. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90350. * @param mesh defines the mesh to be removed
  90351. * @return This mesh (for chaining)
  90352. */
  90353. removeLODLevel(mesh: Mesh): Mesh;
  90354. /**
  90355. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90356. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90357. * @param camera defines the camera to use to compute distance
  90358. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90359. * @return This mesh (for chaining)
  90360. */
  90361. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90362. /**
  90363. * Gets the mesh internal Geometry object
  90364. */
  90365. readonly geometry: Nullable<Geometry>;
  90366. /**
  90367. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90368. * @returns the total number of vertices
  90369. */
  90370. getTotalVertices(): number;
  90371. /**
  90372. * Returns the content of an associated vertex buffer
  90373. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90374. * - VertexBuffer.PositionKind
  90375. * - VertexBuffer.UVKind
  90376. * - VertexBuffer.UV2Kind
  90377. * - VertexBuffer.UV3Kind
  90378. * - VertexBuffer.UV4Kind
  90379. * - VertexBuffer.UV5Kind
  90380. * - VertexBuffer.UV6Kind
  90381. * - VertexBuffer.ColorKind
  90382. * - VertexBuffer.MatricesIndicesKind
  90383. * - VertexBuffer.MatricesIndicesExtraKind
  90384. * - VertexBuffer.MatricesWeightsKind
  90385. * - VertexBuffer.MatricesWeightsExtraKind
  90386. * @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
  90387. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90388. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90389. */
  90390. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90391. /**
  90392. * Returns the mesh VertexBuffer object from the requested `kind`
  90393. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90394. * - VertexBuffer.PositionKind
  90395. * - VertexBuffer.NormalKind
  90396. * - VertexBuffer.UVKind
  90397. * - VertexBuffer.UV2Kind
  90398. * - VertexBuffer.UV3Kind
  90399. * - VertexBuffer.UV4Kind
  90400. * - VertexBuffer.UV5Kind
  90401. * - VertexBuffer.UV6Kind
  90402. * - VertexBuffer.ColorKind
  90403. * - VertexBuffer.MatricesIndicesKind
  90404. * - VertexBuffer.MatricesIndicesExtraKind
  90405. * - VertexBuffer.MatricesWeightsKind
  90406. * - VertexBuffer.MatricesWeightsExtraKind
  90407. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90408. */
  90409. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90410. /**
  90411. * Tests if a specific vertex buffer is associated with this mesh
  90412. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90413. * - VertexBuffer.PositionKind
  90414. * - VertexBuffer.NormalKind
  90415. * - VertexBuffer.UVKind
  90416. * - VertexBuffer.UV2Kind
  90417. * - VertexBuffer.UV3Kind
  90418. * - VertexBuffer.UV4Kind
  90419. * - VertexBuffer.UV5Kind
  90420. * - VertexBuffer.UV6Kind
  90421. * - VertexBuffer.ColorKind
  90422. * - VertexBuffer.MatricesIndicesKind
  90423. * - VertexBuffer.MatricesIndicesExtraKind
  90424. * - VertexBuffer.MatricesWeightsKind
  90425. * - VertexBuffer.MatricesWeightsExtraKind
  90426. * @returns a boolean
  90427. */
  90428. isVerticesDataPresent(kind: string): boolean;
  90429. /**
  90430. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90431. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90432. * - VertexBuffer.PositionKind
  90433. * - VertexBuffer.UVKind
  90434. * - VertexBuffer.UV2Kind
  90435. * - VertexBuffer.UV3Kind
  90436. * - VertexBuffer.UV4Kind
  90437. * - VertexBuffer.UV5Kind
  90438. * - VertexBuffer.UV6Kind
  90439. * - VertexBuffer.ColorKind
  90440. * - VertexBuffer.MatricesIndicesKind
  90441. * - VertexBuffer.MatricesIndicesExtraKind
  90442. * - VertexBuffer.MatricesWeightsKind
  90443. * - VertexBuffer.MatricesWeightsExtraKind
  90444. * @returns a boolean
  90445. */
  90446. isVertexBufferUpdatable(kind: string): boolean;
  90447. /**
  90448. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90449. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90450. * - VertexBuffer.PositionKind
  90451. * - VertexBuffer.NormalKind
  90452. * - VertexBuffer.UVKind
  90453. * - VertexBuffer.UV2Kind
  90454. * - VertexBuffer.UV3Kind
  90455. * - VertexBuffer.UV4Kind
  90456. * - VertexBuffer.UV5Kind
  90457. * - VertexBuffer.UV6Kind
  90458. * - VertexBuffer.ColorKind
  90459. * - VertexBuffer.MatricesIndicesKind
  90460. * - VertexBuffer.MatricesIndicesExtraKind
  90461. * - VertexBuffer.MatricesWeightsKind
  90462. * - VertexBuffer.MatricesWeightsExtraKind
  90463. * @returns an array of strings
  90464. */
  90465. getVerticesDataKinds(): string[];
  90466. /**
  90467. * Returns a positive integer : the total number of indices in this mesh geometry.
  90468. * @returns the numner of indices or zero if the mesh has no geometry.
  90469. */
  90470. getTotalIndices(): number;
  90471. /**
  90472. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90473. * @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.
  90474. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90475. * @returns the indices array or an empty array if the mesh has no geometry
  90476. */
  90477. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90478. readonly isBlocked: boolean;
  90479. /**
  90480. * Determine if the current mesh is ready to be rendered
  90481. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90482. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90483. * @returns true if all associated assets are ready (material, textures, shaders)
  90484. */
  90485. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90486. /**
  90487. * 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.
  90488. */
  90489. readonly areNormalsFrozen: boolean;
  90490. /**
  90491. * 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.
  90492. * @returns the current mesh
  90493. */
  90494. freezeNormals(): Mesh;
  90495. /**
  90496. * 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
  90497. * @returns the current mesh
  90498. */
  90499. unfreezeNormals(): Mesh;
  90500. /**
  90501. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90502. */
  90503. overridenInstanceCount: number;
  90504. /** @hidden */
  90505. _preActivate(): Mesh;
  90506. /** @hidden */
  90507. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90508. /** @hidden */
  90509. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90510. /**
  90511. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90512. * This means the mesh underlying bounding box and sphere are recomputed.
  90513. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90514. * @returns the current mesh
  90515. */
  90516. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90517. /** @hidden */
  90518. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90519. /**
  90520. * This function will subdivide the mesh into multiple submeshes
  90521. * @param count defines the expected number of submeshes
  90522. */
  90523. subdivide(count: number): void;
  90524. /**
  90525. * Copy a FloatArray into a specific associated vertex buffer
  90526. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90527. * - VertexBuffer.PositionKind
  90528. * - VertexBuffer.UVKind
  90529. * - VertexBuffer.UV2Kind
  90530. * - VertexBuffer.UV3Kind
  90531. * - VertexBuffer.UV4Kind
  90532. * - VertexBuffer.UV5Kind
  90533. * - VertexBuffer.UV6Kind
  90534. * - VertexBuffer.ColorKind
  90535. * - VertexBuffer.MatricesIndicesKind
  90536. * - VertexBuffer.MatricesIndicesExtraKind
  90537. * - VertexBuffer.MatricesWeightsKind
  90538. * - VertexBuffer.MatricesWeightsExtraKind
  90539. * @param data defines the data source
  90540. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90541. * @param stride defines the data stride size (can be null)
  90542. * @returns the current mesh
  90543. */
  90544. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90545. /**
  90546. * Flags an associated vertex buffer as updatable
  90547. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90548. * - VertexBuffer.PositionKind
  90549. * - VertexBuffer.UVKind
  90550. * - VertexBuffer.UV2Kind
  90551. * - VertexBuffer.UV3Kind
  90552. * - VertexBuffer.UV4Kind
  90553. * - VertexBuffer.UV5Kind
  90554. * - VertexBuffer.UV6Kind
  90555. * - VertexBuffer.ColorKind
  90556. * - VertexBuffer.MatricesIndicesKind
  90557. * - VertexBuffer.MatricesIndicesExtraKind
  90558. * - VertexBuffer.MatricesWeightsKind
  90559. * - VertexBuffer.MatricesWeightsExtraKind
  90560. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90561. */
  90562. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90563. /**
  90564. * Sets the mesh global Vertex Buffer
  90565. * @param buffer defines the buffer to use
  90566. * @returns the current mesh
  90567. */
  90568. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90569. /**
  90570. * Update a specific associated vertex buffer
  90571. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90572. * - VertexBuffer.PositionKind
  90573. * - VertexBuffer.UVKind
  90574. * - VertexBuffer.UV2Kind
  90575. * - VertexBuffer.UV3Kind
  90576. * - VertexBuffer.UV4Kind
  90577. * - VertexBuffer.UV5Kind
  90578. * - VertexBuffer.UV6Kind
  90579. * - VertexBuffer.ColorKind
  90580. * - VertexBuffer.MatricesIndicesKind
  90581. * - VertexBuffer.MatricesIndicesExtraKind
  90582. * - VertexBuffer.MatricesWeightsKind
  90583. * - VertexBuffer.MatricesWeightsExtraKind
  90584. * @param data defines the data source
  90585. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90586. * @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)
  90587. * @returns the current mesh
  90588. */
  90589. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90590. /**
  90591. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90592. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90593. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90594. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90595. * @returns the current mesh
  90596. */
  90597. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90598. /**
  90599. * Creates a un-shared specific occurence of the geometry for the mesh.
  90600. * @returns the current mesh
  90601. */
  90602. makeGeometryUnique(): Mesh;
  90603. /**
  90604. * Set the index buffer of this mesh
  90605. * @param indices defines the source data
  90606. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90607. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90608. * @returns the current mesh
  90609. */
  90610. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90611. /**
  90612. * Update the current index buffer
  90613. * @param indices defines the source data
  90614. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90615. * @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)
  90616. * @returns the current mesh
  90617. */
  90618. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90619. /**
  90620. * Invert the geometry to move from a right handed system to a left handed one.
  90621. * @returns the current mesh
  90622. */
  90623. toLeftHanded(): Mesh;
  90624. /** @hidden */
  90625. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90626. /** @hidden */
  90627. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90628. /**
  90629. * Registers for this mesh a javascript function called just before the rendering process
  90630. * @param func defines the function to call before rendering this mesh
  90631. * @returns the current mesh
  90632. */
  90633. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90634. /**
  90635. * Disposes a previously registered javascript function called before the rendering
  90636. * @param func defines the function to remove
  90637. * @returns the current mesh
  90638. */
  90639. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90640. /**
  90641. * Registers for this mesh a javascript function called just after the rendering is complete
  90642. * @param func defines the function to call after rendering this mesh
  90643. * @returns the current mesh
  90644. */
  90645. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90646. /**
  90647. * Disposes a previously registered javascript function called after the rendering.
  90648. * @param func defines the function to remove
  90649. * @returns the current mesh
  90650. */
  90651. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90652. /** @hidden */
  90653. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90654. /** @hidden */
  90655. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90656. /** @hidden */
  90657. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90658. /** @hidden */
  90659. _rebuild(): void;
  90660. /** @hidden */
  90661. _freeze(): void;
  90662. /** @hidden */
  90663. _unFreeze(): void;
  90664. /**
  90665. * 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
  90666. * @param subMesh defines the subMesh to render
  90667. * @param enableAlphaMode defines if alpha mode can be changed
  90668. * @returns the current mesh
  90669. */
  90670. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90671. private _onBeforeDraw;
  90672. /**
  90673. * Renormalize the mesh and patch it up if there are no weights
  90674. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90675. * However in the case of zero weights then we set just a single influence to 1.
  90676. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90677. */
  90678. cleanMatrixWeights(): void;
  90679. private normalizeSkinFourWeights;
  90680. private normalizeSkinWeightsAndExtra;
  90681. /**
  90682. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90683. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90684. * the user know there was an issue with importing the mesh
  90685. * @returns a validation object with skinned, valid and report string
  90686. */
  90687. validateSkinning(): {
  90688. skinned: boolean;
  90689. valid: boolean;
  90690. report: string;
  90691. };
  90692. /** @hidden */
  90693. _checkDelayState(): Mesh;
  90694. private _queueLoad;
  90695. /**
  90696. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90697. * A mesh is in the frustum if its bounding box intersects the frustum
  90698. * @param frustumPlanes defines the frustum to test
  90699. * @returns true if the mesh is in the frustum planes
  90700. */
  90701. isInFrustum(frustumPlanes: Plane[]): boolean;
  90702. /**
  90703. * Sets the mesh material by the material or multiMaterial `id` property
  90704. * @param id is a string identifying the material or the multiMaterial
  90705. * @returns the current mesh
  90706. */
  90707. setMaterialByID(id: string): Mesh;
  90708. /**
  90709. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90710. * @returns an array of IAnimatable
  90711. */
  90712. getAnimatables(): IAnimatable[];
  90713. /**
  90714. * Modifies the mesh geometry according to the passed transformation matrix.
  90715. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90716. * The mesh normals are modified using the same transformation.
  90717. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90718. * @param transform defines the transform matrix to use
  90719. * @see http://doc.babylonjs.com/resources/baking_transformations
  90720. * @returns the current mesh
  90721. */
  90722. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90723. /**
  90724. * Modifies the mesh geometry according to its own current World Matrix.
  90725. * The mesh World Matrix is then reset.
  90726. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90727. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90728. * @see http://doc.babylonjs.com/resources/baking_transformations
  90729. * @returns the current mesh
  90730. */
  90731. bakeCurrentTransformIntoVertices(): Mesh;
  90732. /** @hidden */
  90733. readonly _positions: Nullable<Vector3[]>;
  90734. /** @hidden */
  90735. _resetPointsArrayCache(): Mesh;
  90736. /** @hidden */
  90737. _generatePointsArray(): boolean;
  90738. /**
  90739. * Returns a new Mesh object generated from the current mesh properties.
  90740. * This method must not get confused with createInstance()
  90741. * @param name is a string, the name given to the new mesh
  90742. * @param newParent can be any Node object (default `null`)
  90743. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90744. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90745. * @returns a new mesh
  90746. */
  90747. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90748. /**
  90749. * Releases resources associated with this mesh.
  90750. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90751. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90752. */
  90753. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90754. /**
  90755. * Modifies the mesh geometry according to a displacement map.
  90756. * 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.
  90757. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90758. * @param url is a string, the URL from the image file is to be downloaded.
  90759. * @param minHeight is the lower limit of the displacement.
  90760. * @param maxHeight is the upper limit of the displacement.
  90761. * @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.
  90762. * @param uvOffset is an optional vector2 used to offset UV.
  90763. * @param uvScale is an optional vector2 used to scale UV.
  90764. * @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.
  90765. * @returns the Mesh.
  90766. */
  90767. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90768. /**
  90769. * Modifies the mesh geometry according to a displacementMap buffer.
  90770. * 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.
  90771. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90772. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90773. * @param heightMapWidth is the width of the buffer image.
  90774. * @param heightMapHeight is the height of the buffer image.
  90775. * @param minHeight is the lower limit of the displacement.
  90776. * @param maxHeight is the upper limit of the displacement.
  90777. * @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.
  90778. * @param uvOffset is an optional vector2 used to offset UV.
  90779. * @param uvScale is an optional vector2 used to scale UV.
  90780. * @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.
  90781. * @returns the Mesh.
  90782. */
  90783. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90784. /**
  90785. * Modify the mesh to get a flat shading rendering.
  90786. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90787. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90788. * @returns current mesh
  90789. */
  90790. convertToFlatShadedMesh(): Mesh;
  90791. /**
  90792. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90793. * In other words, more vertices, no more indices and a single bigger VBO.
  90794. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90795. * @returns current mesh
  90796. */
  90797. convertToUnIndexedMesh(): Mesh;
  90798. /**
  90799. * Inverses facet orientations.
  90800. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90801. * @param flipNormals will also inverts the normals
  90802. * @returns current mesh
  90803. */
  90804. flipFaces(flipNormals?: boolean): Mesh;
  90805. /**
  90806. * Increase the number of facets and hence vertices in a mesh
  90807. * Vertex normals are interpolated from existing vertex normals
  90808. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90809. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90810. */
  90811. increaseVertices(numberPerEdge: number): void;
  90812. /**
  90813. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90814. * This will undo any application of covertToFlatShadedMesh
  90815. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90816. */
  90817. forceSharedVertices(): void;
  90818. /** @hidden */
  90819. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90820. /** @hidden */
  90821. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90822. /**
  90823. * Creates a new InstancedMesh object from the mesh model.
  90824. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90825. * @param name defines the name of the new instance
  90826. * @returns a new InstancedMesh
  90827. */
  90828. createInstance(name: string): InstancedMesh;
  90829. /**
  90830. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90831. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90832. * @returns the current mesh
  90833. */
  90834. synchronizeInstances(): Mesh;
  90835. /**
  90836. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90837. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90838. * This should be used together with the simplification to avoid disappearing triangles.
  90839. * @param successCallback an optional success callback to be called after the optimization finished.
  90840. * @returns the current mesh
  90841. */
  90842. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90843. /**
  90844. * Serialize current mesh
  90845. * @param serializationObject defines the object which will receive the serialization data
  90846. */
  90847. serialize(serializationObject: any): void;
  90848. /** @hidden */
  90849. _syncGeometryWithMorphTargetManager(): void;
  90850. /** @hidden */
  90851. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90852. /**
  90853. * Returns a new Mesh object parsed from the source provided.
  90854. * @param parsedMesh is the source
  90855. * @param scene defines the hosting scene
  90856. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90857. * @returns a new Mesh
  90858. */
  90859. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90860. /**
  90861. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90862. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90863. * @param name defines the name of the mesh to create
  90864. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90865. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90866. * @param closePath creates a seam between the first and the last points of each path of the path array
  90867. * @param offset is taken in account only if the `pathArray` is containing a single path
  90868. * @param scene defines the hosting scene
  90869. * @param updatable defines if the mesh must be flagged as updatable
  90870. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90871. * @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)
  90872. * @returns a new Mesh
  90873. */
  90874. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90875. /**
  90876. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90877. * @param name defines the name of the mesh to create
  90878. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90879. * @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
  90880. * @param scene defines the hosting scene
  90881. * @param updatable defines if the mesh must be flagged as updatable
  90882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90883. * @returns a new Mesh
  90884. */
  90885. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90886. /**
  90887. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90888. * @param name defines the name of the mesh to create
  90889. * @param size sets the size (float) of each box side (default 1)
  90890. * @param scene defines the hosting scene
  90891. * @param updatable defines if the mesh must be flagged as updatable
  90892. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90893. * @returns a new Mesh
  90894. */
  90895. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90896. /**
  90897. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90898. * @param name defines the name of the mesh to create
  90899. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90900. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90901. * @param scene defines the hosting scene
  90902. * @param updatable defines if the mesh must be flagged as updatable
  90903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90904. * @returns a new Mesh
  90905. */
  90906. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90907. /**
  90908. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90909. * @param name defines the name of the mesh to create
  90910. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90911. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90912. * @param scene defines the hosting scene
  90913. * @returns a new Mesh
  90914. */
  90915. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90916. /**
  90917. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90918. * @param name defines the name of the mesh to create
  90919. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90920. * @param diameterTop set the top cap diameter (floats, default 1)
  90921. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90922. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90923. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90924. * @param scene defines the hosting scene
  90925. * @param updatable defines if the mesh must be flagged as updatable
  90926. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90927. * @returns a new Mesh
  90928. */
  90929. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90930. /**
  90931. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90932. * @param name defines the name of the mesh to create
  90933. * @param diameter sets the diameter size (float) of the torus (default 1)
  90934. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90935. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90936. * @param scene defines the hosting scene
  90937. * @param updatable defines if the mesh must be flagged as updatable
  90938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90939. * @returns a new Mesh
  90940. */
  90941. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90942. /**
  90943. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90944. * @param name defines the name of the mesh to create
  90945. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90946. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90947. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90948. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90949. * @param p the number of windings on X axis (positive integers, default 2)
  90950. * @param q the number of windings on Y axis (positive integers, default 3)
  90951. * @param scene defines the hosting scene
  90952. * @param updatable defines if the mesh must be flagged as updatable
  90953. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90954. * @returns a new Mesh
  90955. */
  90956. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90957. /**
  90958. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90959. * @param name defines the name of the mesh to create
  90960. * @param points is an array successive Vector3
  90961. * @param scene defines the hosting scene
  90962. * @param updatable defines if the mesh must be flagged as updatable
  90963. * @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).
  90964. * @returns a new Mesh
  90965. */
  90966. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90967. /**
  90968. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90969. * @param name defines the name of the mesh to create
  90970. * @param points is an array successive Vector3
  90971. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90972. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90973. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90974. * @param scene defines the hosting scene
  90975. * @param updatable defines if the mesh must be flagged as updatable
  90976. * @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)
  90977. * @returns a new Mesh
  90978. */
  90979. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90980. /**
  90981. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90982. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90983. * 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.
  90984. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90985. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90986. * Remember you can only change the shape positions, not their number when updating a polygon.
  90987. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90988. * @param name defines the name of the mesh to create
  90989. * @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
  90990. * @param scene defines the hosting scene
  90991. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90992. * @param updatable defines if the mesh must be flagged as updatable
  90993. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90994. * @param earcutInjection can be used to inject your own earcut reference
  90995. * @returns a new Mesh
  90996. */
  90997. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90998. /**
  90999. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91000. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91001. * @param name defines the name of the mesh to create
  91002. * @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
  91003. * @param depth defines the height of extrusion
  91004. * @param scene defines the hosting scene
  91005. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91006. * @param updatable defines if the mesh must be flagged as updatable
  91007. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91008. * @param earcutInjection can be used to inject your own earcut reference
  91009. * @returns a new Mesh
  91010. */
  91011. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91012. /**
  91013. * Creates an extruded shape mesh.
  91014. * 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
  91015. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91016. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91017. * @param name defines the name of the mesh to create
  91018. * @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
  91019. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91020. * @param scale is the value to scale the shape
  91021. * @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
  91022. * @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
  91023. * @param scene defines the hosting scene
  91024. * @param updatable defines if the mesh must be flagged as updatable
  91025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91026. * @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)
  91027. * @returns a new Mesh
  91028. */
  91029. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91030. /**
  91031. * Creates an custom extruded shape mesh.
  91032. * The custom extrusion is a parametric shape.
  91033. * It has no predefined shape. Its final shape will depend on the input parameters.
  91034. * Please consider using the same method from the MeshBuilder class instead
  91035. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91036. * @param name defines the name of the mesh to create
  91037. * @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
  91038. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91039. * @param scaleFunction is a custom Javascript function called on each path point
  91040. * @param rotationFunction is a custom Javascript function called on each path point
  91041. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91042. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91043. * @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
  91044. * @param scene defines the hosting scene
  91045. * @param updatable defines if the mesh must be flagged as updatable
  91046. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91047. * @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)
  91048. * @returns a new Mesh
  91049. */
  91050. 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;
  91051. /**
  91052. * Creates lathe mesh.
  91053. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91054. * Please consider using the same method from the MeshBuilder class instead
  91055. * @param name defines the name of the mesh to create
  91056. * @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
  91057. * @param radius is the radius value of the lathe
  91058. * @param tessellation is the side number of the lathe.
  91059. * @param scene defines the hosting scene
  91060. * @param updatable defines if the mesh must be flagged as updatable
  91061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91062. * @returns a new Mesh
  91063. */
  91064. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91065. /**
  91066. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91067. * @param name defines the name of the mesh to create
  91068. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91069. * @param scene defines the hosting scene
  91070. * @param updatable defines if the mesh must be flagged as updatable
  91071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91072. * @returns a new Mesh
  91073. */
  91074. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91075. /**
  91076. * Creates a ground mesh.
  91077. * Please consider using the same method from the MeshBuilder class instead
  91078. * @param name defines the name of the mesh to create
  91079. * @param width set the width of the ground
  91080. * @param height set the height of the ground
  91081. * @param subdivisions sets the number of subdivisions per side
  91082. * @param scene defines the hosting scene
  91083. * @param updatable defines if the mesh must be flagged as updatable
  91084. * @returns a new Mesh
  91085. */
  91086. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91087. /**
  91088. * Creates a tiled ground mesh.
  91089. * Please consider using the same method from the MeshBuilder class instead
  91090. * @param name defines the name of the mesh to create
  91091. * @param xmin set the ground minimum X coordinate
  91092. * @param zmin set the ground minimum Y coordinate
  91093. * @param xmax set the ground maximum X coordinate
  91094. * @param zmax set the ground maximum Z coordinate
  91095. * @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
  91096. * @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
  91097. * @param scene defines the hosting scene
  91098. * @param updatable defines if the mesh must be flagged as updatable
  91099. * @returns a new Mesh
  91100. */
  91101. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91102. w: number;
  91103. h: number;
  91104. }, precision: {
  91105. w: number;
  91106. h: number;
  91107. }, scene: Scene, updatable?: boolean): Mesh;
  91108. /**
  91109. * Creates a ground mesh from a height map.
  91110. * Please consider using the same method from the MeshBuilder class instead
  91111. * @see http://doc.babylonjs.com/babylon101/height_map
  91112. * @param name defines the name of the mesh to create
  91113. * @param url sets the URL of the height map image resource
  91114. * @param width set the ground width size
  91115. * @param height set the ground height size
  91116. * @param subdivisions sets the number of subdivision per side
  91117. * @param minHeight is the minimum altitude on the ground
  91118. * @param maxHeight is the maximum altitude on the ground
  91119. * @param scene defines the hosting scene
  91120. * @param updatable defines if the mesh must be flagged as updatable
  91121. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91122. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91123. * @returns a new Mesh
  91124. */
  91125. 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;
  91126. /**
  91127. * Creates a tube mesh.
  91128. * The tube is a parametric shape.
  91129. * It has no predefined shape. Its final shape will depend on the input parameters.
  91130. * Please consider using the same method from the MeshBuilder class instead
  91131. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91132. * @param name defines the name of the mesh to create
  91133. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91134. * @param radius sets the tube radius size
  91135. * @param tessellation is the number of sides on the tubular surface
  91136. * @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
  91137. * @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
  91138. * @param scene defines the hosting scene
  91139. * @param updatable defines if the mesh must be flagged as updatable
  91140. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91141. * @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)
  91142. * @returns a new Mesh
  91143. */
  91144. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91145. (i: number, distance: number): number;
  91146. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91147. /**
  91148. * Creates a polyhedron mesh.
  91149. * Please consider using the same method from the MeshBuilder class instead.
  91150. * * 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
  91151. * * The parameter `size` (positive float, default 1) sets the polygon size
  91152. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91153. * * 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`
  91154. * * 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
  91155. * * 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)`)
  91156. * * 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
  91157. * * 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
  91158. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91159. * * If you create a double-sided mesh, you can choose what parts of 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
  91160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91161. * @param name defines the name of the mesh to create
  91162. * @param options defines the options used to create the mesh
  91163. * @param scene defines the hosting scene
  91164. * @returns a new Mesh
  91165. */
  91166. static CreatePolyhedron(name: string, options: {
  91167. type?: number;
  91168. size?: number;
  91169. sizeX?: number;
  91170. sizeY?: number;
  91171. sizeZ?: number;
  91172. custom?: any;
  91173. faceUV?: Vector4[];
  91174. faceColors?: Color4[];
  91175. updatable?: boolean;
  91176. sideOrientation?: number;
  91177. }, scene: Scene): Mesh;
  91178. /**
  91179. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91180. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91181. * * 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`)
  91182. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91183. * * 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
  91184. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91185. * * If you create a double-sided mesh, you can choose what parts of 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
  91186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91187. * @param name defines the name of the mesh
  91188. * @param options defines the options used to create the mesh
  91189. * @param scene defines the hosting scene
  91190. * @returns a new Mesh
  91191. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91192. */
  91193. static CreateIcoSphere(name: string, options: {
  91194. radius?: number;
  91195. flat?: boolean;
  91196. subdivisions?: number;
  91197. sideOrientation?: number;
  91198. updatable?: boolean;
  91199. }, scene: Scene): Mesh;
  91200. /**
  91201. * Creates a decal mesh.
  91202. * Please consider using the same method from the MeshBuilder class instead.
  91203. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91204. * @param name defines the name of the mesh
  91205. * @param sourceMesh defines the mesh receiving the decal
  91206. * @param position sets the position of the decal in world coordinates
  91207. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91208. * @param size sets the decal scaling
  91209. * @param angle sets the angle to rotate the decal
  91210. * @returns a new Mesh
  91211. */
  91212. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91213. /**
  91214. * Prepare internal position array for software CPU skinning
  91215. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91216. */
  91217. setPositionsForCPUSkinning(): Float32Array;
  91218. /**
  91219. * Prepare internal normal array for software CPU skinning
  91220. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91221. */
  91222. setNormalsForCPUSkinning(): Float32Array;
  91223. /**
  91224. * Updates the vertex buffer by applying transformation from the bones
  91225. * @param skeleton defines the skeleton to apply to current mesh
  91226. * @returns the current mesh
  91227. */
  91228. applySkeleton(skeleton: Skeleton): Mesh;
  91229. /**
  91230. * 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
  91231. * @param meshes defines the list of meshes to scan
  91232. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91233. */
  91234. static MinMax(meshes: AbstractMesh[]): {
  91235. min: Vector3;
  91236. max: Vector3;
  91237. };
  91238. /**
  91239. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91240. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91241. * @returns a vector3
  91242. */
  91243. static Center(meshesOrMinMaxVector: {
  91244. min: Vector3;
  91245. max: Vector3;
  91246. } | AbstractMesh[]): Vector3;
  91247. /**
  91248. * Merge the array of meshes into a single mesh for performance reasons.
  91249. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91250. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91251. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91252. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91253. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91254. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91255. * @returns a new mesh
  91256. */
  91257. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91258. /** @hidden */
  91259. addInstance(instance: InstancedMesh): void;
  91260. /** @hidden */
  91261. removeInstance(instance: InstancedMesh): void;
  91262. }
  91263. }
  91264. declare module BABYLON {
  91265. /**
  91266. * This is the base class of all the camera used in the application.
  91267. * @see http://doc.babylonjs.com/features/cameras
  91268. */
  91269. export class Camera extends Node {
  91270. /** @hidden */
  91271. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91272. /**
  91273. * This is the default projection mode used by the cameras.
  91274. * It helps recreating a feeling of perspective and better appreciate depth.
  91275. * This is the best way to simulate real life cameras.
  91276. */
  91277. static readonly PERSPECTIVE_CAMERA: number;
  91278. /**
  91279. * This helps creating camera with an orthographic mode.
  91280. * 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.
  91281. */
  91282. static readonly ORTHOGRAPHIC_CAMERA: number;
  91283. /**
  91284. * This is the default FOV mode for perspective cameras.
  91285. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91286. */
  91287. static readonly FOVMODE_VERTICAL_FIXED: number;
  91288. /**
  91289. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91290. */
  91291. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91292. /**
  91293. * This specifies ther is no need for a camera rig.
  91294. * Basically only one eye is rendered corresponding to the camera.
  91295. */
  91296. static readonly RIG_MODE_NONE: number;
  91297. /**
  91298. * Simulates a camera Rig with one blue eye and one red eye.
  91299. * This can be use with 3d blue and red glasses.
  91300. */
  91301. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91302. /**
  91303. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91304. */
  91305. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91306. /**
  91307. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91308. */
  91309. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91310. /**
  91311. * Defines that both eyes of the camera will be rendered over under each other.
  91312. */
  91313. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91314. /**
  91315. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91316. */
  91317. static readonly RIG_MODE_VR: number;
  91318. /**
  91319. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91320. */
  91321. static readonly RIG_MODE_WEBVR: number;
  91322. /**
  91323. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91324. */
  91325. static readonly RIG_MODE_CUSTOM: number;
  91326. /**
  91327. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91328. */
  91329. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91330. /**
  91331. * Define the input manager associated with the camera.
  91332. */
  91333. inputs: CameraInputsManager<Camera>;
  91334. /** @hidden */
  91335. _position: Vector3;
  91336. /**
  91337. * Define the current local position of the camera in the scene
  91338. */
  91339. position: Vector3;
  91340. /**
  91341. * The vector the camera should consider as up.
  91342. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91343. */
  91344. upVector: Vector3;
  91345. /**
  91346. * Define the current limit on the left side for an orthographic camera
  91347. * In scene unit
  91348. */
  91349. orthoLeft: Nullable<number>;
  91350. /**
  91351. * Define the current limit on the right side for an orthographic camera
  91352. * In scene unit
  91353. */
  91354. orthoRight: Nullable<number>;
  91355. /**
  91356. * Define the current limit on the bottom side for an orthographic camera
  91357. * In scene unit
  91358. */
  91359. orthoBottom: Nullable<number>;
  91360. /**
  91361. * Define the current limit on the top side for an orthographic camera
  91362. * In scene unit
  91363. */
  91364. orthoTop: Nullable<number>;
  91365. /**
  91366. * Field Of View is set in Radians. (default is 0.8)
  91367. */
  91368. fov: number;
  91369. /**
  91370. * Define the minimum distance the camera can see from.
  91371. * This is important to note that the depth buffer are not infinite and the closer it starts
  91372. * the more your scene might encounter depth fighting issue.
  91373. */
  91374. minZ: number;
  91375. /**
  91376. * Define the maximum distance the camera can see to.
  91377. * This is important to note that the depth buffer are not infinite and the further it end
  91378. * the more your scene might encounter depth fighting issue.
  91379. */
  91380. maxZ: number;
  91381. /**
  91382. * Define the default inertia of the camera.
  91383. * This helps giving a smooth feeling to the camera movement.
  91384. */
  91385. inertia: number;
  91386. /**
  91387. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91388. */
  91389. mode: number;
  91390. /**
  91391. * Define wether the camera is intermediate.
  91392. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91393. */
  91394. isIntermediate: boolean;
  91395. /**
  91396. * Define the viewport of the camera.
  91397. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91398. */
  91399. viewport: Viewport;
  91400. /**
  91401. * Restricts the camera to viewing objects with the same layerMask.
  91402. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91403. */
  91404. layerMask: number;
  91405. /**
  91406. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91407. */
  91408. fovMode: number;
  91409. /**
  91410. * Rig mode of the camera.
  91411. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91412. * This is normally controlled byt the camera themselves as internal use.
  91413. */
  91414. cameraRigMode: number;
  91415. /**
  91416. * Defines the distance between both "eyes" in case of a RIG
  91417. */
  91418. interaxialDistance: number;
  91419. /**
  91420. * Defines if stereoscopic rendering is done side by side or over under.
  91421. */
  91422. isStereoscopicSideBySide: boolean;
  91423. /**
  91424. * 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
  91425. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91426. * else in the scene. (Eg. security camera)
  91427. *
  91428. * 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)
  91429. */
  91430. customRenderTargets: RenderTargetTexture[];
  91431. /**
  91432. * When set, the camera will render to this render target instead of the default canvas
  91433. *
  91434. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91435. */
  91436. outputRenderTarget: Nullable<RenderTargetTexture>;
  91437. /**
  91438. * Observable triggered when the camera view matrix has changed.
  91439. */
  91440. onViewMatrixChangedObservable: Observable<Camera>;
  91441. /**
  91442. * Observable triggered when the camera Projection matrix has changed.
  91443. */
  91444. onProjectionMatrixChangedObservable: Observable<Camera>;
  91445. /**
  91446. * Observable triggered when the inputs have been processed.
  91447. */
  91448. onAfterCheckInputsObservable: Observable<Camera>;
  91449. /**
  91450. * Observable triggered when reset has been called and applied to the camera.
  91451. */
  91452. onRestoreStateObservable: Observable<Camera>;
  91453. /** @hidden */
  91454. _cameraRigParams: any;
  91455. /** @hidden */
  91456. _rigCameras: Camera[];
  91457. /** @hidden */
  91458. _rigPostProcess: Nullable<PostProcess>;
  91459. protected _webvrViewMatrix: Matrix;
  91460. /** @hidden */
  91461. _skipRendering: boolean;
  91462. /** @hidden */
  91463. _projectionMatrix: Matrix;
  91464. /** @hidden */
  91465. _postProcesses: Nullable<PostProcess>[];
  91466. /** @hidden */
  91467. _activeMeshes: SmartArray<AbstractMesh>;
  91468. protected _globalPosition: Vector3;
  91469. /** @hidden */
  91470. _computedViewMatrix: Matrix;
  91471. private _doNotComputeProjectionMatrix;
  91472. private _transformMatrix;
  91473. private _frustumPlanes;
  91474. private _refreshFrustumPlanes;
  91475. private _storedFov;
  91476. private _stateStored;
  91477. /**
  91478. * Instantiates a new camera object.
  91479. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91480. * @see http://doc.babylonjs.com/features/cameras
  91481. * @param name Defines the name of the camera in the scene
  91482. * @param position Defines the position of the camera
  91483. * @param scene Defines the scene the camera belongs too
  91484. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91485. */
  91486. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91487. /**
  91488. * Store current camera state (fov, position, etc..)
  91489. * @returns the camera
  91490. */
  91491. storeState(): Camera;
  91492. /**
  91493. * Restores the camera state values if it has been stored. You must call storeState() first
  91494. */
  91495. protected _restoreStateValues(): boolean;
  91496. /**
  91497. * Restored camera state. You must call storeState() first.
  91498. * @returns true if restored and false otherwise
  91499. */
  91500. restoreState(): boolean;
  91501. /**
  91502. * Gets the class name of the camera.
  91503. * @returns the class name
  91504. */
  91505. getClassName(): string;
  91506. /** @hidden */
  91507. readonly _isCamera: boolean;
  91508. /**
  91509. * Gets a string representation of the camera useful for debug purpose.
  91510. * @param fullDetails Defines that a more verboe level of logging is required
  91511. * @returns the string representation
  91512. */
  91513. toString(fullDetails?: boolean): string;
  91514. /**
  91515. * Gets the current world space position of the camera.
  91516. */
  91517. readonly globalPosition: Vector3;
  91518. /**
  91519. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91520. * @returns the active meshe list
  91521. */
  91522. getActiveMeshes(): SmartArray<AbstractMesh>;
  91523. /**
  91524. * Check wether a mesh is part of the current active mesh list of the camera
  91525. * @param mesh Defines the mesh to check
  91526. * @returns true if active, false otherwise
  91527. */
  91528. isActiveMesh(mesh: Mesh): boolean;
  91529. /**
  91530. * Is this camera ready to be used/rendered
  91531. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91532. * @return true if the camera is ready
  91533. */
  91534. isReady(completeCheck?: boolean): boolean;
  91535. /** @hidden */
  91536. _initCache(): void;
  91537. /** @hidden */
  91538. _updateCache(ignoreParentClass?: boolean): void;
  91539. /** @hidden */
  91540. _isSynchronized(): boolean;
  91541. /** @hidden */
  91542. _isSynchronizedViewMatrix(): boolean;
  91543. /** @hidden */
  91544. _isSynchronizedProjectionMatrix(): boolean;
  91545. /**
  91546. * Attach the input controls to a specific dom element to get the input from.
  91547. * @param element Defines the element the controls should be listened from
  91548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91549. */
  91550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91551. /**
  91552. * Detach the current controls from the specified dom element.
  91553. * @param element Defines the element to stop listening the inputs from
  91554. */
  91555. detachControl(element: HTMLElement): void;
  91556. /**
  91557. * Update the camera state according to the different inputs gathered during the frame.
  91558. */
  91559. update(): void;
  91560. /** @hidden */
  91561. _checkInputs(): void;
  91562. /** @hidden */
  91563. readonly rigCameras: Camera[];
  91564. /**
  91565. * Gets the post process used by the rig cameras
  91566. */
  91567. readonly rigPostProcess: Nullable<PostProcess>;
  91568. /**
  91569. * Internal, gets the first post proces.
  91570. * @returns the first post process to be run on this camera.
  91571. */
  91572. _getFirstPostProcess(): Nullable<PostProcess>;
  91573. private _cascadePostProcessesToRigCams;
  91574. /**
  91575. * Attach a post process to the camera.
  91576. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91577. * @param postProcess The post process to attach to the camera
  91578. * @param insertAt The position of the post process in case several of them are in use in the scene
  91579. * @returns the position the post process has been inserted at
  91580. */
  91581. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91582. /**
  91583. * Detach a post process to the camera.
  91584. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91585. * @param postProcess The post process to detach from the camera
  91586. */
  91587. detachPostProcess(postProcess: PostProcess): void;
  91588. /**
  91589. * Gets the current world matrix of the camera
  91590. */
  91591. getWorldMatrix(): Matrix;
  91592. /** @hidden */
  91593. _getViewMatrix(): Matrix;
  91594. /**
  91595. * Gets the current view matrix of the camera.
  91596. * @param force forces the camera to recompute the matrix without looking at the cached state
  91597. * @returns the view matrix
  91598. */
  91599. getViewMatrix(force?: boolean): Matrix;
  91600. /**
  91601. * Freeze the projection matrix.
  91602. * It will prevent the cache check of the camera projection compute and can speed up perf
  91603. * if no parameter of the camera are meant to change
  91604. * @param projection Defines manually a projection if necessary
  91605. */
  91606. freezeProjectionMatrix(projection?: Matrix): void;
  91607. /**
  91608. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91609. */
  91610. unfreezeProjectionMatrix(): void;
  91611. /**
  91612. * Gets the current projection matrix of the camera.
  91613. * @param force forces the camera to recompute the matrix without looking at the cached state
  91614. * @returns the projection matrix
  91615. */
  91616. getProjectionMatrix(force?: boolean): Matrix;
  91617. /**
  91618. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91619. * @returns a Matrix
  91620. */
  91621. getTransformationMatrix(): Matrix;
  91622. private _updateFrustumPlanes;
  91623. /**
  91624. * Checks if a cullable object (mesh...) is in the camera frustum
  91625. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91626. * @param target The object to check
  91627. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91628. * @returns true if the object is in frustum otherwise false
  91629. */
  91630. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91631. /**
  91632. * Checks if a cullable object (mesh...) is in the camera frustum
  91633. * Unlike isInFrustum this cheks the full bounding box
  91634. * @param target The object to check
  91635. * @returns true if the object is in frustum otherwise false
  91636. */
  91637. isCompletelyInFrustum(target: ICullable): boolean;
  91638. /**
  91639. * Gets a ray in the forward direction from the camera.
  91640. * @param length Defines the length of the ray to create
  91641. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91642. * @param origin Defines the start point of the ray which defaults to the camera position
  91643. * @returns the forward ray
  91644. */
  91645. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91646. /**
  91647. * Releases resources associated with this node.
  91648. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91649. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91650. */
  91651. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91652. /** @hidden */
  91653. _isLeftCamera: boolean;
  91654. /**
  91655. * Gets the left camera of a rig setup in case of Rigged Camera
  91656. */
  91657. readonly isLeftCamera: boolean;
  91658. /** @hidden */
  91659. _isRightCamera: boolean;
  91660. /**
  91661. * Gets the right camera of a rig setup in case of Rigged Camera
  91662. */
  91663. readonly isRightCamera: boolean;
  91664. /**
  91665. * Gets the left camera of a rig setup in case of Rigged Camera
  91666. */
  91667. readonly leftCamera: Nullable<FreeCamera>;
  91668. /**
  91669. * Gets the right camera of a rig setup in case of Rigged Camera
  91670. */
  91671. readonly rightCamera: Nullable<FreeCamera>;
  91672. /**
  91673. * Gets the left camera target of a rig setup in case of Rigged Camera
  91674. * @returns the target position
  91675. */
  91676. getLeftTarget(): Nullable<Vector3>;
  91677. /**
  91678. * Gets the right camera target of a rig setup in case of Rigged Camera
  91679. * @returns the target position
  91680. */
  91681. getRightTarget(): Nullable<Vector3>;
  91682. /**
  91683. * @hidden
  91684. */
  91685. setCameraRigMode(mode: number, rigParams: any): void;
  91686. /** @hidden */
  91687. static _setStereoscopicRigMode(camera: Camera): void;
  91688. /** @hidden */
  91689. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91690. /** @hidden */
  91691. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91692. /** @hidden */
  91693. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91694. /** @hidden */
  91695. _getVRProjectionMatrix(): Matrix;
  91696. protected _updateCameraRotationMatrix(): void;
  91697. protected _updateWebVRCameraRotationMatrix(): void;
  91698. /**
  91699. * This function MUST be overwritten by the different WebVR cameras available.
  91700. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91701. * @hidden
  91702. */
  91703. _getWebVRProjectionMatrix(): Matrix;
  91704. /**
  91705. * This function MUST be overwritten by the different WebVR cameras available.
  91706. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91707. * @hidden
  91708. */
  91709. _getWebVRViewMatrix(): Matrix;
  91710. /** @hidden */
  91711. setCameraRigParameter(name: string, value: any): void;
  91712. /**
  91713. * needs to be overridden by children so sub has required properties to be copied
  91714. * @hidden
  91715. */
  91716. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91717. /**
  91718. * May need to be overridden by children
  91719. * @hidden
  91720. */
  91721. _updateRigCameras(): void;
  91722. /** @hidden */
  91723. _setupInputs(): void;
  91724. /**
  91725. * Serialiaze the camera setup to a json represention
  91726. * @returns the JSON representation
  91727. */
  91728. serialize(): any;
  91729. /**
  91730. * Clones the current camera.
  91731. * @param name The cloned camera name
  91732. * @returns the cloned camera
  91733. */
  91734. clone(name: string): Camera;
  91735. /**
  91736. * Gets the direction of the camera relative to a given local axis.
  91737. * @param localAxis Defines the reference axis to provide a relative direction.
  91738. * @return the direction
  91739. */
  91740. getDirection(localAxis: Vector3): Vector3;
  91741. /**
  91742. * Returns the current camera absolute rotation
  91743. */
  91744. readonly absoluteRotation: Quaternion;
  91745. /**
  91746. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91747. * @param localAxis Defines the reference axis to provide a relative direction.
  91748. * @param result Defines the vector to store the result in
  91749. */
  91750. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91751. /**
  91752. * Gets a camera constructor for a given camera type
  91753. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91754. * @param name The name of the camera the result will be able to instantiate
  91755. * @param scene The scene the result will construct the camera in
  91756. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91757. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91758. * @returns a factory method to construc the camera
  91759. */
  91760. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91761. /**
  91762. * Compute the world matrix of the camera.
  91763. * @returns the camera workd matrix
  91764. */
  91765. computeWorldMatrix(): Matrix;
  91766. /**
  91767. * Parse a JSON and creates the camera from the parsed information
  91768. * @param parsedCamera The JSON to parse
  91769. * @param scene The scene to instantiate the camera in
  91770. * @returns the newly constructed camera
  91771. */
  91772. static Parse(parsedCamera: any, scene: Scene): Camera;
  91773. }
  91774. }
  91775. declare module BABYLON {
  91776. /**
  91777. * Class containing static functions to help procedurally build meshes
  91778. */
  91779. export class DiscBuilder {
  91780. /**
  91781. * Creates a plane polygonal mesh. By default, this is a disc
  91782. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91783. * * 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
  91784. * * 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
  91785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91788. * @param name defines the name of the mesh
  91789. * @param options defines the options used to create the mesh
  91790. * @param scene defines the hosting scene
  91791. * @returns the plane polygonal mesh
  91792. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91793. */
  91794. static CreateDisc(name: string, options: {
  91795. radius?: number;
  91796. tessellation?: number;
  91797. arc?: number;
  91798. updatable?: boolean;
  91799. sideOrientation?: number;
  91800. frontUVs?: Vector4;
  91801. backUVs?: Vector4;
  91802. }, scene?: Nullable<Scene>): Mesh;
  91803. }
  91804. }
  91805. declare module BABYLON {
  91806. /**
  91807. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91808. *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.
  91809. * The SPS is also a particle system. It provides some methods to manage the particles.
  91810. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91811. *
  91812. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91813. */
  91814. export class SolidParticleSystem implements IDisposable {
  91815. /**
  91816. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91817. * Example : var p = SPS.particles[i];
  91818. */
  91819. particles: SolidParticle[];
  91820. /**
  91821. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91822. */
  91823. nbParticles: number;
  91824. /**
  91825. * If the particles must ever face the camera (default false). Useful for planar particles.
  91826. */
  91827. billboard: boolean;
  91828. /**
  91829. * Recompute normals when adding a shape
  91830. */
  91831. recomputeNormals: boolean;
  91832. /**
  91833. * This a counter ofr your own usage. It's not set by any SPS functions.
  91834. */
  91835. counter: number;
  91836. /**
  91837. * The SPS name. This name is also given to the underlying mesh.
  91838. */
  91839. name: string;
  91840. /**
  91841. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91842. */
  91843. mesh: Mesh;
  91844. /**
  91845. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91846. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91847. */
  91848. vars: any;
  91849. /**
  91850. * This array is populated when the SPS is set as 'pickable'.
  91851. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91852. * Each element of this array is an object `{idx: int, faceId: int}`.
  91853. * `idx` is the picked particle index in the `SPS.particles` array
  91854. * `faceId` is the picked face index counted within this particle.
  91855. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91856. */
  91857. pickedParticles: {
  91858. idx: number;
  91859. faceId: number;
  91860. }[];
  91861. /**
  91862. * This array is populated when `enableDepthSort` is set to true.
  91863. * Each element of this array is an instance of the class DepthSortedParticle.
  91864. */
  91865. depthSortedParticles: DepthSortedParticle[];
  91866. /**
  91867. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91868. * @hidden
  91869. */
  91870. _bSphereOnly: boolean;
  91871. /**
  91872. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91873. * @hidden
  91874. */
  91875. _bSphereRadiusFactor: number;
  91876. private _scene;
  91877. private _positions;
  91878. private _indices;
  91879. private _normals;
  91880. private _colors;
  91881. private _uvs;
  91882. private _indices32;
  91883. private _positions32;
  91884. private _normals32;
  91885. private _fixedNormal32;
  91886. private _colors32;
  91887. private _uvs32;
  91888. private _index;
  91889. private _updatable;
  91890. private _pickable;
  91891. private _isVisibilityBoxLocked;
  91892. private _alwaysVisible;
  91893. private _depthSort;
  91894. private _shapeCounter;
  91895. private _copy;
  91896. private _color;
  91897. private _computeParticleColor;
  91898. private _computeParticleTexture;
  91899. private _computeParticleRotation;
  91900. private _computeParticleVertex;
  91901. private _computeBoundingBox;
  91902. private _depthSortParticles;
  91903. private _camera;
  91904. private _mustUnrotateFixedNormals;
  91905. private _particlesIntersect;
  91906. private _needs32Bits;
  91907. /**
  91908. * Creates a SPS (Solid Particle System) object.
  91909. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91910. * @param scene (Scene) is the scene in which the SPS is added.
  91911. * @param options defines the options of the sps e.g.
  91912. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91913. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91914. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91915. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91916. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91917. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91918. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91919. */
  91920. constructor(name: string, scene: Scene, options?: {
  91921. updatable?: boolean;
  91922. isPickable?: boolean;
  91923. enableDepthSort?: boolean;
  91924. particleIntersection?: boolean;
  91925. boundingSphereOnly?: boolean;
  91926. bSphereRadiusFactor?: number;
  91927. });
  91928. /**
  91929. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91930. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91931. * @returns the created mesh
  91932. */
  91933. buildMesh(): Mesh;
  91934. /**
  91935. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91936. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91937. * Thus the particles generated from `digest()` have their property `position` set yet.
  91938. * @param mesh ( Mesh ) is the mesh to be digested
  91939. * @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
  91940. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91941. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91942. * @returns the current SPS
  91943. */
  91944. digest(mesh: Mesh, options?: {
  91945. facetNb?: number;
  91946. number?: number;
  91947. delta?: number;
  91948. }): SolidParticleSystem;
  91949. private _unrotateFixedNormals;
  91950. private _resetCopy;
  91951. private _meshBuilder;
  91952. private _posToShape;
  91953. private _uvsToShapeUV;
  91954. private _addParticle;
  91955. /**
  91956. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91957. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91958. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91959. * @param nb (positive integer) the number of particles to be created from this model
  91960. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91961. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91962. * @returns the number of shapes in the system
  91963. */
  91964. addShape(mesh: Mesh, nb: number, options?: {
  91965. positionFunction?: any;
  91966. vertexFunction?: any;
  91967. }): number;
  91968. private _rebuildParticle;
  91969. /**
  91970. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91971. * @returns the SPS.
  91972. */
  91973. rebuildMesh(): SolidParticleSystem;
  91974. /**
  91975. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91976. * This method calls `updateParticle()` for each particle of the SPS.
  91977. * For an animated SPS, it is usually called within the render loop.
  91978. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91979. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91980. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91981. * @returns the SPS.
  91982. */
  91983. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91984. /**
  91985. * Disposes the SPS.
  91986. */
  91987. dispose(): void;
  91988. /**
  91989. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91990. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91991. * @returns the SPS.
  91992. */
  91993. refreshVisibleSize(): SolidParticleSystem;
  91994. /**
  91995. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91996. * @param size the size (float) of the visibility box
  91997. * note : this doesn't lock the SPS mesh bounding box.
  91998. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91999. */
  92000. setVisibilityBox(size: number): void;
  92001. /**
  92002. * Gets whether the SPS as always visible or not
  92003. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92004. */
  92005. /**
  92006. * Sets the SPS as always visible or not
  92007. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92008. */
  92009. isAlwaysVisible: boolean;
  92010. /**
  92011. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92012. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92013. */
  92014. /**
  92015. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92016. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92017. */
  92018. isVisibilityBoxLocked: boolean;
  92019. /**
  92020. * Tells to `setParticles()` to compute the particle rotations or not.
  92021. * Default value : true. The SPS is faster when it's set to false.
  92022. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92023. */
  92024. /**
  92025. * Gets if `setParticles()` computes the particle rotations or not.
  92026. * Default value : true. The SPS is faster when it's set to false.
  92027. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92028. */
  92029. computeParticleRotation: boolean;
  92030. /**
  92031. * Tells to `setParticles()` to compute the particle colors or not.
  92032. * Default value : true. The SPS is faster when it's set to false.
  92033. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92034. */
  92035. /**
  92036. * Gets if `setParticles()` computes the particle colors or not.
  92037. * Default value : true. The SPS is faster when it's set to false.
  92038. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92039. */
  92040. computeParticleColor: boolean;
  92041. /**
  92042. * Gets if `setParticles()` computes the particle textures or not.
  92043. * Default value : true. The SPS is faster when it's set to false.
  92044. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92045. */
  92046. computeParticleTexture: boolean;
  92047. /**
  92048. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92049. * Default value : false. The SPS is faster when it's set to false.
  92050. * Note : the particle custom vertex positions aren't stored values.
  92051. */
  92052. /**
  92053. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92054. * Default value : false. The SPS is faster when it's set to false.
  92055. * Note : the particle custom vertex positions aren't stored values.
  92056. */
  92057. computeParticleVertex: boolean;
  92058. /**
  92059. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92060. */
  92061. /**
  92062. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92063. */
  92064. computeBoundingBox: boolean;
  92065. /**
  92066. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92067. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92068. * Default : `true`
  92069. */
  92070. /**
  92071. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92072. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92073. * Default : `true`
  92074. */
  92075. depthSortParticles: boolean;
  92076. /**
  92077. * This function does nothing. It may be overwritten to set all the particle first values.
  92078. * The SPS doesn't call this function, you may have to call it by your own.
  92079. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92080. */
  92081. initParticles(): void;
  92082. /**
  92083. * This function does nothing. It may be overwritten to recycle a particle.
  92084. * The SPS doesn't call this function, you may have to call it by your own.
  92085. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92086. * @param particle The particle to recycle
  92087. * @returns the recycled particle
  92088. */
  92089. recycleParticle(particle: SolidParticle): SolidParticle;
  92090. /**
  92091. * Updates a particle : this function should be overwritten by the user.
  92092. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92094. * @example : just set a particle position or velocity and recycle conditions
  92095. * @param particle The particle to update
  92096. * @returns the updated particle
  92097. */
  92098. updateParticle(particle: SolidParticle): SolidParticle;
  92099. /**
  92100. * Updates a vertex of a particle : it can be overwritten by the user.
  92101. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92102. * @param particle the current particle
  92103. * @param vertex the current index of the current particle
  92104. * @param pt the index of the current vertex in the particle shape
  92105. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92106. * @example : just set a vertex particle position
  92107. * @returns the updated vertex
  92108. */
  92109. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92110. /**
  92111. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92112. * This does nothing and may be overwritten by the user.
  92113. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92114. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92115. * @param update the boolean update value actually passed to setParticles()
  92116. */
  92117. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92118. /**
  92119. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92120. * This will be passed three parameters.
  92121. * This does nothing and may be overwritten by the user.
  92122. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92123. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92124. * @param update the boolean update value actually passed to setParticles()
  92125. */
  92126. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92127. }
  92128. }
  92129. declare module BABYLON {
  92130. /**
  92131. * Represents one particle of a solid particle system.
  92132. */
  92133. export class SolidParticle {
  92134. /**
  92135. * particle global index
  92136. */
  92137. idx: number;
  92138. /**
  92139. * The color of the particle
  92140. */
  92141. color: Nullable<Color4>;
  92142. /**
  92143. * The world space position of the particle.
  92144. */
  92145. position: Vector3;
  92146. /**
  92147. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92148. */
  92149. rotation: Vector3;
  92150. /**
  92151. * The world space rotation quaternion of the particle.
  92152. */
  92153. rotationQuaternion: Nullable<Quaternion>;
  92154. /**
  92155. * The scaling of the particle.
  92156. */
  92157. scaling: Vector3;
  92158. /**
  92159. * The uvs of the particle.
  92160. */
  92161. uvs: Vector4;
  92162. /**
  92163. * The current speed of the particle.
  92164. */
  92165. velocity: Vector3;
  92166. /**
  92167. * The pivot point in the particle local space.
  92168. */
  92169. pivot: Vector3;
  92170. /**
  92171. * Must the particle be translated from its pivot point in its local space ?
  92172. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92173. * Default : false
  92174. */
  92175. translateFromPivot: boolean;
  92176. /**
  92177. * Is the particle active or not ?
  92178. */
  92179. alive: boolean;
  92180. /**
  92181. * Is the particle visible or not ?
  92182. */
  92183. isVisible: boolean;
  92184. /**
  92185. * Index of this particle in the global "positions" array (Internal use)
  92186. * @hidden
  92187. */
  92188. _pos: number;
  92189. /**
  92190. * @hidden Index of this particle in the global "indices" array (Internal use)
  92191. */
  92192. _ind: number;
  92193. /**
  92194. * @hidden ModelShape of this particle (Internal use)
  92195. */
  92196. _model: ModelShape;
  92197. /**
  92198. * ModelShape id of this particle
  92199. */
  92200. shapeId: number;
  92201. /**
  92202. * Index of the particle in its shape id
  92203. */
  92204. idxInShape: number;
  92205. /**
  92206. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92207. */
  92208. _modelBoundingInfo: BoundingInfo;
  92209. /**
  92210. * @hidden Particle BoundingInfo object (Internal use)
  92211. */
  92212. _boundingInfo: BoundingInfo;
  92213. /**
  92214. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92215. */
  92216. _sps: SolidParticleSystem;
  92217. /**
  92218. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92219. */
  92220. _stillInvisible: boolean;
  92221. /**
  92222. * @hidden Last computed particle rotation matrix
  92223. */
  92224. _rotationMatrix: number[];
  92225. /**
  92226. * Parent particle Id, if any.
  92227. * Default null.
  92228. */
  92229. parentId: Nullable<number>;
  92230. /**
  92231. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92232. * The possible values are :
  92233. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92234. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92235. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92236. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92237. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92238. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92239. * */
  92240. cullingStrategy: number;
  92241. /**
  92242. * @hidden Internal global position in the SPS.
  92243. */
  92244. _globalPosition: Vector3;
  92245. /**
  92246. * Creates a Solid Particle object.
  92247. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92248. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92249. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92250. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92251. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92252. * @param shapeId (integer) is the model shape identifier in the SPS.
  92253. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92254. * @param sps defines the sps it is associated to
  92255. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92256. */
  92257. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92258. /**
  92259. * Legacy support, changed scale to scaling
  92260. */
  92261. /**
  92262. * Legacy support, changed scale to scaling
  92263. */
  92264. scale: Vector3;
  92265. /**
  92266. * Legacy support, changed quaternion to rotationQuaternion
  92267. */
  92268. /**
  92269. * Legacy support, changed quaternion to rotationQuaternion
  92270. */
  92271. quaternion: Nullable<Quaternion>;
  92272. /**
  92273. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92274. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92275. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92276. * @returns true if it intersects
  92277. */
  92278. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92279. /**
  92280. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92281. * A particle is in the frustum if its bounding box intersects the frustum
  92282. * @param frustumPlanes defines the frustum to test
  92283. * @returns true if the particle is in the frustum planes
  92284. */
  92285. isInFrustum(frustumPlanes: Plane[]): boolean;
  92286. /**
  92287. * get the rotation matrix of the particle
  92288. * @hidden
  92289. */
  92290. getRotationMatrix(m: Matrix): void;
  92291. }
  92292. /**
  92293. * Represents the shape of the model used by one particle of a solid particle system.
  92294. * SPS internal tool, don't use it manually.
  92295. */
  92296. export class ModelShape {
  92297. /**
  92298. * The shape id
  92299. * @hidden
  92300. */
  92301. shapeID: number;
  92302. /**
  92303. * flat array of model positions (internal use)
  92304. * @hidden
  92305. */
  92306. _shape: Vector3[];
  92307. /**
  92308. * flat array of model UVs (internal use)
  92309. * @hidden
  92310. */
  92311. _shapeUV: number[];
  92312. /**
  92313. * length of the shape in the model indices array (internal use)
  92314. * @hidden
  92315. */
  92316. _indicesLength: number;
  92317. /**
  92318. * Custom position function (internal use)
  92319. * @hidden
  92320. */
  92321. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92322. /**
  92323. * Custom vertex function (internal use)
  92324. * @hidden
  92325. */
  92326. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92327. /**
  92328. * 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.
  92329. * SPS internal tool, don't use it manually.
  92330. * @hidden
  92331. */
  92332. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  92333. }
  92334. /**
  92335. * Represents a Depth Sorted Particle in the solid particle system.
  92336. */
  92337. export class DepthSortedParticle {
  92338. /**
  92339. * Index of the particle in the "indices" array
  92340. */
  92341. ind: number;
  92342. /**
  92343. * Length of the particle shape in the "indices" array
  92344. */
  92345. indicesLength: number;
  92346. /**
  92347. * Squared distance from the particle to the camera
  92348. */
  92349. sqDistance: number;
  92350. }
  92351. }
  92352. declare module BABYLON {
  92353. /**
  92354. * @hidden
  92355. */
  92356. export class _MeshCollisionData {
  92357. _checkCollisions: boolean;
  92358. _collisionMask: number;
  92359. _collisionGroup: number;
  92360. _collider: Nullable<Collider>;
  92361. _oldPositionForCollisions: Vector3;
  92362. _diffPositionForCollisions: Vector3;
  92363. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92364. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92365. }
  92366. }
  92367. declare module BABYLON {
  92368. /** @hidden */
  92369. class _FacetDataStorage {
  92370. facetPositions: Vector3[];
  92371. facetNormals: Vector3[];
  92372. facetPartitioning: number[][];
  92373. facetNb: number;
  92374. partitioningSubdivisions: number;
  92375. partitioningBBoxRatio: number;
  92376. facetDataEnabled: boolean;
  92377. facetParameters: any;
  92378. bbSize: Vector3;
  92379. subDiv: {
  92380. max: number;
  92381. X: number;
  92382. Y: number;
  92383. Z: number;
  92384. };
  92385. facetDepthSort: boolean;
  92386. facetDepthSortEnabled: boolean;
  92387. depthSortedIndices: IndicesArray;
  92388. depthSortedFacets: {
  92389. ind: number;
  92390. sqDistance: number;
  92391. }[];
  92392. facetDepthSortFunction: (f1: {
  92393. ind: number;
  92394. sqDistance: number;
  92395. }, f2: {
  92396. ind: number;
  92397. sqDistance: number;
  92398. }) => number;
  92399. facetDepthSortFrom: Vector3;
  92400. facetDepthSortOrigin: Vector3;
  92401. invertedMatrix: Matrix;
  92402. }
  92403. /**
  92404. * @hidden
  92405. **/
  92406. class _InternalAbstractMeshDataInfo {
  92407. _hasVertexAlpha: boolean;
  92408. _useVertexColors: boolean;
  92409. _numBoneInfluencers: number;
  92410. _applyFog: boolean;
  92411. _receiveShadows: boolean;
  92412. _facetData: _FacetDataStorage;
  92413. _visibility: number;
  92414. _skeleton: Nullable<Skeleton>;
  92415. _layerMask: number;
  92416. _computeBonesUsingShaders: boolean;
  92417. _isActive: boolean;
  92418. _onlyForInstances: boolean;
  92419. _isActiveIntermediate: boolean;
  92420. _onlyForInstancesIntermediate: boolean;
  92421. }
  92422. /**
  92423. * Class used to store all common mesh properties
  92424. */
  92425. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92426. /** No occlusion */
  92427. static OCCLUSION_TYPE_NONE: number;
  92428. /** Occlusion set to optimisitic */
  92429. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92430. /** Occlusion set to strict */
  92431. static OCCLUSION_TYPE_STRICT: number;
  92432. /** Use an accurante occlusion algorithm */
  92433. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92434. /** Use a conservative occlusion algorithm */
  92435. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92436. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92437. * Test order :
  92438. * Is the bounding sphere outside the frustum ?
  92439. * If not, are the bounding box vertices outside the frustum ?
  92440. * It not, then the cullable object is in the frustum.
  92441. */
  92442. static readonly CULLINGSTRATEGY_STANDARD: number;
  92443. /** Culling strategy : Bounding Sphere Only.
  92444. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92445. * It's also less accurate than the standard because some not visible objects can still be selected.
  92446. * Test : is the bounding sphere outside the frustum ?
  92447. * If not, then the cullable object is in the frustum.
  92448. */
  92449. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92450. /** Culling strategy : Optimistic Inclusion.
  92451. * This in an inclusion test first, then the standard exclusion test.
  92452. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92453. * 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.
  92454. * Anyway, it's as accurate as the standard strategy.
  92455. * Test :
  92456. * Is the cullable object bounding sphere center in the frustum ?
  92457. * If not, apply the default culling strategy.
  92458. */
  92459. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92460. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92461. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92462. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92463. * 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.
  92464. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92465. * Test :
  92466. * Is the cullable object bounding sphere center in the frustum ?
  92467. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92468. */
  92469. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92470. /**
  92471. * No billboard
  92472. */
  92473. static readonly BILLBOARDMODE_NONE: number;
  92474. /** Billboard on X axis */
  92475. static readonly BILLBOARDMODE_X: number;
  92476. /** Billboard on Y axis */
  92477. static readonly BILLBOARDMODE_Y: number;
  92478. /** Billboard on Z axis */
  92479. static readonly BILLBOARDMODE_Z: number;
  92480. /** Billboard on all axes */
  92481. static readonly BILLBOARDMODE_ALL: number;
  92482. /** Billboard on using position instead of orientation */
  92483. static readonly BILLBOARDMODE_USE_POSITION: number;
  92484. /** @hidden */
  92485. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92486. /**
  92487. * The culling strategy to use to check whether the mesh must be rendered or not.
  92488. * This value can be changed at any time and will be used on the next render mesh selection.
  92489. * The possible values are :
  92490. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92491. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92492. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92493. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92494. * Please read each static variable documentation to get details about the culling process.
  92495. * */
  92496. cullingStrategy: number;
  92497. /**
  92498. * Gets the number of facets in the mesh
  92499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92500. */
  92501. readonly facetNb: number;
  92502. /**
  92503. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92505. */
  92506. partitioningSubdivisions: number;
  92507. /**
  92508. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92509. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92511. */
  92512. partitioningBBoxRatio: number;
  92513. /**
  92514. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92515. * Works only for updatable meshes.
  92516. * Doesn't work with multi-materials
  92517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92518. */
  92519. mustDepthSortFacets: boolean;
  92520. /**
  92521. * The location (Vector3) where the facet depth sort must be computed from.
  92522. * By default, the active camera position.
  92523. * Used only when facet depth sort is enabled
  92524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92525. */
  92526. facetDepthSortFrom: Vector3;
  92527. /**
  92528. * gets a boolean indicating if facetData is enabled
  92529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92530. */
  92531. readonly isFacetDataEnabled: boolean;
  92532. /** @hidden */
  92533. _updateNonUniformScalingState(value: boolean): boolean;
  92534. /**
  92535. * An event triggered when this mesh collides with another one
  92536. */
  92537. onCollideObservable: Observable<AbstractMesh>;
  92538. /** Set a function to call when this mesh collides with another one */
  92539. onCollide: () => void;
  92540. /**
  92541. * An event triggered when the collision's position changes
  92542. */
  92543. onCollisionPositionChangeObservable: Observable<Vector3>;
  92544. /** Set a function to call when the collision's position changes */
  92545. onCollisionPositionChange: () => void;
  92546. /**
  92547. * An event triggered when material is changed
  92548. */
  92549. onMaterialChangedObservable: Observable<AbstractMesh>;
  92550. /**
  92551. * Gets or sets the orientation for POV movement & rotation
  92552. */
  92553. definedFacingForward: boolean;
  92554. /** @hidden */
  92555. _occlusionQuery: Nullable<WebGLQuery>;
  92556. /** @hidden */
  92557. _renderingGroup: Nullable<RenderingGroup>;
  92558. /**
  92559. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92560. */
  92561. /**
  92562. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92563. */
  92564. visibility: number;
  92565. /** Gets or sets the alpha index used to sort transparent meshes
  92566. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92567. */
  92568. alphaIndex: number;
  92569. /**
  92570. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92571. */
  92572. isVisible: boolean;
  92573. /**
  92574. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92575. */
  92576. isPickable: boolean;
  92577. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92578. showSubMeshesBoundingBox: boolean;
  92579. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92580. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92581. */
  92582. isBlocker: boolean;
  92583. /**
  92584. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92585. */
  92586. enablePointerMoveEvents: boolean;
  92587. /**
  92588. * Specifies the rendering group id for this mesh (0 by default)
  92589. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92590. */
  92591. renderingGroupId: number;
  92592. private _material;
  92593. /** Gets or sets current material */
  92594. material: Nullable<Material>;
  92595. /**
  92596. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92597. * @see http://doc.babylonjs.com/babylon101/shadows
  92598. */
  92599. receiveShadows: boolean;
  92600. /** Defines color to use when rendering outline */
  92601. outlineColor: Color3;
  92602. /** Define width to use when rendering outline */
  92603. outlineWidth: number;
  92604. /** Defines color to use when rendering overlay */
  92605. overlayColor: Color3;
  92606. /** Defines alpha to use when rendering overlay */
  92607. overlayAlpha: number;
  92608. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92609. hasVertexAlpha: boolean;
  92610. /** 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) */
  92611. useVertexColors: boolean;
  92612. /**
  92613. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92614. */
  92615. computeBonesUsingShaders: boolean;
  92616. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92617. numBoneInfluencers: number;
  92618. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92619. applyFog: boolean;
  92620. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92621. useOctreeForRenderingSelection: boolean;
  92622. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92623. useOctreeForPicking: boolean;
  92624. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92625. useOctreeForCollisions: boolean;
  92626. /**
  92627. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92628. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92629. */
  92630. layerMask: number;
  92631. /**
  92632. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92633. */
  92634. alwaysSelectAsActiveMesh: boolean;
  92635. /**
  92636. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92637. */
  92638. doNotSyncBoundingInfo: boolean;
  92639. /**
  92640. * Gets or sets the current action manager
  92641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92642. */
  92643. actionManager: Nullable<AbstractActionManager>;
  92644. private _meshCollisionData;
  92645. /**
  92646. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92647. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92648. */
  92649. ellipsoid: Vector3;
  92650. /**
  92651. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92652. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92653. */
  92654. ellipsoidOffset: Vector3;
  92655. /**
  92656. * Gets or sets a collision mask used to mask collisions (default is -1).
  92657. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92658. */
  92659. collisionMask: number;
  92660. /**
  92661. * Gets or sets the current collision group mask (-1 by default).
  92662. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92663. */
  92664. collisionGroup: number;
  92665. /**
  92666. * Defines edge width used when edgesRenderer is enabled
  92667. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92668. */
  92669. edgesWidth: number;
  92670. /**
  92671. * Defines edge color used when edgesRenderer is enabled
  92672. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92673. */
  92674. edgesColor: Color4;
  92675. /** @hidden */
  92676. _edgesRenderer: Nullable<IEdgesRenderer>;
  92677. /** @hidden */
  92678. _masterMesh: Nullable<AbstractMesh>;
  92679. /** @hidden */
  92680. _boundingInfo: Nullable<BoundingInfo>;
  92681. /** @hidden */
  92682. _renderId: number;
  92683. /**
  92684. * Gets or sets the list of subMeshes
  92685. * @see http://doc.babylonjs.com/how_to/multi_materials
  92686. */
  92687. subMeshes: SubMesh[];
  92688. /** @hidden */
  92689. _intersectionsInProgress: AbstractMesh[];
  92690. /** @hidden */
  92691. _unIndexed: boolean;
  92692. /** @hidden */
  92693. _lightSources: Light[];
  92694. /** Gets the list of lights affecting that mesh */
  92695. readonly lightSources: Light[];
  92696. /** @hidden */
  92697. readonly _positions: Nullable<Vector3[]>;
  92698. /** @hidden */
  92699. _waitingData: {
  92700. lods: Nullable<any>;
  92701. actions: Nullable<any>;
  92702. freezeWorldMatrix: Nullable<boolean>;
  92703. };
  92704. /** @hidden */
  92705. _bonesTransformMatrices: Nullable<Float32Array>;
  92706. /** @hidden */
  92707. _transformMatrixTexture: Nullable<RawTexture>;
  92708. /**
  92709. * Gets or sets a skeleton to apply skining transformations
  92710. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92711. */
  92712. skeleton: Nullable<Skeleton>;
  92713. /**
  92714. * An event triggered when the mesh is rebuilt.
  92715. */
  92716. onRebuildObservable: Observable<AbstractMesh>;
  92717. /**
  92718. * Creates a new AbstractMesh
  92719. * @param name defines the name of the mesh
  92720. * @param scene defines the hosting scene
  92721. */
  92722. constructor(name: string, scene?: Nullable<Scene>);
  92723. /**
  92724. * Returns the string "AbstractMesh"
  92725. * @returns "AbstractMesh"
  92726. */
  92727. getClassName(): string;
  92728. /**
  92729. * Gets a string representation of the current mesh
  92730. * @param fullDetails defines a boolean indicating if full details must be included
  92731. * @returns a string representation of the current mesh
  92732. */
  92733. toString(fullDetails?: boolean): string;
  92734. /**
  92735. * @hidden
  92736. */
  92737. protected _getEffectiveParent(): Nullable<Node>;
  92738. /** @hidden */
  92739. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92740. /** @hidden */
  92741. _rebuild(): void;
  92742. /** @hidden */
  92743. _resyncLightSources(): void;
  92744. /** @hidden */
  92745. _resyncLighSource(light: Light): void;
  92746. /** @hidden */
  92747. _unBindEffect(): void;
  92748. /** @hidden */
  92749. _removeLightSource(light: Light, dispose: boolean): void;
  92750. private _markSubMeshesAsDirty;
  92751. /** @hidden */
  92752. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92753. /** @hidden */
  92754. _markSubMeshesAsAttributesDirty(): void;
  92755. /** @hidden */
  92756. _markSubMeshesAsMiscDirty(): void;
  92757. /**
  92758. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92759. */
  92760. scaling: Vector3;
  92761. /**
  92762. * Returns true if the mesh is blocked. Implemented by child classes
  92763. */
  92764. readonly isBlocked: boolean;
  92765. /**
  92766. * Returns the mesh itself by default. Implemented by child classes
  92767. * @param camera defines the camera to use to pick the right LOD level
  92768. * @returns the currentAbstractMesh
  92769. */
  92770. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92771. /**
  92772. * Returns 0 by default. Implemented by child classes
  92773. * @returns an integer
  92774. */
  92775. getTotalVertices(): number;
  92776. /**
  92777. * Returns a positive integer : the total number of indices in this mesh geometry.
  92778. * @returns the numner of indices or zero if the mesh has no geometry.
  92779. */
  92780. getTotalIndices(): number;
  92781. /**
  92782. * Returns null by default. Implemented by child classes
  92783. * @returns null
  92784. */
  92785. getIndices(): Nullable<IndicesArray>;
  92786. /**
  92787. * Returns the array of the requested vertex data kind. Implemented by child classes
  92788. * @param kind defines the vertex data kind to use
  92789. * @returns null
  92790. */
  92791. getVerticesData(kind: string): Nullable<FloatArray>;
  92792. /**
  92793. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92794. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92795. * Note that a new underlying VertexBuffer object is created each call.
  92796. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92797. * @param kind defines vertex data kind:
  92798. * * VertexBuffer.PositionKind
  92799. * * VertexBuffer.UVKind
  92800. * * VertexBuffer.UV2Kind
  92801. * * VertexBuffer.UV3Kind
  92802. * * VertexBuffer.UV4Kind
  92803. * * VertexBuffer.UV5Kind
  92804. * * VertexBuffer.UV6Kind
  92805. * * VertexBuffer.ColorKind
  92806. * * VertexBuffer.MatricesIndicesKind
  92807. * * VertexBuffer.MatricesIndicesExtraKind
  92808. * * VertexBuffer.MatricesWeightsKind
  92809. * * VertexBuffer.MatricesWeightsExtraKind
  92810. * @param data defines the data source
  92811. * @param updatable defines if the data must be flagged as updatable (or static)
  92812. * @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
  92813. * @returns the current mesh
  92814. */
  92815. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92816. /**
  92817. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92818. * If the mesh has no geometry, it is simply returned as it is.
  92819. * @param kind defines vertex data kind:
  92820. * * VertexBuffer.PositionKind
  92821. * * VertexBuffer.UVKind
  92822. * * VertexBuffer.UV2Kind
  92823. * * VertexBuffer.UV3Kind
  92824. * * VertexBuffer.UV4Kind
  92825. * * VertexBuffer.UV5Kind
  92826. * * VertexBuffer.UV6Kind
  92827. * * VertexBuffer.ColorKind
  92828. * * VertexBuffer.MatricesIndicesKind
  92829. * * VertexBuffer.MatricesIndicesExtraKind
  92830. * * VertexBuffer.MatricesWeightsKind
  92831. * * VertexBuffer.MatricesWeightsExtraKind
  92832. * @param data defines the data source
  92833. * @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
  92834. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92835. * @returns the current mesh
  92836. */
  92837. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92838. /**
  92839. * Sets the mesh indices,
  92840. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92841. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92842. * @param totalVertices Defines the total number of vertices
  92843. * @returns the current mesh
  92844. */
  92845. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92846. /**
  92847. * Gets a boolean indicating if specific vertex data is present
  92848. * @param kind defines the vertex data kind to use
  92849. * @returns true is data kind is present
  92850. */
  92851. isVerticesDataPresent(kind: string): boolean;
  92852. /**
  92853. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92854. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92855. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92856. * @returns a BoundingInfo
  92857. */
  92858. getBoundingInfo(): BoundingInfo;
  92859. /**
  92860. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92861. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92862. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92863. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92864. * @returns the current mesh
  92865. */
  92866. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92867. /**
  92868. * Overwrite the current bounding info
  92869. * @param boundingInfo defines the new bounding info
  92870. * @returns the current mesh
  92871. */
  92872. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92873. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92874. readonly useBones: boolean;
  92875. /** @hidden */
  92876. _preActivate(): void;
  92877. /** @hidden */
  92878. _preActivateForIntermediateRendering(renderId: number): void;
  92879. /** @hidden */
  92880. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92881. /** @hidden */
  92882. _postActivate(): void;
  92883. /** @hidden */
  92884. _freeze(): void;
  92885. /** @hidden */
  92886. _unFreeze(): void;
  92887. /**
  92888. * Gets the current world matrix
  92889. * @returns a Matrix
  92890. */
  92891. getWorldMatrix(): Matrix;
  92892. /** @hidden */
  92893. _getWorldMatrixDeterminant(): number;
  92894. /**
  92895. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92896. */
  92897. readonly isAnInstance: boolean;
  92898. /**
  92899. * Gets a boolean indicating if this mesh has instances
  92900. */
  92901. readonly hasInstances: boolean;
  92902. /**
  92903. * Perform relative position change from the point of view of behind the front of the mesh.
  92904. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92905. * Supports definition of mesh facing forward or backward
  92906. * @param amountRight defines the distance on the right axis
  92907. * @param amountUp defines the distance on the up axis
  92908. * @param amountForward defines the distance on the forward axis
  92909. * @returns the current mesh
  92910. */
  92911. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92912. /**
  92913. * Calculate relative position change from the point of view of behind the front of the mesh.
  92914. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92915. * Supports definition of mesh facing forward or backward
  92916. * @param amountRight defines the distance on the right axis
  92917. * @param amountUp defines the distance on the up axis
  92918. * @param amountForward defines the distance on the forward axis
  92919. * @returns the new displacement vector
  92920. */
  92921. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92922. /**
  92923. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92924. * Supports definition of mesh facing forward or backward
  92925. * @param flipBack defines the flip
  92926. * @param twirlClockwise defines the twirl
  92927. * @param tiltRight defines the tilt
  92928. * @returns the current mesh
  92929. */
  92930. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92931. /**
  92932. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92933. * Supports definition of mesh facing forward or backward.
  92934. * @param flipBack defines the flip
  92935. * @param twirlClockwise defines the twirl
  92936. * @param tiltRight defines the tilt
  92937. * @returns the new rotation vector
  92938. */
  92939. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92940. /**
  92941. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92942. * This means the mesh underlying bounding box and sphere are recomputed.
  92943. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92944. * @returns the current mesh
  92945. */
  92946. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92947. /** @hidden */
  92948. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92949. /** @hidden */
  92950. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92951. /** @hidden */
  92952. _updateBoundingInfo(): AbstractMesh;
  92953. /** @hidden */
  92954. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92955. /** @hidden */
  92956. protected _afterComputeWorldMatrix(): void;
  92957. /** @hidden */
  92958. readonly _effectiveMesh: AbstractMesh;
  92959. /**
  92960. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92961. * A mesh is in the frustum if its bounding box intersects the frustum
  92962. * @param frustumPlanes defines the frustum to test
  92963. * @returns true if the mesh is in the frustum planes
  92964. */
  92965. isInFrustum(frustumPlanes: Plane[]): boolean;
  92966. /**
  92967. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92968. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92969. * @param frustumPlanes defines the frustum to test
  92970. * @returns true if the mesh is completely in the frustum planes
  92971. */
  92972. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92973. /**
  92974. * True if the mesh intersects another mesh or a SolidParticle object
  92975. * @param mesh defines a target mesh or SolidParticle to test
  92976. * @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)
  92977. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92978. * @returns true if there is an intersection
  92979. */
  92980. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92981. /**
  92982. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92983. * @param point defines the point to test
  92984. * @returns true if there is an intersection
  92985. */
  92986. intersectsPoint(point: Vector3): boolean;
  92987. /**
  92988. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92990. */
  92991. checkCollisions: boolean;
  92992. /**
  92993. * Gets Collider object used to compute collisions (not physics)
  92994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92995. */
  92996. readonly collider: Nullable<Collider>;
  92997. /**
  92998. * Move the mesh using collision engine
  92999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93000. * @param displacement defines the requested displacement vector
  93001. * @returns the current mesh
  93002. */
  93003. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93004. private _onCollisionPositionChange;
  93005. /** @hidden */
  93006. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93007. /** @hidden */
  93008. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93009. /** @hidden */
  93010. _checkCollision(collider: Collider): AbstractMesh;
  93011. /** @hidden */
  93012. _generatePointsArray(): boolean;
  93013. /**
  93014. * Checks if the passed Ray intersects with the mesh
  93015. * @param ray defines the ray to use
  93016. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93018. * @returns the picking info
  93019. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93020. */
  93021. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93022. /**
  93023. * Clones the current mesh
  93024. * @param name defines the mesh name
  93025. * @param newParent defines the new mesh parent
  93026. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93027. * @returns the new mesh
  93028. */
  93029. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93030. /**
  93031. * Disposes all the submeshes of the current meshnp
  93032. * @returns the current mesh
  93033. */
  93034. releaseSubMeshes(): AbstractMesh;
  93035. /**
  93036. * Releases resources associated with this abstract mesh.
  93037. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93038. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93039. */
  93040. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93041. /**
  93042. * Adds the passed mesh as a child to the current mesh
  93043. * @param mesh defines the child mesh
  93044. * @returns the current mesh
  93045. */
  93046. addChild(mesh: AbstractMesh): AbstractMesh;
  93047. /**
  93048. * Removes the passed mesh from the current mesh children list
  93049. * @param mesh defines the child mesh
  93050. * @returns the current mesh
  93051. */
  93052. removeChild(mesh: AbstractMesh): AbstractMesh;
  93053. /** @hidden */
  93054. private _initFacetData;
  93055. /**
  93056. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93057. * This method can be called within the render loop.
  93058. * 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
  93059. * @returns the current mesh
  93060. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93061. */
  93062. updateFacetData(): AbstractMesh;
  93063. /**
  93064. * Returns the facetLocalNormals array.
  93065. * The normals are expressed in the mesh local spac
  93066. * @returns an array of Vector3
  93067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93068. */
  93069. getFacetLocalNormals(): Vector3[];
  93070. /**
  93071. * Returns the facetLocalPositions array.
  93072. * The facet positions are expressed in the mesh local space
  93073. * @returns an array of Vector3
  93074. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93075. */
  93076. getFacetLocalPositions(): Vector3[];
  93077. /**
  93078. * Returns the facetLocalPartioning array
  93079. * @returns an array of array of numbers
  93080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93081. */
  93082. getFacetLocalPartitioning(): number[][];
  93083. /**
  93084. * Returns the i-th facet position in the world system.
  93085. * This method allocates a new Vector3 per call
  93086. * @param i defines the facet index
  93087. * @returns a new Vector3
  93088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93089. */
  93090. getFacetPosition(i: number): Vector3;
  93091. /**
  93092. * Sets the reference Vector3 with the i-th facet position in the world system
  93093. * @param i defines the facet index
  93094. * @param ref defines the target vector
  93095. * @returns the current mesh
  93096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93097. */
  93098. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93099. /**
  93100. * Returns the i-th facet normal in the world system.
  93101. * This method allocates a new Vector3 per call
  93102. * @param i defines the facet index
  93103. * @returns a new Vector3
  93104. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93105. */
  93106. getFacetNormal(i: number): Vector3;
  93107. /**
  93108. * Sets the reference Vector3 with the i-th facet normal in the world system
  93109. * @param i defines the facet index
  93110. * @param ref defines the target vector
  93111. * @returns the current mesh
  93112. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93113. */
  93114. getFacetNormalToRef(i: number, ref: Vector3): this;
  93115. /**
  93116. * 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)
  93117. * @param x defines x coordinate
  93118. * @param y defines y coordinate
  93119. * @param z defines z coordinate
  93120. * @returns the array of facet indexes
  93121. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93122. */
  93123. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93124. /**
  93125. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93126. * @param projected sets as the (x,y,z) world projection on the facet
  93127. * @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
  93128. * @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
  93129. * @param x defines x coordinate
  93130. * @param y defines y coordinate
  93131. * @param z defines z coordinate
  93132. * @returns the face index if found (or null instead)
  93133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93134. */
  93135. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93136. /**
  93137. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93138. * @param projected sets as the (x,y,z) local projection on the facet
  93139. * @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
  93140. * @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
  93141. * @param x defines x coordinate
  93142. * @param y defines y coordinate
  93143. * @param z defines z coordinate
  93144. * @returns the face index if found (or null instead)
  93145. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93146. */
  93147. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93148. /**
  93149. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93150. * @returns the parameters
  93151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93152. */
  93153. getFacetDataParameters(): any;
  93154. /**
  93155. * Disables the feature FacetData and frees the related memory
  93156. * @returns the current mesh
  93157. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93158. */
  93159. disableFacetData(): AbstractMesh;
  93160. /**
  93161. * Updates the AbstractMesh indices array
  93162. * @param indices defines the data source
  93163. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93164. * @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)
  93165. * @returns the current mesh
  93166. */
  93167. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93168. /**
  93169. * Creates new normals data for the mesh
  93170. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93171. * @returns the current mesh
  93172. */
  93173. createNormals(updatable: boolean): AbstractMesh;
  93174. /**
  93175. * Align the mesh with a normal
  93176. * @param normal defines the normal to use
  93177. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93178. * @returns the current mesh
  93179. */
  93180. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93181. /** @hidden */
  93182. _checkOcclusionQuery(): boolean;
  93183. /**
  93184. * Disables the mesh edge rendering mode
  93185. * @returns the currentAbstractMesh
  93186. */
  93187. disableEdgesRendering(): AbstractMesh;
  93188. /**
  93189. * Enables the edge rendering mode on the mesh.
  93190. * This mode makes the mesh edges visible
  93191. * @param epsilon defines the maximal distance between two angles to detect a face
  93192. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93193. * @returns the currentAbstractMesh
  93194. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93195. */
  93196. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93197. }
  93198. }
  93199. declare module BABYLON {
  93200. /**
  93201. * Interface used to define ActionEvent
  93202. */
  93203. export interface IActionEvent {
  93204. /** The mesh or sprite that triggered the action */
  93205. source: any;
  93206. /** The X mouse cursor position at the time of the event */
  93207. pointerX: number;
  93208. /** The Y mouse cursor position at the time of the event */
  93209. pointerY: number;
  93210. /** The mesh that is currently pointed at (can be null) */
  93211. meshUnderPointer: Nullable<AbstractMesh>;
  93212. /** the original (browser) event that triggered the ActionEvent */
  93213. sourceEvent?: any;
  93214. /** additional data for the event */
  93215. additionalData?: any;
  93216. }
  93217. /**
  93218. * ActionEvent is the event being sent when an action is triggered.
  93219. */
  93220. export class ActionEvent implements IActionEvent {
  93221. /** The mesh or sprite that triggered the action */
  93222. source: any;
  93223. /** The X mouse cursor position at the time of the event */
  93224. pointerX: number;
  93225. /** The Y mouse cursor position at the time of the event */
  93226. pointerY: number;
  93227. /** The mesh that is currently pointed at (can be null) */
  93228. meshUnderPointer: Nullable<AbstractMesh>;
  93229. /** the original (browser) event that triggered the ActionEvent */
  93230. sourceEvent?: any;
  93231. /** additional data for the event */
  93232. additionalData?: any;
  93233. /**
  93234. * Creates a new ActionEvent
  93235. * @param source The mesh or sprite that triggered the action
  93236. * @param pointerX The X mouse cursor position at the time of the event
  93237. * @param pointerY The Y mouse cursor position at the time of the event
  93238. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93239. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93240. * @param additionalData additional data for the event
  93241. */
  93242. constructor(
  93243. /** The mesh or sprite that triggered the action */
  93244. source: any,
  93245. /** The X mouse cursor position at the time of the event */
  93246. pointerX: number,
  93247. /** The Y mouse cursor position at the time of the event */
  93248. pointerY: number,
  93249. /** The mesh that is currently pointed at (can be null) */
  93250. meshUnderPointer: Nullable<AbstractMesh>,
  93251. /** the original (browser) event that triggered the ActionEvent */
  93252. sourceEvent?: any,
  93253. /** additional data for the event */
  93254. additionalData?: any);
  93255. /**
  93256. * Helper function to auto-create an ActionEvent from a source mesh.
  93257. * @param source The source mesh that triggered the event
  93258. * @param evt The original (browser) event
  93259. * @param additionalData additional data for the event
  93260. * @returns the new ActionEvent
  93261. */
  93262. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93263. /**
  93264. * Helper function to auto-create an ActionEvent from a source sprite
  93265. * @param source The source sprite that triggered the event
  93266. * @param scene Scene associated with the sprite
  93267. * @param evt The original (browser) event
  93268. * @param additionalData additional data for the event
  93269. * @returns the new ActionEvent
  93270. */
  93271. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93272. /**
  93273. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93274. * @param scene the scene where the event occurred
  93275. * @param evt The original (browser) event
  93276. * @returns the new ActionEvent
  93277. */
  93278. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93279. /**
  93280. * Helper function to auto-create an ActionEvent from a primitive
  93281. * @param prim defines the target primitive
  93282. * @param pointerPos defines the pointer position
  93283. * @param evt The original (browser) event
  93284. * @param additionalData additional data for the event
  93285. * @returns the new ActionEvent
  93286. */
  93287. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93288. }
  93289. }
  93290. declare module BABYLON {
  93291. /**
  93292. * Abstract class used to decouple action Manager from scene and meshes.
  93293. * Do not instantiate.
  93294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93295. */
  93296. export abstract class AbstractActionManager implements IDisposable {
  93297. /** Gets the list of active triggers */
  93298. static Triggers: {
  93299. [key: string]: number;
  93300. };
  93301. /** Gets the cursor to use when hovering items */
  93302. hoverCursor: string;
  93303. /** Gets the list of actions */
  93304. actions: IAction[];
  93305. /**
  93306. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93307. */
  93308. isRecursive: boolean;
  93309. /**
  93310. * Releases all associated resources
  93311. */
  93312. abstract dispose(): void;
  93313. /**
  93314. * Does this action manager has pointer triggers
  93315. */
  93316. abstract readonly hasPointerTriggers: boolean;
  93317. /**
  93318. * Does this action manager has pick triggers
  93319. */
  93320. abstract readonly hasPickTriggers: boolean;
  93321. /**
  93322. * Process a specific trigger
  93323. * @param trigger defines the trigger to process
  93324. * @param evt defines the event details to be processed
  93325. */
  93326. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93327. /**
  93328. * Does this action manager handles actions of any of the given triggers
  93329. * @param triggers defines the triggers to be tested
  93330. * @return a boolean indicating whether one (or more) of the triggers is handled
  93331. */
  93332. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93333. /**
  93334. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93335. * speed.
  93336. * @param triggerA defines the trigger to be tested
  93337. * @param triggerB defines the trigger to be tested
  93338. * @return a boolean indicating whether one (or more) of the triggers is handled
  93339. */
  93340. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93341. /**
  93342. * Does this action manager handles actions of a given trigger
  93343. * @param trigger defines the trigger to be tested
  93344. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93345. * @return whether the trigger is handled
  93346. */
  93347. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93348. /**
  93349. * Serialize this manager to a JSON object
  93350. * @param name defines the property name to store this manager
  93351. * @returns a JSON representation of this manager
  93352. */
  93353. abstract serialize(name: string): any;
  93354. /**
  93355. * Registers an action to this action manager
  93356. * @param action defines the action to be registered
  93357. * @return the action amended (prepared) after registration
  93358. */
  93359. abstract registerAction(action: IAction): Nullable<IAction>;
  93360. /**
  93361. * Unregisters an action to this action manager
  93362. * @param action defines the action to be unregistered
  93363. * @return a boolean indicating whether the action has been unregistered
  93364. */
  93365. abstract unregisterAction(action: IAction): Boolean;
  93366. /**
  93367. * Does exist one action manager with at least one trigger
  93368. **/
  93369. static readonly HasTriggers: boolean;
  93370. /**
  93371. * Does exist one action manager with at least one pick trigger
  93372. **/
  93373. static readonly HasPickTriggers: boolean;
  93374. /**
  93375. * Does exist one action manager that handles actions of a given trigger
  93376. * @param trigger defines the trigger to be tested
  93377. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93378. **/
  93379. static HasSpecificTrigger(trigger: number): boolean;
  93380. }
  93381. }
  93382. declare module BABYLON {
  93383. /**
  93384. * Defines how a node can be built from a string name.
  93385. */
  93386. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93387. /**
  93388. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93389. */
  93390. export class Node implements IBehaviorAware<Node> {
  93391. /** @hidden */
  93392. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93393. private static _NodeConstructors;
  93394. /**
  93395. * Add a new node constructor
  93396. * @param type defines the type name of the node to construct
  93397. * @param constructorFunc defines the constructor function
  93398. */
  93399. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93400. /**
  93401. * Returns a node constructor based on type name
  93402. * @param type defines the type name
  93403. * @param name defines the new node name
  93404. * @param scene defines the hosting scene
  93405. * @param options defines optional options to transmit to constructors
  93406. * @returns the new constructor or null
  93407. */
  93408. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93409. /**
  93410. * Gets or sets the name of the node
  93411. */
  93412. name: string;
  93413. /**
  93414. * Gets or sets the id of the node
  93415. */
  93416. id: string;
  93417. /**
  93418. * Gets or sets the unique id of the node
  93419. */
  93420. uniqueId: number;
  93421. /**
  93422. * Gets or sets a string used to store user defined state for the node
  93423. */
  93424. state: string;
  93425. /**
  93426. * Gets or sets an object used to store user defined information for the node
  93427. */
  93428. metadata: any;
  93429. /**
  93430. * For internal use only. Please do not use.
  93431. */
  93432. reservedDataStore: any;
  93433. /**
  93434. * List of inspectable custom properties (used by the Inspector)
  93435. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93436. */
  93437. inspectableCustomProperties: IInspectable[];
  93438. /**
  93439. * Gets or sets a boolean used to define if the node must be serialized
  93440. */
  93441. doNotSerialize: boolean;
  93442. /** @hidden */
  93443. _isDisposed: boolean;
  93444. /**
  93445. * Gets a list of Animations associated with the node
  93446. */
  93447. animations: Animation[];
  93448. protected _ranges: {
  93449. [name: string]: Nullable<AnimationRange>;
  93450. };
  93451. /**
  93452. * Callback raised when the node is ready to be used
  93453. */
  93454. onReady: Nullable<(node: Node) => void>;
  93455. private _isEnabled;
  93456. private _isParentEnabled;
  93457. private _isReady;
  93458. /** @hidden */
  93459. _currentRenderId: number;
  93460. private _parentUpdateId;
  93461. /** @hidden */
  93462. _childUpdateId: number;
  93463. /** @hidden */
  93464. _waitingParentId: Nullable<string>;
  93465. /** @hidden */
  93466. _scene: Scene;
  93467. /** @hidden */
  93468. _cache: any;
  93469. private _parentNode;
  93470. private _children;
  93471. /** @hidden */
  93472. _worldMatrix: Matrix;
  93473. /** @hidden */
  93474. _worldMatrixDeterminant: number;
  93475. /** @hidden */
  93476. _worldMatrixDeterminantIsDirty: boolean;
  93477. /** @hidden */
  93478. private _sceneRootNodesIndex;
  93479. /**
  93480. * Gets a boolean indicating if the node has been disposed
  93481. * @returns true if the node was disposed
  93482. */
  93483. isDisposed(): boolean;
  93484. /**
  93485. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93486. * @see https://doc.babylonjs.com/how_to/parenting
  93487. */
  93488. parent: Nullable<Node>;
  93489. private addToSceneRootNodes;
  93490. private removeFromSceneRootNodes;
  93491. private _animationPropertiesOverride;
  93492. /**
  93493. * Gets or sets the animation properties override
  93494. */
  93495. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93496. /**
  93497. * Gets a string idenfifying the name of the class
  93498. * @returns "Node" string
  93499. */
  93500. getClassName(): string;
  93501. /** @hidden */
  93502. readonly _isNode: boolean;
  93503. /**
  93504. * An event triggered when the mesh is disposed
  93505. */
  93506. onDisposeObservable: Observable<Node>;
  93507. private _onDisposeObserver;
  93508. /**
  93509. * Sets a callback that will be raised when the node will be disposed
  93510. */
  93511. onDispose: () => void;
  93512. /**
  93513. * Creates a new Node
  93514. * @param name the name and id to be given to this node
  93515. * @param scene the scene this node will be added to
  93516. * @param addToRootNodes the node will be added to scene.rootNodes
  93517. */
  93518. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93519. /**
  93520. * Gets the scene of the node
  93521. * @returns a scene
  93522. */
  93523. getScene(): Scene;
  93524. /**
  93525. * Gets the engine of the node
  93526. * @returns a Engine
  93527. */
  93528. getEngine(): Engine;
  93529. private _behaviors;
  93530. /**
  93531. * Attach a behavior to the node
  93532. * @see http://doc.babylonjs.com/features/behaviour
  93533. * @param behavior defines the behavior to attach
  93534. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93535. * @returns the current Node
  93536. */
  93537. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93538. /**
  93539. * Remove an attached behavior
  93540. * @see http://doc.babylonjs.com/features/behaviour
  93541. * @param behavior defines the behavior to attach
  93542. * @returns the current Node
  93543. */
  93544. removeBehavior(behavior: Behavior<Node>): Node;
  93545. /**
  93546. * Gets the list of attached behaviors
  93547. * @see http://doc.babylonjs.com/features/behaviour
  93548. */
  93549. readonly behaviors: Behavior<Node>[];
  93550. /**
  93551. * Gets an attached behavior by name
  93552. * @param name defines the name of the behavior to look for
  93553. * @see http://doc.babylonjs.com/features/behaviour
  93554. * @returns null if behavior was not found else the requested behavior
  93555. */
  93556. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93557. /**
  93558. * Returns the latest update of the World matrix
  93559. * @returns a Matrix
  93560. */
  93561. getWorldMatrix(): Matrix;
  93562. /** @hidden */
  93563. _getWorldMatrixDeterminant(): number;
  93564. /**
  93565. * Returns directly the latest state of the mesh World matrix.
  93566. * A Matrix is returned.
  93567. */
  93568. readonly worldMatrixFromCache: Matrix;
  93569. /** @hidden */
  93570. _initCache(): void;
  93571. /** @hidden */
  93572. updateCache(force?: boolean): void;
  93573. /** @hidden */
  93574. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93575. /** @hidden */
  93576. _updateCache(ignoreParentClass?: boolean): void;
  93577. /** @hidden */
  93578. _isSynchronized(): boolean;
  93579. /** @hidden */
  93580. _markSyncedWithParent(): void;
  93581. /** @hidden */
  93582. isSynchronizedWithParent(): boolean;
  93583. /** @hidden */
  93584. isSynchronized(): boolean;
  93585. /**
  93586. * Is this node ready to be used/rendered
  93587. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93588. * @return true if the node is ready
  93589. */
  93590. isReady(completeCheck?: boolean): boolean;
  93591. /**
  93592. * Is this node enabled?
  93593. * 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
  93594. * @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
  93595. * @return whether this node (and its parent) is enabled
  93596. */
  93597. isEnabled(checkAncestors?: boolean): boolean;
  93598. /** @hidden */
  93599. protected _syncParentEnabledState(): void;
  93600. /**
  93601. * Set the enabled state of this node
  93602. * @param value defines the new enabled state
  93603. */
  93604. setEnabled(value: boolean): void;
  93605. /**
  93606. * Is this node a descendant of the given node?
  93607. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93608. * @param ancestor defines the parent node to inspect
  93609. * @returns a boolean indicating if this node is a descendant of the given node
  93610. */
  93611. isDescendantOf(ancestor: Node): boolean;
  93612. /** @hidden */
  93613. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93614. /**
  93615. * Will return all nodes that have this node as ascendant
  93616. * @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
  93617. * @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
  93618. * @return all children nodes of all types
  93619. */
  93620. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93621. /**
  93622. * Get all child-meshes of this node
  93623. * @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)
  93624. * @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
  93625. * @returns an array of AbstractMesh
  93626. */
  93627. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93628. /**
  93629. * Get all direct children of this node
  93630. * @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
  93631. * @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)
  93632. * @returns an array of Node
  93633. */
  93634. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93635. /** @hidden */
  93636. _setReady(state: boolean): void;
  93637. /**
  93638. * Get an animation by name
  93639. * @param name defines the name of the animation to look for
  93640. * @returns null if not found else the requested animation
  93641. */
  93642. getAnimationByName(name: string): Nullable<Animation>;
  93643. /**
  93644. * Creates an animation range for this node
  93645. * @param name defines the name of the range
  93646. * @param from defines the starting key
  93647. * @param to defines the end key
  93648. */
  93649. createAnimationRange(name: string, from: number, to: number): void;
  93650. /**
  93651. * Delete a specific animation range
  93652. * @param name defines the name of the range to delete
  93653. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93654. */
  93655. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93656. /**
  93657. * Get an animation range by name
  93658. * @param name defines the name of the animation range to look for
  93659. * @returns null if not found else the requested animation range
  93660. */
  93661. getAnimationRange(name: string): Nullable<AnimationRange>;
  93662. /**
  93663. * Gets the list of all animation ranges defined on this node
  93664. * @returns an array
  93665. */
  93666. getAnimationRanges(): Nullable<AnimationRange>[];
  93667. /**
  93668. * Will start the animation sequence
  93669. * @param name defines the range frames for animation sequence
  93670. * @param loop defines if the animation should loop (false by default)
  93671. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93672. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93673. * @returns the object created for this animation. If range does not exist, it will return null
  93674. */
  93675. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93676. /**
  93677. * Serialize animation ranges into a JSON compatible object
  93678. * @returns serialization object
  93679. */
  93680. serializeAnimationRanges(): any;
  93681. /**
  93682. * Computes the world matrix of the node
  93683. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93684. * @returns the world matrix
  93685. */
  93686. computeWorldMatrix(force?: boolean): Matrix;
  93687. /**
  93688. * Releases resources associated with this node.
  93689. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93690. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93691. */
  93692. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93693. /**
  93694. * Parse animation range data from a serialization object and store them into a given node
  93695. * @param node defines where to store the animation ranges
  93696. * @param parsedNode defines the serialization object to read data from
  93697. * @param scene defines the hosting scene
  93698. */
  93699. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93700. /**
  93701. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93702. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93703. * @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
  93704. * @returns the new bounding vectors
  93705. */
  93706. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93707. min: Vector3;
  93708. max: Vector3;
  93709. };
  93710. }
  93711. }
  93712. declare module BABYLON {
  93713. /**
  93714. * @hidden
  93715. */
  93716. export class _IAnimationState {
  93717. key: number;
  93718. repeatCount: number;
  93719. workValue?: any;
  93720. loopMode?: number;
  93721. offsetValue?: any;
  93722. highLimitValue?: any;
  93723. }
  93724. /**
  93725. * Class used to store any kind of animation
  93726. */
  93727. export class Animation {
  93728. /**Name of the animation */
  93729. name: string;
  93730. /**Property to animate */
  93731. targetProperty: string;
  93732. /**The frames per second of the animation */
  93733. framePerSecond: number;
  93734. /**The data type of the animation */
  93735. dataType: number;
  93736. /**The loop mode of the animation */
  93737. loopMode?: number | undefined;
  93738. /**Specifies if blending should be enabled */
  93739. enableBlending?: boolean | undefined;
  93740. /**
  93741. * Use matrix interpolation instead of using direct key value when animating matrices
  93742. */
  93743. static AllowMatricesInterpolation: boolean;
  93744. /**
  93745. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93746. */
  93747. static AllowMatrixDecomposeForInterpolation: boolean;
  93748. /**
  93749. * Stores the key frames of the animation
  93750. */
  93751. private _keys;
  93752. /**
  93753. * Stores the easing function of the animation
  93754. */
  93755. private _easingFunction;
  93756. /**
  93757. * @hidden Internal use only
  93758. */
  93759. _runtimeAnimations: RuntimeAnimation[];
  93760. /**
  93761. * The set of event that will be linked to this animation
  93762. */
  93763. private _events;
  93764. /**
  93765. * Stores an array of target property paths
  93766. */
  93767. targetPropertyPath: string[];
  93768. /**
  93769. * Stores the blending speed of the animation
  93770. */
  93771. blendingSpeed: number;
  93772. /**
  93773. * Stores the animation ranges for the animation
  93774. */
  93775. private _ranges;
  93776. /**
  93777. * @hidden Internal use
  93778. */
  93779. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93780. /**
  93781. * Sets up an animation
  93782. * @param property The property to animate
  93783. * @param animationType The animation type to apply
  93784. * @param framePerSecond The frames per second of the animation
  93785. * @param easingFunction The easing function used in the animation
  93786. * @returns The created animation
  93787. */
  93788. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93789. /**
  93790. * Create and start an animation on a node
  93791. * @param name defines the name of the global animation that will be run on all nodes
  93792. * @param node defines the root node where the animation will take place
  93793. * @param targetProperty defines property to animate
  93794. * @param framePerSecond defines the number of frame per second yo use
  93795. * @param totalFrame defines the number of frames in total
  93796. * @param from defines the initial value
  93797. * @param to defines the final value
  93798. * @param loopMode defines which loop mode you want to use (off by default)
  93799. * @param easingFunction defines the easing function to use (linear by default)
  93800. * @param onAnimationEnd defines the callback to call when animation end
  93801. * @returns the animatable created for this animation
  93802. */
  93803. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93804. /**
  93805. * Create and start an animation on a node and its descendants
  93806. * @param name defines the name of the global animation that will be run on all nodes
  93807. * @param node defines the root node where the animation will take place
  93808. * @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
  93809. * @param targetProperty defines property to animate
  93810. * @param framePerSecond defines the number of frame per second to use
  93811. * @param totalFrame defines the number of frames in total
  93812. * @param from defines the initial value
  93813. * @param to defines the final value
  93814. * @param loopMode defines which loop mode you want to use (off by default)
  93815. * @param easingFunction defines the easing function to use (linear by default)
  93816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93817. * @returns the list of animatables created for all nodes
  93818. * @example https://www.babylonjs-playground.com/#MH0VLI
  93819. */
  93820. 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[]>;
  93821. /**
  93822. * Creates a new animation, merges it with the existing animations and starts it
  93823. * @param name Name of the animation
  93824. * @param node Node which contains the scene that begins the animations
  93825. * @param targetProperty Specifies which property to animate
  93826. * @param framePerSecond The frames per second of the animation
  93827. * @param totalFrame The total number of frames
  93828. * @param from The frame at the beginning of the animation
  93829. * @param to The frame at the end of the animation
  93830. * @param loopMode Specifies the loop mode of the animation
  93831. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93832. * @param onAnimationEnd Callback to run once the animation is complete
  93833. * @returns Nullable animation
  93834. */
  93835. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93836. /**
  93837. * Transition property of an host to the target Value
  93838. * @param property The property to transition
  93839. * @param targetValue The target Value of the property
  93840. * @param host The object where the property to animate belongs
  93841. * @param scene Scene used to run the animation
  93842. * @param frameRate Framerate (in frame/s) to use
  93843. * @param transition The transition type we want to use
  93844. * @param duration The duration of the animation, in milliseconds
  93845. * @param onAnimationEnd Callback trigger at the end of the animation
  93846. * @returns Nullable animation
  93847. */
  93848. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93849. /**
  93850. * Return the array of runtime animations currently using this animation
  93851. */
  93852. readonly runtimeAnimations: RuntimeAnimation[];
  93853. /**
  93854. * Specifies if any of the runtime animations are currently running
  93855. */
  93856. readonly hasRunningRuntimeAnimations: boolean;
  93857. /**
  93858. * Initializes the animation
  93859. * @param name Name of the animation
  93860. * @param targetProperty Property to animate
  93861. * @param framePerSecond The frames per second of the animation
  93862. * @param dataType The data type of the animation
  93863. * @param loopMode The loop mode of the animation
  93864. * @param enableBlending Specifies if blending should be enabled
  93865. */
  93866. constructor(
  93867. /**Name of the animation */
  93868. name: string,
  93869. /**Property to animate */
  93870. targetProperty: string,
  93871. /**The frames per second of the animation */
  93872. framePerSecond: number,
  93873. /**The data type of the animation */
  93874. dataType: number,
  93875. /**The loop mode of the animation */
  93876. loopMode?: number | undefined,
  93877. /**Specifies if blending should be enabled */
  93878. enableBlending?: boolean | undefined);
  93879. /**
  93880. * Converts the animation to a string
  93881. * @param fullDetails support for multiple levels of logging within scene loading
  93882. * @returns String form of the animation
  93883. */
  93884. toString(fullDetails?: boolean): string;
  93885. /**
  93886. * Add an event to this animation
  93887. * @param event Event to add
  93888. */
  93889. addEvent(event: AnimationEvent): void;
  93890. /**
  93891. * Remove all events found at the given frame
  93892. * @param frame The frame to remove events from
  93893. */
  93894. removeEvents(frame: number): void;
  93895. /**
  93896. * Retrieves all the events from the animation
  93897. * @returns Events from the animation
  93898. */
  93899. getEvents(): AnimationEvent[];
  93900. /**
  93901. * Creates an animation range
  93902. * @param name Name of the animation range
  93903. * @param from Starting frame of the animation range
  93904. * @param to Ending frame of the animation
  93905. */
  93906. createRange(name: string, from: number, to: number): void;
  93907. /**
  93908. * Deletes an animation range by name
  93909. * @param name Name of the animation range to delete
  93910. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93911. */
  93912. deleteRange(name: string, deleteFrames?: boolean): void;
  93913. /**
  93914. * Gets the animation range by name, or null if not defined
  93915. * @param name Name of the animation range
  93916. * @returns Nullable animation range
  93917. */
  93918. getRange(name: string): Nullable<AnimationRange>;
  93919. /**
  93920. * Gets the key frames from the animation
  93921. * @returns The key frames of the animation
  93922. */
  93923. getKeys(): Array<IAnimationKey>;
  93924. /**
  93925. * Gets the highest frame rate of the animation
  93926. * @returns Highest frame rate of the animation
  93927. */
  93928. getHighestFrame(): number;
  93929. /**
  93930. * Gets the easing function of the animation
  93931. * @returns Easing function of the animation
  93932. */
  93933. getEasingFunction(): IEasingFunction;
  93934. /**
  93935. * Sets the easing function of the animation
  93936. * @param easingFunction A custom mathematical formula for animation
  93937. */
  93938. setEasingFunction(easingFunction: EasingFunction): void;
  93939. /**
  93940. * Interpolates a scalar linearly
  93941. * @param startValue Start value of the animation curve
  93942. * @param endValue End value of the animation curve
  93943. * @param gradient Scalar amount to interpolate
  93944. * @returns Interpolated scalar value
  93945. */
  93946. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93947. /**
  93948. * Interpolates a scalar cubically
  93949. * @param startValue Start value of the animation curve
  93950. * @param outTangent End tangent of the animation
  93951. * @param endValue End value of the animation curve
  93952. * @param inTangent Start tangent of the animation curve
  93953. * @param gradient Scalar amount to interpolate
  93954. * @returns Interpolated scalar value
  93955. */
  93956. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93957. /**
  93958. * Interpolates a quaternion using a spherical linear interpolation
  93959. * @param startValue Start value of the animation curve
  93960. * @param endValue End value of the animation curve
  93961. * @param gradient Scalar amount to interpolate
  93962. * @returns Interpolated quaternion value
  93963. */
  93964. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93965. /**
  93966. * Interpolates a quaternion cubically
  93967. * @param startValue Start value of the animation curve
  93968. * @param outTangent End tangent of the animation curve
  93969. * @param endValue End value of the animation curve
  93970. * @param inTangent Start tangent of the animation curve
  93971. * @param gradient Scalar amount to interpolate
  93972. * @returns Interpolated quaternion value
  93973. */
  93974. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93975. /**
  93976. * Interpolates a Vector3 linearl
  93977. * @param startValue Start value of the animation curve
  93978. * @param endValue End value of the animation curve
  93979. * @param gradient Scalar amount to interpolate
  93980. * @returns Interpolated scalar value
  93981. */
  93982. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93983. /**
  93984. * Interpolates a Vector3 cubically
  93985. * @param startValue Start value of the animation curve
  93986. * @param outTangent End tangent of the animation
  93987. * @param endValue End value of the animation curve
  93988. * @param inTangent Start tangent of the animation curve
  93989. * @param gradient Scalar amount to interpolate
  93990. * @returns InterpolatedVector3 value
  93991. */
  93992. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93993. /**
  93994. * Interpolates a Vector2 linearly
  93995. * @param startValue Start value of the animation curve
  93996. * @param endValue End value of the animation curve
  93997. * @param gradient Scalar amount to interpolate
  93998. * @returns Interpolated Vector2 value
  93999. */
  94000. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94001. /**
  94002. * Interpolates a Vector2 cubically
  94003. * @param startValue Start value of the animation curve
  94004. * @param outTangent End tangent of the animation
  94005. * @param endValue End value of the animation curve
  94006. * @param inTangent Start tangent of the animation curve
  94007. * @param gradient Scalar amount to interpolate
  94008. * @returns Interpolated Vector2 value
  94009. */
  94010. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94011. /**
  94012. * Interpolates a size linearly
  94013. * @param startValue Start value of the animation curve
  94014. * @param endValue End value of the animation curve
  94015. * @param gradient Scalar amount to interpolate
  94016. * @returns Interpolated Size value
  94017. */
  94018. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94019. /**
  94020. * Interpolates a Color3 linearly
  94021. * @param startValue Start value of the animation curve
  94022. * @param endValue End value of the animation curve
  94023. * @param gradient Scalar amount to interpolate
  94024. * @returns Interpolated Color3 value
  94025. */
  94026. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94027. /**
  94028. * @hidden Internal use only
  94029. */
  94030. _getKeyValue(value: any): any;
  94031. /**
  94032. * @hidden Internal use only
  94033. */
  94034. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94035. /**
  94036. * Defines the function to use to interpolate matrices
  94037. * @param startValue defines the start matrix
  94038. * @param endValue defines the end matrix
  94039. * @param gradient defines the gradient between both matrices
  94040. * @param result defines an optional target matrix where to store the interpolation
  94041. * @returns the interpolated matrix
  94042. */
  94043. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94044. /**
  94045. * Makes a copy of the animation
  94046. * @returns Cloned animation
  94047. */
  94048. clone(): Animation;
  94049. /**
  94050. * Sets the key frames of the animation
  94051. * @param values The animation key frames to set
  94052. */
  94053. setKeys(values: Array<IAnimationKey>): void;
  94054. /**
  94055. * Serializes the animation to an object
  94056. * @returns Serialized object
  94057. */
  94058. serialize(): any;
  94059. /**
  94060. * Float animation type
  94061. */
  94062. private static _ANIMATIONTYPE_FLOAT;
  94063. /**
  94064. * Vector3 animation type
  94065. */
  94066. private static _ANIMATIONTYPE_VECTOR3;
  94067. /**
  94068. * Quaternion animation type
  94069. */
  94070. private static _ANIMATIONTYPE_QUATERNION;
  94071. /**
  94072. * Matrix animation type
  94073. */
  94074. private static _ANIMATIONTYPE_MATRIX;
  94075. /**
  94076. * Color3 animation type
  94077. */
  94078. private static _ANIMATIONTYPE_COLOR3;
  94079. /**
  94080. * Vector2 animation type
  94081. */
  94082. private static _ANIMATIONTYPE_VECTOR2;
  94083. /**
  94084. * Size animation type
  94085. */
  94086. private static _ANIMATIONTYPE_SIZE;
  94087. /**
  94088. * Relative Loop Mode
  94089. */
  94090. private static _ANIMATIONLOOPMODE_RELATIVE;
  94091. /**
  94092. * Cycle Loop Mode
  94093. */
  94094. private static _ANIMATIONLOOPMODE_CYCLE;
  94095. /**
  94096. * Constant Loop Mode
  94097. */
  94098. private static _ANIMATIONLOOPMODE_CONSTANT;
  94099. /**
  94100. * Get the float animation type
  94101. */
  94102. static readonly ANIMATIONTYPE_FLOAT: number;
  94103. /**
  94104. * Get the Vector3 animation type
  94105. */
  94106. static readonly ANIMATIONTYPE_VECTOR3: number;
  94107. /**
  94108. * Get the Vector2 animation type
  94109. */
  94110. static readonly ANIMATIONTYPE_VECTOR2: number;
  94111. /**
  94112. * Get the Size animation type
  94113. */
  94114. static readonly ANIMATIONTYPE_SIZE: number;
  94115. /**
  94116. * Get the Quaternion animation type
  94117. */
  94118. static readonly ANIMATIONTYPE_QUATERNION: number;
  94119. /**
  94120. * Get the Matrix animation type
  94121. */
  94122. static readonly ANIMATIONTYPE_MATRIX: number;
  94123. /**
  94124. * Get the Color3 animation type
  94125. */
  94126. static readonly ANIMATIONTYPE_COLOR3: number;
  94127. /**
  94128. * Get the Relative Loop Mode
  94129. */
  94130. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94131. /**
  94132. * Get the Cycle Loop Mode
  94133. */
  94134. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94135. /**
  94136. * Get the Constant Loop Mode
  94137. */
  94138. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94139. /** @hidden */
  94140. static _UniversalLerp(left: any, right: any, amount: number): any;
  94141. /**
  94142. * Parses an animation object and creates an animation
  94143. * @param parsedAnimation Parsed animation object
  94144. * @returns Animation object
  94145. */
  94146. static Parse(parsedAnimation: any): Animation;
  94147. /**
  94148. * Appends the serialized animations from the source animations
  94149. * @param source Source containing the animations
  94150. * @param destination Target to store the animations
  94151. */
  94152. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94153. }
  94154. }
  94155. declare module BABYLON {
  94156. /**
  94157. * Interface containing an array of animations
  94158. */
  94159. export interface IAnimatable {
  94160. /**
  94161. * Array of animations
  94162. */
  94163. animations: Nullable<Array<Animation>>;
  94164. }
  94165. }
  94166. declare module BABYLON {
  94167. /**
  94168. * This represents all the required information to add a fresnel effect on a material:
  94169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94170. */
  94171. export class FresnelParameters {
  94172. private _isEnabled;
  94173. /**
  94174. * Define if the fresnel effect is enable or not.
  94175. */
  94176. isEnabled: boolean;
  94177. /**
  94178. * Define the color used on edges (grazing angle)
  94179. */
  94180. leftColor: Color3;
  94181. /**
  94182. * Define the color used on center
  94183. */
  94184. rightColor: Color3;
  94185. /**
  94186. * Define bias applied to computed fresnel term
  94187. */
  94188. bias: number;
  94189. /**
  94190. * Defined the power exponent applied to fresnel term
  94191. */
  94192. power: number;
  94193. /**
  94194. * Clones the current fresnel and its valuues
  94195. * @returns a clone fresnel configuration
  94196. */
  94197. clone(): FresnelParameters;
  94198. /**
  94199. * Serializes the current fresnel parameters to a JSON representation.
  94200. * @return the JSON serialization
  94201. */
  94202. serialize(): any;
  94203. /**
  94204. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94205. * @param parsedFresnelParameters Define the JSON representation
  94206. * @returns the parsed parameters
  94207. */
  94208. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94209. }
  94210. }
  94211. declare module BABYLON {
  94212. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94213. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94214. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94215. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94216. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94217. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94218. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94219. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94220. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94221. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94222. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94223. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94224. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94225. /**
  94226. * Decorator used to define property that can be serialized as reference to a camera
  94227. * @param sourceName defines the name of the property to decorate
  94228. */
  94229. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94230. /**
  94231. * Class used to help serialization objects
  94232. */
  94233. export class SerializationHelper {
  94234. /** @hidden */
  94235. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94236. /** @hidden */
  94237. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94238. /** @hidden */
  94239. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94240. /** @hidden */
  94241. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94242. /**
  94243. * Appends the serialized animations from the source animations
  94244. * @param source Source containing the animations
  94245. * @param destination Target to store the animations
  94246. */
  94247. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94248. /**
  94249. * Static function used to serialized a specific entity
  94250. * @param entity defines the entity to serialize
  94251. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94252. * @returns a JSON compatible object representing the serialization of the entity
  94253. */
  94254. static Serialize<T>(entity: T, serializationObject?: any): any;
  94255. /**
  94256. * Creates a new entity from a serialization data object
  94257. * @param creationFunction defines a function used to instanciated the new entity
  94258. * @param source defines the source serialization data
  94259. * @param scene defines the hosting scene
  94260. * @param rootUrl defines the root url for resources
  94261. * @returns a new entity
  94262. */
  94263. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94264. /**
  94265. * Clones an object
  94266. * @param creationFunction defines the function used to instanciate the new object
  94267. * @param source defines the source object
  94268. * @returns the cloned object
  94269. */
  94270. static Clone<T>(creationFunction: () => T, source: T): T;
  94271. /**
  94272. * Instanciates a new object based on a source one (some data will be shared between both object)
  94273. * @param creationFunction defines the function used to instanciate the new object
  94274. * @param source defines the source object
  94275. * @returns the new object
  94276. */
  94277. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94278. }
  94279. }
  94280. declare module BABYLON {
  94281. /**
  94282. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94283. */
  94284. export interface CubeMapInfo {
  94285. /**
  94286. * The pixel array for the front face.
  94287. * This is stored in format, left to right, up to down format.
  94288. */
  94289. front: Nullable<ArrayBufferView>;
  94290. /**
  94291. * The pixel array for the back face.
  94292. * This is stored in format, left to right, up to down format.
  94293. */
  94294. back: Nullable<ArrayBufferView>;
  94295. /**
  94296. * The pixel array for the left face.
  94297. * This is stored in format, left to right, up to down format.
  94298. */
  94299. left: Nullable<ArrayBufferView>;
  94300. /**
  94301. * The pixel array for the right face.
  94302. * This is stored in format, left to right, up to down format.
  94303. */
  94304. right: Nullable<ArrayBufferView>;
  94305. /**
  94306. * The pixel array for the up face.
  94307. * This is stored in format, left to right, up to down format.
  94308. */
  94309. up: Nullable<ArrayBufferView>;
  94310. /**
  94311. * The pixel array for the down face.
  94312. * This is stored in format, left to right, up to down format.
  94313. */
  94314. down: Nullable<ArrayBufferView>;
  94315. /**
  94316. * The size of the cubemap stored.
  94317. *
  94318. * Each faces will be size * size pixels.
  94319. */
  94320. size: number;
  94321. /**
  94322. * The format of the texture.
  94323. *
  94324. * RGBA, RGB.
  94325. */
  94326. format: number;
  94327. /**
  94328. * The type of the texture data.
  94329. *
  94330. * UNSIGNED_INT, FLOAT.
  94331. */
  94332. type: number;
  94333. /**
  94334. * Specifies whether the texture is in gamma space.
  94335. */
  94336. gammaSpace: boolean;
  94337. }
  94338. /**
  94339. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94340. */
  94341. export class PanoramaToCubeMapTools {
  94342. private static FACE_FRONT;
  94343. private static FACE_BACK;
  94344. private static FACE_RIGHT;
  94345. private static FACE_LEFT;
  94346. private static FACE_DOWN;
  94347. private static FACE_UP;
  94348. /**
  94349. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94350. *
  94351. * @param float32Array The source data.
  94352. * @param inputWidth The width of the input panorama.
  94353. * @param inputHeight The height of the input panorama.
  94354. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94355. * @return The cubemap data
  94356. */
  94357. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94358. private static CreateCubemapTexture;
  94359. private static CalcProjectionSpherical;
  94360. }
  94361. }
  94362. declare module BABYLON {
  94363. /**
  94364. * Helper class dealing with the extraction of spherical polynomial dataArray
  94365. * from a cube map.
  94366. */
  94367. export class CubeMapToSphericalPolynomialTools {
  94368. private static FileFaces;
  94369. /**
  94370. * Converts a texture to the according Spherical Polynomial data.
  94371. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94372. *
  94373. * @param texture The texture to extract the information from.
  94374. * @return The Spherical Polynomial data.
  94375. */
  94376. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94377. /**
  94378. * Converts a cubemap to the according Spherical Polynomial data.
  94379. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94380. *
  94381. * @param cubeInfo The Cube map to extract the information from.
  94382. * @return The Spherical Polynomial data.
  94383. */
  94384. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94385. }
  94386. }
  94387. declare module BABYLON {
  94388. /**
  94389. * Class used to manipulate GUIDs
  94390. */
  94391. export class GUID {
  94392. /**
  94393. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94394. * Be aware Math.random() could cause collisions, but:
  94395. * "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"
  94396. * @returns a pseudo random id
  94397. */
  94398. static RandomId(): string;
  94399. }
  94400. }
  94401. declare module BABYLON {
  94402. /**
  94403. * Base class of all the textures in babylon.
  94404. * It groups all the common properties the materials, post process, lights... might need
  94405. * in order to make a correct use of the texture.
  94406. */
  94407. export class BaseTexture implements IAnimatable {
  94408. /**
  94409. * Default anisotropic filtering level for the application.
  94410. * It is set to 4 as a good tradeoff between perf and quality.
  94411. */
  94412. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94413. /**
  94414. * Gets or sets the unique id of the texture
  94415. */
  94416. uniqueId: number;
  94417. /**
  94418. * Define the name of the texture.
  94419. */
  94420. name: string;
  94421. /**
  94422. * Gets or sets an object used to store user defined information.
  94423. */
  94424. metadata: any;
  94425. /**
  94426. * For internal use only. Please do not use.
  94427. */
  94428. reservedDataStore: any;
  94429. private _hasAlpha;
  94430. /**
  94431. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94432. */
  94433. hasAlpha: boolean;
  94434. /**
  94435. * Defines if the alpha value should be determined via the rgb values.
  94436. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94437. */
  94438. getAlphaFromRGB: boolean;
  94439. /**
  94440. * Intensity or strength of the texture.
  94441. * It is commonly used by materials to fine tune the intensity of the texture
  94442. */
  94443. level: number;
  94444. /**
  94445. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94446. * This is part of the texture as textures usually maps to one uv set.
  94447. */
  94448. coordinatesIndex: number;
  94449. private _coordinatesMode;
  94450. /**
  94451. * How a texture is mapped.
  94452. *
  94453. * | Value | Type | Description |
  94454. * | ----- | ----------------------------------- | ----------- |
  94455. * | 0 | EXPLICIT_MODE | |
  94456. * | 1 | SPHERICAL_MODE | |
  94457. * | 2 | PLANAR_MODE | |
  94458. * | 3 | CUBIC_MODE | |
  94459. * | 4 | PROJECTION_MODE | |
  94460. * | 5 | SKYBOX_MODE | |
  94461. * | 6 | INVCUBIC_MODE | |
  94462. * | 7 | EQUIRECTANGULAR_MODE | |
  94463. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94464. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94465. */
  94466. coordinatesMode: number;
  94467. /**
  94468. * | Value | Type | Description |
  94469. * | ----- | ------------------ | ----------- |
  94470. * | 0 | CLAMP_ADDRESSMODE | |
  94471. * | 1 | WRAP_ADDRESSMODE | |
  94472. * | 2 | MIRROR_ADDRESSMODE | |
  94473. */
  94474. wrapU: number;
  94475. /**
  94476. * | Value | Type | Description |
  94477. * | ----- | ------------------ | ----------- |
  94478. * | 0 | CLAMP_ADDRESSMODE | |
  94479. * | 1 | WRAP_ADDRESSMODE | |
  94480. * | 2 | MIRROR_ADDRESSMODE | |
  94481. */
  94482. wrapV: number;
  94483. /**
  94484. * | Value | Type | Description |
  94485. * | ----- | ------------------ | ----------- |
  94486. * | 0 | CLAMP_ADDRESSMODE | |
  94487. * | 1 | WRAP_ADDRESSMODE | |
  94488. * | 2 | MIRROR_ADDRESSMODE | |
  94489. */
  94490. wrapR: number;
  94491. /**
  94492. * With compliant hardware and browser (supporting anisotropic filtering)
  94493. * this defines the level of anisotropic filtering in the texture.
  94494. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94495. */
  94496. anisotropicFilteringLevel: number;
  94497. /**
  94498. * Define if the texture is a cube texture or if false a 2d texture.
  94499. */
  94500. isCube: boolean;
  94501. /**
  94502. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94503. */
  94504. is3D: boolean;
  94505. /**
  94506. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94507. * HDR texture are usually stored in linear space.
  94508. * This only impacts the PBR and Background materials
  94509. */
  94510. gammaSpace: boolean;
  94511. /**
  94512. * Gets or sets whether or not the texture contains RGBD data.
  94513. */
  94514. isRGBD: boolean;
  94515. /**
  94516. * Is Z inverted in the texture (useful in a cube texture).
  94517. */
  94518. invertZ: boolean;
  94519. /**
  94520. * Are mip maps generated for this texture or not.
  94521. */
  94522. readonly noMipmap: boolean;
  94523. /**
  94524. * @hidden
  94525. */
  94526. lodLevelInAlpha: boolean;
  94527. /**
  94528. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94529. */
  94530. lodGenerationOffset: number;
  94531. /**
  94532. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94533. */
  94534. lodGenerationScale: number;
  94535. /**
  94536. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94537. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94538. * average roughness values.
  94539. */
  94540. linearSpecularLOD: boolean;
  94541. /**
  94542. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94543. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94544. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94545. */
  94546. irradianceTexture: Nullable<BaseTexture>;
  94547. /**
  94548. * Define if the texture is a render target.
  94549. */
  94550. isRenderTarget: boolean;
  94551. /**
  94552. * Define the unique id of the texture in the scene.
  94553. */
  94554. readonly uid: string;
  94555. /**
  94556. * Return a string representation of the texture.
  94557. * @returns the texture as a string
  94558. */
  94559. toString(): string;
  94560. /**
  94561. * Get the class name of the texture.
  94562. * @returns "BaseTexture"
  94563. */
  94564. getClassName(): string;
  94565. /**
  94566. * Define the list of animation attached to the texture.
  94567. */
  94568. animations: Animation[];
  94569. /**
  94570. * An event triggered when the texture is disposed.
  94571. */
  94572. onDisposeObservable: Observable<BaseTexture>;
  94573. private _onDisposeObserver;
  94574. /**
  94575. * Callback triggered when the texture has been disposed.
  94576. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94577. */
  94578. onDispose: () => void;
  94579. /**
  94580. * Define the current state of the loading sequence when in delayed load mode.
  94581. */
  94582. delayLoadState: number;
  94583. private _scene;
  94584. /** @hidden */
  94585. _texture: Nullable<InternalTexture>;
  94586. private _uid;
  94587. /**
  94588. * Define if the texture is preventinga material to render or not.
  94589. * If not and the texture is not ready, the engine will use a default black texture instead.
  94590. */
  94591. readonly isBlocking: boolean;
  94592. /**
  94593. * Instantiates a new BaseTexture.
  94594. * Base class of all the textures in babylon.
  94595. * It groups all the common properties the materials, post process, lights... might need
  94596. * in order to make a correct use of the texture.
  94597. * @param scene Define the scene the texture blongs to
  94598. */
  94599. constructor(scene: Nullable<Scene>);
  94600. /**
  94601. * Get the scene the texture belongs to.
  94602. * @returns the scene or null if undefined
  94603. */
  94604. getScene(): Nullable<Scene>;
  94605. /**
  94606. * Get the texture transform matrix used to offset tile the texture for istance.
  94607. * @returns the transformation matrix
  94608. */
  94609. getTextureMatrix(): Matrix;
  94610. /**
  94611. * Get the texture reflection matrix used to rotate/transform the reflection.
  94612. * @returns the reflection matrix
  94613. */
  94614. getReflectionTextureMatrix(): Matrix;
  94615. /**
  94616. * Get the underlying lower level texture from Babylon.
  94617. * @returns the insternal texture
  94618. */
  94619. getInternalTexture(): Nullable<InternalTexture>;
  94620. /**
  94621. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94622. * @returns true if ready or not blocking
  94623. */
  94624. isReadyOrNotBlocking(): boolean;
  94625. /**
  94626. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94627. * @returns true if fully ready
  94628. */
  94629. isReady(): boolean;
  94630. private _cachedSize;
  94631. /**
  94632. * Get the size of the texture.
  94633. * @returns the texture size.
  94634. */
  94635. getSize(): ISize;
  94636. /**
  94637. * Get the base size of the texture.
  94638. * It can be different from the size if the texture has been resized for POT for instance
  94639. * @returns the base size
  94640. */
  94641. getBaseSize(): ISize;
  94642. /**
  94643. * Update the sampling mode of the texture.
  94644. * Default is Trilinear mode.
  94645. *
  94646. * | Value | Type | Description |
  94647. * | ----- | ------------------ | ----------- |
  94648. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94649. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94650. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94651. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94652. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94653. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94654. * | 7 | NEAREST_LINEAR | |
  94655. * | 8 | NEAREST_NEAREST | |
  94656. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94657. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94658. * | 11 | LINEAR_LINEAR | |
  94659. * | 12 | LINEAR_NEAREST | |
  94660. *
  94661. * > _mag_: magnification filter (close to the viewer)
  94662. * > _min_: minification filter (far from the viewer)
  94663. * > _mip_: filter used between mip map levels
  94664. *@param samplingMode Define the new sampling mode of the texture
  94665. */
  94666. updateSamplingMode(samplingMode: number): void;
  94667. /**
  94668. * Scales the texture if is `canRescale()`
  94669. * @param ratio the resize factor we want to use to rescale
  94670. */
  94671. scale(ratio: number): void;
  94672. /**
  94673. * Get if the texture can rescale.
  94674. */
  94675. readonly canRescale: boolean;
  94676. /** @hidden */
  94677. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94678. /** @hidden */
  94679. _rebuild(): void;
  94680. /**
  94681. * Triggers the load sequence in delayed load mode.
  94682. */
  94683. delayLoad(): void;
  94684. /**
  94685. * Clones the texture.
  94686. * @returns the cloned texture
  94687. */
  94688. clone(): Nullable<BaseTexture>;
  94689. /**
  94690. * Get the texture underlying type (INT, FLOAT...)
  94691. */
  94692. readonly textureType: number;
  94693. /**
  94694. * Get the texture underlying format (RGB, RGBA...)
  94695. */
  94696. readonly textureFormat: number;
  94697. /**
  94698. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94699. * This will returns an RGBA array buffer containing either in values (0-255) or
  94700. * float values (0-1) depending of the underlying buffer type.
  94701. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94702. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94703. * @param buffer defines a user defined buffer to fill with data (can be null)
  94704. * @returns The Array buffer containing the pixels data.
  94705. */
  94706. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94707. /**
  94708. * Release and destroy the underlying lower level texture aka internalTexture.
  94709. */
  94710. releaseInternalTexture(): void;
  94711. /**
  94712. * Get the polynomial representation of the texture data.
  94713. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94714. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94715. */
  94716. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94717. /** @hidden */
  94718. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94719. /** @hidden */
  94720. readonly _lodTextureMid: Nullable<BaseTexture>;
  94721. /** @hidden */
  94722. readonly _lodTextureLow: Nullable<BaseTexture>;
  94723. /**
  94724. * Dispose the texture and release its associated resources.
  94725. */
  94726. dispose(): void;
  94727. /**
  94728. * Serialize the texture into a JSON representation that can be parsed later on.
  94729. * @returns the JSON representation of the texture
  94730. */
  94731. serialize(): any;
  94732. /**
  94733. * Helper function to be called back once a list of texture contains only ready textures.
  94734. * @param textures Define the list of textures to wait for
  94735. * @param callback Define the callback triggered once the entire list will be ready
  94736. */
  94737. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94738. }
  94739. }
  94740. declare module BABYLON {
  94741. /**
  94742. * Options to be used when creating an effect.
  94743. */
  94744. export class EffectCreationOptions {
  94745. /**
  94746. * Atrributes that will be used in the shader.
  94747. */
  94748. attributes: string[];
  94749. /**
  94750. * Uniform varible names that will be set in the shader.
  94751. */
  94752. uniformsNames: string[];
  94753. /**
  94754. * Uniform buffer varible names that will be set in the shader.
  94755. */
  94756. uniformBuffersNames: string[];
  94757. /**
  94758. * Sampler texture variable names that will be set in the shader.
  94759. */
  94760. samplers: string[];
  94761. /**
  94762. * Define statements that will be set in the shader.
  94763. */
  94764. defines: any;
  94765. /**
  94766. * Possible fallbacks for this effect to improve performance when needed.
  94767. */
  94768. fallbacks: Nullable<IEffectFallbacks>;
  94769. /**
  94770. * Callback that will be called when the shader is compiled.
  94771. */
  94772. onCompiled: Nullable<(effect: Effect) => void>;
  94773. /**
  94774. * Callback that will be called if an error occurs during shader compilation.
  94775. */
  94776. onError: Nullable<(effect: Effect, errors: string) => void>;
  94777. /**
  94778. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94779. */
  94780. indexParameters?: any;
  94781. /**
  94782. * Max number of lights that can be used in the shader.
  94783. */
  94784. maxSimultaneousLights?: number;
  94785. /**
  94786. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94787. */
  94788. transformFeedbackVaryings?: Nullable<string[]>;
  94789. }
  94790. /**
  94791. * Effect containing vertex and fragment shader that can be executed on an object.
  94792. */
  94793. export class Effect implements IDisposable {
  94794. /**
  94795. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94796. */
  94797. static ShadersRepository: string;
  94798. /**
  94799. * Name of the effect.
  94800. */
  94801. name: any;
  94802. /**
  94803. * String container all the define statements that should be set on the shader.
  94804. */
  94805. defines: string;
  94806. /**
  94807. * Callback that will be called when the shader is compiled.
  94808. */
  94809. onCompiled: Nullable<(effect: Effect) => void>;
  94810. /**
  94811. * Callback that will be called if an error occurs during shader compilation.
  94812. */
  94813. onError: Nullable<(effect: Effect, errors: string) => void>;
  94814. /**
  94815. * Callback that will be called when effect is bound.
  94816. */
  94817. onBind: Nullable<(effect: Effect) => void>;
  94818. /**
  94819. * Unique ID of the effect.
  94820. */
  94821. uniqueId: number;
  94822. /**
  94823. * Observable that will be called when the shader is compiled.
  94824. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94825. */
  94826. onCompileObservable: Observable<Effect>;
  94827. /**
  94828. * Observable that will be called if an error occurs during shader compilation.
  94829. */
  94830. onErrorObservable: Observable<Effect>;
  94831. /** @hidden */
  94832. _onBindObservable: Nullable<Observable<Effect>>;
  94833. /**
  94834. * Observable that will be called when effect is bound.
  94835. */
  94836. readonly onBindObservable: Observable<Effect>;
  94837. /** @hidden */
  94838. _bonesComputationForcedToCPU: boolean;
  94839. private static _uniqueIdSeed;
  94840. private _engine;
  94841. private _uniformBuffersNames;
  94842. private _uniformsNames;
  94843. private _samplerList;
  94844. private _samplers;
  94845. private _isReady;
  94846. private _compilationError;
  94847. private _attributesNames;
  94848. private _attributes;
  94849. private _uniforms;
  94850. /**
  94851. * Key for the effect.
  94852. * @hidden
  94853. */
  94854. _key: string;
  94855. private _indexParameters;
  94856. private _fallbacks;
  94857. private _vertexSourceCode;
  94858. private _fragmentSourceCode;
  94859. private _vertexSourceCodeOverride;
  94860. private _fragmentSourceCodeOverride;
  94861. private _transformFeedbackVaryings;
  94862. /**
  94863. * Compiled shader to webGL program.
  94864. * @hidden
  94865. */
  94866. _pipelineContext: Nullable<IPipelineContext>;
  94867. private _valueCache;
  94868. private static _baseCache;
  94869. /**
  94870. * Instantiates an effect.
  94871. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94872. * @param baseName Name of the effect.
  94873. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94874. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94875. * @param samplers List of sampler variables that will be passed to the shader.
  94876. * @param engine Engine to be used to render the effect
  94877. * @param defines Define statements to be added to the shader.
  94878. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94879. * @param onCompiled Callback that will be called when the shader is compiled.
  94880. * @param onError Callback that will be called if an error occurs during shader compilation.
  94881. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94882. */
  94883. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  94884. private _useFinalCode;
  94885. /**
  94886. * Unique key for this effect
  94887. */
  94888. readonly key: string;
  94889. /**
  94890. * If the effect has been compiled and prepared.
  94891. * @returns if the effect is compiled and prepared.
  94892. */
  94893. isReady(): boolean;
  94894. private _isReadyInternal;
  94895. /**
  94896. * The engine the effect was initialized with.
  94897. * @returns the engine.
  94898. */
  94899. getEngine(): Engine;
  94900. /**
  94901. * The pipeline context for this effect
  94902. * @returns the associated pipeline context
  94903. */
  94904. getPipelineContext(): Nullable<IPipelineContext>;
  94905. /**
  94906. * The set of names of attribute variables for the shader.
  94907. * @returns An array of attribute names.
  94908. */
  94909. getAttributesNames(): string[];
  94910. /**
  94911. * Returns the attribute at the given index.
  94912. * @param index The index of the attribute.
  94913. * @returns The location of the attribute.
  94914. */
  94915. getAttributeLocation(index: number): number;
  94916. /**
  94917. * Returns the attribute based on the name of the variable.
  94918. * @param name of the attribute to look up.
  94919. * @returns the attribute location.
  94920. */
  94921. getAttributeLocationByName(name: string): number;
  94922. /**
  94923. * The number of attributes.
  94924. * @returns the numnber of attributes.
  94925. */
  94926. getAttributesCount(): number;
  94927. /**
  94928. * Gets the index of a uniform variable.
  94929. * @param uniformName of the uniform to look up.
  94930. * @returns the index.
  94931. */
  94932. getUniformIndex(uniformName: string): number;
  94933. /**
  94934. * Returns the attribute based on the name of the variable.
  94935. * @param uniformName of the uniform to look up.
  94936. * @returns the location of the uniform.
  94937. */
  94938. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94939. /**
  94940. * Returns an array of sampler variable names
  94941. * @returns The array of sampler variable neames.
  94942. */
  94943. getSamplers(): string[];
  94944. /**
  94945. * The error from the last compilation.
  94946. * @returns the error string.
  94947. */
  94948. getCompilationError(): string;
  94949. /**
  94950. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94951. * @param func The callback to be used.
  94952. */
  94953. executeWhenCompiled(func: (effect: Effect) => void): void;
  94954. private _checkIsReady;
  94955. /** @hidden */
  94956. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94957. /** @hidden */
  94958. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94959. /** @hidden */
  94960. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94961. /**
  94962. * Recompiles the webGL program
  94963. * @param vertexSourceCode The source code for the vertex shader.
  94964. * @param fragmentSourceCode The source code for the fragment shader.
  94965. * @param onCompiled Callback called when completed.
  94966. * @param onError Callback called on error.
  94967. * @hidden
  94968. */
  94969. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94970. /**
  94971. * Prepares the effect
  94972. * @hidden
  94973. */
  94974. _prepareEffect(): void;
  94975. private _processCompilationErrors;
  94976. /**
  94977. * Checks if the effect is supported. (Must be called after compilation)
  94978. */
  94979. readonly isSupported: boolean;
  94980. /**
  94981. * Binds a texture to the engine to be used as output of the shader.
  94982. * @param channel Name of the output variable.
  94983. * @param texture Texture to bind.
  94984. * @hidden
  94985. */
  94986. _bindTexture(channel: string, texture: InternalTexture): void;
  94987. /**
  94988. * Sets a texture on the engine to be used in the shader.
  94989. * @param channel Name of the sampler variable.
  94990. * @param texture Texture to set.
  94991. */
  94992. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94993. /**
  94994. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94995. * @param channel Name of the sampler variable.
  94996. * @param texture Texture to set.
  94997. */
  94998. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94999. /**
  95000. * Sets an array of textures on the engine to be used in the shader.
  95001. * @param channel Name of the variable.
  95002. * @param textures Textures to set.
  95003. */
  95004. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95005. /**
  95006. * 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)
  95007. * @param channel Name of the sampler variable.
  95008. * @param postProcess Post process to get the input texture from.
  95009. */
  95010. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95011. /**
  95012. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95013. * 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)
  95014. * @param channel Name of the sampler variable.
  95015. * @param postProcess Post process to get the output texture from.
  95016. */
  95017. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95018. /** @hidden */
  95019. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95020. /** @hidden */
  95021. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95022. /** @hidden */
  95023. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95024. /** @hidden */
  95025. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95026. /**
  95027. * Binds a buffer to a uniform.
  95028. * @param buffer Buffer to bind.
  95029. * @param name Name of the uniform variable to bind to.
  95030. */
  95031. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95032. /**
  95033. * Binds block to a uniform.
  95034. * @param blockName Name of the block to bind.
  95035. * @param index Index to bind.
  95036. */
  95037. bindUniformBlock(blockName: string, index: number): void;
  95038. /**
  95039. * Sets an interger value on a uniform variable.
  95040. * @param uniformName Name of the variable.
  95041. * @param value Value to be set.
  95042. * @returns this effect.
  95043. */
  95044. setInt(uniformName: string, value: number): Effect;
  95045. /**
  95046. * Sets an int array on a uniform variable.
  95047. * @param uniformName Name of the variable.
  95048. * @param array array to be set.
  95049. * @returns this effect.
  95050. */
  95051. setIntArray(uniformName: string, array: Int32Array): Effect;
  95052. /**
  95053. * 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)
  95054. * @param uniformName Name of the variable.
  95055. * @param array array to be set.
  95056. * @returns this effect.
  95057. */
  95058. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95059. /**
  95060. * 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)
  95061. * @param uniformName Name of the variable.
  95062. * @param array array to be set.
  95063. * @returns this effect.
  95064. */
  95065. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95066. /**
  95067. * 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)
  95068. * @param uniformName Name of the variable.
  95069. * @param array array to be set.
  95070. * @returns this effect.
  95071. */
  95072. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95073. /**
  95074. * Sets an float array on a uniform variable.
  95075. * @param uniformName Name of the variable.
  95076. * @param array array to be set.
  95077. * @returns this effect.
  95078. */
  95079. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95080. /**
  95081. * 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)
  95082. * @param uniformName Name of the variable.
  95083. * @param array array to be set.
  95084. * @returns this effect.
  95085. */
  95086. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95087. /**
  95088. * 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)
  95089. * @param uniformName Name of the variable.
  95090. * @param array array to be set.
  95091. * @returns this effect.
  95092. */
  95093. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95094. /**
  95095. * 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)
  95096. * @param uniformName Name of the variable.
  95097. * @param array array to be set.
  95098. * @returns this effect.
  95099. */
  95100. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95101. /**
  95102. * Sets an array on a uniform variable.
  95103. * @param uniformName Name of the variable.
  95104. * @param array array to be set.
  95105. * @returns this effect.
  95106. */
  95107. setArray(uniformName: string, array: number[]): Effect;
  95108. /**
  95109. * 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)
  95110. * @param uniformName Name of the variable.
  95111. * @param array array to be set.
  95112. * @returns this effect.
  95113. */
  95114. setArray2(uniformName: string, array: number[]): Effect;
  95115. /**
  95116. * 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)
  95117. * @param uniformName Name of the variable.
  95118. * @param array array to be set.
  95119. * @returns this effect.
  95120. */
  95121. setArray3(uniformName: string, array: number[]): Effect;
  95122. /**
  95123. * 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)
  95124. * @param uniformName Name of the variable.
  95125. * @param array array to be set.
  95126. * @returns this effect.
  95127. */
  95128. setArray4(uniformName: string, array: number[]): Effect;
  95129. /**
  95130. * Sets matrices on a uniform variable.
  95131. * @param uniformName Name of the variable.
  95132. * @param matrices matrices to be set.
  95133. * @returns this effect.
  95134. */
  95135. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95136. /**
  95137. * Sets matrix on a uniform variable.
  95138. * @param uniformName Name of the variable.
  95139. * @param matrix matrix to be set.
  95140. * @returns this effect.
  95141. */
  95142. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95143. /**
  95144. * 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)
  95145. * @param uniformName Name of the variable.
  95146. * @param matrix matrix to be set.
  95147. * @returns this effect.
  95148. */
  95149. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95150. /**
  95151. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95152. * @param uniformName Name of the variable.
  95153. * @param matrix matrix to be set.
  95154. * @returns this effect.
  95155. */
  95156. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95157. /**
  95158. * Sets a float on a uniform variable.
  95159. * @param uniformName Name of the variable.
  95160. * @param value value to be set.
  95161. * @returns this effect.
  95162. */
  95163. setFloat(uniformName: string, value: number): Effect;
  95164. /**
  95165. * Sets a boolean on a uniform variable.
  95166. * @param uniformName Name of the variable.
  95167. * @param bool value to be set.
  95168. * @returns this effect.
  95169. */
  95170. setBool(uniformName: string, bool: boolean): Effect;
  95171. /**
  95172. * Sets a Vector2 on a uniform variable.
  95173. * @param uniformName Name of the variable.
  95174. * @param vector2 vector2 to be set.
  95175. * @returns this effect.
  95176. */
  95177. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95178. /**
  95179. * Sets a float2 on a uniform variable.
  95180. * @param uniformName Name of the variable.
  95181. * @param x First float in float2.
  95182. * @param y Second float in float2.
  95183. * @returns this effect.
  95184. */
  95185. setFloat2(uniformName: string, x: number, y: number): Effect;
  95186. /**
  95187. * Sets a Vector3 on a uniform variable.
  95188. * @param uniformName Name of the variable.
  95189. * @param vector3 Value to be set.
  95190. * @returns this effect.
  95191. */
  95192. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95193. /**
  95194. * Sets a float3 on a uniform variable.
  95195. * @param uniformName Name of the variable.
  95196. * @param x First float in float3.
  95197. * @param y Second float in float3.
  95198. * @param z Third float in float3.
  95199. * @returns this effect.
  95200. */
  95201. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95202. /**
  95203. * Sets a Vector4 on a uniform variable.
  95204. * @param uniformName Name of the variable.
  95205. * @param vector4 Value to be set.
  95206. * @returns this effect.
  95207. */
  95208. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95209. /**
  95210. * Sets a float4 on a uniform variable.
  95211. * @param uniformName Name of the variable.
  95212. * @param x First float in float4.
  95213. * @param y Second float in float4.
  95214. * @param z Third float in float4.
  95215. * @param w Fourth float in float4.
  95216. * @returns this effect.
  95217. */
  95218. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95219. /**
  95220. * Sets a Color3 on a uniform variable.
  95221. * @param uniformName Name of the variable.
  95222. * @param color3 Value to be set.
  95223. * @returns this effect.
  95224. */
  95225. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95226. /**
  95227. * Sets a Color4 on a uniform variable.
  95228. * @param uniformName Name of the variable.
  95229. * @param color3 Value to be set.
  95230. * @param alpha Alpha value to be set.
  95231. * @returns this effect.
  95232. */
  95233. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95234. /**
  95235. * Sets a Color4 on a uniform variable
  95236. * @param uniformName defines the name of the variable
  95237. * @param color4 defines the value to be set
  95238. * @returns this effect.
  95239. */
  95240. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95241. /** Release all associated resources */
  95242. dispose(): void;
  95243. /**
  95244. * This function will add a new shader to the shader store
  95245. * @param name the name of the shader
  95246. * @param pixelShader optional pixel shader content
  95247. * @param vertexShader optional vertex shader content
  95248. */
  95249. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95250. /**
  95251. * Store of each shader (The can be looked up using effect.key)
  95252. */
  95253. static ShadersStore: {
  95254. [key: string]: string;
  95255. };
  95256. /**
  95257. * Store of each included file for a shader (The can be looked up using effect.key)
  95258. */
  95259. static IncludesShadersStore: {
  95260. [key: string]: string;
  95261. };
  95262. /**
  95263. * Resets the cache of effects.
  95264. */
  95265. static ResetCache(): void;
  95266. }
  95267. }
  95268. declare module BABYLON {
  95269. /**
  95270. * Class used to describe the capabilities of the engine relatively to the current browser
  95271. */
  95272. export class EngineCapabilities {
  95273. /** Maximum textures units per fragment shader */
  95274. maxTexturesImageUnits: number;
  95275. /** Maximum texture units per vertex shader */
  95276. maxVertexTextureImageUnits: number;
  95277. /** Maximum textures units in the entire pipeline */
  95278. maxCombinedTexturesImageUnits: number;
  95279. /** Maximum texture size */
  95280. maxTextureSize: number;
  95281. /** Maximum cube texture size */
  95282. maxCubemapTextureSize: number;
  95283. /** Maximum render texture size */
  95284. maxRenderTextureSize: number;
  95285. /** Maximum number of vertex attributes */
  95286. maxVertexAttribs: number;
  95287. /** Maximum number of varyings */
  95288. maxVaryingVectors: number;
  95289. /** Maximum number of uniforms per vertex shader */
  95290. maxVertexUniformVectors: number;
  95291. /** Maximum number of uniforms per fragment shader */
  95292. maxFragmentUniformVectors: number;
  95293. /** Defines if standard derivates (dx/dy) are supported */
  95294. standardDerivatives: boolean;
  95295. /** Defines if s3tc texture compression is supported */
  95296. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95297. /** Defines if pvrtc texture compression is supported */
  95298. pvrtc: any;
  95299. /** Defines if etc1 texture compression is supported */
  95300. etc1: any;
  95301. /** Defines if etc2 texture compression is supported */
  95302. etc2: any;
  95303. /** Defines if astc texture compression is supported */
  95304. astc: any;
  95305. /** Defines if float textures are supported */
  95306. textureFloat: boolean;
  95307. /** Defines if vertex array objects are supported */
  95308. vertexArrayObject: boolean;
  95309. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95310. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95311. /** Gets the maximum level of anisotropy supported */
  95312. maxAnisotropy: number;
  95313. /** Defines if instancing is supported */
  95314. instancedArrays: boolean;
  95315. /** Defines if 32 bits indices are supported */
  95316. uintIndices: boolean;
  95317. /** Defines if high precision shaders are supported */
  95318. highPrecisionShaderSupported: boolean;
  95319. /** Defines if depth reading in the fragment shader is supported */
  95320. fragmentDepthSupported: boolean;
  95321. /** Defines if float texture linear filtering is supported*/
  95322. textureFloatLinearFiltering: boolean;
  95323. /** Defines if rendering to float textures is supported */
  95324. textureFloatRender: boolean;
  95325. /** Defines if half float textures are supported*/
  95326. textureHalfFloat: boolean;
  95327. /** Defines if half float texture linear filtering is supported*/
  95328. textureHalfFloatLinearFiltering: boolean;
  95329. /** Defines if rendering to half float textures is supported */
  95330. textureHalfFloatRender: boolean;
  95331. /** Defines if textureLOD shader command is supported */
  95332. textureLOD: boolean;
  95333. /** Defines if draw buffers extension is supported */
  95334. drawBuffersExtension: boolean;
  95335. /** Defines if depth textures are supported */
  95336. depthTextureExtension: boolean;
  95337. /** Defines if float color buffer are supported */
  95338. colorBufferFloat: boolean;
  95339. /** Gets disjoint timer query extension (null if not supported) */
  95340. timerQuery: EXT_disjoint_timer_query;
  95341. /** Defines if timestamp can be used with timer query */
  95342. canUseTimestampForTimerQuery: boolean;
  95343. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95344. multiview: any;
  95345. /** Function used to let the system compiles shaders in background */
  95346. parallelShaderCompile: {
  95347. COMPLETION_STATUS_KHR: number;
  95348. };
  95349. /** Max number of texture samples for MSAA */
  95350. maxMSAASamples: number;
  95351. /** Defines if the blend min max extension is supported */
  95352. blendMinMax: boolean;
  95353. }
  95354. }
  95355. declare module BABYLON {
  95356. /**
  95357. * This class is used to track a performance counter which is number based.
  95358. * The user has access to many properties which give statistics of different nature.
  95359. *
  95360. * The implementer can track two kinds of Performance Counter: time and count.
  95361. * 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.
  95362. * 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.
  95363. */
  95364. export class PerfCounter {
  95365. /**
  95366. * Gets or sets a global boolean to turn on and off all the counters
  95367. */
  95368. static Enabled: boolean;
  95369. /**
  95370. * Returns the smallest value ever
  95371. */
  95372. readonly min: number;
  95373. /**
  95374. * Returns the biggest value ever
  95375. */
  95376. readonly max: number;
  95377. /**
  95378. * Returns the average value since the performance counter is running
  95379. */
  95380. readonly average: number;
  95381. /**
  95382. * Returns the average value of the last second the counter was monitored
  95383. */
  95384. readonly lastSecAverage: number;
  95385. /**
  95386. * Returns the current value
  95387. */
  95388. readonly current: number;
  95389. /**
  95390. * Gets the accumulated total
  95391. */
  95392. readonly total: number;
  95393. /**
  95394. * Gets the total value count
  95395. */
  95396. readonly count: number;
  95397. /**
  95398. * Creates a new counter
  95399. */
  95400. constructor();
  95401. /**
  95402. * Call this method to start monitoring a new frame.
  95403. * 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.
  95404. */
  95405. fetchNewFrame(): void;
  95406. /**
  95407. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95408. * @param newCount the count value to add to the monitored count
  95409. * @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.
  95410. */
  95411. addCount(newCount: number, fetchResult: boolean): void;
  95412. /**
  95413. * Start monitoring this performance counter
  95414. */
  95415. beginMonitoring(): void;
  95416. /**
  95417. * Compute the time lapsed since the previous beginMonitoring() call.
  95418. * @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
  95419. */
  95420. endMonitoring(newFrame?: boolean): void;
  95421. private _fetchResult;
  95422. private _startMonitoringTime;
  95423. private _min;
  95424. private _max;
  95425. private _average;
  95426. private _current;
  95427. private _totalValueCount;
  95428. private _totalAccumulated;
  95429. private _lastSecAverage;
  95430. private _lastSecAccumulated;
  95431. private _lastSecTime;
  95432. private _lastSecValueCount;
  95433. }
  95434. }
  95435. declare module BABYLON {
  95436. /**
  95437. * @hidden
  95438. **/
  95439. export class DepthCullingState {
  95440. private _isDepthTestDirty;
  95441. private _isDepthMaskDirty;
  95442. private _isDepthFuncDirty;
  95443. private _isCullFaceDirty;
  95444. private _isCullDirty;
  95445. private _isZOffsetDirty;
  95446. private _isFrontFaceDirty;
  95447. private _depthTest;
  95448. private _depthMask;
  95449. private _depthFunc;
  95450. private _cull;
  95451. private _cullFace;
  95452. private _zOffset;
  95453. private _frontFace;
  95454. /**
  95455. * Initializes the state.
  95456. */
  95457. constructor();
  95458. readonly isDirty: boolean;
  95459. zOffset: number;
  95460. cullFace: Nullable<number>;
  95461. cull: Nullable<boolean>;
  95462. depthFunc: Nullable<number>;
  95463. depthMask: boolean;
  95464. depthTest: boolean;
  95465. frontFace: Nullable<number>;
  95466. reset(): void;
  95467. apply(gl: WebGLRenderingContext): void;
  95468. }
  95469. }
  95470. declare module BABYLON {
  95471. /**
  95472. * @hidden
  95473. **/
  95474. export class StencilState {
  95475. /** 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 */
  95476. static readonly ALWAYS: number;
  95477. /** Passed to stencilOperation to specify that stencil value must be kept */
  95478. static readonly KEEP: number;
  95479. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95480. static readonly REPLACE: number;
  95481. private _isStencilTestDirty;
  95482. private _isStencilMaskDirty;
  95483. private _isStencilFuncDirty;
  95484. private _isStencilOpDirty;
  95485. private _stencilTest;
  95486. private _stencilMask;
  95487. private _stencilFunc;
  95488. private _stencilFuncRef;
  95489. private _stencilFuncMask;
  95490. private _stencilOpStencilFail;
  95491. private _stencilOpDepthFail;
  95492. private _stencilOpStencilDepthPass;
  95493. readonly isDirty: boolean;
  95494. stencilFunc: number;
  95495. stencilFuncRef: number;
  95496. stencilFuncMask: number;
  95497. stencilOpStencilFail: number;
  95498. stencilOpDepthFail: number;
  95499. stencilOpStencilDepthPass: number;
  95500. stencilMask: number;
  95501. stencilTest: boolean;
  95502. constructor();
  95503. reset(): void;
  95504. apply(gl: WebGLRenderingContext): void;
  95505. }
  95506. }
  95507. declare module BABYLON {
  95508. /**
  95509. * @hidden
  95510. **/
  95511. export class AlphaState {
  95512. private _isAlphaBlendDirty;
  95513. private _isBlendFunctionParametersDirty;
  95514. private _isBlendEquationParametersDirty;
  95515. private _isBlendConstantsDirty;
  95516. private _alphaBlend;
  95517. private _blendFunctionParameters;
  95518. private _blendEquationParameters;
  95519. private _blendConstants;
  95520. /**
  95521. * Initializes the state.
  95522. */
  95523. constructor();
  95524. readonly isDirty: boolean;
  95525. alphaBlend: boolean;
  95526. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95527. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95528. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95529. reset(): void;
  95530. apply(gl: WebGLRenderingContext): void;
  95531. }
  95532. }
  95533. declare module BABYLON {
  95534. /** @hidden */
  95535. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95536. attributeProcessor(attribute: string): string;
  95537. varyingProcessor(varying: string, isFragment: boolean): string;
  95538. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95539. }
  95540. }
  95541. declare module BABYLON {
  95542. /**
  95543. * Interface for attribute information associated with buffer instanciation
  95544. */
  95545. export class InstancingAttributeInfo {
  95546. /**
  95547. * Index/offset of the attribute in the vertex shader
  95548. */
  95549. index: number;
  95550. /**
  95551. * size of the attribute, 1, 2, 3 or 4
  95552. */
  95553. attributeSize: number;
  95554. /**
  95555. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95556. * default is FLOAT
  95557. */
  95558. attribyteType: number;
  95559. /**
  95560. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95561. */
  95562. normalized: boolean;
  95563. /**
  95564. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95565. */
  95566. offset: number;
  95567. /**
  95568. * Name of the GLSL attribute, for debugging purpose only
  95569. */
  95570. attributeName: string;
  95571. }
  95572. }
  95573. declare module BABYLON {
  95574. interface ThinEngine {
  95575. /**
  95576. * Update a video texture
  95577. * @param texture defines the texture to update
  95578. * @param video defines the video element to use
  95579. * @param invertY defines if data must be stored with Y axis inverted
  95580. */
  95581. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95582. }
  95583. }
  95584. declare module BABYLON {
  95585. /**
  95586. * Settings for finer control over video usage
  95587. */
  95588. export interface VideoTextureSettings {
  95589. /**
  95590. * Applies `autoplay` to video, if specified
  95591. */
  95592. autoPlay?: boolean;
  95593. /**
  95594. * Applies `loop` to video, if specified
  95595. */
  95596. loop?: boolean;
  95597. /**
  95598. * Automatically updates internal texture from video at every frame in the render loop
  95599. */
  95600. autoUpdateTexture: boolean;
  95601. /**
  95602. * Image src displayed during the video loading or until the user interacts with the video.
  95603. */
  95604. poster?: string;
  95605. }
  95606. /**
  95607. * If you want to display a video in your scene, this is the special texture for that.
  95608. * This special texture works similar to other textures, with the exception of a few parameters.
  95609. * @see https://doc.babylonjs.com/how_to/video_texture
  95610. */
  95611. export class VideoTexture extends Texture {
  95612. /**
  95613. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95614. */
  95615. readonly autoUpdateTexture: boolean;
  95616. /**
  95617. * The video instance used by the texture internally
  95618. */
  95619. readonly video: HTMLVideoElement;
  95620. private _onUserActionRequestedObservable;
  95621. /**
  95622. * Event triggerd when a dom action is required by the user to play the video.
  95623. * This happens due to recent changes in browser policies preventing video to auto start.
  95624. */
  95625. readonly onUserActionRequestedObservable: Observable<Texture>;
  95626. private _generateMipMaps;
  95627. private _engine;
  95628. private _stillImageCaptured;
  95629. private _displayingPosterTexture;
  95630. private _settings;
  95631. private _createInternalTextureOnEvent;
  95632. private _frameId;
  95633. /**
  95634. * Creates a video texture.
  95635. * If you want to display a video in your scene, this is the special texture for that.
  95636. * This special texture works similar to other textures, with the exception of a few parameters.
  95637. * @see https://doc.babylonjs.com/how_to/video_texture
  95638. * @param name optional name, will detect from video source, if not defined
  95639. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95640. * @param scene is obviously the current scene.
  95641. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95642. * @param invertY is false by default but can be used to invert video on Y axis
  95643. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95644. * @param settings allows finer control over video usage
  95645. */
  95646. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95647. private _getName;
  95648. private _getVideo;
  95649. private _createInternalTexture;
  95650. private reset;
  95651. /**
  95652. * @hidden Internal method to initiate `update`.
  95653. */
  95654. _rebuild(): void;
  95655. /**
  95656. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95657. */
  95658. update(): void;
  95659. /**
  95660. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95661. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95662. */
  95663. updateTexture(isVisible: boolean): void;
  95664. protected _updateInternalTexture: () => void;
  95665. /**
  95666. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95667. * @param url New url.
  95668. */
  95669. updateURL(url: string): void;
  95670. /**
  95671. * Dispose the texture and release its associated resources.
  95672. */
  95673. dispose(): void;
  95674. /**
  95675. * Creates a video texture straight from a stream.
  95676. * @param scene Define the scene the texture should be created in
  95677. * @param stream Define the stream the texture should be created from
  95678. * @returns The created video texture as a promise
  95679. */
  95680. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95681. /**
  95682. * Creates a video texture straight from your WebCam video feed.
  95683. * @param scene Define the scene the texture should be created in
  95684. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95685. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95686. * @returns The created video texture as a promise
  95687. */
  95688. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95689. minWidth: number;
  95690. maxWidth: number;
  95691. minHeight: number;
  95692. maxHeight: number;
  95693. deviceId: string;
  95694. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95695. /**
  95696. * Creates a video texture straight from your WebCam video feed.
  95697. * @param scene Define the scene the texture should be created in
  95698. * @param onReady Define a callback to triggered once the texture will be ready
  95699. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95700. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95701. */
  95702. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95703. minWidth: number;
  95704. maxWidth: number;
  95705. minHeight: number;
  95706. maxHeight: number;
  95707. deviceId: string;
  95708. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95709. }
  95710. }
  95711. declare module BABYLON {
  95712. /**
  95713. * Defines the interface used by objects working like Scene
  95714. * @hidden
  95715. */
  95716. interface ISceneLike {
  95717. _addPendingData(data: any): void;
  95718. _removePendingData(data: any): void;
  95719. offlineProvider: IOfflineProvider;
  95720. }
  95721. /** Interface defining initialization parameters for Engine class */
  95722. export interface EngineOptions extends WebGLContextAttributes {
  95723. /**
  95724. * Defines if the engine should no exceed a specified device ratio
  95725. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95726. */
  95727. limitDeviceRatio?: number;
  95728. /**
  95729. * Defines if webvr should be enabled automatically
  95730. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95731. */
  95732. autoEnableWebVR?: boolean;
  95733. /**
  95734. * Defines if webgl2 should be turned off even if supported
  95735. * @see http://doc.babylonjs.com/features/webgl2
  95736. */
  95737. disableWebGL2Support?: boolean;
  95738. /**
  95739. * Defines if webaudio should be initialized as well
  95740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95741. */
  95742. audioEngine?: boolean;
  95743. /**
  95744. * Defines if animations should run using a deterministic lock step
  95745. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95746. */
  95747. deterministicLockstep?: boolean;
  95748. /** Defines the maximum steps to use with deterministic lock step mode */
  95749. lockstepMaxSteps?: number;
  95750. /**
  95751. * Defines that engine should ignore context lost events
  95752. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95753. */
  95754. doNotHandleContextLost?: boolean;
  95755. /**
  95756. * Defines that engine should ignore modifying touch action attribute and style
  95757. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95758. */
  95759. doNotHandleTouchAction?: boolean;
  95760. /**
  95761. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95762. */
  95763. useHighPrecisionFloats?: boolean;
  95764. }
  95765. /**
  95766. * The base engine class (root of all engines)
  95767. */
  95768. export class ThinEngine {
  95769. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95770. static ExceptionList: ({
  95771. key: string;
  95772. capture: string;
  95773. captureConstraint: number;
  95774. targets: string[];
  95775. } | {
  95776. key: string;
  95777. capture: null;
  95778. captureConstraint: null;
  95779. targets: string[];
  95780. })[];
  95781. /** @hidden */
  95782. static _TextureLoaders: IInternalTextureLoader[];
  95783. /**
  95784. * Returns the current npm package of the sdk
  95785. */
  95786. static readonly NpmPackage: string;
  95787. /**
  95788. * Returns the current version of the framework
  95789. */
  95790. static readonly Version: string;
  95791. /**
  95792. * Returns a string describing the current engine
  95793. */
  95794. readonly description: string;
  95795. /**
  95796. * Gets or sets the epsilon value used by collision engine
  95797. */
  95798. static CollisionsEpsilon: number;
  95799. /**
  95800. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95801. */
  95802. static ShadersRepository: string;
  95803. /** @hidden */
  95804. _shaderProcessor: IShaderProcessor;
  95805. /**
  95806. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95807. */
  95808. forcePOTTextures: boolean;
  95809. /**
  95810. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95811. */
  95812. isFullscreen: boolean;
  95813. /**
  95814. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95815. */
  95816. cullBackFaces: boolean;
  95817. /**
  95818. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95819. */
  95820. renderEvenInBackground: boolean;
  95821. /**
  95822. * Gets or sets a boolean indicating that cache can be kept between frames
  95823. */
  95824. preventCacheWipeBetweenFrames: boolean;
  95825. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95826. validateShaderPrograms: boolean;
  95827. /**
  95828. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95829. */
  95830. disableUniformBuffers: boolean;
  95831. /** @hidden */
  95832. _uniformBuffers: UniformBuffer[];
  95833. /**
  95834. * Gets a boolean indicating that the engine supports uniform buffers
  95835. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95836. */
  95837. readonly supportsUniformBuffers: boolean;
  95838. /** @hidden */
  95839. _gl: WebGLRenderingContext;
  95840. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95841. protected _windowIsBackground: boolean;
  95842. protected _webGLVersion: number;
  95843. protected _highPrecisionShadersAllowed: boolean;
  95844. /** @hidden */
  95845. readonly _shouldUseHighPrecisionShader: boolean;
  95846. /**
  95847. * Gets a boolean indicating that only power of 2 textures are supported
  95848. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95849. */
  95850. readonly needPOTTextures: boolean;
  95851. /** @hidden */
  95852. _badOS: boolean;
  95853. /** @hidden */
  95854. _badDesktopOS: boolean;
  95855. private _hardwareScalingLevel;
  95856. /** @hidden */
  95857. _caps: EngineCapabilities;
  95858. private _isStencilEnable;
  95859. protected _colorWrite: boolean;
  95860. /** @hidden */
  95861. _drawCalls: PerfCounter;
  95862. private _glVersion;
  95863. private _glRenderer;
  95864. private _glVendor;
  95865. /** @hidden */
  95866. _videoTextureSupported: boolean;
  95867. protected _renderingQueueLaunched: boolean;
  95868. protected _activeRenderLoops: (() => void)[];
  95869. /**
  95870. * Observable signaled when a context lost event is raised
  95871. */
  95872. onContextLostObservable: Observable<ThinEngine>;
  95873. /**
  95874. * Observable signaled when a context restored event is raised
  95875. */
  95876. onContextRestoredObservable: Observable<ThinEngine>;
  95877. private _onContextLost;
  95878. private _onContextRestored;
  95879. protected _contextWasLost: boolean;
  95880. /** @hidden */
  95881. _doNotHandleContextLost: boolean;
  95882. /**
  95883. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95885. */
  95886. doNotHandleContextLost: boolean;
  95887. /**
  95888. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95889. */
  95890. disableVertexArrayObjects: boolean;
  95891. /** @hidden */
  95892. protected _depthCullingState: DepthCullingState;
  95893. /** @hidden */
  95894. protected _stencilState: StencilState;
  95895. /** @hidden */
  95896. protected _alphaState: AlphaState;
  95897. /** @hidden */
  95898. _internalTexturesCache: InternalTexture[];
  95899. /** @hidden */
  95900. protected _activeChannel: number;
  95901. private _currentTextureChannel;
  95902. /** @hidden */
  95903. protected _boundTexturesCache: {
  95904. [key: string]: Nullable<InternalTexture>;
  95905. };
  95906. /** @hidden */
  95907. protected _currentEffect: Nullable<Effect>;
  95908. /** @hidden */
  95909. protected _currentProgram: Nullable<WebGLProgram>;
  95910. private _compiledEffects;
  95911. private _vertexAttribArraysEnabled;
  95912. /** @hidden */
  95913. protected _cachedViewport: Nullable<IViewportLike>;
  95914. private _cachedVertexArrayObject;
  95915. /** @hidden */
  95916. protected _cachedVertexBuffers: any;
  95917. /** @hidden */
  95918. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95919. /** @hidden */
  95920. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95921. /** @hidden */
  95922. _currentRenderTarget: Nullable<InternalTexture>;
  95923. private _uintIndicesCurrentlySet;
  95924. private _currentBoundBuffer;
  95925. /** @hidden */
  95926. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95927. private _currentBufferPointers;
  95928. private _currentInstanceLocations;
  95929. private _currentInstanceBuffers;
  95930. private _textureUnits;
  95931. /** @hidden */
  95932. _workingCanvas: Nullable<HTMLCanvasElement>;
  95933. /** @hidden */
  95934. _workingContext: Nullable<CanvasRenderingContext2D>;
  95935. /** @hidden */
  95936. _bindedRenderFunction: any;
  95937. private _vaoRecordInProgress;
  95938. private _mustWipeVertexAttributes;
  95939. private _emptyTexture;
  95940. private _emptyCubeTexture;
  95941. private _emptyTexture3D;
  95942. /** @hidden */
  95943. _frameHandler: number;
  95944. private _nextFreeTextureSlots;
  95945. private _maxSimultaneousTextures;
  95946. private _activeRequests;
  95947. protected _texturesSupported: string[];
  95948. /** @hidden */
  95949. _textureFormatInUse: Nullable<string>;
  95950. protected readonly _supportsHardwareTextureRescaling: boolean;
  95951. /**
  95952. * Gets the list of texture formats supported
  95953. */
  95954. readonly texturesSupported: Array<string>;
  95955. /**
  95956. * Gets the list of texture formats in use
  95957. */
  95958. readonly textureFormatInUse: Nullable<string>;
  95959. /**
  95960. * Gets the current viewport
  95961. */
  95962. readonly currentViewport: Nullable<IViewportLike>;
  95963. /**
  95964. * Gets the default empty texture
  95965. */
  95966. readonly emptyTexture: InternalTexture;
  95967. /**
  95968. * Gets the default empty 3D texture
  95969. */
  95970. readonly emptyTexture3D: InternalTexture;
  95971. /**
  95972. * Gets the default empty cube texture
  95973. */
  95974. readonly emptyCubeTexture: InternalTexture;
  95975. /**
  95976. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95977. */
  95978. readonly premultipliedAlpha: boolean;
  95979. /**
  95980. * Creates a new engine
  95981. * @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
  95982. * @param antialias defines enable antialiasing (default: false)
  95983. * @param options defines further options to be sent to the getContext() function
  95984. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95985. */
  95986. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95987. private _rebuildInternalTextures;
  95988. private _rebuildEffects;
  95989. /**
  95990. * Gets a boolean indicating if all created effects are ready
  95991. * @returns true if all effects are ready
  95992. */
  95993. areAllEffectsReady(): boolean;
  95994. protected _rebuildBuffers(): void;
  95995. private _initGLContext;
  95996. /**
  95997. * Gets version of the current webGL context
  95998. */
  95999. readonly webGLVersion: number;
  96000. /**
  96001. * Gets a string idenfifying the name of the class
  96002. * @returns "Engine" string
  96003. */
  96004. getClassName(): string;
  96005. /**
  96006. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96007. */
  96008. readonly isStencilEnable: boolean;
  96009. /** @hidden */
  96010. _prepareWorkingCanvas(): void;
  96011. /**
  96012. * Reset the texture cache to empty state
  96013. */
  96014. resetTextureCache(): void;
  96015. /**
  96016. * Gets an object containing information about the current webGL context
  96017. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96018. */
  96019. getGlInfo(): {
  96020. vendor: string;
  96021. renderer: string;
  96022. version: string;
  96023. };
  96024. /**
  96025. * Defines the hardware scaling level.
  96026. * By default the hardware scaling level is computed from the window device ratio.
  96027. * 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.
  96028. * @param level defines the level to use
  96029. */
  96030. setHardwareScalingLevel(level: number): void;
  96031. /**
  96032. * Gets the current hardware scaling level.
  96033. * By default the hardware scaling level is computed from the window device ratio.
  96034. * 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.
  96035. * @returns a number indicating the current hardware scaling level
  96036. */
  96037. getHardwareScalingLevel(): number;
  96038. /**
  96039. * Gets the list of loaded textures
  96040. * @returns an array containing all loaded textures
  96041. */
  96042. getLoadedTexturesCache(): InternalTexture[];
  96043. /**
  96044. * Gets the object containing all engine capabilities
  96045. * @returns the EngineCapabilities object
  96046. */
  96047. getCaps(): EngineCapabilities;
  96048. /**
  96049. * stop executing a render loop function and remove it from the execution array
  96050. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96051. */
  96052. stopRenderLoop(renderFunction?: () => void): void;
  96053. /** @hidden */
  96054. _renderLoop(): void;
  96055. /**
  96056. * Gets the HTML canvas attached with the current webGL context
  96057. * @returns a HTML canvas
  96058. */
  96059. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96060. /**
  96061. * Gets host window
  96062. * @returns the host window object
  96063. */
  96064. getHostWindow(): Window;
  96065. /**
  96066. * Gets the current render width
  96067. * @param useScreen defines if screen size must be used (or the current render target if any)
  96068. * @returns a number defining the current render width
  96069. */
  96070. getRenderWidth(useScreen?: boolean): number;
  96071. /**
  96072. * Gets the current render height
  96073. * @param useScreen defines if screen size must be used (or the current render target if any)
  96074. * @returns a number defining the current render height
  96075. */
  96076. getRenderHeight(useScreen?: boolean): number;
  96077. /**
  96078. * Can be used to override the current requestAnimationFrame requester.
  96079. * @hidden
  96080. */
  96081. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96082. /**
  96083. * Register and execute a render loop. The engine can have more than one render function
  96084. * @param renderFunction defines the function to continuously execute
  96085. */
  96086. runRenderLoop(renderFunction: () => void): void;
  96087. /**
  96088. * Clear the current render buffer or the current render target (if any is set up)
  96089. * @param color defines the color to use
  96090. * @param backBuffer defines if the back buffer must be cleared
  96091. * @param depth defines if the depth buffer must be cleared
  96092. * @param stencil defines if the stencil buffer must be cleared
  96093. */
  96094. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96095. private _viewportCached;
  96096. /** @hidden */
  96097. _viewport(x: number, y: number, width: number, height: number): void;
  96098. /**
  96099. * Set the WebGL's viewport
  96100. * @param viewport defines the viewport element to be used
  96101. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96102. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96103. */
  96104. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96105. /**
  96106. * Begin a new frame
  96107. */
  96108. beginFrame(): void;
  96109. /**
  96110. * Enf the current frame
  96111. */
  96112. endFrame(): void;
  96113. /**
  96114. * Resize the view according to the canvas' size
  96115. */
  96116. resize(): void;
  96117. /**
  96118. * Force a specific size of the canvas
  96119. * @param width defines the new canvas' width
  96120. * @param height defines the new canvas' height
  96121. */
  96122. setSize(width: number, height: number): void;
  96123. /**
  96124. * Binds the frame buffer to the specified texture.
  96125. * @param texture The texture to render to or null for the default canvas
  96126. * @param faceIndex The face of the texture to render to in case of cube texture
  96127. * @param requiredWidth The width of the target to render to
  96128. * @param requiredHeight The height of the target to render to
  96129. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96130. * @param depthStencilTexture The depth stencil texture to use to render
  96131. * @param lodLevel defines le lod level to bind to the frame buffer
  96132. */
  96133. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96134. /** @hidden */
  96135. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96136. /**
  96137. * Unbind the current render target texture from the webGL context
  96138. * @param texture defines the render target texture to unbind
  96139. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96140. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96141. */
  96142. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96143. /**
  96144. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96145. */
  96146. flushFramebuffer(): void;
  96147. /**
  96148. * Unbind the current render target and bind the default framebuffer
  96149. */
  96150. restoreDefaultFramebuffer(): void;
  96151. private _resetVertexBufferBinding;
  96152. /**
  96153. * Creates a vertex buffer
  96154. * @param data the data for the vertex buffer
  96155. * @returns the new WebGL static buffer
  96156. */
  96157. createVertexBuffer(data: DataArray): DataBuffer;
  96158. private _createVertexBuffer;
  96159. /**
  96160. * Creates a dynamic vertex buffer
  96161. * @param data the data for the dynamic vertex buffer
  96162. * @returns the new WebGL dynamic buffer
  96163. */
  96164. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96165. /**
  96166. * Update a dynamic index buffer
  96167. * @param indexBuffer defines the target index buffer
  96168. * @param indices defines the data to update
  96169. * @param offset defines the offset in the target index buffer where update should start
  96170. */
  96171. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96172. /**
  96173. * Updates a dynamic vertex buffer.
  96174. * @param vertexBuffer the vertex buffer to update
  96175. * @param data the data used to update the vertex buffer
  96176. * @param byteOffset the byte offset of the data
  96177. * @param byteLength the byte length of the data
  96178. */
  96179. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96180. private _resetIndexBufferBinding;
  96181. /**
  96182. * Creates a new index buffer
  96183. * @param indices defines the content of the index buffer
  96184. * @param updatable defines if the index buffer must be updatable
  96185. * @returns a new webGL buffer
  96186. */
  96187. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96188. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96189. /**
  96190. * Bind a webGL buffer to the webGL context
  96191. * @param buffer defines the buffer to bind
  96192. */
  96193. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96194. private bindIndexBuffer;
  96195. private bindBuffer;
  96196. /**
  96197. * update the bound buffer with the given data
  96198. * @param data defines the data to update
  96199. */
  96200. updateArrayBuffer(data: Float32Array): void;
  96201. private _vertexAttribPointer;
  96202. private _bindIndexBufferWithCache;
  96203. private _bindVertexBuffersAttributes;
  96204. /**
  96205. * Records a vertex array object
  96206. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96207. * @param vertexBuffers defines the list of vertex buffers to store
  96208. * @param indexBuffer defines the index buffer to store
  96209. * @param effect defines the effect to store
  96210. * @returns the new vertex array object
  96211. */
  96212. recordVertexArrayObject(vertexBuffers: {
  96213. [key: string]: VertexBuffer;
  96214. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96215. /**
  96216. * Bind a specific vertex array object
  96217. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96218. * @param vertexArrayObject defines the vertex array object to bind
  96219. * @param indexBuffer defines the index buffer to bind
  96220. */
  96221. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96222. /**
  96223. * Bind webGl buffers directly to the webGL context
  96224. * @param vertexBuffer defines the vertex buffer to bind
  96225. * @param indexBuffer defines the index buffer to bind
  96226. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96227. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96228. * @param effect defines the effect associated with the vertex buffer
  96229. */
  96230. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96231. private _unbindVertexArrayObject;
  96232. /**
  96233. * Bind a list of vertex buffers to the webGL context
  96234. * @param vertexBuffers defines the list of vertex buffers to bind
  96235. * @param indexBuffer defines the index buffer to bind
  96236. * @param effect defines the effect associated with the vertex buffers
  96237. */
  96238. bindBuffers(vertexBuffers: {
  96239. [key: string]: Nullable<VertexBuffer>;
  96240. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96241. /**
  96242. * Unbind all instance attributes
  96243. */
  96244. unbindInstanceAttributes(): void;
  96245. /**
  96246. * Release and free the memory of a vertex array object
  96247. * @param vao defines the vertex array object to delete
  96248. */
  96249. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96250. /** @hidden */
  96251. _releaseBuffer(buffer: DataBuffer): boolean;
  96252. protected _deleteBuffer(buffer: DataBuffer): void;
  96253. /**
  96254. * Creates a webGL buffer to use with instanciation
  96255. * @param capacity defines the size of the buffer
  96256. * @returns the webGL buffer
  96257. */
  96258. createInstancesBuffer(capacity: number): DataBuffer;
  96259. /**
  96260. * Delete a webGL buffer used with instanciation
  96261. * @param buffer defines the webGL buffer to delete
  96262. */
  96263. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96264. /**
  96265. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96266. * @param instancesBuffer defines the webGL buffer to update and bind
  96267. * @param data defines the data to store in the buffer
  96268. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96269. */
  96270. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96271. /**
  96272. * Apply all cached states (depth, culling, stencil and alpha)
  96273. */
  96274. applyStates(): void;
  96275. /**
  96276. * Send a draw order
  96277. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96278. * @param indexStart defines the starting index
  96279. * @param indexCount defines the number of index to draw
  96280. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96281. */
  96282. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96283. /**
  96284. * Draw a list of points
  96285. * @param verticesStart defines the index of first vertex to draw
  96286. * @param verticesCount defines the count of vertices to draw
  96287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96288. */
  96289. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96290. /**
  96291. * Draw a list of unindexed primitives
  96292. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96293. * @param verticesStart defines the index of first vertex to draw
  96294. * @param verticesCount defines the count of vertices to draw
  96295. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96296. */
  96297. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96298. /**
  96299. * Draw a list of indexed primitives
  96300. * @param fillMode defines the primitive to use
  96301. * @param indexStart defines the starting index
  96302. * @param indexCount defines the number of index to draw
  96303. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96304. */
  96305. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96306. /**
  96307. * Draw a list of unindexed primitives
  96308. * @param fillMode defines the primitive to use
  96309. * @param verticesStart defines the index of first vertex to draw
  96310. * @param verticesCount defines the count of vertices to draw
  96311. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96312. */
  96313. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96314. private _drawMode;
  96315. /** @hidden */
  96316. _releaseEffect(effect: Effect): void;
  96317. /** @hidden */
  96318. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96319. /**
  96320. * Create a new effect (used to store vertex/fragment shaders)
  96321. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96322. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96323. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96324. * @param samplers defines an array of string used to represent textures
  96325. * @param defines defines the string containing the defines to use to compile the shaders
  96326. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96327. * @param onCompiled defines a function to call when the effect creation is successful
  96328. * @param onError defines a function to call when the effect creation has failed
  96329. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96330. * @returns the new Effect
  96331. */
  96332. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96333. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96334. private _compileShader;
  96335. private _compileRawShader;
  96336. /**
  96337. * Directly creates a webGL program
  96338. * @param pipelineContext defines the pipeline context to attach to
  96339. * @param vertexCode defines the vertex shader code to use
  96340. * @param fragmentCode defines the fragment shader code to use
  96341. * @param context defines the webGL context to use (if not set, the current one will be used)
  96342. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96343. * @returns the new webGL program
  96344. */
  96345. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96346. /**
  96347. * Creates a webGL program
  96348. * @param pipelineContext defines the pipeline context to attach to
  96349. * @param vertexCode defines the vertex shader code to use
  96350. * @param fragmentCode defines the fragment shader code to use
  96351. * @param defines defines the string containing the defines to use to compile the shaders
  96352. * @param context defines the webGL context to use (if not set, the current one will be used)
  96353. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96354. * @returns the new webGL program
  96355. */
  96356. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96357. /**
  96358. * Creates a new pipeline context
  96359. * @returns the new pipeline
  96360. */
  96361. createPipelineContext(): IPipelineContext;
  96362. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96363. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96364. /** @hidden */
  96365. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96366. /** @hidden */
  96367. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96368. /** @hidden */
  96369. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96370. /**
  96371. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96372. * @param pipelineContext defines the pipeline context to use
  96373. * @param uniformsNames defines the list of uniform names
  96374. * @returns an array of webGL uniform locations
  96375. */
  96376. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96377. /**
  96378. * Gets the lsit of active attributes for a given webGL program
  96379. * @param pipelineContext defines the pipeline context to use
  96380. * @param attributesNames defines the list of attribute names to get
  96381. * @returns an array of indices indicating the offset of each attribute
  96382. */
  96383. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96384. /**
  96385. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96386. * @param effect defines the effect to activate
  96387. */
  96388. enableEffect(effect: Nullable<Effect>): void;
  96389. /**
  96390. * Set the value of an uniform to an array of int32
  96391. * @param uniform defines the webGL uniform location where to store the value
  96392. * @param array defines the array of int32 to store
  96393. */
  96394. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96395. /**
  96396. * Set the value of an uniform to an array of int32 (stored as vec2)
  96397. * @param uniform defines the webGL uniform location where to store the value
  96398. * @param array defines the array of int32 to store
  96399. */
  96400. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96401. /**
  96402. * Set the value of an uniform to an array of int32 (stored as vec3)
  96403. * @param uniform defines the webGL uniform location where to store the value
  96404. * @param array defines the array of int32 to store
  96405. */
  96406. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96407. /**
  96408. * Set the value of an uniform to an array of int32 (stored as vec4)
  96409. * @param uniform defines the webGL uniform location where to store the value
  96410. * @param array defines the array of int32 to store
  96411. */
  96412. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96413. /**
  96414. * Set the value of an uniform to an array of float32
  96415. * @param uniform defines the webGL uniform location where to store the value
  96416. * @param array defines the array of float32 to store
  96417. */
  96418. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96419. /**
  96420. * Set the value of an uniform to an array of float32 (stored as vec2)
  96421. * @param uniform defines the webGL uniform location where to store the value
  96422. * @param array defines the array of float32 to store
  96423. */
  96424. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96425. /**
  96426. * Set the value of an uniform to an array of float32 (stored as vec3)
  96427. * @param uniform defines the webGL uniform location where to store the value
  96428. * @param array defines the array of float32 to store
  96429. */
  96430. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96431. /**
  96432. * Set the value of an uniform to an array of float32 (stored as vec4)
  96433. * @param uniform defines the webGL uniform location where to store the value
  96434. * @param array defines the array of float32 to store
  96435. */
  96436. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96437. /**
  96438. * Set the value of an uniform to an array of number
  96439. * @param uniform defines the webGL uniform location where to store the value
  96440. * @param array defines the array of number to store
  96441. */
  96442. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96443. /**
  96444. * Set the value of an uniform to an array of number (stored as vec2)
  96445. * @param uniform defines the webGL uniform location where to store the value
  96446. * @param array defines the array of number to store
  96447. */
  96448. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96449. /**
  96450. * Set the value of an uniform to an array of number (stored as vec3)
  96451. * @param uniform defines the webGL uniform location where to store the value
  96452. * @param array defines the array of number to store
  96453. */
  96454. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96455. /**
  96456. * Set the value of an uniform to an array of number (stored as vec4)
  96457. * @param uniform defines the webGL uniform location where to store the value
  96458. * @param array defines the array of number to store
  96459. */
  96460. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96461. /**
  96462. * Set the value of an uniform to an array of float32 (stored as matrices)
  96463. * @param uniform defines the webGL uniform location where to store the value
  96464. * @param matrices defines the array of float32 to store
  96465. */
  96466. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96467. /**
  96468. * Set the value of an uniform to a matrix (3x3)
  96469. * @param uniform defines the webGL uniform location where to store the value
  96470. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96471. */
  96472. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96473. /**
  96474. * Set the value of an uniform to a matrix (2x2)
  96475. * @param uniform defines the webGL uniform location where to store the value
  96476. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96477. */
  96478. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96479. /**
  96480. * Set the value of an uniform to a number (int)
  96481. * @param uniform defines the webGL uniform location where to store the value
  96482. * @param value defines the int number to store
  96483. */
  96484. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96485. /**
  96486. * Set the value of an uniform to a number (float)
  96487. * @param uniform defines the webGL uniform location where to store the value
  96488. * @param value defines the float number to store
  96489. */
  96490. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96491. /**
  96492. * Set the value of an uniform to a vec2
  96493. * @param uniform defines the webGL uniform location where to store the value
  96494. * @param x defines the 1st component of the value
  96495. * @param y defines the 2nd component of the value
  96496. */
  96497. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96498. /**
  96499. * Set the value of an uniform to a vec3
  96500. * @param uniform defines the webGL uniform location where to store the value
  96501. * @param x defines the 1st component of the value
  96502. * @param y defines the 2nd component of the value
  96503. * @param z defines the 3rd component of the value
  96504. */
  96505. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96506. /**
  96507. * Set the value of an uniform to a boolean
  96508. * @param uniform defines the webGL uniform location where to store the value
  96509. * @param bool defines the boolean to store
  96510. */
  96511. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96512. /**
  96513. * Set the value of an uniform to a vec4
  96514. * @param uniform defines the webGL uniform location where to store the value
  96515. * @param x defines the 1st component of the value
  96516. * @param y defines the 2nd component of the value
  96517. * @param z defines the 3rd component of the value
  96518. * @param w defines the 4th component of the value
  96519. */
  96520. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96521. /**
  96522. * Sets a Color4 on a uniform variable
  96523. * @param uniform defines the uniform location
  96524. * @param color4 defines the value to be set
  96525. */
  96526. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96527. /**
  96528. * Gets the depth culling state manager
  96529. */
  96530. readonly depthCullingState: DepthCullingState;
  96531. /**
  96532. * Gets the alpha state manager
  96533. */
  96534. readonly alphaState: AlphaState;
  96535. /**
  96536. * Gets the stencil state manager
  96537. */
  96538. readonly stencilState: StencilState;
  96539. /**
  96540. * Clears the list of texture accessible through engine.
  96541. * This can help preventing texture load conflict due to name collision.
  96542. */
  96543. clearInternalTexturesCache(): void;
  96544. /**
  96545. * Force the entire cache to be cleared
  96546. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96547. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96548. */
  96549. wipeCaches(bruteForce?: boolean): void;
  96550. /** @hidden */
  96551. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96552. min: number;
  96553. mag: number;
  96554. };
  96555. /** @hidden */
  96556. _createTexture(): WebGLTexture;
  96557. /**
  96558. * Usually called from Texture.ts.
  96559. * Passed information to create a WebGLTexture
  96560. * @param urlArg defines a value which contains one of the following:
  96561. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96562. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96563. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96564. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96565. * @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)
  96566. * @param scene needed for loading to the correct scene
  96567. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96568. * @param onLoad optional callback to be called upon successful completion
  96569. * @param onError optional callback to be called upon failure
  96570. * @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
  96571. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96572. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96573. * @param forcedExtension defines the extension to use to pick the right loader
  96574. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96575. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96576. */
  96577. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96578. /**
  96579. * @hidden
  96580. */
  96581. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96582. /**
  96583. * Creates a raw texture
  96584. * @param data defines the data to store in the texture
  96585. * @param width defines the width of the texture
  96586. * @param height defines the height of the texture
  96587. * @param format defines the format of the data
  96588. * @param generateMipMaps defines if the engine should generate the mip levels
  96589. * @param invertY defines if data must be stored with Y axis inverted
  96590. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96591. * @param compression defines the compression used (null by default)
  96592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96593. * @returns the raw texture inside an InternalTexture
  96594. */
  96595. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96596. /**
  96597. * Creates a new raw cube texture
  96598. * @param data defines the array of data to use to create each face
  96599. * @param size defines the size of the textures
  96600. * @param format defines the format of the data
  96601. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96602. * @param generateMipMaps defines if the engine should generate the mip levels
  96603. * @param invertY defines if data must be stored with Y axis inverted
  96604. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96605. * @param compression defines the compression used (null by default)
  96606. * @returns the cube texture as an InternalTexture
  96607. */
  96608. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96609. /**
  96610. * Creates a new raw 3D texture
  96611. * @param data defines the data used to create the texture
  96612. * @param width defines the width of the texture
  96613. * @param height defines the height of the texture
  96614. * @param depth defines the depth of the texture
  96615. * @param format defines the format of the texture
  96616. * @param generateMipMaps defines if the engine must generate mip levels
  96617. * @param invertY defines if data must be stored with Y axis inverted
  96618. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96619. * @param compression defines the compressed used (can be null)
  96620. * @param textureType defines the compressed used (can be null)
  96621. * @returns a new raw 3D texture (stored in an InternalTexture)
  96622. */
  96623. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96624. private _unpackFlipYCached;
  96625. /**
  96626. * In case you are sharing the context with other applications, it might
  96627. * be interested to not cache the unpack flip y state to ensure a consistent
  96628. * value would be set.
  96629. */
  96630. enableUnpackFlipYCached: boolean;
  96631. /** @hidden */
  96632. _unpackFlipY(value: boolean): void;
  96633. /** @hidden */
  96634. _getUnpackAlignement(): number;
  96635. /**
  96636. * Update the sampling mode of a given texture
  96637. * @param samplingMode defines the required sampling mode
  96638. * @param texture defines the texture to update
  96639. */
  96640. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96641. /**
  96642. * Updates a depth texture Comparison Mode and Function.
  96643. * If the comparison Function is equal to 0, the mode will be set to none.
  96644. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96645. * @param texture The texture to set the comparison function for
  96646. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96647. */
  96648. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96649. /** @hidden */
  96650. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96651. width: number;
  96652. height: number;
  96653. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96654. /**
  96655. * Creates a depth stencil texture.
  96656. * This is only available in WebGL 2 or with the depth texture extension available.
  96657. * @param size The size of face edge in the texture.
  96658. * @param options The options defining the texture.
  96659. * @returns The texture
  96660. */
  96661. createDepthStencilTexture(size: number | {
  96662. width: number;
  96663. height: number;
  96664. }, options: DepthTextureCreationOptions): InternalTexture;
  96665. /**
  96666. * Creates a depth stencil texture.
  96667. * This is only available in WebGL 2 or with the depth texture extension available.
  96668. * @param size The size of face edge in the texture.
  96669. * @param options The options defining the texture.
  96670. * @returns The texture
  96671. */
  96672. private _createDepthStencilTexture;
  96673. /**
  96674. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96675. * @param renderTarget The render target to set the frame buffer for
  96676. */
  96677. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96678. /** @hidden */
  96679. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96680. /** @hidden */
  96681. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96682. /** @hidden */
  96683. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96684. /** @hidden */
  96685. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96686. /** @hidden */
  96687. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96688. /**
  96689. * @hidden
  96690. */
  96691. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96692. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96693. private _prepareWebGLTexture;
  96694. /** @hidden */
  96695. _releaseFramebufferObjects(texture: InternalTexture): void;
  96696. /** @hidden */
  96697. _releaseTexture(texture: InternalTexture): void;
  96698. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96699. protected _setProgram(program: WebGLProgram): void;
  96700. protected _boundUniforms: {
  96701. [key: number]: WebGLUniformLocation;
  96702. };
  96703. /**
  96704. * Binds an effect to the webGL context
  96705. * @param effect defines the effect to bind
  96706. */
  96707. bindSamplers(effect: Effect): void;
  96708. private _activateCurrentTexture;
  96709. /** @hidden */
  96710. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96711. /** @hidden */
  96712. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96713. /**
  96714. * Unbind all textures from the webGL context
  96715. */
  96716. unbindAllTextures(): void;
  96717. /**
  96718. * Sets a texture to the according uniform.
  96719. * @param channel The texture channel
  96720. * @param uniform The uniform to set
  96721. * @param texture The texture to apply
  96722. */
  96723. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96724. private _bindSamplerUniformToChannel;
  96725. private _getTextureWrapMode;
  96726. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96727. /**
  96728. * Sets an array of texture to the webGL context
  96729. * @param channel defines the channel where the texture array must be set
  96730. * @param uniform defines the associated uniform location
  96731. * @param textures defines the array of textures to bind
  96732. */
  96733. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96734. /** @hidden */
  96735. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96736. private _setTextureParameterFloat;
  96737. private _setTextureParameterInteger;
  96738. /**
  96739. * Unbind all vertex attributes from the webGL context
  96740. */
  96741. unbindAllAttributes(): void;
  96742. /**
  96743. * 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
  96744. */
  96745. releaseEffects(): void;
  96746. /**
  96747. * Dispose and release all associated resources
  96748. */
  96749. dispose(): void;
  96750. /**
  96751. * Attach a new callback raised when context lost event is fired
  96752. * @param callback defines the callback to call
  96753. */
  96754. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96755. /**
  96756. * Attach a new callback raised when context restored event is fired
  96757. * @param callback defines the callback to call
  96758. */
  96759. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96760. /**
  96761. * Get the current error code of the webGL context
  96762. * @returns the error code
  96763. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96764. */
  96765. getError(): number;
  96766. private _canRenderToFloatFramebuffer;
  96767. private _canRenderToHalfFloatFramebuffer;
  96768. private _canRenderToFramebuffer;
  96769. /** @hidden */
  96770. _getWebGLTextureType(type: number): number;
  96771. /** @hidden */
  96772. _getInternalFormat(format: number): number;
  96773. /** @hidden */
  96774. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96775. /** @hidden */
  96776. _getRGBAMultiSampleBufferFormat(type: number): number;
  96777. /** @hidden */
  96778. _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;
  96779. /**
  96780. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96781. * @returns true if the engine can be created
  96782. * @ignorenaming
  96783. */
  96784. static isSupported(): boolean;
  96785. /**
  96786. * Find the next highest power of two.
  96787. * @param x Number to start search from.
  96788. * @return Next highest power of two.
  96789. */
  96790. static CeilingPOT(x: number): number;
  96791. /**
  96792. * Find the next lowest power of two.
  96793. * @param x Number to start search from.
  96794. * @return Next lowest power of two.
  96795. */
  96796. static FloorPOT(x: number): number;
  96797. /**
  96798. * Find the nearest power of two.
  96799. * @param x Number to start search from.
  96800. * @return Next nearest power of two.
  96801. */
  96802. static NearestPOT(x: number): number;
  96803. /**
  96804. * Get the closest exponent of two
  96805. * @param value defines the value to approximate
  96806. * @param max defines the maximum value to return
  96807. * @param mode defines how to define the closest value
  96808. * @returns closest exponent of two of the given value
  96809. */
  96810. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96811. /**
  96812. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96813. * @param func - the function to be called
  96814. * @param requester - the object that will request the next frame. Falls back to window.
  96815. * @returns frame number
  96816. */
  96817. static QueueNewFrame(func: () => void, requester?: any): number;
  96818. }
  96819. }
  96820. declare module BABYLON {
  96821. /**
  96822. * Class used to store data associated with WebGL texture data for the engine
  96823. * This class should not be used directly
  96824. */
  96825. export class InternalTexture {
  96826. /** @hidden */
  96827. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96828. /**
  96829. * The source of the texture data is unknown
  96830. */
  96831. static DATASOURCE_UNKNOWN: number;
  96832. /**
  96833. * Texture data comes from an URL
  96834. */
  96835. static DATASOURCE_URL: number;
  96836. /**
  96837. * Texture data is only used for temporary storage
  96838. */
  96839. static DATASOURCE_TEMP: number;
  96840. /**
  96841. * Texture data comes from raw data (ArrayBuffer)
  96842. */
  96843. static DATASOURCE_RAW: number;
  96844. /**
  96845. * Texture content is dynamic (video or dynamic texture)
  96846. */
  96847. static DATASOURCE_DYNAMIC: number;
  96848. /**
  96849. * Texture content is generated by rendering to it
  96850. */
  96851. static DATASOURCE_RENDERTARGET: number;
  96852. /**
  96853. * Texture content is part of a multi render target process
  96854. */
  96855. static DATASOURCE_MULTIRENDERTARGET: number;
  96856. /**
  96857. * Texture data comes from a cube data file
  96858. */
  96859. static DATASOURCE_CUBE: number;
  96860. /**
  96861. * Texture data comes from a raw cube data
  96862. */
  96863. static DATASOURCE_CUBERAW: number;
  96864. /**
  96865. * Texture data come from a prefiltered cube data file
  96866. */
  96867. static DATASOURCE_CUBEPREFILTERED: number;
  96868. /**
  96869. * Texture content is raw 3D data
  96870. */
  96871. static DATASOURCE_RAW3D: number;
  96872. /**
  96873. * Texture content is a depth texture
  96874. */
  96875. static DATASOURCE_DEPTHTEXTURE: number;
  96876. /**
  96877. * Texture data comes from a raw cube data encoded with RGBD
  96878. */
  96879. static DATASOURCE_CUBERAW_RGBD: number;
  96880. /**
  96881. * Defines if the texture is ready
  96882. */
  96883. isReady: boolean;
  96884. /**
  96885. * Defines if the texture is a cube texture
  96886. */
  96887. isCube: boolean;
  96888. /**
  96889. * Defines if the texture contains 3D data
  96890. */
  96891. is3D: boolean;
  96892. /**
  96893. * Defines if the texture contains multiview data
  96894. */
  96895. isMultiview: boolean;
  96896. /**
  96897. * Gets the URL used to load this texture
  96898. */
  96899. url: string;
  96900. /**
  96901. * Gets the sampling mode of the texture
  96902. */
  96903. samplingMode: number;
  96904. /**
  96905. * Gets a boolean indicating if the texture needs mipmaps generation
  96906. */
  96907. generateMipMaps: boolean;
  96908. /**
  96909. * Gets the number of samples used by the texture (WebGL2+ only)
  96910. */
  96911. samples: number;
  96912. /**
  96913. * Gets the type of the texture (int, float...)
  96914. */
  96915. type: number;
  96916. /**
  96917. * Gets the format of the texture (RGB, RGBA...)
  96918. */
  96919. format: number;
  96920. /**
  96921. * Observable called when the texture is loaded
  96922. */
  96923. onLoadedObservable: Observable<InternalTexture>;
  96924. /**
  96925. * Gets the width of the texture
  96926. */
  96927. width: number;
  96928. /**
  96929. * Gets the height of the texture
  96930. */
  96931. height: number;
  96932. /**
  96933. * Gets the depth of the texture
  96934. */
  96935. depth: number;
  96936. /**
  96937. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  96938. */
  96939. baseWidth: number;
  96940. /**
  96941. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  96942. */
  96943. baseHeight: number;
  96944. /**
  96945. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  96946. */
  96947. baseDepth: number;
  96948. /**
  96949. * Gets a boolean indicating if the texture is inverted on Y axis
  96950. */
  96951. invertY: boolean;
  96952. /** @hidden */
  96953. _invertVScale: boolean;
  96954. /** @hidden */
  96955. _associatedChannel: number;
  96956. /** @hidden */
  96957. _dataSource: number;
  96958. /** @hidden */
  96959. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  96960. /** @hidden */
  96961. _bufferView: Nullable<ArrayBufferView>;
  96962. /** @hidden */
  96963. _bufferViewArray: Nullable<ArrayBufferView[]>;
  96964. /** @hidden */
  96965. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  96966. /** @hidden */
  96967. _size: number;
  96968. /** @hidden */
  96969. _extension: string;
  96970. /** @hidden */
  96971. _files: Nullable<string[]>;
  96972. /** @hidden */
  96973. _workingCanvas: Nullable<HTMLCanvasElement>;
  96974. /** @hidden */
  96975. _workingContext: Nullable<CanvasRenderingContext2D>;
  96976. /** @hidden */
  96977. _framebuffer: Nullable<WebGLFramebuffer>;
  96978. /** @hidden */
  96979. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  96980. /** @hidden */
  96981. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  96982. /** @hidden */
  96983. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  96984. /** @hidden */
  96985. _attachments: Nullable<number[]>;
  96986. /** @hidden */
  96987. _cachedCoordinatesMode: Nullable<number>;
  96988. /** @hidden */
  96989. _cachedWrapU: Nullable<number>;
  96990. /** @hidden */
  96991. _cachedWrapV: Nullable<number>;
  96992. /** @hidden */
  96993. _cachedWrapR: Nullable<number>;
  96994. /** @hidden */
  96995. _cachedAnisotropicFilteringLevel: Nullable<number>;
  96996. /** @hidden */
  96997. _isDisabled: boolean;
  96998. /** @hidden */
  96999. _compression: Nullable<string>;
  97000. /** @hidden */
  97001. _generateStencilBuffer: boolean;
  97002. /** @hidden */
  97003. _generateDepthBuffer: boolean;
  97004. /** @hidden */
  97005. _comparisonFunction: number;
  97006. /** @hidden */
  97007. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97008. /** @hidden */
  97009. _lodGenerationScale: number;
  97010. /** @hidden */
  97011. _lodGenerationOffset: number;
  97012. /** @hidden */
  97013. _colorTextureArray: Nullable<WebGLTexture>;
  97014. /** @hidden */
  97015. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97016. /** @hidden */
  97017. _lodTextureHigh: Nullable<BaseTexture>;
  97018. /** @hidden */
  97019. _lodTextureMid: Nullable<BaseTexture>;
  97020. /** @hidden */
  97021. _lodTextureLow: Nullable<BaseTexture>;
  97022. /** @hidden */
  97023. _isRGBD: boolean;
  97024. /** @hidden */
  97025. _linearSpecularLOD: boolean;
  97026. /** @hidden */
  97027. _irradianceTexture: Nullable<BaseTexture>;
  97028. /** @hidden */
  97029. _webGLTexture: Nullable<WebGLTexture>;
  97030. /** @hidden */
  97031. _references: number;
  97032. private _engine;
  97033. /**
  97034. * Gets the Engine the texture belongs to.
  97035. * @returns The babylon engine
  97036. */
  97037. getEngine(): ThinEngine;
  97038. /**
  97039. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  97040. */
  97041. readonly dataSource: number;
  97042. /**
  97043. * Creates a new InternalTexture
  97044. * @param engine defines the engine to use
  97045. * @param dataSource defines the type of data that will be used
  97046. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97047. */
  97048. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  97049. /**
  97050. * Increments the number of references (ie. the number of Texture that point to it)
  97051. */
  97052. incrementReferences(): void;
  97053. /**
  97054. * Change the size of the texture (not the size of the content)
  97055. * @param width defines the new width
  97056. * @param height defines the new height
  97057. * @param depth defines the new depth (1 by default)
  97058. */
  97059. updateSize(width: int, height: int, depth?: int): void;
  97060. /** @hidden */
  97061. _rebuild(): void;
  97062. /** @hidden */
  97063. _swapAndDie(target: InternalTexture): void;
  97064. /**
  97065. * Dispose the current allocated resources
  97066. */
  97067. dispose(): void;
  97068. }
  97069. }
  97070. declare module BABYLON {
  97071. /**
  97072. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97074. */
  97075. export class Analyser {
  97076. /**
  97077. * Gets or sets the smoothing
  97078. * @ignorenaming
  97079. */
  97080. SMOOTHING: number;
  97081. /**
  97082. * Gets or sets the FFT table size
  97083. * @ignorenaming
  97084. */
  97085. FFT_SIZE: number;
  97086. /**
  97087. * Gets or sets the bar graph amplitude
  97088. * @ignorenaming
  97089. */
  97090. BARGRAPHAMPLITUDE: number;
  97091. /**
  97092. * Gets or sets the position of the debug canvas
  97093. * @ignorenaming
  97094. */
  97095. DEBUGCANVASPOS: {
  97096. x: number;
  97097. y: number;
  97098. };
  97099. /**
  97100. * Gets or sets the debug canvas size
  97101. * @ignorenaming
  97102. */
  97103. DEBUGCANVASSIZE: {
  97104. width: number;
  97105. height: number;
  97106. };
  97107. private _byteFreqs;
  97108. private _byteTime;
  97109. private _floatFreqs;
  97110. private _webAudioAnalyser;
  97111. private _debugCanvas;
  97112. private _debugCanvasContext;
  97113. private _scene;
  97114. private _registerFunc;
  97115. private _audioEngine;
  97116. /**
  97117. * Creates a new analyser
  97118. * @param scene defines hosting scene
  97119. */
  97120. constructor(scene: Scene);
  97121. /**
  97122. * Get the number of data values you will have to play with for the visualization
  97123. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97124. * @returns a number
  97125. */
  97126. getFrequencyBinCount(): number;
  97127. /**
  97128. * Gets the current frequency data as a byte array
  97129. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97130. * @returns a Uint8Array
  97131. */
  97132. getByteFrequencyData(): Uint8Array;
  97133. /**
  97134. * Gets the current waveform as a byte array
  97135. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97136. * @returns a Uint8Array
  97137. */
  97138. getByteTimeDomainData(): Uint8Array;
  97139. /**
  97140. * Gets the current frequency data as a float array
  97141. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97142. * @returns a Float32Array
  97143. */
  97144. getFloatFrequencyData(): Float32Array;
  97145. /**
  97146. * Renders the debug canvas
  97147. */
  97148. drawDebugCanvas(): void;
  97149. /**
  97150. * Stops rendering the debug canvas and removes it
  97151. */
  97152. stopDebugCanvas(): void;
  97153. /**
  97154. * Connects two audio nodes
  97155. * @param inputAudioNode defines first node to connect
  97156. * @param outputAudioNode defines second node to connect
  97157. */
  97158. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97159. /**
  97160. * Releases all associated resources
  97161. */
  97162. dispose(): void;
  97163. }
  97164. }
  97165. declare module BABYLON {
  97166. /**
  97167. * This represents an audio engine and it is responsible
  97168. * to play, synchronize and analyse sounds throughout the application.
  97169. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97170. */
  97171. export interface IAudioEngine extends IDisposable {
  97172. /**
  97173. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97174. */
  97175. readonly canUseWebAudio: boolean;
  97176. /**
  97177. * Gets the current AudioContext if available.
  97178. */
  97179. readonly audioContext: Nullable<AudioContext>;
  97180. /**
  97181. * The master gain node defines the global audio volume of your audio engine.
  97182. */
  97183. readonly masterGain: GainNode;
  97184. /**
  97185. * Gets whether or not mp3 are supported by your browser.
  97186. */
  97187. readonly isMP3supported: boolean;
  97188. /**
  97189. * Gets whether or not ogg are supported by your browser.
  97190. */
  97191. readonly isOGGsupported: boolean;
  97192. /**
  97193. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97194. * @ignoreNaming
  97195. */
  97196. WarnedWebAudioUnsupported: boolean;
  97197. /**
  97198. * Defines if the audio engine relies on a custom unlocked button.
  97199. * In this case, the embedded button will not be displayed.
  97200. */
  97201. useCustomUnlockedButton: boolean;
  97202. /**
  97203. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97204. */
  97205. readonly unlocked: boolean;
  97206. /**
  97207. * Event raised when audio has been unlocked on the browser.
  97208. */
  97209. onAudioUnlockedObservable: Observable<AudioEngine>;
  97210. /**
  97211. * Event raised when audio has been locked on the browser.
  97212. */
  97213. onAudioLockedObservable: Observable<AudioEngine>;
  97214. /**
  97215. * Flags the audio engine in Locked state.
  97216. * This happens due to new browser policies preventing audio to autoplay.
  97217. */
  97218. lock(): void;
  97219. /**
  97220. * Unlocks the audio engine once a user action has been done on the dom.
  97221. * This is helpful to resume play once browser policies have been satisfied.
  97222. */
  97223. unlock(): void;
  97224. }
  97225. /**
  97226. * This represents the default audio engine used in babylon.
  97227. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97228. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97229. */
  97230. export class AudioEngine implements IAudioEngine {
  97231. private _audioContext;
  97232. private _audioContextInitialized;
  97233. private _muteButton;
  97234. private _hostElement;
  97235. /**
  97236. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97237. */
  97238. canUseWebAudio: boolean;
  97239. /**
  97240. * The master gain node defines the global audio volume of your audio engine.
  97241. */
  97242. masterGain: GainNode;
  97243. /**
  97244. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97245. * @ignoreNaming
  97246. */
  97247. WarnedWebAudioUnsupported: boolean;
  97248. /**
  97249. * Gets whether or not mp3 are supported by your browser.
  97250. */
  97251. isMP3supported: boolean;
  97252. /**
  97253. * Gets whether or not ogg are supported by your browser.
  97254. */
  97255. isOGGsupported: boolean;
  97256. /**
  97257. * Gets whether audio has been unlocked on the device.
  97258. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97259. * a user interaction has happened.
  97260. */
  97261. unlocked: boolean;
  97262. /**
  97263. * Defines if the audio engine relies on a custom unlocked button.
  97264. * In this case, the embedded button will not be displayed.
  97265. */
  97266. useCustomUnlockedButton: boolean;
  97267. /**
  97268. * Event raised when audio has been unlocked on the browser.
  97269. */
  97270. onAudioUnlockedObservable: Observable<AudioEngine>;
  97271. /**
  97272. * Event raised when audio has been locked on the browser.
  97273. */
  97274. onAudioLockedObservable: Observable<AudioEngine>;
  97275. /**
  97276. * Gets the current AudioContext if available.
  97277. */
  97278. readonly audioContext: Nullable<AudioContext>;
  97279. private _connectedAnalyser;
  97280. /**
  97281. * Instantiates a new audio engine.
  97282. *
  97283. * There should be only one per page as some browsers restrict the number
  97284. * of audio contexts you can create.
  97285. * @param hostElement defines the host element where to display the mute icon if necessary
  97286. */
  97287. constructor(hostElement?: Nullable<HTMLElement>);
  97288. /**
  97289. * Flags the audio engine in Locked state.
  97290. * This happens due to new browser policies preventing audio to autoplay.
  97291. */
  97292. lock(): void;
  97293. /**
  97294. * Unlocks the audio engine once a user action has been done on the dom.
  97295. * This is helpful to resume play once browser policies have been satisfied.
  97296. */
  97297. unlock(): void;
  97298. private _resumeAudioContext;
  97299. private _initializeAudioContext;
  97300. private _tryToRun;
  97301. private _triggerRunningState;
  97302. private _triggerSuspendedState;
  97303. private _displayMuteButton;
  97304. private _moveButtonToTopLeft;
  97305. private _onResize;
  97306. private _hideMuteButton;
  97307. /**
  97308. * Destroy and release the resources associated with the audio ccontext.
  97309. */
  97310. dispose(): void;
  97311. /**
  97312. * Gets the global volume sets on the master gain.
  97313. * @returns the global volume if set or -1 otherwise
  97314. */
  97315. getGlobalVolume(): number;
  97316. /**
  97317. * Sets the global volume of your experience (sets on the master gain).
  97318. * @param newVolume Defines the new global volume of the application
  97319. */
  97320. setGlobalVolume(newVolume: number): void;
  97321. /**
  97322. * Connect the audio engine to an audio analyser allowing some amazing
  97323. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97325. * @param analyser The analyser to connect to the engine
  97326. */
  97327. connectToAnalyser(analyser: Analyser): void;
  97328. }
  97329. }
  97330. declare module BABYLON {
  97331. /**
  97332. * Interface used to present a loading screen while loading a scene
  97333. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97334. */
  97335. export interface ILoadingScreen {
  97336. /**
  97337. * Function called to display the loading screen
  97338. */
  97339. displayLoadingUI: () => void;
  97340. /**
  97341. * Function called to hide the loading screen
  97342. */
  97343. hideLoadingUI: () => void;
  97344. /**
  97345. * Gets or sets the color to use for the background
  97346. */
  97347. loadingUIBackgroundColor: string;
  97348. /**
  97349. * Gets or sets the text to display while loading
  97350. */
  97351. loadingUIText: string;
  97352. }
  97353. /**
  97354. * Class used for the default loading screen
  97355. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97356. */
  97357. export class DefaultLoadingScreen implements ILoadingScreen {
  97358. private _renderingCanvas;
  97359. private _loadingText;
  97360. private _loadingDivBackgroundColor;
  97361. private _loadingDiv;
  97362. private _loadingTextDiv;
  97363. /** Gets or sets the logo url to use for the default loading screen */
  97364. static DefaultLogoUrl: string;
  97365. /** Gets or sets the spinner url to use for the default loading screen */
  97366. static DefaultSpinnerUrl: string;
  97367. /**
  97368. * Creates a new default loading screen
  97369. * @param _renderingCanvas defines the canvas used to render the scene
  97370. * @param _loadingText defines the default text to display
  97371. * @param _loadingDivBackgroundColor defines the default background color
  97372. */
  97373. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97374. /**
  97375. * Function called to display the loading screen
  97376. */
  97377. displayLoadingUI(): void;
  97378. /**
  97379. * Function called to hide the loading screen
  97380. */
  97381. hideLoadingUI(): void;
  97382. /**
  97383. * Gets or sets the text to display while loading
  97384. */
  97385. loadingUIText: string;
  97386. /**
  97387. * Gets or sets the color to use for the background
  97388. */
  97389. loadingUIBackgroundColor: string;
  97390. private _resizeLoadingUI;
  97391. }
  97392. }
  97393. declare module BABYLON {
  97394. /**
  97395. * Interface for any object that can request an animation frame
  97396. */
  97397. export interface ICustomAnimationFrameRequester {
  97398. /**
  97399. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97400. */
  97401. renderFunction?: Function;
  97402. /**
  97403. * Called to request the next frame to render to
  97404. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97405. */
  97406. requestAnimationFrame: Function;
  97407. /**
  97408. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97409. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97410. */
  97411. requestID?: number;
  97412. }
  97413. }
  97414. declare module BABYLON {
  97415. /**
  97416. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97417. */
  97418. export class PerformanceMonitor {
  97419. private _enabled;
  97420. private _rollingFrameTime;
  97421. private _lastFrameTimeMs;
  97422. /**
  97423. * constructor
  97424. * @param frameSampleSize The number of samples required to saturate the sliding window
  97425. */
  97426. constructor(frameSampleSize?: number);
  97427. /**
  97428. * Samples current frame
  97429. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97430. */
  97431. sampleFrame(timeMs?: number): void;
  97432. /**
  97433. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97434. */
  97435. readonly averageFrameTime: number;
  97436. /**
  97437. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97438. */
  97439. readonly averageFrameTimeVariance: number;
  97440. /**
  97441. * Returns the frame time of the most recent frame
  97442. */
  97443. readonly instantaneousFrameTime: number;
  97444. /**
  97445. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97446. */
  97447. readonly averageFPS: number;
  97448. /**
  97449. * Returns the average framerate in frames per second using the most recent frame time
  97450. */
  97451. readonly instantaneousFPS: number;
  97452. /**
  97453. * Returns true if enough samples have been taken to completely fill the sliding window
  97454. */
  97455. readonly isSaturated: boolean;
  97456. /**
  97457. * Enables contributions to the sliding window sample set
  97458. */
  97459. enable(): void;
  97460. /**
  97461. * Disables contributions to the sliding window sample set
  97462. * Samples will not be interpolated over the disabled period
  97463. */
  97464. disable(): void;
  97465. /**
  97466. * Returns true if sampling is enabled
  97467. */
  97468. readonly isEnabled: boolean;
  97469. /**
  97470. * Resets performance monitor
  97471. */
  97472. reset(): void;
  97473. }
  97474. /**
  97475. * RollingAverage
  97476. *
  97477. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97478. */
  97479. export class RollingAverage {
  97480. /**
  97481. * Current average
  97482. */
  97483. average: number;
  97484. /**
  97485. * Current variance
  97486. */
  97487. variance: number;
  97488. protected _samples: Array<number>;
  97489. protected _sampleCount: number;
  97490. protected _pos: number;
  97491. protected _m2: number;
  97492. /**
  97493. * constructor
  97494. * @param length The number of samples required to saturate the sliding window
  97495. */
  97496. constructor(length: number);
  97497. /**
  97498. * Adds a sample to the sample set
  97499. * @param v The sample value
  97500. */
  97501. add(v: number): void;
  97502. /**
  97503. * Returns previously added values or null if outside of history or outside the sliding window domain
  97504. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97505. * @return Value previously recorded with add() or null if outside of range
  97506. */
  97507. history(i: number): number;
  97508. /**
  97509. * Returns true if enough samples have been taken to completely fill the sliding window
  97510. * @return true if sample-set saturated
  97511. */
  97512. isSaturated(): boolean;
  97513. /**
  97514. * Resets the rolling average (equivalent to 0 samples taken so far)
  97515. */
  97516. reset(): void;
  97517. /**
  97518. * Wraps a value around the sample range boundaries
  97519. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97520. * @return Wrapped position in sample range
  97521. */
  97522. protected _wrapPosition(i: number): number;
  97523. }
  97524. }
  97525. declare module BABYLON {
  97526. /**
  97527. * Defines the interface used by display changed events
  97528. */
  97529. export interface IDisplayChangedEventArgs {
  97530. /** Gets the vrDisplay object (if any) */
  97531. vrDisplay: Nullable<any>;
  97532. /** Gets a boolean indicating if webVR is supported */
  97533. vrSupported: boolean;
  97534. }
  97535. /**
  97536. * Defines the interface used by objects containing a viewport (like a camera)
  97537. */
  97538. interface IViewportOwnerLike {
  97539. /**
  97540. * Gets or sets the viewport
  97541. */
  97542. viewport: IViewportLike;
  97543. }
  97544. /**
  97545. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97546. */
  97547. export class Engine extends ThinEngine {
  97548. /** Defines that alpha blending is disabled */
  97549. static readonly ALPHA_DISABLE: number;
  97550. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97551. static readonly ALPHA_ADD: number;
  97552. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97553. static readonly ALPHA_COMBINE: number;
  97554. /** Defines that alpha blending to DEST - SRC * DEST */
  97555. static readonly ALPHA_SUBTRACT: number;
  97556. /** Defines that alpha blending to SRC * DEST */
  97557. static readonly ALPHA_MULTIPLY: number;
  97558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97559. static readonly ALPHA_MAXIMIZED: number;
  97560. /** Defines that alpha blending to SRC + DEST */
  97561. static readonly ALPHA_ONEONE: number;
  97562. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97563. static readonly ALPHA_PREMULTIPLIED: number;
  97564. /**
  97565. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97566. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97567. */
  97568. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97569. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97570. static readonly ALPHA_INTERPOLATE: number;
  97571. /**
  97572. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97573. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97574. */
  97575. static readonly ALPHA_SCREENMODE: number;
  97576. /** Defines that the ressource is not delayed*/
  97577. static readonly DELAYLOADSTATE_NONE: number;
  97578. /** Defines that the ressource was successfully delay loaded */
  97579. static readonly DELAYLOADSTATE_LOADED: number;
  97580. /** Defines that the ressource is currently delay loading */
  97581. static readonly DELAYLOADSTATE_LOADING: number;
  97582. /** Defines that the ressource is delayed and has not started loading */
  97583. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97584. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97585. static readonly NEVER: number;
  97586. /** 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 */
  97587. static readonly ALWAYS: number;
  97588. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97589. static readonly LESS: number;
  97590. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97591. static readonly EQUAL: number;
  97592. /** 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 */
  97593. static readonly LEQUAL: number;
  97594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97595. static readonly GREATER: number;
  97596. /** 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 */
  97597. static readonly GEQUAL: number;
  97598. /** 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 */
  97599. static readonly NOTEQUAL: number;
  97600. /** Passed to stencilOperation to specify that stencil value must be kept */
  97601. static readonly KEEP: number;
  97602. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97603. static readonly REPLACE: number;
  97604. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97605. static readonly INCR: number;
  97606. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97607. static readonly DECR: number;
  97608. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97609. static readonly INVERT: number;
  97610. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97611. static readonly INCR_WRAP: number;
  97612. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97613. static readonly DECR_WRAP: number;
  97614. /** Texture is not repeating outside of 0..1 UVs */
  97615. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97616. /** Texture is repeating outside of 0..1 UVs */
  97617. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97618. /** Texture is repeating and mirrored */
  97619. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97620. /** ALPHA */
  97621. static readonly TEXTUREFORMAT_ALPHA: number;
  97622. /** LUMINANCE */
  97623. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97624. /** LUMINANCE_ALPHA */
  97625. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97626. /** RGB */
  97627. static readonly TEXTUREFORMAT_RGB: number;
  97628. /** RGBA */
  97629. static readonly TEXTUREFORMAT_RGBA: number;
  97630. /** RED */
  97631. static readonly TEXTUREFORMAT_RED: number;
  97632. /** RED (2nd reference) */
  97633. static readonly TEXTUREFORMAT_R: number;
  97634. /** RG */
  97635. static readonly TEXTUREFORMAT_RG: number;
  97636. /** RED_INTEGER */
  97637. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97638. /** RED_INTEGER (2nd reference) */
  97639. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97640. /** RG_INTEGER */
  97641. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97642. /** RGB_INTEGER */
  97643. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97644. /** RGBA_INTEGER */
  97645. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97646. /** UNSIGNED_BYTE */
  97647. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97648. /** UNSIGNED_BYTE (2nd reference) */
  97649. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97650. /** FLOAT */
  97651. static readonly TEXTURETYPE_FLOAT: number;
  97652. /** HALF_FLOAT */
  97653. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97654. /** BYTE */
  97655. static readonly TEXTURETYPE_BYTE: number;
  97656. /** SHORT */
  97657. static readonly TEXTURETYPE_SHORT: number;
  97658. /** UNSIGNED_SHORT */
  97659. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97660. /** INT */
  97661. static readonly TEXTURETYPE_INT: number;
  97662. /** UNSIGNED_INT */
  97663. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97664. /** UNSIGNED_SHORT_4_4_4_4 */
  97665. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97666. /** UNSIGNED_SHORT_5_5_5_1 */
  97667. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97668. /** UNSIGNED_SHORT_5_6_5 */
  97669. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97670. /** UNSIGNED_INT_2_10_10_10_REV */
  97671. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97672. /** UNSIGNED_INT_24_8 */
  97673. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97674. /** UNSIGNED_INT_10F_11F_11F_REV */
  97675. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97676. /** UNSIGNED_INT_5_9_9_9_REV */
  97677. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97678. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97679. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97680. /** nearest is mag = nearest and min = nearest and mip = linear */
  97681. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97683. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97684. /** Trilinear is mag = linear and min = linear and mip = linear */
  97685. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97686. /** nearest is mag = nearest and min = nearest and mip = linear */
  97687. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97689. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97690. /** Trilinear is mag = linear and min = linear and mip = linear */
  97691. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97692. /** mag = nearest and min = nearest and mip = nearest */
  97693. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97694. /** mag = nearest and min = linear and mip = nearest */
  97695. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97696. /** mag = nearest and min = linear and mip = linear */
  97697. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97698. /** mag = nearest and min = linear and mip = none */
  97699. static readonly TEXTURE_NEAREST_LINEAR: number;
  97700. /** mag = nearest and min = nearest and mip = none */
  97701. static readonly TEXTURE_NEAREST_NEAREST: number;
  97702. /** mag = linear and min = nearest and mip = nearest */
  97703. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97704. /** mag = linear and min = nearest and mip = linear */
  97705. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97706. /** mag = linear and min = linear and mip = none */
  97707. static readonly TEXTURE_LINEAR_LINEAR: number;
  97708. /** mag = linear and min = nearest and mip = none */
  97709. static readonly TEXTURE_LINEAR_NEAREST: number;
  97710. /** Explicit coordinates mode */
  97711. static readonly TEXTURE_EXPLICIT_MODE: number;
  97712. /** Spherical coordinates mode */
  97713. static readonly TEXTURE_SPHERICAL_MODE: number;
  97714. /** Planar coordinates mode */
  97715. static readonly TEXTURE_PLANAR_MODE: number;
  97716. /** Cubic coordinates mode */
  97717. static readonly TEXTURE_CUBIC_MODE: number;
  97718. /** Projection coordinates mode */
  97719. static readonly TEXTURE_PROJECTION_MODE: number;
  97720. /** Skybox coordinates mode */
  97721. static readonly TEXTURE_SKYBOX_MODE: number;
  97722. /** Inverse Cubic coordinates mode */
  97723. static readonly TEXTURE_INVCUBIC_MODE: number;
  97724. /** Equirectangular coordinates mode */
  97725. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97726. /** Equirectangular Fixed coordinates mode */
  97727. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97728. /** Equirectangular Fixed Mirrored coordinates mode */
  97729. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97730. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97731. static readonly SCALEMODE_FLOOR: number;
  97732. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97733. static readonly SCALEMODE_NEAREST: number;
  97734. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97735. static readonly SCALEMODE_CEILING: number;
  97736. /**
  97737. * Returns the current npm package of the sdk
  97738. */
  97739. static readonly NpmPackage: string;
  97740. /**
  97741. * Returns the current version of the framework
  97742. */
  97743. static readonly Version: string;
  97744. /** Gets the list of created engines */
  97745. static readonly Instances: Engine[];
  97746. /**
  97747. * Gets the latest created engine
  97748. */
  97749. static readonly LastCreatedEngine: Nullable<Engine>;
  97750. /**
  97751. * Gets the latest created scene
  97752. */
  97753. static readonly LastCreatedScene: Nullable<Scene>;
  97754. /**
  97755. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97756. * @param flag defines which part of the materials must be marked as dirty
  97757. * @param predicate defines a predicate used to filter which materials should be affected
  97758. */
  97759. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97760. /**
  97761. * Method called to create the default loading screen.
  97762. * This can be overriden in your own app.
  97763. * @param canvas The rendering canvas element
  97764. * @returns The loading screen
  97765. */
  97766. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97767. /**
  97768. * Method called to create the default rescale post process on each engine.
  97769. */
  97770. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97771. /**
  97772. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97773. **/
  97774. enableOfflineSupport: boolean;
  97775. /**
  97776. * 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)
  97777. **/
  97778. disableManifestCheck: boolean;
  97779. /**
  97780. * Gets the list of created scenes
  97781. */
  97782. scenes: Scene[];
  97783. /**
  97784. * Event raised when a new scene is created
  97785. */
  97786. onNewSceneAddedObservable: Observable<Scene>;
  97787. /**
  97788. * Gets the list of created postprocesses
  97789. */
  97790. postProcesses: PostProcess[];
  97791. /**
  97792. * Gets a boolean indicating if the pointer is currently locked
  97793. */
  97794. isPointerLock: boolean;
  97795. /**
  97796. * Observable event triggered each time the rendering canvas is resized
  97797. */
  97798. onResizeObservable: Observable<Engine>;
  97799. /**
  97800. * Observable event triggered each time the canvas loses focus
  97801. */
  97802. onCanvasBlurObservable: Observable<Engine>;
  97803. /**
  97804. * Observable event triggered each time the canvas gains focus
  97805. */
  97806. onCanvasFocusObservable: Observable<Engine>;
  97807. /**
  97808. * Observable event triggered each time the canvas receives pointerout event
  97809. */
  97810. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97811. /**
  97812. * Observable event triggered before each texture is initialized
  97813. */
  97814. onBeforeTextureInitObservable: Observable<Texture>;
  97815. /**
  97816. * Observable raised when the engine begins a new frame
  97817. */
  97818. onBeginFrameObservable: Observable<Engine>;
  97819. /**
  97820. * If set, will be used to request the next animation frame for the render loop
  97821. */
  97822. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97823. /**
  97824. * Observable raised when the engine ends the current frame
  97825. */
  97826. onEndFrameObservable: Observable<Engine>;
  97827. /**
  97828. * Observable raised when the engine is about to compile a shader
  97829. */
  97830. onBeforeShaderCompilationObservable: Observable<Engine>;
  97831. /**
  97832. * Observable raised when the engine has jsut compiled a shader
  97833. */
  97834. onAfterShaderCompilationObservable: Observable<Engine>;
  97835. /**
  97836. * Gets the audio engine
  97837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97838. * @ignorenaming
  97839. */
  97840. static audioEngine: IAudioEngine;
  97841. /**
  97842. * Default AudioEngine factory responsible of creating the Audio Engine.
  97843. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  97844. */
  97845. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  97846. /**
  97847. * Default offline support factory responsible of creating a tool used to store data locally.
  97848. * By default, this will create a Database object if the workload has been embedded.
  97849. */
  97850. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  97851. private _loadingScreen;
  97852. private _pointerLockRequested;
  97853. private _dummyFramebuffer;
  97854. private _rescalePostProcess;
  97855. /** @hidden */
  97856. protected _alphaMode: number;
  97857. /** @hidden */
  97858. protected _alphaEquation: number;
  97859. private _deterministicLockstep;
  97860. private _lockstepMaxSteps;
  97861. protected readonly _supportsHardwareTextureRescaling: boolean;
  97862. private _fps;
  97863. private _deltaTime;
  97864. /**
  97865. * Turn this value on if you want to pause FPS computation when in background
  97866. */
  97867. disablePerformanceMonitorInBackground: boolean;
  97868. private _performanceMonitor;
  97869. /**
  97870. * Gets the performance monitor attached to this engine
  97871. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  97872. */
  97873. readonly performanceMonitor: PerformanceMonitor;
  97874. private _onFocus;
  97875. private _onBlur;
  97876. private _onCanvasPointerOut;
  97877. private _onCanvasBlur;
  97878. private _onCanvasFocus;
  97879. private _onFullscreenChange;
  97880. private _onPointerLockChange;
  97881. /**
  97882. * Creates a new engine
  97883. * @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
  97884. * @param antialias defines enable antialiasing (default: false)
  97885. * @param options defines further options to be sent to the getContext() function
  97886. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  97887. */
  97888. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  97889. /**
  97890. * Gets current aspect ratio
  97891. * @param viewportOwner defines the camera to use to get the aspect ratio
  97892. * @param useScreen defines if screen size must be used (or the current render target if any)
  97893. * @returns a number defining the aspect ratio
  97894. */
  97895. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  97896. /**
  97897. * Gets current screen aspect ratio
  97898. * @returns a number defining the aspect ratio
  97899. */
  97900. getScreenAspectRatio(): number;
  97901. /**
  97902. * Gets host document
  97903. * @returns the host document object
  97904. */
  97905. getHostDocument(): Document;
  97906. /**
  97907. * Gets the client rect of the HTML canvas attached with the current webGL context
  97908. * @returns a client rectanglee
  97909. */
  97910. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  97911. /**
  97912. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  97913. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97914. * @returns true if engine is in deterministic lock step mode
  97915. */
  97916. isDeterministicLockStep(): boolean;
  97917. /**
  97918. * Gets the max steps when engine is running in deterministic lock step
  97919. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  97920. * @returns the max steps
  97921. */
  97922. getLockstepMaxSteps(): number;
  97923. /**
  97924. * Force the mipmap generation for the given render target texture
  97925. * @param texture defines the render target texture to use
  97926. */
  97927. generateMipMapsForCubemap(texture: InternalTexture): void;
  97928. /** States */
  97929. /**
  97930. * Set various states to the webGL context
  97931. * @param culling defines backface culling state
  97932. * @param zOffset defines the value to apply to zOffset (0 by default)
  97933. * @param force defines if states must be applied even if cache is up to date
  97934. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97935. */
  97936. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97937. /**
  97938. * Set the z offset to apply to current rendering
  97939. * @param value defines the offset to apply
  97940. */
  97941. setZOffset(value: number): void;
  97942. /**
  97943. * Gets the current value of the zOffset
  97944. * @returns the current zOffset state
  97945. */
  97946. getZOffset(): number;
  97947. /**
  97948. * Enable or disable depth buffering
  97949. * @param enable defines the state to set
  97950. */
  97951. setDepthBuffer(enable: boolean): void;
  97952. /**
  97953. * Gets a boolean indicating if depth writing is enabled
  97954. * @returns the current depth writing state
  97955. */
  97956. getDepthWrite(): boolean;
  97957. /**
  97958. * Enable or disable depth writing
  97959. * @param enable defines the state to set
  97960. */
  97961. setDepthWrite(enable: boolean): void;
  97962. /**
  97963. * Enable or disable color writing
  97964. * @param enable defines the state to set
  97965. */
  97966. setColorWrite(enable: boolean): void;
  97967. /**
  97968. * Gets a boolean indicating if color writing is enabled
  97969. * @returns the current color writing state
  97970. */
  97971. getColorWrite(): boolean;
  97972. /**
  97973. * Sets alpha constants used by some alpha blending modes
  97974. * @param r defines the red component
  97975. * @param g defines the green component
  97976. * @param b defines the blue component
  97977. * @param a defines the alpha component
  97978. */
  97979. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97980. /**
  97981. * Sets the current alpha mode
  97982. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97983. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97984. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97985. */
  97986. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97987. /**
  97988. * Gets the current alpha mode
  97989. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97990. * @returns the current alpha mode
  97991. */
  97992. getAlphaMode(): number;
  97993. /**
  97994. * Sets the current alpha equation
  97995. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97996. */
  97997. setAlphaEquation(equation: number): void;
  97998. /**
  97999. * Gets the current alpha equation.
  98000. * @returns the current alpha equation
  98001. */
  98002. getAlphaEquation(): number;
  98003. /**
  98004. * Gets a boolean indicating if stencil buffer is enabled
  98005. * @returns the current stencil buffer state
  98006. */
  98007. getStencilBuffer(): boolean;
  98008. /**
  98009. * Enable or disable the stencil buffer
  98010. * @param enable defines if the stencil buffer must be enabled or disabled
  98011. */
  98012. setStencilBuffer(enable: boolean): void;
  98013. /**
  98014. * Gets the current stencil mask
  98015. * @returns a number defining the new stencil mask to use
  98016. */
  98017. getStencilMask(): number;
  98018. /**
  98019. * Sets the current stencil mask
  98020. * @param mask defines the new stencil mask to use
  98021. */
  98022. setStencilMask(mask: number): void;
  98023. /**
  98024. * Gets the current stencil function
  98025. * @returns a number defining the stencil function to use
  98026. */
  98027. getStencilFunction(): number;
  98028. /**
  98029. * Gets the current stencil reference value
  98030. * @returns a number defining the stencil reference value to use
  98031. */
  98032. getStencilFunctionReference(): number;
  98033. /**
  98034. * Gets the current stencil mask
  98035. * @returns a number defining the stencil mask to use
  98036. */
  98037. getStencilFunctionMask(): number;
  98038. /**
  98039. * Sets the current stencil function
  98040. * @param stencilFunc defines the new stencil function to use
  98041. */
  98042. setStencilFunction(stencilFunc: number): void;
  98043. /**
  98044. * Sets the current stencil reference
  98045. * @param reference defines the new stencil reference to use
  98046. */
  98047. setStencilFunctionReference(reference: number): void;
  98048. /**
  98049. * Sets the current stencil mask
  98050. * @param mask defines the new stencil mask to use
  98051. */
  98052. setStencilFunctionMask(mask: number): void;
  98053. /**
  98054. * Gets the current stencil operation when stencil fails
  98055. * @returns a number defining stencil operation to use when stencil fails
  98056. */
  98057. getStencilOperationFail(): number;
  98058. /**
  98059. * Gets the current stencil operation when depth fails
  98060. * @returns a number defining stencil operation to use when depth fails
  98061. */
  98062. getStencilOperationDepthFail(): number;
  98063. /**
  98064. * Gets the current stencil operation when stencil passes
  98065. * @returns a number defining stencil operation to use when stencil passes
  98066. */
  98067. getStencilOperationPass(): number;
  98068. /**
  98069. * Sets the stencil operation to use when stencil fails
  98070. * @param operation defines the stencil operation to use when stencil fails
  98071. */
  98072. setStencilOperationFail(operation: number): void;
  98073. /**
  98074. * Sets the stencil operation to use when depth fails
  98075. * @param operation defines the stencil operation to use when depth fails
  98076. */
  98077. setStencilOperationDepthFail(operation: number): void;
  98078. /**
  98079. * Sets the stencil operation to use when stencil passes
  98080. * @param operation defines the stencil operation to use when stencil passes
  98081. */
  98082. setStencilOperationPass(operation: number): void;
  98083. /**
  98084. * Sets a boolean indicating if the dithering state is enabled or disabled
  98085. * @param value defines the dithering state
  98086. */
  98087. setDitheringState(value: boolean): void;
  98088. /**
  98089. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98090. * @param value defines the rasterizer state
  98091. */
  98092. setRasterizerState(value: boolean): void;
  98093. /**
  98094. * Gets the current depth function
  98095. * @returns a number defining the depth function
  98096. */
  98097. getDepthFunction(): Nullable<number>;
  98098. /**
  98099. * Sets the current depth function
  98100. * @param depthFunc defines the function to use
  98101. */
  98102. setDepthFunction(depthFunc: number): void;
  98103. /**
  98104. * Sets the current depth function to GREATER
  98105. */
  98106. setDepthFunctionToGreater(): void;
  98107. /**
  98108. * Sets the current depth function to GEQUAL
  98109. */
  98110. setDepthFunctionToGreaterOrEqual(): void;
  98111. /**
  98112. * Sets the current depth function to LESS
  98113. */
  98114. setDepthFunctionToLess(): void;
  98115. /**
  98116. * Sets the current depth function to LEQUAL
  98117. */
  98118. setDepthFunctionToLessOrEqual(): void;
  98119. private _cachedStencilBuffer;
  98120. private _cachedStencilFunction;
  98121. private _cachedStencilMask;
  98122. private _cachedStencilOperationPass;
  98123. private _cachedStencilOperationFail;
  98124. private _cachedStencilOperationDepthFail;
  98125. private _cachedStencilReference;
  98126. /**
  98127. * Caches the the state of the stencil buffer
  98128. */
  98129. cacheStencilState(): void;
  98130. /**
  98131. * Restores the state of the stencil buffer
  98132. */
  98133. restoreStencilState(): void;
  98134. /**
  98135. * Directly set the WebGL Viewport
  98136. * @param x defines the x coordinate of the viewport (in screen space)
  98137. * @param y defines the y coordinate of the viewport (in screen space)
  98138. * @param width defines the width of the viewport (in screen space)
  98139. * @param height defines the height of the viewport (in screen space)
  98140. * @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
  98141. */
  98142. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98143. /**
  98144. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98145. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98146. * @param y defines the y-coordinate of the corner of the clear rectangle
  98147. * @param width defines the width of the clear rectangle
  98148. * @param height defines the height of the clear rectangle
  98149. * @param clearColor defines the clear color
  98150. */
  98151. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98152. /**
  98153. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98154. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98155. * @param y defines the y-coordinate of the corner of the clear rectangle
  98156. * @param width defines the width of the clear rectangle
  98157. * @param height defines the height of the clear rectangle
  98158. */
  98159. enableScissor(x: number, y: number, width: number, height: number): void;
  98160. /**
  98161. * Disable previously set scissor test rectangle
  98162. */
  98163. disableScissor(): void;
  98164. /**
  98165. * Initializes a webVR display and starts listening to display change events
  98166. * The onVRDisplayChangedObservable will be notified upon these changes
  98167. * @returns The onVRDisplayChangedObservable
  98168. */
  98169. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98170. /** @hidden */
  98171. _prepareVRComponent(): void;
  98172. /** @hidden */
  98173. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98174. /** @hidden */
  98175. _submitVRFrame(): void;
  98176. /**
  98177. * Call this function to leave webVR mode
  98178. * Will do nothing if webVR is not supported or if there is no webVR device
  98179. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98180. */
  98181. disableVR(): void;
  98182. /**
  98183. * Gets a boolean indicating that the system is in VR mode and is presenting
  98184. * @returns true if VR mode is engaged
  98185. */
  98186. isVRPresenting(): boolean;
  98187. /** @hidden */
  98188. _requestVRFrame(): void;
  98189. /** @hidden */
  98190. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98191. /**
  98192. * Gets the source code of the vertex shader associated with a specific webGL program
  98193. * @param program defines the program to use
  98194. * @returns a string containing the source code of the vertex shader associated with the program
  98195. */
  98196. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98197. /**
  98198. * Gets the source code of the fragment shader associated with a specific webGL program
  98199. * @param program defines the program to use
  98200. * @returns a string containing the source code of the fragment shader associated with the program
  98201. */
  98202. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98203. /**
  98204. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98205. * @param x defines the x coordinate of the rectangle where pixels must be read
  98206. * @param y defines the y coordinate of the rectangle where pixels must be read
  98207. * @param width defines the width of the rectangle where pixels must be read
  98208. * @param height defines the height of the rectangle where pixels must be read
  98209. * @returns a Uint8Array containing RGBA colors
  98210. */
  98211. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98212. /**
  98213. * Sets a depth stencil texture from a render target to the according uniform.
  98214. * @param channel The texture channel
  98215. * @param uniform The uniform to set
  98216. * @param texture The render target texture containing the depth stencil texture to apply
  98217. */
  98218. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98219. /**
  98220. * Sets a texture to the webGL context from a postprocess
  98221. * @param channel defines the channel to use
  98222. * @param postProcess defines the source postprocess
  98223. */
  98224. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98225. /**
  98226. * Binds the output of the passed in post process to the texture channel specified
  98227. * @param channel The channel the texture should be bound to
  98228. * @param postProcess The post process which's output should be bound
  98229. */
  98230. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98231. /** @hidden */
  98232. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98233. protected _rebuildBuffers(): void;
  98234. _renderLoop(): void;
  98235. /**
  98236. * Toggle full screen mode
  98237. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98238. */
  98239. switchFullscreen(requestPointerLock: boolean): void;
  98240. /**
  98241. * Enters full screen mode
  98242. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98243. */
  98244. enterFullscreen(requestPointerLock: boolean): void;
  98245. /**
  98246. * Exits full screen mode
  98247. */
  98248. exitFullscreen(): void;
  98249. /**
  98250. * Enters Pointerlock mode
  98251. */
  98252. enterPointerlock(): void;
  98253. /**
  98254. * Exits Pointerlock mode
  98255. */
  98256. exitPointerlock(): void;
  98257. /**
  98258. * Begin a new frame
  98259. */
  98260. beginFrame(): void;
  98261. /**
  98262. * Enf the current frame
  98263. */
  98264. endFrame(): void;
  98265. resize(): void;
  98266. /**
  98267. * Set the compressed texture format to use, based on the formats you have, and the formats
  98268. * supported by the hardware / browser.
  98269. *
  98270. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98271. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98272. * to API arguments needed to compressed textures. This puts the burden on the container
  98273. * generator to house the arcane code for determining these for current & future formats.
  98274. *
  98275. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98276. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98277. *
  98278. * Note: The result of this call is not taken into account when a texture is base64.
  98279. *
  98280. * @param formatsAvailable defines the list of those format families you have created
  98281. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98282. *
  98283. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98284. * @returns The extension selected.
  98285. */
  98286. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98287. /**
  98288. * Force a specific size of the canvas
  98289. * @param width defines the new canvas' width
  98290. * @param height defines the new canvas' height
  98291. */
  98292. setSize(width: number, height: number): void;
  98293. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98294. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98295. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98296. _releaseTexture(texture: InternalTexture): void;
  98297. /**
  98298. * @hidden
  98299. * Rescales a texture
  98300. * @param source input texutre
  98301. * @param destination destination texture
  98302. * @param scene scene to use to render the resize
  98303. * @param internalFormat format to use when resizing
  98304. * @param onComplete callback to be called when resize has completed
  98305. */
  98306. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98307. /**
  98308. * Gets the current framerate
  98309. * @returns a number representing the framerate
  98310. */
  98311. getFps(): number;
  98312. /**
  98313. * Gets the time spent between current and previous frame
  98314. * @returns a number representing the delta time in ms
  98315. */
  98316. getDeltaTime(): number;
  98317. private _measureFps;
  98318. /**
  98319. * Creates a new render target texture
  98320. * @param size defines the size of the texture
  98321. * @param options defines the options used to create the texture
  98322. * @returns a new render target texture stored in an InternalTexture
  98323. */
  98324. createRenderTargetTexture(size: number | {
  98325. width: number;
  98326. height: number;
  98327. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98328. /**
  98329. * Updates the sample count of a render target texture
  98330. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98331. * @param texture defines the texture to update
  98332. * @param samples defines the sample count to set
  98333. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98334. */
  98335. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98336. /** @hidden */
  98337. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98338. dispose(): void;
  98339. private _disableTouchAction;
  98340. /**
  98341. * Display the loading screen
  98342. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98343. */
  98344. displayLoadingUI(): void;
  98345. /**
  98346. * Hide the loading screen
  98347. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98348. */
  98349. hideLoadingUI(): void;
  98350. /**
  98351. * Gets the current loading screen object
  98352. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98353. */
  98354. /**
  98355. * Sets the current loading screen object
  98356. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98357. */
  98358. loadingScreen: ILoadingScreen;
  98359. /**
  98360. * Sets the current loading screen text
  98361. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98362. */
  98363. loadingUIText: string;
  98364. /**
  98365. * Sets the current loading screen background color
  98366. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98367. */
  98368. loadingUIBackgroundColor: string;
  98369. /** Pointerlock and fullscreen */
  98370. /**
  98371. * Ask the browser to promote the current element to pointerlock mode
  98372. * @param element defines the DOM element to promote
  98373. */
  98374. static _RequestPointerlock(element: HTMLElement): void;
  98375. /**
  98376. * Asks the browser to exit pointerlock mode
  98377. */
  98378. static _ExitPointerlock(): void;
  98379. /**
  98380. * Ask the browser to promote the current element to fullscreen rendering mode
  98381. * @param element defines the DOM element to promote
  98382. */
  98383. static _RequestFullscreen(element: HTMLElement): void;
  98384. /**
  98385. * Asks the browser to exit fullscreen mode
  98386. */
  98387. static _ExitFullscreen(): void;
  98388. }
  98389. }
  98390. declare module BABYLON {
  98391. /**
  98392. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98393. * during the life time of the application.
  98394. */
  98395. export class EngineStore {
  98396. /** Gets the list of created engines */
  98397. static Instances: Engine[];
  98398. /** @hidden */
  98399. static _LastCreatedScene: Nullable<Scene>;
  98400. /**
  98401. * Gets the latest created engine
  98402. */
  98403. static readonly LastCreatedEngine: Nullable<Engine>;
  98404. /**
  98405. * Gets the latest created scene
  98406. */
  98407. static readonly LastCreatedScene: Nullable<Scene>;
  98408. /**
  98409. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98410. * @ignorenaming
  98411. */
  98412. static UseFallbackTexture: boolean;
  98413. /**
  98414. * Texture content used if a texture cannot loaded
  98415. * @ignorenaming
  98416. */
  98417. static FallbackTexture: string;
  98418. }
  98419. }
  98420. declare module BABYLON {
  98421. /**
  98422. * Helper class that provides a small promise polyfill
  98423. */
  98424. export class PromisePolyfill {
  98425. /**
  98426. * Static function used to check if the polyfill is required
  98427. * If this is the case then the function will inject the polyfill to window.Promise
  98428. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98429. */
  98430. static Apply(force?: boolean): void;
  98431. }
  98432. }
  98433. declare module BABYLON {
  98434. /**
  98435. * Interface for screenshot methods with describe argument called `size` as object with options
  98436. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98437. */
  98438. export interface IScreenshotSize {
  98439. /**
  98440. * number in pixels for canvas height
  98441. */
  98442. height?: number;
  98443. /**
  98444. * multiplier allowing render at a higher or lower resolution
  98445. * If value is defined then height and width will be ignored and taken from camera
  98446. */
  98447. precision?: number;
  98448. /**
  98449. * number in pixels for canvas width
  98450. */
  98451. width?: number;
  98452. }
  98453. }
  98454. declare module BABYLON {
  98455. interface IColor4Like {
  98456. r: float;
  98457. g: float;
  98458. b: float;
  98459. a: float;
  98460. }
  98461. /**
  98462. * Class containing a set of static utilities functions
  98463. */
  98464. export class Tools {
  98465. /**
  98466. * Gets or sets the base URL to use to load assets
  98467. */
  98468. static BaseUrl: string;
  98469. /**
  98470. * Enable/Disable Custom HTTP Request Headers globally.
  98471. * default = false
  98472. * @see CustomRequestHeaders
  98473. */
  98474. static UseCustomRequestHeaders: boolean;
  98475. /**
  98476. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98477. * i.e. when loading files, where the server/service expects an Authorization header
  98478. */
  98479. static CustomRequestHeaders: {
  98480. [key: string]: string;
  98481. };
  98482. /**
  98483. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98484. */
  98485. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98486. /**
  98487. * Default behaviour for cors in the application.
  98488. * It can be a string if the expected behavior is identical in the entire app.
  98489. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98490. */
  98491. static CorsBehavior: string | ((url: string | string[]) => string);
  98492. /**
  98493. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98494. * @ignorenaming
  98495. */
  98496. static UseFallbackTexture: boolean;
  98497. /**
  98498. * Use this object to register external classes like custom textures or material
  98499. * to allow the laoders to instantiate them
  98500. */
  98501. static RegisteredExternalClasses: {
  98502. [key: string]: Object;
  98503. };
  98504. /**
  98505. * Texture content used if a texture cannot loaded
  98506. * @ignorenaming
  98507. */
  98508. static fallbackTexture: string;
  98509. /**
  98510. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98511. * @param u defines the coordinate on X axis
  98512. * @param v defines the coordinate on Y axis
  98513. * @param width defines the width of the source data
  98514. * @param height defines the height of the source data
  98515. * @param pixels defines the source byte array
  98516. * @param color defines the output color
  98517. */
  98518. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98519. /**
  98520. * Interpolates between a and b via alpha
  98521. * @param a The lower value (returned when alpha = 0)
  98522. * @param b The upper value (returned when alpha = 1)
  98523. * @param alpha The interpolation-factor
  98524. * @return The mixed value
  98525. */
  98526. static Mix(a: number, b: number, alpha: number): number;
  98527. /**
  98528. * Tries to instantiate a new object from a given class name
  98529. * @param className defines the class name to instantiate
  98530. * @returns the new object or null if the system was not able to do the instantiation
  98531. */
  98532. static Instantiate(className: string): any;
  98533. /**
  98534. * Provides a slice function that will work even on IE
  98535. * @param data defines the array to slice
  98536. * @param start defines the start of the data (optional)
  98537. * @param end defines the end of the data (optional)
  98538. * @returns the new sliced array
  98539. */
  98540. static Slice<T>(data: T, start?: number, end?: number): T;
  98541. /**
  98542. * Polyfill for setImmediate
  98543. * @param action defines the action to execute after the current execution block
  98544. */
  98545. static SetImmediate(action: () => void): void;
  98546. /**
  98547. * Function indicating if a number is an exponent of 2
  98548. * @param value defines the value to test
  98549. * @returns true if the value is an exponent of 2
  98550. */
  98551. static IsExponentOfTwo(value: number): boolean;
  98552. private static _tmpFloatArray;
  98553. /**
  98554. * Returns the nearest 32-bit single precision float representation of a Number
  98555. * @param value A Number. If the parameter is of a different type, it will get converted
  98556. * to a number or to NaN if it cannot be converted
  98557. * @returns number
  98558. */
  98559. static FloatRound(value: number): number;
  98560. /**
  98561. * Extracts the filename from a path
  98562. * @param path defines the path to use
  98563. * @returns the filename
  98564. */
  98565. static GetFilename(path: string): string;
  98566. /**
  98567. * Extracts the "folder" part of a path (everything before the filename).
  98568. * @param uri The URI to extract the info from
  98569. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98570. * @returns The "folder" part of the path
  98571. */
  98572. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98573. /**
  98574. * Extracts text content from a DOM element hierarchy
  98575. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98576. */
  98577. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98578. /**
  98579. * Convert an angle in radians to degrees
  98580. * @param angle defines the angle to convert
  98581. * @returns the angle in degrees
  98582. */
  98583. static ToDegrees(angle: number): number;
  98584. /**
  98585. * Convert an angle in degrees to radians
  98586. * @param angle defines the angle to convert
  98587. * @returns the angle in radians
  98588. */
  98589. static ToRadians(angle: number): number;
  98590. /**
  98591. * Encode a buffer to a base64 string
  98592. * @param buffer defines the buffer to encode
  98593. * @returns the encoded string
  98594. */
  98595. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98596. /**
  98597. * Returns an array if obj is not an array
  98598. * @param obj defines the object to evaluate as an array
  98599. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98600. * @returns either obj directly if obj is an array or a new array containing obj
  98601. */
  98602. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98603. /**
  98604. * Gets the pointer prefix to use
  98605. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98606. */
  98607. static GetPointerPrefix(): string;
  98608. /**
  98609. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98610. * @param url define the url we are trying
  98611. * @param element define the dom element where to configure the cors policy
  98612. */
  98613. static SetCorsBehavior(url: string | string[], element: {
  98614. crossOrigin: string | null;
  98615. }): void;
  98616. /**
  98617. * Removes unwanted characters from an url
  98618. * @param url defines the url to clean
  98619. * @returns the cleaned url
  98620. */
  98621. static CleanUrl(url: string): string;
  98622. /**
  98623. * Gets or sets a function used to pre-process url before using them to load assets
  98624. */
  98625. static PreprocessUrl: (url: string) => string;
  98626. /**
  98627. * Loads an image as an HTMLImageElement.
  98628. * @param input url string, ArrayBuffer, or Blob to load
  98629. * @param onLoad callback called when the image successfully loads
  98630. * @param onError callback called when the image fails to load
  98631. * @param offlineProvider offline provider for caching
  98632. * @returns the HTMLImageElement of the loaded image
  98633. */
  98634. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98635. /**
  98636. * Loads a file
  98637. * @param url url string, ArrayBuffer, or Blob to load
  98638. * @param onSuccess callback called when the file successfully loads
  98639. * @param onProgress callback called while file is loading (if the server supports this mode)
  98640. * @param offlineProvider defines the offline provider for caching
  98641. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98642. * @param onError callback called when the file fails to load
  98643. * @returns a file request object
  98644. */
  98645. 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;
  98646. /**
  98647. * Loads a file from a url
  98648. * @param url the file url to load
  98649. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98650. */
  98651. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98652. /**
  98653. * Load a script (identified by an url). When the url returns, the
  98654. * content of this file is added into a new script element, attached to the DOM (body element)
  98655. * @param scriptUrl defines the url of the script to laod
  98656. * @param onSuccess defines the callback called when the script is loaded
  98657. * @param onError defines the callback to call if an error occurs
  98658. * @param scriptId defines the id of the script element
  98659. */
  98660. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98661. /**
  98662. * Load an asynchronous script (identified by an url). When the url returns, the
  98663. * content of this file is added into a new script element, attached to the DOM (body element)
  98664. * @param scriptUrl defines the url of the script to laod
  98665. * @param scriptId defines the id of the script element
  98666. * @returns a promise request object
  98667. */
  98668. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98669. /**
  98670. * Loads a file from a blob
  98671. * @param fileToLoad defines the blob to use
  98672. * @param callback defines the callback to call when data is loaded
  98673. * @param progressCallback defines the callback to call during loading process
  98674. * @returns a file request object
  98675. */
  98676. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98677. /**
  98678. * Loads a file
  98679. * @param fileToLoad defines the file to load
  98680. * @param callback defines the callback to call when data is loaded
  98681. * @param progressCallBack defines the callback to call during loading process
  98682. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98683. * @returns a file request object
  98684. */
  98685. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98686. /**
  98687. * Creates a data url from a given string content
  98688. * @param content defines the content to convert
  98689. * @returns the new data url link
  98690. */
  98691. static FileAsURL(content: string): string;
  98692. /**
  98693. * Format the given number to a specific decimal format
  98694. * @param value defines the number to format
  98695. * @param decimals defines the number of decimals to use
  98696. * @returns the formatted string
  98697. */
  98698. static Format(value: number, decimals?: number): string;
  98699. /**
  98700. * Tries to copy an object by duplicating every property
  98701. * @param source defines the source object
  98702. * @param destination defines the target object
  98703. * @param doNotCopyList defines a list of properties to avoid
  98704. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98705. */
  98706. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98707. /**
  98708. * Gets a boolean indicating if the given object has no own property
  98709. * @param obj defines the object to test
  98710. * @returns true if object has no own property
  98711. */
  98712. static IsEmpty(obj: any): boolean;
  98713. /**
  98714. * Function used to register events at window level
  98715. * @param windowElement defines the Window object to use
  98716. * @param events defines the events to register
  98717. */
  98718. static RegisterTopRootEvents(windowElement: Window, events: {
  98719. name: string;
  98720. handler: Nullable<(e: FocusEvent) => any>;
  98721. }[]): void;
  98722. /**
  98723. * Function used to unregister events from window level
  98724. * @param windowElement defines the Window object to use
  98725. * @param events defines the events to unregister
  98726. */
  98727. static UnregisterTopRootEvents(windowElement: Window, events: {
  98728. name: string;
  98729. handler: Nullable<(e: FocusEvent) => any>;
  98730. }[]): void;
  98731. /**
  98732. * @ignore
  98733. */
  98734. static _ScreenshotCanvas: HTMLCanvasElement;
  98735. /**
  98736. * Dumps the current bound framebuffer
  98737. * @param width defines the rendering width
  98738. * @param height defines the rendering height
  98739. * @param engine defines the hosting engine
  98740. * @param successCallback defines the callback triggered once the data are available
  98741. * @param mimeType defines the mime type of the result
  98742. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98743. */
  98744. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98745. /**
  98746. * Converts the canvas data to blob.
  98747. * This acts as a polyfill for browsers not supporting the to blob function.
  98748. * @param canvas Defines the canvas to extract the data from
  98749. * @param successCallback Defines the callback triggered once the data are available
  98750. * @param mimeType Defines the mime type of the result
  98751. */
  98752. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98753. /**
  98754. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98755. * @param successCallback defines the callback triggered once the data are available
  98756. * @param mimeType defines the mime type of the result
  98757. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98758. */
  98759. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98760. /**
  98761. * Downloads a blob in the browser
  98762. * @param blob defines the blob to download
  98763. * @param fileName defines the name of the downloaded file
  98764. */
  98765. static Download(blob: Blob, fileName: string): void;
  98766. /**
  98767. * Captures a screenshot of the current rendering
  98768. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98769. * @param engine defines the rendering engine
  98770. * @param camera defines the source camera
  98771. * @param size This parameter can be set to a single number or to an object with the
  98772. * following (optional) properties: precision, width, height. If a single number is passed,
  98773. * it will be used for both width and height. If an object is passed, the screenshot size
  98774. * will be derived from the parameters. The precision property is a multiplier allowing
  98775. * rendering at a higher or lower resolution
  98776. * @param successCallback defines the callback receives a single parameter which contains the
  98777. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98778. * src parameter of an <img> to display it
  98779. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98780. * Check your browser for supported MIME types
  98781. */
  98782. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98783. /**
  98784. * Captures a screenshot of the current rendering
  98785. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98786. * @param engine defines the rendering engine
  98787. * @param camera defines the source camera
  98788. * @param size This parameter can be set to a single number or to an object with the
  98789. * following (optional) properties: precision, width, height. If a single number is passed,
  98790. * it will be used for both width and height. If an object is passed, the screenshot size
  98791. * will be derived from the parameters. The precision property is a multiplier allowing
  98792. * rendering at a higher or lower resolution
  98793. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98794. * Check your browser for supported MIME types
  98795. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98796. * to the src parameter of an <img> to display it
  98797. */
  98798. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98799. /**
  98800. * Generates an image screenshot from the specified camera.
  98801. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98802. * @param engine The engine to use for rendering
  98803. * @param camera The camera to use for rendering
  98804. * @param size This parameter can be set to a single number or to an object with the
  98805. * following (optional) properties: precision, width, height. If a single number is passed,
  98806. * it will be used for both width and height. If an object is passed, the screenshot size
  98807. * will be derived from the parameters. The precision property is a multiplier allowing
  98808. * rendering at a higher or lower resolution
  98809. * @param successCallback The callback receives a single parameter which contains the
  98810. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98811. * src parameter of an <img> to display it
  98812. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98813. * Check your browser for supported MIME types
  98814. * @param samples Texture samples (default: 1)
  98815. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98816. * @param fileName A name for for the downloaded file.
  98817. */
  98818. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98819. /**
  98820. * Generates an image screenshot from the specified camera.
  98821. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98822. * @param engine The engine to use for rendering
  98823. * @param camera The camera to use for rendering
  98824. * @param size This parameter can be set to a single number or to an object with the
  98825. * following (optional) properties: precision, width, height. If a single number is passed,
  98826. * it will be used for both width and height. If an object is passed, the screenshot size
  98827. * will be derived from the parameters. The precision property is a multiplier allowing
  98828. * rendering at a higher or lower resolution
  98829. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98830. * Check your browser for supported MIME types
  98831. * @param samples Texture samples (default: 1)
  98832. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98833. * @param fileName A name for for the downloaded file.
  98834. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98835. * to the src parameter of an <img> to display it
  98836. */
  98837. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98838. /**
  98839. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98840. * Be aware Math.random() could cause collisions, but:
  98841. * "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"
  98842. * @returns a pseudo random id
  98843. */
  98844. static RandomId(): string;
  98845. /**
  98846. * Test if the given uri is a base64 string
  98847. * @param uri The uri to test
  98848. * @return True if the uri is a base64 string or false otherwise
  98849. */
  98850. static IsBase64(uri: string): boolean;
  98851. /**
  98852. * Decode the given base64 uri.
  98853. * @param uri The uri to decode
  98854. * @return The decoded base64 data.
  98855. */
  98856. static DecodeBase64(uri: string): ArrayBuffer;
  98857. /**
  98858. * Gets the absolute url.
  98859. * @param url the input url
  98860. * @return the absolute url
  98861. */
  98862. static GetAbsoluteUrl(url: string): string;
  98863. /**
  98864. * No log
  98865. */
  98866. static readonly NoneLogLevel: number;
  98867. /**
  98868. * Only message logs
  98869. */
  98870. static readonly MessageLogLevel: number;
  98871. /**
  98872. * Only warning logs
  98873. */
  98874. static readonly WarningLogLevel: number;
  98875. /**
  98876. * Only error logs
  98877. */
  98878. static readonly ErrorLogLevel: number;
  98879. /**
  98880. * All logs
  98881. */
  98882. static readonly AllLogLevel: number;
  98883. /**
  98884. * Gets a value indicating the number of loading errors
  98885. * @ignorenaming
  98886. */
  98887. static readonly errorsCount: number;
  98888. /**
  98889. * Callback called when a new log is added
  98890. */
  98891. static OnNewCacheEntry: (entry: string) => void;
  98892. /**
  98893. * Log a message to the console
  98894. * @param message defines the message to log
  98895. */
  98896. static Log(message: string): void;
  98897. /**
  98898. * Write a warning message to the console
  98899. * @param message defines the message to log
  98900. */
  98901. static Warn(message: string): void;
  98902. /**
  98903. * Write an error message to the console
  98904. * @param message defines the message to log
  98905. */
  98906. static Error(message: string): void;
  98907. /**
  98908. * Gets current log cache (list of logs)
  98909. */
  98910. static readonly LogCache: string;
  98911. /**
  98912. * Clears the log cache
  98913. */
  98914. static ClearLogCache(): void;
  98915. /**
  98916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98917. */
  98918. static LogLevels: number;
  98919. /**
  98920. * Checks if the window object exists
  98921. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98922. */
  98923. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98924. /**
  98925. * No performance log
  98926. */
  98927. static readonly PerformanceNoneLogLevel: number;
  98928. /**
  98929. * Use user marks to log performance
  98930. */
  98931. static readonly PerformanceUserMarkLogLevel: number;
  98932. /**
  98933. * Log performance to the console
  98934. */
  98935. static readonly PerformanceConsoleLogLevel: number;
  98936. private static _performance;
  98937. /**
  98938. * Sets the current performance log level
  98939. */
  98940. static PerformanceLogLevel: number;
  98941. private static _StartPerformanceCounterDisabled;
  98942. private static _EndPerformanceCounterDisabled;
  98943. private static _StartUserMark;
  98944. private static _EndUserMark;
  98945. private static _StartPerformanceConsole;
  98946. private static _EndPerformanceConsole;
  98947. /**
  98948. * Starts a performance counter
  98949. */
  98950. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98951. /**
  98952. * Ends a specific performance coutner
  98953. */
  98954. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98955. /**
  98956. * Gets either window.performance.now() if supported or Date.now() else
  98957. */
  98958. static readonly Now: number;
  98959. /**
  98960. * This method will return the name of the class used to create the instance of the given object.
  98961. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98962. * @param object the object to get the class name from
  98963. * @param isType defines if the object is actually a type
  98964. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98965. */
  98966. static GetClassName(object: any, isType?: boolean): string;
  98967. /**
  98968. * Gets the first element of an array satisfying a given predicate
  98969. * @param array defines the array to browse
  98970. * @param predicate defines the predicate to use
  98971. * @returns null if not found or the element
  98972. */
  98973. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98974. /**
  98975. * This method will return the name of the full name of the class, including its owning module (if any).
  98976. * 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).
  98977. * @param object the object to get the class name from
  98978. * @param isType defines if the object is actually a type
  98979. * @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.
  98980. * @ignorenaming
  98981. */
  98982. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98983. /**
  98984. * Returns a promise that resolves after the given amount of time.
  98985. * @param delay Number of milliseconds to delay
  98986. * @returns Promise that resolves after the given amount of time
  98987. */
  98988. static DelayAsync(delay: number): Promise<void>;
  98989. }
  98990. /**
  98991. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98992. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98993. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98994. * @param name The name of the class, case should be preserved
  98995. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98996. */
  98997. export function className(name: string, module?: string): (target: Object) => void;
  98998. /**
  98999. * An implementation of a loop for asynchronous functions.
  99000. */
  99001. export class AsyncLoop {
  99002. /**
  99003. * Defines the number of iterations for the loop
  99004. */
  99005. iterations: number;
  99006. /**
  99007. * Defines the current index of the loop.
  99008. */
  99009. index: number;
  99010. private _done;
  99011. private _fn;
  99012. private _successCallback;
  99013. /**
  99014. * Constructor.
  99015. * @param iterations the number of iterations.
  99016. * @param func the function to run each iteration
  99017. * @param successCallback the callback that will be called upon succesful execution
  99018. * @param offset starting offset.
  99019. */
  99020. constructor(
  99021. /**
  99022. * Defines the number of iterations for the loop
  99023. */
  99024. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99025. /**
  99026. * Execute the next iteration. Must be called after the last iteration was finished.
  99027. */
  99028. executeNext(): void;
  99029. /**
  99030. * Break the loop and run the success callback.
  99031. */
  99032. breakLoop(): void;
  99033. /**
  99034. * Create and run an async loop.
  99035. * @param iterations the number of iterations.
  99036. * @param fn the function to run each iteration
  99037. * @param successCallback the callback that will be called upon succesful execution
  99038. * @param offset starting offset.
  99039. * @returns the created async loop object
  99040. */
  99041. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99042. /**
  99043. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99044. * @param iterations total number of iterations
  99045. * @param syncedIterations number of synchronous iterations in each async iteration.
  99046. * @param fn the function to call each iteration.
  99047. * @param callback a success call back that will be called when iterating stops.
  99048. * @param breakFunction a break condition (optional)
  99049. * @param timeout timeout settings for the setTimeout function. default - 0.
  99050. * @returns the created async loop object
  99051. */
  99052. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99053. }
  99054. }
  99055. declare module BABYLON {
  99056. /**
  99057. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99058. * The underlying implementation relies on an associative array to ensure the best performances.
  99059. * The value can be anything including 'null' but except 'undefined'
  99060. */
  99061. export class StringDictionary<T> {
  99062. /**
  99063. * This will clear this dictionary and copy the content from the 'source' one.
  99064. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99065. * @param source the dictionary to take the content from and copy to this dictionary
  99066. */
  99067. copyFrom(source: StringDictionary<T>): void;
  99068. /**
  99069. * Get a value based from its key
  99070. * @param key the given key to get the matching value from
  99071. * @return the value if found, otherwise undefined is returned
  99072. */
  99073. get(key: string): T | undefined;
  99074. /**
  99075. * Get a value from its key or add it if it doesn't exist.
  99076. * This method will ensure you that a given key/data will be present in the dictionary.
  99077. * @param key the given key to get the matching value from
  99078. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99079. * The factory will only be invoked if there's no data for the given key.
  99080. * @return the value corresponding to the key.
  99081. */
  99082. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99083. /**
  99084. * Get a value from its key if present in the dictionary otherwise add it
  99085. * @param key the key to get the value from
  99086. * @param val if there's no such key/value pair in the dictionary add it with this value
  99087. * @return the value corresponding to the key
  99088. */
  99089. getOrAdd(key: string, val: T): T;
  99090. /**
  99091. * Check if there's a given key in the dictionary
  99092. * @param key the key to check for
  99093. * @return true if the key is present, false otherwise
  99094. */
  99095. contains(key: string): boolean;
  99096. /**
  99097. * Add a new key and its corresponding value
  99098. * @param key the key to add
  99099. * @param value the value corresponding to the key
  99100. * @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
  99101. */
  99102. add(key: string, value: T): boolean;
  99103. /**
  99104. * Update a specific value associated to a key
  99105. * @param key defines the key to use
  99106. * @param value defines the value to store
  99107. * @returns true if the value was updated (or false if the key was not found)
  99108. */
  99109. set(key: string, value: T): boolean;
  99110. /**
  99111. * Get the element of the given key and remove it from the dictionary
  99112. * @param key defines the key to search
  99113. * @returns the value associated with the key or null if not found
  99114. */
  99115. getAndRemove(key: string): Nullable<T>;
  99116. /**
  99117. * Remove a key/value from the dictionary.
  99118. * @param key the key to remove
  99119. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99120. */
  99121. remove(key: string): boolean;
  99122. /**
  99123. * Clear the whole content of the dictionary
  99124. */
  99125. clear(): void;
  99126. /**
  99127. * Gets the current count
  99128. */
  99129. readonly count: number;
  99130. /**
  99131. * Execute a callback on each key/val of the dictionary.
  99132. * Note that you can remove any element in this dictionary in the callback implementation
  99133. * @param callback the callback to execute on a given key/value pair
  99134. */
  99135. forEach(callback: (key: string, val: T) => void): void;
  99136. /**
  99137. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99138. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99139. * Note that you can remove any element in this dictionary in the callback implementation
  99140. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99141. * @returns the first item
  99142. */
  99143. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99144. private _count;
  99145. private _data;
  99146. }
  99147. }
  99148. declare module BABYLON {
  99149. /** @hidden */
  99150. export interface ICollisionCoordinator {
  99151. createCollider(): Collider;
  99152. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99153. init(scene: Scene): void;
  99154. }
  99155. /** @hidden */
  99156. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99157. private _scene;
  99158. private _scaledPosition;
  99159. private _scaledVelocity;
  99160. private _finalPosition;
  99161. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99162. createCollider(): Collider;
  99163. init(scene: Scene): void;
  99164. private _collideWithWorld;
  99165. }
  99166. }
  99167. declare module BABYLON {
  99168. /**
  99169. * Class used to manage all inputs for the scene.
  99170. */
  99171. export class InputManager {
  99172. /** The distance in pixel that you have to move to prevent some events */
  99173. static DragMovementThreshold: number;
  99174. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99175. static LongPressDelay: number;
  99176. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99177. static DoubleClickDelay: number;
  99178. /** If you need to check double click without raising a single click at first click, enable this flag */
  99179. static ExclusiveDoubleClickMode: boolean;
  99180. private _wheelEventName;
  99181. private _onPointerMove;
  99182. private _onPointerDown;
  99183. private _onPointerUp;
  99184. private _initClickEvent;
  99185. private _initActionManager;
  99186. private _delayedSimpleClick;
  99187. private _delayedSimpleClickTimeout;
  99188. private _previousDelayedSimpleClickTimeout;
  99189. private _meshPickProceed;
  99190. private _previousButtonPressed;
  99191. private _currentPickResult;
  99192. private _previousPickResult;
  99193. private _totalPointersPressed;
  99194. private _doubleClickOccured;
  99195. private _pointerOverMesh;
  99196. private _pickedDownMesh;
  99197. private _pickedUpMesh;
  99198. private _pointerX;
  99199. private _pointerY;
  99200. private _unTranslatedPointerX;
  99201. private _unTranslatedPointerY;
  99202. private _startingPointerPosition;
  99203. private _previousStartingPointerPosition;
  99204. private _startingPointerTime;
  99205. private _previousStartingPointerTime;
  99206. private _pointerCaptures;
  99207. private _onKeyDown;
  99208. private _onKeyUp;
  99209. private _onCanvasFocusObserver;
  99210. private _onCanvasBlurObserver;
  99211. private _scene;
  99212. /**
  99213. * Creates a new InputManager
  99214. * @param scene defines the hosting scene
  99215. */
  99216. constructor(scene: Scene);
  99217. /**
  99218. * Gets the mesh that is currently under the pointer
  99219. */
  99220. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99221. /**
  99222. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99223. */
  99224. readonly unTranslatedPointer: Vector2;
  99225. /**
  99226. * Gets or sets the current on-screen X position of the pointer
  99227. */
  99228. pointerX: number;
  99229. /**
  99230. * Gets or sets the current on-screen Y position of the pointer
  99231. */
  99232. pointerY: number;
  99233. private _updatePointerPosition;
  99234. private _processPointerMove;
  99235. private _setRayOnPointerInfo;
  99236. private _checkPrePointerObservable;
  99237. /**
  99238. * Use this method to simulate a pointer move on a mesh
  99239. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99240. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99241. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99242. */
  99243. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99244. /**
  99245. * Use this method to simulate a pointer down on a mesh
  99246. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99247. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99248. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99249. */
  99250. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99251. private _processPointerDown;
  99252. /** @hidden */
  99253. _isPointerSwiping(): boolean;
  99254. /**
  99255. * Use this method to simulate a pointer up on a mesh
  99256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99259. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99260. */
  99261. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99262. private _processPointerUp;
  99263. /**
  99264. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99265. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99266. * @returns true if the pointer was captured
  99267. */
  99268. isPointerCaptured(pointerId?: number): boolean;
  99269. /**
  99270. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99271. * @param attachUp defines if you want to attach events to pointerup
  99272. * @param attachDown defines if you want to attach events to pointerdown
  99273. * @param attachMove defines if you want to attach events to pointermove
  99274. */
  99275. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99276. /**
  99277. * Detaches all event handlers
  99278. */
  99279. detachControl(): void;
  99280. /**
  99281. * Force the value of meshUnderPointer
  99282. * @param mesh defines the mesh to use
  99283. */
  99284. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99285. /**
  99286. * Gets the mesh under the pointer
  99287. * @returns a Mesh or null if no mesh is under the pointer
  99288. */
  99289. getPointerOverMesh(): Nullable<AbstractMesh>;
  99290. }
  99291. }
  99292. declare module BABYLON {
  99293. /**
  99294. * Helper class used to generate session unique ID
  99295. */
  99296. export class UniqueIdGenerator {
  99297. private static _UniqueIdCounter;
  99298. /**
  99299. * Gets an unique (relatively to the current scene) Id
  99300. */
  99301. static readonly UniqueId: number;
  99302. }
  99303. }
  99304. declare module BABYLON {
  99305. /**
  99306. * This class defines the direct association between an animation and a target
  99307. */
  99308. export class TargetedAnimation {
  99309. /**
  99310. * Animation to perform
  99311. */
  99312. animation: Animation;
  99313. /**
  99314. * Target to animate
  99315. */
  99316. target: any;
  99317. /**
  99318. * Serialize the object
  99319. * @returns the JSON object representing the current entity
  99320. */
  99321. serialize(): any;
  99322. }
  99323. /**
  99324. * Use this class to create coordinated animations on multiple targets
  99325. */
  99326. export class AnimationGroup implements IDisposable {
  99327. /** The name of the animation group */
  99328. name: string;
  99329. private _scene;
  99330. private _targetedAnimations;
  99331. private _animatables;
  99332. private _from;
  99333. private _to;
  99334. private _isStarted;
  99335. private _isPaused;
  99336. private _speedRatio;
  99337. private _loopAnimation;
  99338. /**
  99339. * Gets or sets the unique id of the node
  99340. */
  99341. uniqueId: number;
  99342. /**
  99343. * This observable will notify when one animation have ended
  99344. */
  99345. onAnimationEndObservable: Observable<TargetedAnimation>;
  99346. /**
  99347. * Observer raised when one animation loops
  99348. */
  99349. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99350. /**
  99351. * This observable will notify when all animations have ended.
  99352. */
  99353. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99354. /**
  99355. * This observable will notify when all animations have paused.
  99356. */
  99357. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99358. /**
  99359. * This observable will notify when all animations are playing.
  99360. */
  99361. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99362. /**
  99363. * Gets the first frame
  99364. */
  99365. readonly from: number;
  99366. /**
  99367. * Gets the last frame
  99368. */
  99369. readonly to: number;
  99370. /**
  99371. * Define if the animations are started
  99372. */
  99373. readonly isStarted: boolean;
  99374. /**
  99375. * Gets a value indicating that the current group is playing
  99376. */
  99377. readonly isPlaying: boolean;
  99378. /**
  99379. * Gets or sets the speed ratio to use for all animations
  99380. */
  99381. /**
  99382. * Gets or sets the speed ratio to use for all animations
  99383. */
  99384. speedRatio: number;
  99385. /**
  99386. * Gets or sets if all animations should loop or not
  99387. */
  99388. loopAnimation: boolean;
  99389. /**
  99390. * Gets the targeted animations for this animation group
  99391. */
  99392. readonly targetedAnimations: Array<TargetedAnimation>;
  99393. /**
  99394. * returning the list of animatables controlled by this animation group.
  99395. */
  99396. readonly animatables: Array<Animatable>;
  99397. /**
  99398. * Instantiates a new Animation Group.
  99399. * This helps managing several animations at once.
  99400. * @see http://doc.babylonjs.com/how_to/group
  99401. * @param name Defines the name of the group
  99402. * @param scene Defines the scene the group belongs to
  99403. */
  99404. constructor(
  99405. /** The name of the animation group */
  99406. name: string, scene?: Nullable<Scene>);
  99407. /**
  99408. * Add an animation (with its target) in the group
  99409. * @param animation defines the animation we want to add
  99410. * @param target defines the target of the animation
  99411. * @returns the TargetedAnimation object
  99412. */
  99413. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99414. /**
  99415. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99416. * It can add constant keys at begin or end
  99417. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99418. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99419. * @returns the animation group
  99420. */
  99421. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99422. /**
  99423. * Start all animations on given targets
  99424. * @param loop defines if animations must loop
  99425. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99426. * @param from defines the from key (optional)
  99427. * @param to defines the to key (optional)
  99428. * @returns the current animation group
  99429. */
  99430. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99431. /**
  99432. * Pause all animations
  99433. * @returns the animation group
  99434. */
  99435. pause(): AnimationGroup;
  99436. /**
  99437. * Play all animations to initial state
  99438. * This function will start() the animations if they were not started or will restart() them if they were paused
  99439. * @param loop defines if animations must loop
  99440. * @returns the animation group
  99441. */
  99442. play(loop?: boolean): AnimationGroup;
  99443. /**
  99444. * Reset all animations to initial state
  99445. * @returns the animation group
  99446. */
  99447. reset(): AnimationGroup;
  99448. /**
  99449. * Restart animations from key 0
  99450. * @returns the animation group
  99451. */
  99452. restart(): AnimationGroup;
  99453. /**
  99454. * Stop all animations
  99455. * @returns the animation group
  99456. */
  99457. stop(): AnimationGroup;
  99458. /**
  99459. * Set animation weight for all animatables
  99460. * @param weight defines the weight to use
  99461. * @return the animationGroup
  99462. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99463. */
  99464. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99465. /**
  99466. * Synchronize and normalize all animatables with a source animatable
  99467. * @param root defines the root animatable to synchronize with
  99468. * @return the animationGroup
  99469. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99470. */
  99471. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99472. /**
  99473. * Goes to a specific frame in this animation group
  99474. * @param frame the frame number to go to
  99475. * @return the animationGroup
  99476. */
  99477. goToFrame(frame: number): AnimationGroup;
  99478. /**
  99479. * Dispose all associated resources
  99480. */
  99481. dispose(): void;
  99482. private _checkAnimationGroupEnded;
  99483. /**
  99484. * Clone the current animation group and returns a copy
  99485. * @param newName defines the name of the new group
  99486. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99487. * @returns the new aniamtion group
  99488. */
  99489. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99490. /**
  99491. * Serializes the animationGroup to an object
  99492. * @returns Serialized object
  99493. */
  99494. serialize(): any;
  99495. /**
  99496. * Returns a new AnimationGroup object parsed from the source provided.
  99497. * @param parsedAnimationGroup defines the source
  99498. * @param scene defines the scene that will receive the animationGroup
  99499. * @returns a new AnimationGroup
  99500. */
  99501. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99502. /**
  99503. * Returns the string "AnimationGroup"
  99504. * @returns "AnimationGroup"
  99505. */
  99506. getClassName(): string;
  99507. /**
  99508. * Creates a detailled string about the object
  99509. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99510. * @returns a string representing the object
  99511. */
  99512. toString(fullDetails?: boolean): string;
  99513. }
  99514. }
  99515. declare module BABYLON {
  99516. /**
  99517. * Define an interface for all classes that will hold resources
  99518. */
  99519. export interface IDisposable {
  99520. /**
  99521. * Releases all held resources
  99522. */
  99523. dispose(): void;
  99524. }
  99525. /** Interface defining initialization parameters for Scene class */
  99526. export interface SceneOptions {
  99527. /**
  99528. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99529. * It will improve performance when the number of geometries becomes important.
  99530. */
  99531. useGeometryUniqueIdsMap?: boolean;
  99532. /**
  99533. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99534. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99535. */
  99536. useMaterialMeshMap?: boolean;
  99537. /**
  99538. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99539. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99540. */
  99541. useClonedMeshhMap?: boolean;
  99542. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99543. virtual?: boolean;
  99544. }
  99545. /**
  99546. * Represents a scene to be rendered by the engine.
  99547. * @see http://doc.babylonjs.com/features/scene
  99548. */
  99549. export class Scene extends AbstractScene implements IAnimatable {
  99550. /** The fog is deactivated */
  99551. static readonly FOGMODE_NONE: number;
  99552. /** The fog density is following an exponential function */
  99553. static readonly FOGMODE_EXP: number;
  99554. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99555. static readonly FOGMODE_EXP2: number;
  99556. /** The fog density is following a linear function. */
  99557. static readonly FOGMODE_LINEAR: number;
  99558. /**
  99559. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99560. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99561. */
  99562. static MinDeltaTime: number;
  99563. /**
  99564. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99566. */
  99567. static MaxDeltaTime: number;
  99568. /**
  99569. * Factory used to create the default material.
  99570. * @param name The name of the material to create
  99571. * @param scene The scene to create the material for
  99572. * @returns The default material
  99573. */
  99574. static DefaultMaterialFactory(scene: Scene): Material;
  99575. /**
  99576. * Factory used to create the a collision coordinator.
  99577. * @returns The collision coordinator
  99578. */
  99579. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99580. /** @hidden */
  99581. _inputManager: InputManager;
  99582. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99583. cameraToUseForPointers: Nullable<Camera>;
  99584. /** @hidden */
  99585. readonly _isScene: boolean;
  99586. /**
  99587. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99588. */
  99589. autoClear: boolean;
  99590. /**
  99591. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99592. */
  99593. autoClearDepthAndStencil: boolean;
  99594. /**
  99595. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99596. */
  99597. clearColor: Color4;
  99598. /**
  99599. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99600. */
  99601. ambientColor: Color3;
  99602. /**
  99603. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99604. * It should only be one of the following (if not the default embedded one):
  99605. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99606. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99607. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99608. * The material properties need to be setup according to the type of texture in use.
  99609. */
  99610. environmentBRDFTexture: BaseTexture;
  99611. /** @hidden */
  99612. protected _environmentTexture: Nullable<BaseTexture>;
  99613. /**
  99614. * Texture used in all pbr material as the reflection texture.
  99615. * As in the majority of the scene they are the same (exception for multi room and so on),
  99616. * this is easier to reference from here than from all the materials.
  99617. */
  99618. /**
  99619. * Texture used in all pbr material as the reflection texture.
  99620. * As in the majority of the scene they are the same (exception for multi room and so on),
  99621. * this is easier to set here than in all the materials.
  99622. */
  99623. environmentTexture: Nullable<BaseTexture>;
  99624. /** @hidden */
  99625. protected _environmentIntensity: number;
  99626. /**
  99627. * Intensity of the environment in all pbr material.
  99628. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99629. * As in the majority of the scene they are the same (exception for multi room and so on),
  99630. * this is easier to reference from here than from all the materials.
  99631. */
  99632. /**
  99633. * Intensity of the environment in all pbr material.
  99634. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99635. * As in the majority of the scene they are the same (exception for multi room and so on),
  99636. * this is easier to set here than in all the materials.
  99637. */
  99638. environmentIntensity: number;
  99639. /** @hidden */
  99640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99641. /**
  99642. * Default image processing configuration used either in the rendering
  99643. * Forward main pass or through the imageProcessingPostProcess if present.
  99644. * As in the majority of the scene they are the same (exception for multi camera),
  99645. * this is easier to reference from here than from all the materials and post process.
  99646. *
  99647. * No setter as we it is a shared configuration, you can set the values instead.
  99648. */
  99649. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99650. private _forceWireframe;
  99651. /**
  99652. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99653. */
  99654. forceWireframe: boolean;
  99655. private _forcePointsCloud;
  99656. /**
  99657. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99658. */
  99659. forcePointsCloud: boolean;
  99660. /**
  99661. * Gets or sets the active clipplane 1
  99662. */
  99663. clipPlane: Nullable<Plane>;
  99664. /**
  99665. * Gets or sets the active clipplane 2
  99666. */
  99667. clipPlane2: Nullable<Plane>;
  99668. /**
  99669. * Gets or sets the active clipplane 3
  99670. */
  99671. clipPlane3: Nullable<Plane>;
  99672. /**
  99673. * Gets or sets the active clipplane 4
  99674. */
  99675. clipPlane4: Nullable<Plane>;
  99676. /**
  99677. * Gets or sets a boolean indicating if animations are enabled
  99678. */
  99679. animationsEnabled: boolean;
  99680. private _animationPropertiesOverride;
  99681. /**
  99682. * Gets or sets the animation properties override
  99683. */
  99684. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99685. /**
  99686. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99687. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99688. */
  99689. useConstantAnimationDeltaTime: boolean;
  99690. /**
  99691. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99692. * Please note that it requires to run a ray cast through the scene on every frame
  99693. */
  99694. constantlyUpdateMeshUnderPointer: boolean;
  99695. /**
  99696. * Defines the HTML cursor to use when hovering over interactive elements
  99697. */
  99698. hoverCursor: string;
  99699. /**
  99700. * Defines the HTML default cursor to use (empty by default)
  99701. */
  99702. defaultCursor: string;
  99703. /**
  99704. * This is used to call preventDefault() on pointer down
  99705. * in order to block unwanted artifacts like system double clicks
  99706. */
  99707. preventDefaultOnPointerDown: boolean;
  99708. /**
  99709. * This is used to call preventDefault() on pointer up
  99710. * in order to block unwanted artifacts like system double clicks
  99711. */
  99712. preventDefaultOnPointerUp: boolean;
  99713. /**
  99714. * Gets or sets user defined metadata
  99715. */
  99716. metadata: any;
  99717. /**
  99718. * For internal use only. Please do not use.
  99719. */
  99720. reservedDataStore: any;
  99721. /**
  99722. * Gets the name of the plugin used to load this scene (null by default)
  99723. */
  99724. loadingPluginName: string;
  99725. /**
  99726. * Use this array to add regular expressions used to disable offline support for specific urls
  99727. */
  99728. disableOfflineSupportExceptionRules: RegExp[];
  99729. /**
  99730. * An event triggered when the scene is disposed.
  99731. */
  99732. onDisposeObservable: Observable<Scene>;
  99733. private _onDisposeObserver;
  99734. /** Sets a function to be executed when this scene is disposed. */
  99735. onDispose: () => void;
  99736. /**
  99737. * An event triggered before rendering the scene (right after animations and physics)
  99738. */
  99739. onBeforeRenderObservable: Observable<Scene>;
  99740. private _onBeforeRenderObserver;
  99741. /** Sets a function to be executed before rendering this scene */
  99742. beforeRender: Nullable<() => void>;
  99743. /**
  99744. * An event triggered after rendering the scene
  99745. */
  99746. onAfterRenderObservable: Observable<Scene>;
  99747. /**
  99748. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99749. */
  99750. onAfterRenderCameraObservable: Observable<Camera>;
  99751. private _onAfterRenderObserver;
  99752. /** Sets a function to be executed after rendering this scene */
  99753. afterRender: Nullable<() => void>;
  99754. /**
  99755. * An event triggered before animating the scene
  99756. */
  99757. onBeforeAnimationsObservable: Observable<Scene>;
  99758. /**
  99759. * An event triggered after animations processing
  99760. */
  99761. onAfterAnimationsObservable: Observable<Scene>;
  99762. /**
  99763. * An event triggered before draw calls are ready to be sent
  99764. */
  99765. onBeforeDrawPhaseObservable: Observable<Scene>;
  99766. /**
  99767. * An event triggered after draw calls have been sent
  99768. */
  99769. onAfterDrawPhaseObservable: Observable<Scene>;
  99770. /**
  99771. * An event triggered when the scene is ready
  99772. */
  99773. onReadyObservable: Observable<Scene>;
  99774. /**
  99775. * An event triggered before rendering a camera
  99776. */
  99777. onBeforeCameraRenderObservable: Observable<Camera>;
  99778. private _onBeforeCameraRenderObserver;
  99779. /** Sets a function to be executed before rendering a camera*/
  99780. beforeCameraRender: () => void;
  99781. /**
  99782. * An event triggered after rendering a camera
  99783. */
  99784. onAfterCameraRenderObservable: Observable<Camera>;
  99785. private _onAfterCameraRenderObserver;
  99786. /** Sets a function to be executed after rendering a camera*/
  99787. afterCameraRender: () => void;
  99788. /**
  99789. * An event triggered when active meshes evaluation is about to start
  99790. */
  99791. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99792. /**
  99793. * An event triggered when active meshes evaluation is done
  99794. */
  99795. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99796. /**
  99797. * An event triggered when particles rendering is about to start
  99798. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99799. */
  99800. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99801. /**
  99802. * An event triggered when particles rendering is done
  99803. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99804. */
  99805. onAfterParticlesRenderingObservable: Observable<Scene>;
  99806. /**
  99807. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99808. */
  99809. onDataLoadedObservable: Observable<Scene>;
  99810. /**
  99811. * An event triggered when a camera is created
  99812. */
  99813. onNewCameraAddedObservable: Observable<Camera>;
  99814. /**
  99815. * An event triggered when a camera is removed
  99816. */
  99817. onCameraRemovedObservable: Observable<Camera>;
  99818. /**
  99819. * An event triggered when a light is created
  99820. */
  99821. onNewLightAddedObservable: Observable<Light>;
  99822. /**
  99823. * An event triggered when a light is removed
  99824. */
  99825. onLightRemovedObservable: Observable<Light>;
  99826. /**
  99827. * An event triggered when a geometry is created
  99828. */
  99829. onNewGeometryAddedObservable: Observable<Geometry>;
  99830. /**
  99831. * An event triggered when a geometry is removed
  99832. */
  99833. onGeometryRemovedObservable: Observable<Geometry>;
  99834. /**
  99835. * An event triggered when a transform node is created
  99836. */
  99837. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99838. /**
  99839. * An event triggered when a transform node is removed
  99840. */
  99841. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99842. /**
  99843. * An event triggered when a mesh is created
  99844. */
  99845. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99846. /**
  99847. * An event triggered when a mesh is removed
  99848. */
  99849. onMeshRemovedObservable: Observable<AbstractMesh>;
  99850. /**
  99851. * An event triggered when a skeleton is created
  99852. */
  99853. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99854. /**
  99855. * An event triggered when a skeleton is removed
  99856. */
  99857. onSkeletonRemovedObservable: Observable<Skeleton>;
  99858. /**
  99859. * An event triggered when a material is created
  99860. */
  99861. onNewMaterialAddedObservable: Observable<Material>;
  99862. /**
  99863. * An event triggered when a material is removed
  99864. */
  99865. onMaterialRemovedObservable: Observable<Material>;
  99866. /**
  99867. * An event triggered when a texture is created
  99868. */
  99869. onNewTextureAddedObservable: Observable<BaseTexture>;
  99870. /**
  99871. * An event triggered when a texture is removed
  99872. */
  99873. onTextureRemovedObservable: Observable<BaseTexture>;
  99874. /**
  99875. * An event triggered when render targets are about to be rendered
  99876. * Can happen multiple times per frame.
  99877. */
  99878. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99879. /**
  99880. * An event triggered when render targets were rendered.
  99881. * Can happen multiple times per frame.
  99882. */
  99883. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99884. /**
  99885. * An event triggered before calculating deterministic simulation step
  99886. */
  99887. onBeforeStepObservable: Observable<Scene>;
  99888. /**
  99889. * An event triggered after calculating deterministic simulation step
  99890. */
  99891. onAfterStepObservable: Observable<Scene>;
  99892. /**
  99893. * An event triggered when the activeCamera property is updated
  99894. */
  99895. onActiveCameraChanged: Observable<Scene>;
  99896. /**
  99897. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99898. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99899. * 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)
  99900. */
  99901. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99902. /**
  99903. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99904. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99905. * 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)
  99906. */
  99907. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99908. /**
  99909. * This Observable will when a mesh has been imported into the scene.
  99910. */
  99911. onMeshImportedObservable: Observable<AbstractMesh>;
  99912. /**
  99913. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99914. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99915. */
  99916. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99917. /** @hidden */
  99918. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99919. /**
  99920. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99921. */
  99922. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99923. /**
  99924. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99925. */
  99926. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99927. /**
  99928. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99929. */
  99930. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99931. /** Callback called when a pointer move is detected */
  99932. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99933. /** Callback called when a pointer down is detected */
  99934. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99935. /** Callback called when a pointer up is detected */
  99936. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99937. /** Callback called when a pointer pick is detected */
  99938. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99939. /**
  99940. * 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).
  99941. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99942. */
  99943. onPrePointerObservable: Observable<PointerInfoPre>;
  99944. /**
  99945. * Observable event triggered each time an input event is received from the rendering canvas
  99946. */
  99947. onPointerObservable: Observable<PointerInfo>;
  99948. /**
  99949. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99950. */
  99951. readonly unTranslatedPointer: Vector2;
  99952. /**
  99953. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99954. */
  99955. static DragMovementThreshold: number;
  99956. /**
  99957. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99958. */
  99959. static LongPressDelay: number;
  99960. /**
  99961. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99962. */
  99963. static DoubleClickDelay: number;
  99964. /** If you need to check double click without raising a single click at first click, enable this flag */
  99965. static ExclusiveDoubleClickMode: boolean;
  99966. /** @hidden */
  99967. _mirroredCameraPosition: Nullable<Vector3>;
  99968. /**
  99969. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99970. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99971. */
  99972. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99973. /**
  99974. * Observable event triggered each time an keyboard event is received from the hosting window
  99975. */
  99976. onKeyboardObservable: Observable<KeyboardInfo>;
  99977. private _useRightHandedSystem;
  99978. /**
  99979. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99980. */
  99981. useRightHandedSystem: boolean;
  99982. private _timeAccumulator;
  99983. private _currentStepId;
  99984. private _currentInternalStep;
  99985. /**
  99986. * Sets the step Id used by deterministic lock step
  99987. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99988. * @param newStepId defines the step Id
  99989. */
  99990. setStepId(newStepId: number): void;
  99991. /**
  99992. * Gets the step Id used by deterministic lock step
  99993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99994. * @returns the step Id
  99995. */
  99996. getStepId(): number;
  99997. /**
  99998. * Gets the internal step used by deterministic lock step
  99999. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100000. * @returns the internal step
  100001. */
  100002. getInternalStep(): number;
  100003. private _fogEnabled;
  100004. /**
  100005. * Gets or sets a boolean indicating if fog is enabled on this scene
  100006. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100007. * (Default is true)
  100008. */
  100009. fogEnabled: boolean;
  100010. private _fogMode;
  100011. /**
  100012. * Gets or sets the fog mode to use
  100013. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100014. * | mode | value |
  100015. * | --- | --- |
  100016. * | FOGMODE_NONE | 0 |
  100017. * | FOGMODE_EXP | 1 |
  100018. * | FOGMODE_EXP2 | 2 |
  100019. * | FOGMODE_LINEAR | 3 |
  100020. */
  100021. fogMode: number;
  100022. /**
  100023. * Gets or sets the fog color to use
  100024. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100025. * (Default is Color3(0.2, 0.2, 0.3))
  100026. */
  100027. fogColor: Color3;
  100028. /**
  100029. * Gets or sets the fog density to use
  100030. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100031. * (Default is 0.1)
  100032. */
  100033. fogDensity: number;
  100034. /**
  100035. * Gets or sets the fog start distance to use
  100036. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100037. * (Default is 0)
  100038. */
  100039. fogStart: number;
  100040. /**
  100041. * Gets or sets the fog end distance to use
  100042. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100043. * (Default is 1000)
  100044. */
  100045. fogEnd: number;
  100046. private _shadowsEnabled;
  100047. /**
  100048. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100049. */
  100050. shadowsEnabled: boolean;
  100051. private _lightsEnabled;
  100052. /**
  100053. * Gets or sets a boolean indicating if lights are enabled on this scene
  100054. */
  100055. lightsEnabled: boolean;
  100056. /** All of the active cameras added to this scene. */
  100057. activeCameras: Camera[];
  100058. /** @hidden */
  100059. _activeCamera: Nullable<Camera>;
  100060. /** Gets or sets the current active camera */
  100061. activeCamera: Nullable<Camera>;
  100062. private _defaultMaterial;
  100063. /** The default material used on meshes when no material is affected */
  100064. /** The default material used on meshes when no material is affected */
  100065. defaultMaterial: Material;
  100066. private _texturesEnabled;
  100067. /**
  100068. * Gets or sets a boolean indicating if textures are enabled on this scene
  100069. */
  100070. texturesEnabled: boolean;
  100071. /**
  100072. * Gets or sets a boolean indicating if particles are enabled on this scene
  100073. */
  100074. particlesEnabled: boolean;
  100075. /**
  100076. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100077. */
  100078. spritesEnabled: boolean;
  100079. private _skeletonsEnabled;
  100080. /**
  100081. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100082. */
  100083. skeletonsEnabled: boolean;
  100084. /**
  100085. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100086. */
  100087. lensFlaresEnabled: boolean;
  100088. /**
  100089. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100090. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100091. */
  100092. collisionsEnabled: boolean;
  100093. private _collisionCoordinator;
  100094. /** @hidden */
  100095. readonly collisionCoordinator: ICollisionCoordinator;
  100096. /**
  100097. * Defines the gravity applied to this scene (used only for collisions)
  100098. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100099. */
  100100. gravity: Vector3;
  100101. /**
  100102. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100103. */
  100104. postProcessesEnabled: boolean;
  100105. /**
  100106. * The list of postprocesses added to the scene
  100107. */
  100108. postProcesses: PostProcess[];
  100109. /**
  100110. * Gets the current postprocess manager
  100111. */
  100112. postProcessManager: PostProcessManager;
  100113. /**
  100114. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100115. */
  100116. renderTargetsEnabled: boolean;
  100117. /**
  100118. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100119. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100120. */
  100121. dumpNextRenderTargets: boolean;
  100122. /**
  100123. * The list of user defined render targets added to the scene
  100124. */
  100125. customRenderTargets: RenderTargetTexture[];
  100126. /**
  100127. * Defines if texture loading must be delayed
  100128. * If true, textures will only be loaded when they need to be rendered
  100129. */
  100130. useDelayedTextureLoading: boolean;
  100131. /**
  100132. * Gets the list of meshes imported to the scene through SceneLoader
  100133. */
  100134. importedMeshesFiles: String[];
  100135. /**
  100136. * Gets or sets a boolean indicating if probes are enabled on this scene
  100137. */
  100138. probesEnabled: boolean;
  100139. /**
  100140. * Gets or sets the current offline provider to use to store scene data
  100141. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100142. */
  100143. offlineProvider: IOfflineProvider;
  100144. /**
  100145. * Gets or sets the action manager associated with the scene
  100146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100147. */
  100148. actionManager: AbstractActionManager;
  100149. private _meshesForIntersections;
  100150. /**
  100151. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100152. */
  100153. proceduralTexturesEnabled: boolean;
  100154. private _engine;
  100155. private _totalVertices;
  100156. /** @hidden */
  100157. _activeIndices: PerfCounter;
  100158. /** @hidden */
  100159. _activeParticles: PerfCounter;
  100160. /** @hidden */
  100161. _activeBones: PerfCounter;
  100162. private _animationRatio;
  100163. /** @hidden */
  100164. _animationTimeLast: number;
  100165. /** @hidden */
  100166. _animationTime: number;
  100167. /**
  100168. * Gets or sets a general scale for animation speed
  100169. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100170. */
  100171. animationTimeScale: number;
  100172. /** @hidden */
  100173. _cachedMaterial: Nullable<Material>;
  100174. /** @hidden */
  100175. _cachedEffect: Nullable<Effect>;
  100176. /** @hidden */
  100177. _cachedVisibility: Nullable<number>;
  100178. private _renderId;
  100179. private _frameId;
  100180. private _executeWhenReadyTimeoutId;
  100181. private _intermediateRendering;
  100182. private _viewUpdateFlag;
  100183. private _projectionUpdateFlag;
  100184. /** @hidden */
  100185. _toBeDisposed: Nullable<IDisposable>[];
  100186. private _activeRequests;
  100187. /** @hidden */
  100188. _pendingData: any[];
  100189. private _isDisposed;
  100190. /**
  100191. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100192. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100193. */
  100194. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100195. private _activeMeshes;
  100196. private _processedMaterials;
  100197. private _renderTargets;
  100198. /** @hidden */
  100199. _activeParticleSystems: SmartArray<IParticleSystem>;
  100200. private _activeSkeletons;
  100201. private _softwareSkinnedMeshes;
  100202. private _renderingManager;
  100203. /** @hidden */
  100204. _activeAnimatables: Animatable[];
  100205. private _transformMatrix;
  100206. private _sceneUbo;
  100207. /** @hidden */
  100208. _viewMatrix: Matrix;
  100209. private _projectionMatrix;
  100210. /** @hidden */
  100211. _forcedViewPosition: Nullable<Vector3>;
  100212. /** @hidden */
  100213. _frustumPlanes: Plane[];
  100214. /**
  100215. * Gets the list of frustum planes (built from the active camera)
  100216. */
  100217. readonly frustumPlanes: Plane[];
  100218. /**
  100219. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100220. * This is useful if there are more lights that the maximum simulteanous authorized
  100221. */
  100222. requireLightSorting: boolean;
  100223. /** @hidden */
  100224. readonly useMaterialMeshMap: boolean;
  100225. /** @hidden */
  100226. readonly useClonedMeshhMap: boolean;
  100227. private _externalData;
  100228. private _uid;
  100229. /**
  100230. * @hidden
  100231. * Backing store of defined scene components.
  100232. */
  100233. _components: ISceneComponent[];
  100234. /**
  100235. * @hidden
  100236. * Backing store of defined scene components.
  100237. */
  100238. _serializableComponents: ISceneSerializableComponent[];
  100239. /**
  100240. * List of components to register on the next registration step.
  100241. */
  100242. private _transientComponents;
  100243. /**
  100244. * Registers the transient components if needed.
  100245. */
  100246. private _registerTransientComponents;
  100247. /**
  100248. * @hidden
  100249. * Add a component to the scene.
  100250. * Note that the ccomponent could be registered on th next frame if this is called after
  100251. * the register component stage.
  100252. * @param component Defines the component to add to the scene
  100253. */
  100254. _addComponent(component: ISceneComponent): void;
  100255. /**
  100256. * @hidden
  100257. * Gets a component from the scene.
  100258. * @param name defines the name of the component to retrieve
  100259. * @returns the component or null if not present
  100260. */
  100261. _getComponent(name: string): Nullable<ISceneComponent>;
  100262. /**
  100263. * @hidden
  100264. * Defines the actions happening before camera updates.
  100265. */
  100266. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100267. /**
  100268. * @hidden
  100269. * Defines the actions happening before clear the canvas.
  100270. */
  100271. _beforeClearStage: Stage<SimpleStageAction>;
  100272. /**
  100273. * @hidden
  100274. * Defines the actions when collecting render targets for the frame.
  100275. */
  100276. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100277. /**
  100278. * @hidden
  100279. * Defines the actions happening for one camera in the frame.
  100280. */
  100281. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100282. /**
  100283. * @hidden
  100284. * Defines the actions happening during the per mesh ready checks.
  100285. */
  100286. _isReadyForMeshStage: Stage<MeshStageAction>;
  100287. /**
  100288. * @hidden
  100289. * Defines the actions happening before evaluate active mesh checks.
  100290. */
  100291. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100292. /**
  100293. * @hidden
  100294. * Defines the actions happening during the evaluate sub mesh checks.
  100295. */
  100296. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100297. /**
  100298. * @hidden
  100299. * Defines the actions happening during the active mesh stage.
  100300. */
  100301. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100302. /**
  100303. * @hidden
  100304. * Defines the actions happening during the per camera render target step.
  100305. */
  100306. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100307. /**
  100308. * @hidden
  100309. * Defines the actions happening just before the active camera is drawing.
  100310. */
  100311. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100312. /**
  100313. * @hidden
  100314. * Defines the actions happening just before a render target is drawing.
  100315. */
  100316. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100317. /**
  100318. * @hidden
  100319. * Defines the actions happening just before a rendering group is drawing.
  100320. */
  100321. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100322. /**
  100323. * @hidden
  100324. * Defines the actions happening just before a mesh is drawing.
  100325. */
  100326. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100327. /**
  100328. * @hidden
  100329. * Defines the actions happening just after a mesh has been drawn.
  100330. */
  100331. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100332. /**
  100333. * @hidden
  100334. * Defines the actions happening just after a rendering group has been drawn.
  100335. */
  100336. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100337. /**
  100338. * @hidden
  100339. * Defines the actions happening just after the active camera has been drawn.
  100340. */
  100341. _afterCameraDrawStage: Stage<CameraStageAction>;
  100342. /**
  100343. * @hidden
  100344. * Defines the actions happening just after a render target has been drawn.
  100345. */
  100346. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100347. /**
  100348. * @hidden
  100349. * Defines the actions happening just after rendering all cameras and computing intersections.
  100350. */
  100351. _afterRenderStage: Stage<SimpleStageAction>;
  100352. /**
  100353. * @hidden
  100354. * Defines the actions happening when a pointer move event happens.
  100355. */
  100356. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100357. /**
  100358. * @hidden
  100359. * Defines the actions happening when a pointer down event happens.
  100360. */
  100361. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100362. /**
  100363. * @hidden
  100364. * Defines the actions happening when a pointer up event happens.
  100365. */
  100366. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100367. /**
  100368. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100369. */
  100370. private geometriesByUniqueId;
  100371. /**
  100372. * Creates a new Scene
  100373. * @param engine defines the engine to use to render this scene
  100374. * @param options defines the scene options
  100375. */
  100376. constructor(engine: Engine, options?: SceneOptions);
  100377. /**
  100378. * Gets a string idenfifying the name of the class
  100379. * @returns "Scene" string
  100380. */
  100381. getClassName(): string;
  100382. private _defaultMeshCandidates;
  100383. /**
  100384. * @hidden
  100385. */
  100386. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100387. private _defaultSubMeshCandidates;
  100388. /**
  100389. * @hidden
  100390. */
  100391. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100392. /**
  100393. * Sets the default candidate providers for the scene.
  100394. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100395. * and getCollidingSubMeshCandidates to their default function
  100396. */
  100397. setDefaultCandidateProviders(): void;
  100398. /**
  100399. * Gets the mesh that is currently under the pointer
  100400. */
  100401. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100402. /**
  100403. * Gets or sets the current on-screen X position of the pointer
  100404. */
  100405. pointerX: number;
  100406. /**
  100407. * Gets or sets the current on-screen Y position of the pointer
  100408. */
  100409. pointerY: number;
  100410. /**
  100411. * Gets the cached material (ie. the latest rendered one)
  100412. * @returns the cached material
  100413. */
  100414. getCachedMaterial(): Nullable<Material>;
  100415. /**
  100416. * Gets the cached effect (ie. the latest rendered one)
  100417. * @returns the cached effect
  100418. */
  100419. getCachedEffect(): Nullable<Effect>;
  100420. /**
  100421. * Gets the cached visibility state (ie. the latest rendered one)
  100422. * @returns the cached visibility state
  100423. */
  100424. getCachedVisibility(): Nullable<number>;
  100425. /**
  100426. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100427. * @param material defines the current material
  100428. * @param effect defines the current effect
  100429. * @param visibility defines the current visibility state
  100430. * @returns true if one parameter is not cached
  100431. */
  100432. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100433. /**
  100434. * Gets the engine associated with the scene
  100435. * @returns an Engine
  100436. */
  100437. getEngine(): Engine;
  100438. /**
  100439. * Gets the total number of vertices rendered per frame
  100440. * @returns the total number of vertices rendered per frame
  100441. */
  100442. getTotalVertices(): number;
  100443. /**
  100444. * Gets the performance counter for total vertices
  100445. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100446. */
  100447. readonly totalVerticesPerfCounter: PerfCounter;
  100448. /**
  100449. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100450. * @returns the total number of active indices rendered per frame
  100451. */
  100452. getActiveIndices(): number;
  100453. /**
  100454. * Gets the performance counter for active indices
  100455. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100456. */
  100457. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100458. /**
  100459. * Gets the total number of active particles rendered per frame
  100460. * @returns the total number of active particles rendered per frame
  100461. */
  100462. getActiveParticles(): number;
  100463. /**
  100464. * Gets the performance counter for active particles
  100465. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100466. */
  100467. readonly activeParticlesPerfCounter: PerfCounter;
  100468. /**
  100469. * Gets the total number of active bones rendered per frame
  100470. * @returns the total number of active bones rendered per frame
  100471. */
  100472. getActiveBones(): number;
  100473. /**
  100474. * Gets the performance counter for active bones
  100475. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100476. */
  100477. readonly activeBonesPerfCounter: PerfCounter;
  100478. /**
  100479. * Gets the array of active meshes
  100480. * @returns an array of AbstractMesh
  100481. */
  100482. getActiveMeshes(): SmartArray<AbstractMesh>;
  100483. /**
  100484. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100485. * @returns a number
  100486. */
  100487. getAnimationRatio(): number;
  100488. /**
  100489. * Gets an unique Id for the current render phase
  100490. * @returns a number
  100491. */
  100492. getRenderId(): number;
  100493. /**
  100494. * Gets an unique Id for the current frame
  100495. * @returns a number
  100496. */
  100497. getFrameId(): number;
  100498. /** Call this function if you want to manually increment the render Id*/
  100499. incrementRenderId(): void;
  100500. private _createUbo;
  100501. /**
  100502. * Use this method to simulate a pointer move on a mesh
  100503. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100504. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100505. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100506. * @returns the current scene
  100507. */
  100508. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100509. /**
  100510. * Use this method to simulate a pointer down on a mesh
  100511. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100512. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100513. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100514. * @returns the current scene
  100515. */
  100516. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100517. /**
  100518. * Use this method to simulate a pointer up on a mesh
  100519. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100520. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100521. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100522. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100523. * @returns the current scene
  100524. */
  100525. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100526. /**
  100527. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100528. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100529. * @returns true if the pointer was captured
  100530. */
  100531. isPointerCaptured(pointerId?: number): boolean;
  100532. /**
  100533. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100534. * @param attachUp defines if you want to attach events to pointerup
  100535. * @param attachDown defines if you want to attach events to pointerdown
  100536. * @param attachMove defines if you want to attach events to pointermove
  100537. */
  100538. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100539. /** Detaches all event handlers*/
  100540. detachControl(): void;
  100541. /**
  100542. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100543. * Delay loaded resources are not taking in account
  100544. * @return true if all required resources are ready
  100545. */
  100546. isReady(): boolean;
  100547. /** Resets all cached information relative to material (including effect and visibility) */
  100548. resetCachedMaterial(): void;
  100549. /**
  100550. * Registers a function to be called before every frame render
  100551. * @param func defines the function to register
  100552. */
  100553. registerBeforeRender(func: () => void): void;
  100554. /**
  100555. * Unregisters a function called before every frame render
  100556. * @param func defines the function to unregister
  100557. */
  100558. unregisterBeforeRender(func: () => void): void;
  100559. /**
  100560. * Registers a function to be called after every frame render
  100561. * @param func defines the function to register
  100562. */
  100563. registerAfterRender(func: () => void): void;
  100564. /**
  100565. * Unregisters a function called after every frame render
  100566. * @param func defines the function to unregister
  100567. */
  100568. unregisterAfterRender(func: () => void): void;
  100569. private _executeOnceBeforeRender;
  100570. /**
  100571. * The provided function will run before render once and will be disposed afterwards.
  100572. * A timeout delay can be provided so that the function will be executed in N ms.
  100573. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100574. * @param func The function to be executed.
  100575. * @param timeout optional delay in ms
  100576. */
  100577. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100578. /** @hidden */
  100579. _addPendingData(data: any): void;
  100580. /** @hidden */
  100581. _removePendingData(data: any): void;
  100582. /**
  100583. * Returns the number of items waiting to be loaded
  100584. * @returns the number of items waiting to be loaded
  100585. */
  100586. getWaitingItemsCount(): number;
  100587. /**
  100588. * Returns a boolean indicating if the scene is still loading data
  100589. */
  100590. readonly isLoading: boolean;
  100591. /**
  100592. * Registers a function to be executed when the scene is ready
  100593. * @param {Function} func - the function to be executed
  100594. */
  100595. executeWhenReady(func: () => void): void;
  100596. /**
  100597. * Returns a promise that resolves when the scene is ready
  100598. * @returns A promise that resolves when the scene is ready
  100599. */
  100600. whenReadyAsync(): Promise<void>;
  100601. /** @hidden */
  100602. _checkIsReady(): void;
  100603. /**
  100604. * Gets all animatable attached to the scene
  100605. */
  100606. readonly animatables: Animatable[];
  100607. /**
  100608. * Resets the last animation time frame.
  100609. * Useful to override when animations start running when loading a scene for the first time.
  100610. */
  100611. resetLastAnimationTimeFrame(): void;
  100612. /**
  100613. * Gets the current view matrix
  100614. * @returns a Matrix
  100615. */
  100616. getViewMatrix(): Matrix;
  100617. /**
  100618. * Gets the current projection matrix
  100619. * @returns a Matrix
  100620. */
  100621. getProjectionMatrix(): Matrix;
  100622. /**
  100623. * Gets the current transform matrix
  100624. * @returns a Matrix made of View * Projection
  100625. */
  100626. getTransformMatrix(): Matrix;
  100627. /**
  100628. * Sets the current transform matrix
  100629. * @param viewL defines the View matrix to use
  100630. * @param projectionL defines the Projection matrix to use
  100631. * @param viewR defines the right View matrix to use (if provided)
  100632. * @param projectionR defines the right Projection matrix to use (if provided)
  100633. */
  100634. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100635. /**
  100636. * Gets the uniform buffer used to store scene data
  100637. * @returns a UniformBuffer
  100638. */
  100639. getSceneUniformBuffer(): UniformBuffer;
  100640. /**
  100641. * Gets an unique (relatively to the current scene) Id
  100642. * @returns an unique number for the scene
  100643. */
  100644. getUniqueId(): number;
  100645. /**
  100646. * Add a mesh to the list of scene's meshes
  100647. * @param newMesh defines the mesh to add
  100648. * @param recursive if all child meshes should also be added to the scene
  100649. */
  100650. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100651. /**
  100652. * Remove a mesh for the list of scene's meshes
  100653. * @param toRemove defines the mesh to remove
  100654. * @param recursive if all child meshes should also be removed from the scene
  100655. * @returns the index where the mesh was in the mesh list
  100656. */
  100657. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100658. /**
  100659. * Add a transform node to the list of scene's transform nodes
  100660. * @param newTransformNode defines the transform node to add
  100661. */
  100662. addTransformNode(newTransformNode: TransformNode): void;
  100663. /**
  100664. * Remove a transform node for the list of scene's transform nodes
  100665. * @param toRemove defines the transform node to remove
  100666. * @returns the index where the transform node was in the transform node list
  100667. */
  100668. removeTransformNode(toRemove: TransformNode): number;
  100669. /**
  100670. * Remove a skeleton for the list of scene's skeletons
  100671. * @param toRemove defines the skeleton to remove
  100672. * @returns the index where the skeleton was in the skeleton list
  100673. */
  100674. removeSkeleton(toRemove: Skeleton): number;
  100675. /**
  100676. * Remove a morph target for the list of scene's morph targets
  100677. * @param toRemove defines the morph target to remove
  100678. * @returns the index where the morph target was in the morph target list
  100679. */
  100680. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100681. /**
  100682. * Remove a light for the list of scene's lights
  100683. * @param toRemove defines the light to remove
  100684. * @returns the index where the light was in the light list
  100685. */
  100686. removeLight(toRemove: Light): number;
  100687. /**
  100688. * Remove a camera for the list of scene's cameras
  100689. * @param toRemove defines the camera to remove
  100690. * @returns the index where the camera was in the camera list
  100691. */
  100692. removeCamera(toRemove: Camera): number;
  100693. /**
  100694. * Remove a particle system for the list of scene's particle systems
  100695. * @param toRemove defines the particle system to remove
  100696. * @returns the index where the particle system was in the particle system list
  100697. */
  100698. removeParticleSystem(toRemove: IParticleSystem): number;
  100699. /**
  100700. * Remove a animation for the list of scene's animations
  100701. * @param toRemove defines the animation to remove
  100702. * @returns the index where the animation was in the animation list
  100703. */
  100704. removeAnimation(toRemove: Animation): number;
  100705. /**
  100706. * Will stop the animation of the given target
  100707. * @param target - the target
  100708. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100709. * @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)
  100710. */
  100711. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100712. /**
  100713. * Removes the given animation group from this scene.
  100714. * @param toRemove The animation group to remove
  100715. * @returns The index of the removed animation group
  100716. */
  100717. removeAnimationGroup(toRemove: AnimationGroup): number;
  100718. /**
  100719. * Removes the given multi-material from this scene.
  100720. * @param toRemove The multi-material to remove
  100721. * @returns The index of the removed multi-material
  100722. */
  100723. removeMultiMaterial(toRemove: MultiMaterial): number;
  100724. /**
  100725. * Removes the given material from this scene.
  100726. * @param toRemove The material to remove
  100727. * @returns The index of the removed material
  100728. */
  100729. removeMaterial(toRemove: Material): number;
  100730. /**
  100731. * Removes the given action manager from this scene.
  100732. * @param toRemove The action manager to remove
  100733. * @returns The index of the removed action manager
  100734. */
  100735. removeActionManager(toRemove: AbstractActionManager): number;
  100736. /**
  100737. * Removes the given texture from this scene.
  100738. * @param toRemove The texture to remove
  100739. * @returns The index of the removed texture
  100740. */
  100741. removeTexture(toRemove: BaseTexture): number;
  100742. /**
  100743. * Adds the given light to this scene
  100744. * @param newLight The light to add
  100745. */
  100746. addLight(newLight: Light): void;
  100747. /**
  100748. * Sorts the list list based on light priorities
  100749. */
  100750. sortLightsByPriority(): void;
  100751. /**
  100752. * Adds the given camera to this scene
  100753. * @param newCamera The camera to add
  100754. */
  100755. addCamera(newCamera: Camera): void;
  100756. /**
  100757. * Adds the given skeleton to this scene
  100758. * @param newSkeleton The skeleton to add
  100759. */
  100760. addSkeleton(newSkeleton: Skeleton): void;
  100761. /**
  100762. * Adds the given particle system to this scene
  100763. * @param newParticleSystem The particle system to add
  100764. */
  100765. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100766. /**
  100767. * Adds the given animation to this scene
  100768. * @param newAnimation The animation to add
  100769. */
  100770. addAnimation(newAnimation: Animation): void;
  100771. /**
  100772. * Adds the given animation group to this scene.
  100773. * @param newAnimationGroup The animation group to add
  100774. */
  100775. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100776. /**
  100777. * Adds the given multi-material to this scene
  100778. * @param newMultiMaterial The multi-material to add
  100779. */
  100780. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100781. /**
  100782. * Adds the given material to this scene
  100783. * @param newMaterial The material to add
  100784. */
  100785. addMaterial(newMaterial: Material): void;
  100786. /**
  100787. * Adds the given morph target to this scene
  100788. * @param newMorphTargetManager The morph target to add
  100789. */
  100790. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100791. /**
  100792. * Adds the given geometry to this scene
  100793. * @param newGeometry The geometry to add
  100794. */
  100795. addGeometry(newGeometry: Geometry): void;
  100796. /**
  100797. * Adds the given action manager to this scene
  100798. * @param newActionManager The action manager to add
  100799. */
  100800. addActionManager(newActionManager: AbstractActionManager): void;
  100801. /**
  100802. * Adds the given texture to this scene.
  100803. * @param newTexture The texture to add
  100804. */
  100805. addTexture(newTexture: BaseTexture): void;
  100806. /**
  100807. * Switch active camera
  100808. * @param newCamera defines the new active camera
  100809. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100810. */
  100811. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100812. /**
  100813. * sets the active camera of the scene using its ID
  100814. * @param id defines the camera's ID
  100815. * @return the new active camera or null if none found.
  100816. */
  100817. setActiveCameraByID(id: string): Nullable<Camera>;
  100818. /**
  100819. * sets the active camera of the scene using its name
  100820. * @param name defines the camera's name
  100821. * @returns the new active camera or null if none found.
  100822. */
  100823. setActiveCameraByName(name: string): Nullable<Camera>;
  100824. /**
  100825. * get an animation group using its name
  100826. * @param name defines the material's name
  100827. * @return the animation group or null if none found.
  100828. */
  100829. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100830. /**
  100831. * Get a material using its unique id
  100832. * @param uniqueId defines the material's unique id
  100833. * @return the material or null if none found.
  100834. */
  100835. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100836. /**
  100837. * get a material using its id
  100838. * @param id defines the material's ID
  100839. * @return the material or null if none found.
  100840. */
  100841. getMaterialByID(id: string): Nullable<Material>;
  100842. /**
  100843. * Gets a the last added material using a given id
  100844. * @param id defines the material's ID
  100845. * @return the last material with the given id or null if none found.
  100846. */
  100847. getLastMaterialByID(id: string): Nullable<Material>;
  100848. /**
  100849. * Gets a material using its name
  100850. * @param name defines the material's name
  100851. * @return the material or null if none found.
  100852. */
  100853. getMaterialByName(name: string): Nullable<Material>;
  100854. /**
  100855. * Get a texture using its unique id
  100856. * @param uniqueId defines the texture's unique id
  100857. * @return the texture or null if none found.
  100858. */
  100859. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100860. /**
  100861. * Gets a camera using its id
  100862. * @param id defines the id to look for
  100863. * @returns the camera or null if not found
  100864. */
  100865. getCameraByID(id: string): Nullable<Camera>;
  100866. /**
  100867. * Gets a camera using its unique id
  100868. * @param uniqueId defines the unique id to look for
  100869. * @returns the camera or null if not found
  100870. */
  100871. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100872. /**
  100873. * Gets a camera using its name
  100874. * @param name defines the camera's name
  100875. * @return the camera or null if none found.
  100876. */
  100877. getCameraByName(name: string): Nullable<Camera>;
  100878. /**
  100879. * Gets a bone using its id
  100880. * @param id defines the bone's id
  100881. * @return the bone or null if not found
  100882. */
  100883. getBoneByID(id: string): Nullable<Bone>;
  100884. /**
  100885. * Gets a bone using its id
  100886. * @param name defines the bone's name
  100887. * @return the bone or null if not found
  100888. */
  100889. getBoneByName(name: string): Nullable<Bone>;
  100890. /**
  100891. * Gets a light node using its name
  100892. * @param name defines the the light's name
  100893. * @return the light or null if none found.
  100894. */
  100895. getLightByName(name: string): Nullable<Light>;
  100896. /**
  100897. * Gets a light node using its id
  100898. * @param id defines the light's id
  100899. * @return the light or null if none found.
  100900. */
  100901. getLightByID(id: string): Nullable<Light>;
  100902. /**
  100903. * Gets a light node using its scene-generated unique ID
  100904. * @param uniqueId defines the light's unique id
  100905. * @return the light or null if none found.
  100906. */
  100907. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100908. /**
  100909. * Gets a particle system by id
  100910. * @param id defines the particle system id
  100911. * @return the corresponding system or null if none found
  100912. */
  100913. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100914. /**
  100915. * Gets a geometry using its ID
  100916. * @param id defines the geometry's id
  100917. * @return the geometry or null if none found.
  100918. */
  100919. getGeometryByID(id: string): Nullable<Geometry>;
  100920. private _getGeometryByUniqueID;
  100921. /**
  100922. * Add a new geometry to this scene
  100923. * @param geometry defines the geometry to be added to the scene.
  100924. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100925. * @return a boolean defining if the geometry was added or not
  100926. */
  100927. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100928. /**
  100929. * Removes an existing geometry
  100930. * @param geometry defines the geometry to be removed from the scene
  100931. * @return a boolean defining if the geometry was removed or not
  100932. */
  100933. removeGeometry(geometry: Geometry): boolean;
  100934. /**
  100935. * Gets the list of geometries attached to the scene
  100936. * @returns an array of Geometry
  100937. */
  100938. getGeometries(): Geometry[];
  100939. /**
  100940. * Gets the first added mesh found of a given ID
  100941. * @param id defines the id to search for
  100942. * @return the mesh found or null if not found at all
  100943. */
  100944. getMeshByID(id: string): Nullable<AbstractMesh>;
  100945. /**
  100946. * Gets a list of meshes using their id
  100947. * @param id defines the id to search for
  100948. * @returns a list of meshes
  100949. */
  100950. getMeshesByID(id: string): Array<AbstractMesh>;
  100951. /**
  100952. * Gets the first added transform node found of a given ID
  100953. * @param id defines the id to search for
  100954. * @return the found transform node or null if not found at all.
  100955. */
  100956. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100957. /**
  100958. * Gets a transform node with its auto-generated unique id
  100959. * @param uniqueId efines the unique id to search for
  100960. * @return the found transform node or null if not found at all.
  100961. */
  100962. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100963. /**
  100964. * Gets a list of transform nodes using their id
  100965. * @param id defines the id to search for
  100966. * @returns a list of transform nodes
  100967. */
  100968. getTransformNodesByID(id: string): Array<TransformNode>;
  100969. /**
  100970. * Gets a mesh with its auto-generated unique id
  100971. * @param uniqueId defines the unique id to search for
  100972. * @return the found mesh or null if not found at all.
  100973. */
  100974. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100975. /**
  100976. * Gets a the last added mesh using a given id
  100977. * @param id defines the id to search for
  100978. * @return the found mesh or null if not found at all.
  100979. */
  100980. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100981. /**
  100982. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100983. * @param id defines the id to search for
  100984. * @return the found node or null if not found at all
  100985. */
  100986. getLastEntryByID(id: string): Nullable<Node>;
  100987. /**
  100988. * Gets a node (Mesh, Camera, Light) using a given id
  100989. * @param id defines the id to search for
  100990. * @return the found node or null if not found at all
  100991. */
  100992. getNodeByID(id: string): Nullable<Node>;
  100993. /**
  100994. * Gets a node (Mesh, Camera, Light) using a given name
  100995. * @param name defines the name to search for
  100996. * @return the found node or null if not found at all.
  100997. */
  100998. getNodeByName(name: string): Nullable<Node>;
  100999. /**
  101000. * Gets a mesh using a given name
  101001. * @param name defines the name to search for
  101002. * @return the found mesh or null if not found at all.
  101003. */
  101004. getMeshByName(name: string): Nullable<AbstractMesh>;
  101005. /**
  101006. * Gets a transform node using a given name
  101007. * @param name defines the name to search for
  101008. * @return the found transform node or null if not found at all.
  101009. */
  101010. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101011. /**
  101012. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101013. * @param id defines the id to search for
  101014. * @return the found skeleton or null if not found at all.
  101015. */
  101016. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101017. /**
  101018. * Gets a skeleton using a given auto generated unique id
  101019. * @param uniqueId defines the unique id to search for
  101020. * @return the found skeleton or null if not found at all.
  101021. */
  101022. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101023. /**
  101024. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101025. * @param id defines the id to search for
  101026. * @return the found skeleton or null if not found at all.
  101027. */
  101028. getSkeletonById(id: string): Nullable<Skeleton>;
  101029. /**
  101030. * Gets a skeleton using a given name
  101031. * @param name defines the name to search for
  101032. * @return the found skeleton or null if not found at all.
  101033. */
  101034. getSkeletonByName(name: string): Nullable<Skeleton>;
  101035. /**
  101036. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101037. * @param id defines the id to search for
  101038. * @return the found morph target manager or null if not found at all.
  101039. */
  101040. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101041. /**
  101042. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101043. * @param id defines the id to search for
  101044. * @return the found morph target or null if not found at all.
  101045. */
  101046. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101047. /**
  101048. * Gets a boolean indicating if the given mesh is active
  101049. * @param mesh defines the mesh to look for
  101050. * @returns true if the mesh is in the active list
  101051. */
  101052. isActiveMesh(mesh: AbstractMesh): boolean;
  101053. /**
  101054. * Return a unique id as a string which can serve as an identifier for the scene
  101055. */
  101056. readonly uid: string;
  101057. /**
  101058. * Add an externaly attached data from its key.
  101059. * This method call will fail and return false, if such key already exists.
  101060. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101061. * @param key the unique key that identifies the data
  101062. * @param data the data object to associate to the key for this Engine instance
  101063. * @return true if no such key were already present and the data was added successfully, false otherwise
  101064. */
  101065. addExternalData<T>(key: string, data: T): boolean;
  101066. /**
  101067. * Get an externaly attached data from its key
  101068. * @param key the unique key that identifies the data
  101069. * @return the associated data, if present (can be null), or undefined if not present
  101070. */
  101071. getExternalData<T>(key: string): Nullable<T>;
  101072. /**
  101073. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101074. * @param key the unique key that identifies the data
  101075. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101076. * @return the associated data, can be null if the factory returned null.
  101077. */
  101078. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101079. /**
  101080. * Remove an externaly attached data from the Engine instance
  101081. * @param key the unique key that identifies the data
  101082. * @return true if the data was successfully removed, false if it doesn't exist
  101083. */
  101084. removeExternalData(key: string): boolean;
  101085. private _evaluateSubMesh;
  101086. /**
  101087. * Clear the processed materials smart array preventing retention point in material dispose.
  101088. */
  101089. freeProcessedMaterials(): void;
  101090. private _preventFreeActiveMeshesAndRenderingGroups;
  101091. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101092. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101093. * when disposing several meshes in a row or a hierarchy of meshes.
  101094. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101095. */
  101096. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101097. /**
  101098. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101099. */
  101100. freeActiveMeshes(): void;
  101101. /**
  101102. * Clear the info related to rendering groups preventing retention points during dispose.
  101103. */
  101104. freeRenderingGroups(): void;
  101105. /** @hidden */
  101106. _isInIntermediateRendering(): boolean;
  101107. /**
  101108. * Lambda returning the list of potentially active meshes.
  101109. */
  101110. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101111. /**
  101112. * Lambda returning the list of potentially active sub meshes.
  101113. */
  101114. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101115. /**
  101116. * Lambda returning the list of potentially intersecting sub meshes.
  101117. */
  101118. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101119. /**
  101120. * Lambda returning the list of potentially colliding sub meshes.
  101121. */
  101122. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101123. private _activeMeshesFrozen;
  101124. /**
  101125. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101126. * @returns the current scene
  101127. */
  101128. freezeActiveMeshes(): Scene;
  101129. /**
  101130. * Use this function to restart evaluating active meshes on every frame
  101131. * @returns the current scene
  101132. */
  101133. unfreezeActiveMeshes(): Scene;
  101134. private _evaluateActiveMeshes;
  101135. private _activeMesh;
  101136. /**
  101137. * Update the transform matrix to update from the current active camera
  101138. * @param force defines a boolean used to force the update even if cache is up to date
  101139. */
  101140. updateTransformMatrix(force?: boolean): void;
  101141. private _bindFrameBuffer;
  101142. /** @hidden */
  101143. _allowPostProcessClearColor: boolean;
  101144. /** @hidden */
  101145. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101146. private _processSubCameras;
  101147. private _checkIntersections;
  101148. /** @hidden */
  101149. _advancePhysicsEngineStep(step: number): void;
  101150. /**
  101151. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101152. */
  101153. getDeterministicFrameTime: () => number;
  101154. /** @hidden */
  101155. _animate(): void;
  101156. /** Execute all animations (for a frame) */
  101157. animate(): void;
  101158. /**
  101159. * Render the scene
  101160. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101161. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101162. */
  101163. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101164. /**
  101165. * Freeze all materials
  101166. * A frozen material will not be updatable but should be faster to render
  101167. */
  101168. freezeMaterials(): void;
  101169. /**
  101170. * Unfreeze all materials
  101171. * A frozen material will not be updatable but should be faster to render
  101172. */
  101173. unfreezeMaterials(): void;
  101174. /**
  101175. * Releases all held ressources
  101176. */
  101177. dispose(): void;
  101178. /**
  101179. * Gets if the scene is already disposed
  101180. */
  101181. readonly isDisposed: boolean;
  101182. /**
  101183. * Call this function to reduce memory footprint of the scene.
  101184. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101185. */
  101186. clearCachedVertexData(): void;
  101187. /**
  101188. * This function will remove the local cached buffer data from texture.
  101189. * It will save memory but will prevent the texture from being rebuilt
  101190. */
  101191. cleanCachedTextureBuffer(): void;
  101192. /**
  101193. * Get the world extend vectors with an optional filter
  101194. *
  101195. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101196. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101197. */
  101198. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101199. min: Vector3;
  101200. max: Vector3;
  101201. };
  101202. /**
  101203. * Creates a ray that can be used to pick in the scene
  101204. * @param x defines the x coordinate of the origin (on-screen)
  101205. * @param y defines the y coordinate of the origin (on-screen)
  101206. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101207. * @param camera defines the camera to use for the picking
  101208. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101209. * @returns a Ray
  101210. */
  101211. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101212. /**
  101213. * Creates a ray that can be used to pick in the scene
  101214. * @param x defines the x coordinate of the origin (on-screen)
  101215. * @param y defines the y coordinate of the origin (on-screen)
  101216. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101217. * @param result defines the ray where to store the picking ray
  101218. * @param camera defines the camera to use for the picking
  101219. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101220. * @returns the current scene
  101221. */
  101222. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101223. /**
  101224. * Creates a ray that can be used to pick in the scene
  101225. * @param x defines the x coordinate of the origin (on-screen)
  101226. * @param y defines the y coordinate of the origin (on-screen)
  101227. * @param camera defines the camera to use for the picking
  101228. * @returns a Ray
  101229. */
  101230. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101231. /**
  101232. * Creates a ray that can be used to pick in the scene
  101233. * @param x defines the x coordinate of the origin (on-screen)
  101234. * @param y defines the y coordinate of the origin (on-screen)
  101235. * @param result defines the ray where to store the picking ray
  101236. * @param camera defines the camera to use for the picking
  101237. * @returns the current scene
  101238. */
  101239. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101240. /** Launch a ray to try to pick a mesh in the scene
  101241. * @param x position on screen
  101242. * @param y position on screen
  101243. * @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
  101244. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101245. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101246. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101247. * @returns a PickingInfo
  101248. */
  101249. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101250. /** Use the given ray to pick a mesh in the scene
  101251. * @param ray The ray to use to pick meshes
  101252. * @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
  101253. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101254. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101255. * @returns a PickingInfo
  101256. */
  101257. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101258. /**
  101259. * Launch a ray to try to pick a mesh in the scene
  101260. * @param x X position on screen
  101261. * @param y Y position on screen
  101262. * @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
  101263. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101265. * @returns an array of PickingInfo
  101266. */
  101267. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101268. /**
  101269. * Launch a ray to try to pick a mesh in the scene
  101270. * @param ray Ray to use
  101271. * @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
  101272. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101273. * @returns an array of PickingInfo
  101274. */
  101275. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101276. /**
  101277. * Force the value of meshUnderPointer
  101278. * @param mesh defines the mesh to use
  101279. */
  101280. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101281. /**
  101282. * Gets the mesh under the pointer
  101283. * @returns a Mesh or null if no mesh is under the pointer
  101284. */
  101285. getPointerOverMesh(): Nullable<AbstractMesh>;
  101286. /** @hidden */
  101287. _rebuildGeometries(): void;
  101288. /** @hidden */
  101289. _rebuildTextures(): void;
  101290. private _getByTags;
  101291. /**
  101292. * Get a list of meshes by tags
  101293. * @param tagsQuery defines the tags query to use
  101294. * @param forEach defines a predicate used to filter results
  101295. * @returns an array of Mesh
  101296. */
  101297. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101298. /**
  101299. * Get a list of cameras by tags
  101300. * @param tagsQuery defines the tags query to use
  101301. * @param forEach defines a predicate used to filter results
  101302. * @returns an array of Camera
  101303. */
  101304. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101305. /**
  101306. * Get a list of lights by tags
  101307. * @param tagsQuery defines the tags query to use
  101308. * @param forEach defines a predicate used to filter results
  101309. * @returns an array of Light
  101310. */
  101311. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101312. /**
  101313. * Get a list of materials by tags
  101314. * @param tagsQuery defines the tags query to use
  101315. * @param forEach defines a predicate used to filter results
  101316. * @returns an array of Material
  101317. */
  101318. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101319. /**
  101320. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101321. * This allowed control for front to back rendering or reversly depending of the special needs.
  101322. *
  101323. * @param renderingGroupId The rendering group id corresponding to its index
  101324. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101325. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101326. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101327. */
  101328. 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;
  101329. /**
  101330. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101331. *
  101332. * @param renderingGroupId The rendering group id corresponding to its index
  101333. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101334. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101335. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101336. */
  101337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101338. /**
  101339. * Gets the current auto clear configuration for one rendering group of the rendering
  101340. * manager.
  101341. * @param index the rendering group index to get the information for
  101342. * @returns The auto clear setup for the requested rendering group
  101343. */
  101344. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101345. private _blockMaterialDirtyMechanism;
  101346. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101347. blockMaterialDirtyMechanism: boolean;
  101348. /**
  101349. * Will flag all materials as dirty to trigger new shader compilation
  101350. * @param flag defines the flag used to specify which material part must be marked as dirty
  101351. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101352. */
  101353. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101354. /** @hidden */
  101355. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  101356. /** @hidden */
  101357. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101358. }
  101359. }
  101360. declare module BABYLON {
  101361. /**
  101362. * Set of assets to keep when moving a scene into an asset container.
  101363. */
  101364. export class KeepAssets extends AbstractScene {
  101365. }
  101366. /**
  101367. * Container with a set of assets that can be added or removed from a scene.
  101368. */
  101369. export class AssetContainer extends AbstractScene {
  101370. /**
  101371. * The scene the AssetContainer belongs to.
  101372. */
  101373. scene: Scene;
  101374. /**
  101375. * Instantiates an AssetContainer.
  101376. * @param scene The scene the AssetContainer belongs to.
  101377. */
  101378. constructor(scene: Scene);
  101379. /**
  101380. * Adds all the assets from the container to the scene.
  101381. */
  101382. addAllToScene(): void;
  101383. /**
  101384. * Removes all the assets in the container from the scene
  101385. */
  101386. removeAllFromScene(): void;
  101387. /**
  101388. * Disposes all the assets in the container
  101389. */
  101390. dispose(): void;
  101391. private _moveAssets;
  101392. /**
  101393. * Removes all the assets contained in the scene and adds them to the container.
  101394. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101395. */
  101396. moveAllFromScene(keepAssets?: KeepAssets): void;
  101397. /**
  101398. * 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.
  101399. * @returns the root mesh
  101400. */
  101401. createRootMesh(): Mesh;
  101402. }
  101403. }
  101404. declare module BABYLON {
  101405. /**
  101406. * Defines how the parser contract is defined.
  101407. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101408. */
  101409. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101410. /**
  101411. * Defines how the individual parser contract is defined.
  101412. * These parser can parse an individual asset
  101413. */
  101414. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101415. /**
  101416. * Base class of the scene acting as a container for the different elements composing a scene.
  101417. * This class is dynamically extended by the different components of the scene increasing
  101418. * flexibility and reducing coupling
  101419. */
  101420. export abstract class AbstractScene {
  101421. /**
  101422. * Stores the list of available parsers in the application.
  101423. */
  101424. private static _BabylonFileParsers;
  101425. /**
  101426. * Stores the list of available individual parsers in the application.
  101427. */
  101428. private static _IndividualBabylonFileParsers;
  101429. /**
  101430. * Adds a parser in the list of available ones
  101431. * @param name Defines the name of the parser
  101432. * @param parser Defines the parser to add
  101433. */
  101434. static AddParser(name: string, parser: BabylonFileParser): void;
  101435. /**
  101436. * Gets a general parser from the list of avaialble ones
  101437. * @param name Defines the name of the parser
  101438. * @returns the requested parser or null
  101439. */
  101440. static GetParser(name: string): Nullable<BabylonFileParser>;
  101441. /**
  101442. * Adds n individual parser in the list of available ones
  101443. * @param name Defines the name of the parser
  101444. * @param parser Defines the parser to add
  101445. */
  101446. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101447. /**
  101448. * Gets an individual parser from the list of avaialble ones
  101449. * @param name Defines the name of the parser
  101450. * @returns the requested parser or null
  101451. */
  101452. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101453. /**
  101454. * Parser json data and populate both a scene and its associated container object
  101455. * @param jsonData Defines the data to parse
  101456. * @param scene Defines the scene to parse the data for
  101457. * @param container Defines the container attached to the parsing sequence
  101458. * @param rootUrl Defines the root url of the data
  101459. */
  101460. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101461. /**
  101462. * Gets the list of root nodes (ie. nodes with no parent)
  101463. */
  101464. rootNodes: Node[];
  101465. /** All of the cameras added to this scene
  101466. * @see http://doc.babylonjs.com/babylon101/cameras
  101467. */
  101468. cameras: Camera[];
  101469. /**
  101470. * All of the lights added to this scene
  101471. * @see http://doc.babylonjs.com/babylon101/lights
  101472. */
  101473. lights: Light[];
  101474. /**
  101475. * All of the (abstract) meshes added to this scene
  101476. */
  101477. meshes: AbstractMesh[];
  101478. /**
  101479. * The list of skeletons added to the scene
  101480. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101481. */
  101482. skeletons: Skeleton[];
  101483. /**
  101484. * All of the particle systems added to this scene
  101485. * @see http://doc.babylonjs.com/babylon101/particles
  101486. */
  101487. particleSystems: IParticleSystem[];
  101488. /**
  101489. * Gets a list of Animations associated with the scene
  101490. */
  101491. animations: Animation[];
  101492. /**
  101493. * All of the animation groups added to this scene
  101494. * @see http://doc.babylonjs.com/how_to/group
  101495. */
  101496. animationGroups: AnimationGroup[];
  101497. /**
  101498. * All of the multi-materials added to this scene
  101499. * @see http://doc.babylonjs.com/how_to/multi_materials
  101500. */
  101501. multiMaterials: MultiMaterial[];
  101502. /**
  101503. * All of the materials added to this scene
  101504. * In the context of a Scene, it is not supposed to be modified manually.
  101505. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101506. * Note also that the order of the Material wihin the array is not significant and might change.
  101507. * @see http://doc.babylonjs.com/babylon101/materials
  101508. */
  101509. materials: Material[];
  101510. /**
  101511. * The list of morph target managers added to the scene
  101512. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101513. */
  101514. morphTargetManagers: MorphTargetManager[];
  101515. /**
  101516. * The list of geometries used in the scene.
  101517. */
  101518. geometries: Geometry[];
  101519. /**
  101520. * All of the tranform nodes added to this scene
  101521. * In the context of a Scene, it is not supposed to be modified manually.
  101522. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101523. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101524. * @see http://doc.babylonjs.com/how_to/transformnode
  101525. */
  101526. transformNodes: TransformNode[];
  101527. /**
  101528. * ActionManagers available on the scene.
  101529. */
  101530. actionManagers: AbstractActionManager[];
  101531. /**
  101532. * Textures to keep.
  101533. */
  101534. textures: BaseTexture[];
  101535. /**
  101536. * Environment texture for the scene
  101537. */
  101538. environmentTexture: Nullable<BaseTexture>;
  101539. }
  101540. }
  101541. declare module BABYLON {
  101542. /**
  101543. * Interface used to define options for Sound class
  101544. */
  101545. export interface ISoundOptions {
  101546. /**
  101547. * Does the sound autoplay once loaded.
  101548. */
  101549. autoplay?: boolean;
  101550. /**
  101551. * Does the sound loop after it finishes playing once.
  101552. */
  101553. loop?: boolean;
  101554. /**
  101555. * Sound's volume
  101556. */
  101557. volume?: number;
  101558. /**
  101559. * Is it a spatial sound?
  101560. */
  101561. spatialSound?: boolean;
  101562. /**
  101563. * Maximum distance to hear that sound
  101564. */
  101565. maxDistance?: number;
  101566. /**
  101567. * Uses user defined attenuation function
  101568. */
  101569. useCustomAttenuation?: boolean;
  101570. /**
  101571. * Define the roll off factor of spatial sounds.
  101572. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101573. */
  101574. rolloffFactor?: number;
  101575. /**
  101576. * Define the reference distance the sound should be heard perfectly.
  101577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101578. */
  101579. refDistance?: number;
  101580. /**
  101581. * Define the distance attenuation model the sound will follow.
  101582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101583. */
  101584. distanceModel?: string;
  101585. /**
  101586. * Defines the playback speed (1 by default)
  101587. */
  101588. playbackRate?: number;
  101589. /**
  101590. * Defines if the sound is from a streaming source
  101591. */
  101592. streaming?: boolean;
  101593. /**
  101594. * Defines an optional length (in seconds) inside the sound file
  101595. */
  101596. length?: number;
  101597. /**
  101598. * Defines an optional offset (in seconds) inside the sound file
  101599. */
  101600. offset?: number;
  101601. /**
  101602. * If true, URLs will not be required to state the audio file codec to use.
  101603. */
  101604. skipCodecCheck?: boolean;
  101605. }
  101606. /**
  101607. * Defines a sound that can be played in the application.
  101608. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101610. */
  101611. export class Sound {
  101612. /**
  101613. * The name of the sound in the scene.
  101614. */
  101615. name: string;
  101616. /**
  101617. * Does the sound autoplay once loaded.
  101618. */
  101619. autoplay: boolean;
  101620. /**
  101621. * Does the sound loop after it finishes playing once.
  101622. */
  101623. loop: boolean;
  101624. /**
  101625. * Does the sound use a custom attenuation curve to simulate the falloff
  101626. * happening when the source gets further away from the camera.
  101627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101628. */
  101629. useCustomAttenuation: boolean;
  101630. /**
  101631. * The sound track id this sound belongs to.
  101632. */
  101633. soundTrackId: number;
  101634. /**
  101635. * Is this sound currently played.
  101636. */
  101637. isPlaying: boolean;
  101638. /**
  101639. * Is this sound currently paused.
  101640. */
  101641. isPaused: boolean;
  101642. /**
  101643. * Does this sound enables spatial sound.
  101644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101645. */
  101646. spatialSound: boolean;
  101647. /**
  101648. * Define the reference distance the sound should be heard perfectly.
  101649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101650. */
  101651. refDistance: number;
  101652. /**
  101653. * Define the roll off factor of spatial sounds.
  101654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101655. */
  101656. rolloffFactor: number;
  101657. /**
  101658. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101660. */
  101661. maxDistance: number;
  101662. /**
  101663. * Define the distance attenuation model the sound will follow.
  101664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101665. */
  101666. distanceModel: string;
  101667. /**
  101668. * @hidden
  101669. * Back Compat
  101670. **/
  101671. onended: () => any;
  101672. /**
  101673. * Observable event when the current playing sound finishes.
  101674. */
  101675. onEndedObservable: Observable<Sound>;
  101676. private _panningModel;
  101677. private _playbackRate;
  101678. private _streaming;
  101679. private _startTime;
  101680. private _startOffset;
  101681. private _position;
  101682. /** @hidden */
  101683. _positionInEmitterSpace: boolean;
  101684. private _localDirection;
  101685. private _volume;
  101686. private _isReadyToPlay;
  101687. private _isDirectional;
  101688. private _readyToPlayCallback;
  101689. private _audioBuffer;
  101690. private _soundSource;
  101691. private _streamingSource;
  101692. private _soundPanner;
  101693. private _soundGain;
  101694. private _inputAudioNode;
  101695. private _outputAudioNode;
  101696. private _coneInnerAngle;
  101697. private _coneOuterAngle;
  101698. private _coneOuterGain;
  101699. private _scene;
  101700. private _connectedTransformNode;
  101701. private _customAttenuationFunction;
  101702. private _registerFunc;
  101703. private _isOutputConnected;
  101704. private _htmlAudioElement;
  101705. private _urlType;
  101706. private _length?;
  101707. private _offset?;
  101708. /** @hidden */
  101709. static _SceneComponentInitialization: (scene: Scene) => void;
  101710. /**
  101711. * Create a sound and attach it to a scene
  101712. * @param name Name of your sound
  101713. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101714. * @param scene defines the scene the sound belongs to
  101715. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101716. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101717. */
  101718. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101719. /**
  101720. * Release the sound and its associated resources
  101721. */
  101722. dispose(): void;
  101723. /**
  101724. * Gets if the sounds is ready to be played or not.
  101725. * @returns true if ready, otherwise false
  101726. */
  101727. isReady(): boolean;
  101728. private _soundLoaded;
  101729. /**
  101730. * Sets the data of the sound from an audiobuffer
  101731. * @param audioBuffer The audioBuffer containing the data
  101732. */
  101733. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101734. /**
  101735. * Updates the current sounds options such as maxdistance, loop...
  101736. * @param options A JSON object containing values named as the object properties
  101737. */
  101738. updateOptions(options: ISoundOptions): void;
  101739. private _createSpatialParameters;
  101740. private _updateSpatialParameters;
  101741. /**
  101742. * Switch the panning model to HRTF:
  101743. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101745. */
  101746. switchPanningModelToHRTF(): void;
  101747. /**
  101748. * Switch the panning model to Equal Power:
  101749. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101751. */
  101752. switchPanningModelToEqualPower(): void;
  101753. private _switchPanningModel;
  101754. /**
  101755. * Connect this sound to a sound track audio node like gain...
  101756. * @param soundTrackAudioNode the sound track audio node to connect to
  101757. */
  101758. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101759. /**
  101760. * Transform this sound into a directional source
  101761. * @param coneInnerAngle Size of the inner cone in degree
  101762. * @param coneOuterAngle Size of the outer cone in degree
  101763. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101764. */
  101765. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101766. /**
  101767. * Gets or sets the inner angle for the directional cone.
  101768. */
  101769. /**
  101770. * Gets or sets the inner angle for the directional cone.
  101771. */
  101772. directionalConeInnerAngle: number;
  101773. /**
  101774. * Gets or sets the outer angle for the directional cone.
  101775. */
  101776. /**
  101777. * Gets or sets the outer angle for the directional cone.
  101778. */
  101779. directionalConeOuterAngle: number;
  101780. /**
  101781. * Sets the position of the emitter if spatial sound is enabled
  101782. * @param newPosition Defines the new posisiton
  101783. */
  101784. setPosition(newPosition: Vector3): void;
  101785. /**
  101786. * Sets the local direction of the emitter if spatial sound is enabled
  101787. * @param newLocalDirection Defines the new local direction
  101788. */
  101789. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101790. private _updateDirection;
  101791. /** @hidden */
  101792. updateDistanceFromListener(): void;
  101793. /**
  101794. * Sets a new custom attenuation function for the sound.
  101795. * @param callback Defines the function used for the attenuation
  101796. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101797. */
  101798. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101799. /**
  101800. * Play the sound
  101801. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101802. * @param offset (optional) Start the sound at a specific time in seconds
  101803. * @param length (optional) Sound duration (in seconds)
  101804. */
  101805. play(time?: number, offset?: number, length?: number): void;
  101806. private _onended;
  101807. /**
  101808. * Stop the sound
  101809. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101810. */
  101811. stop(time?: number): void;
  101812. /**
  101813. * Put the sound in pause
  101814. */
  101815. pause(): void;
  101816. /**
  101817. * Sets a dedicated volume for this sounds
  101818. * @param newVolume Define the new volume of the sound
  101819. * @param time Define time for gradual change to new volume
  101820. */
  101821. setVolume(newVolume: number, time?: number): void;
  101822. /**
  101823. * Set the sound play back rate
  101824. * @param newPlaybackRate Define the playback rate the sound should be played at
  101825. */
  101826. setPlaybackRate(newPlaybackRate: number): void;
  101827. /**
  101828. * Gets the volume of the sound.
  101829. * @returns the volume of the sound
  101830. */
  101831. getVolume(): number;
  101832. /**
  101833. * Attach the sound to a dedicated mesh
  101834. * @param transformNode The transform node to connect the sound with
  101835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101836. */
  101837. attachToMesh(transformNode: TransformNode): void;
  101838. /**
  101839. * Detach the sound from the previously attached mesh
  101840. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101841. */
  101842. detachFromMesh(): void;
  101843. private _onRegisterAfterWorldMatrixUpdate;
  101844. /**
  101845. * Clone the current sound in the scene.
  101846. * @returns the new sound clone
  101847. */
  101848. clone(): Nullable<Sound>;
  101849. /**
  101850. * Gets the current underlying audio buffer containing the data
  101851. * @returns the audio buffer
  101852. */
  101853. getAudioBuffer(): Nullable<AudioBuffer>;
  101854. /**
  101855. * Serializes the Sound in a JSON representation
  101856. * @returns the JSON representation of the sound
  101857. */
  101858. serialize(): any;
  101859. /**
  101860. * Parse a JSON representation of a sound to innstantiate in a given scene
  101861. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101862. * @param scene Define the scene the new parsed sound should be created in
  101863. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101864. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101865. * @returns the newly parsed sound
  101866. */
  101867. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101868. }
  101869. }
  101870. declare module BABYLON {
  101871. /**
  101872. * This defines an action helpful to play a defined sound on a triggered action.
  101873. */
  101874. export class PlaySoundAction extends Action {
  101875. private _sound;
  101876. /**
  101877. * Instantiate the action
  101878. * @param triggerOptions defines the trigger options
  101879. * @param sound defines the sound to play
  101880. * @param condition defines the trigger related conditions
  101881. */
  101882. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101883. /** @hidden */
  101884. _prepare(): void;
  101885. /**
  101886. * Execute the action and play the sound.
  101887. */
  101888. execute(): void;
  101889. /**
  101890. * Serializes the actions and its related information.
  101891. * @param parent defines the object to serialize in
  101892. * @returns the serialized object
  101893. */
  101894. serialize(parent: any): any;
  101895. }
  101896. /**
  101897. * This defines an action helpful to stop a defined sound on a triggered action.
  101898. */
  101899. export class StopSoundAction extends Action {
  101900. private _sound;
  101901. /**
  101902. * Instantiate the action
  101903. * @param triggerOptions defines the trigger options
  101904. * @param sound defines the sound to stop
  101905. * @param condition defines the trigger related conditions
  101906. */
  101907. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101908. /** @hidden */
  101909. _prepare(): void;
  101910. /**
  101911. * Execute the action and stop the sound.
  101912. */
  101913. execute(): void;
  101914. /**
  101915. * Serializes the actions and its related information.
  101916. * @param parent defines the object to serialize in
  101917. * @returns the serialized object
  101918. */
  101919. serialize(parent: any): any;
  101920. }
  101921. }
  101922. declare module BABYLON {
  101923. /**
  101924. * This defines an action responsible to change the value of a property
  101925. * by interpolating between its current value and the newly set one once triggered.
  101926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101927. */
  101928. export class InterpolateValueAction extends Action {
  101929. /**
  101930. * Defines the path of the property where the value should be interpolated
  101931. */
  101932. propertyPath: string;
  101933. /**
  101934. * Defines the target value at the end of the interpolation.
  101935. */
  101936. value: any;
  101937. /**
  101938. * Defines the time it will take for the property to interpolate to the value.
  101939. */
  101940. duration: number;
  101941. /**
  101942. * Defines if the other scene animations should be stopped when the action has been triggered
  101943. */
  101944. stopOtherAnimations?: boolean;
  101945. /**
  101946. * Defines a callback raised once the interpolation animation has been done.
  101947. */
  101948. onInterpolationDone?: () => void;
  101949. /**
  101950. * Observable triggered once the interpolation animation has been done.
  101951. */
  101952. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101953. private _target;
  101954. private _effectiveTarget;
  101955. private _property;
  101956. /**
  101957. * Instantiate the action
  101958. * @param triggerOptions defines the trigger options
  101959. * @param target defines the object containing the value to interpolate
  101960. * @param propertyPath defines the path to the property in the target object
  101961. * @param value defines the target value at the end of the interpolation
  101962. * @param duration deines the time it will take for the property to interpolate to the value.
  101963. * @param condition defines the trigger related conditions
  101964. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101965. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101966. */
  101967. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101968. /** @hidden */
  101969. _prepare(): void;
  101970. /**
  101971. * Execute the action starts the value interpolation.
  101972. */
  101973. execute(): void;
  101974. /**
  101975. * Serializes the actions and its related information.
  101976. * @param parent defines the object to serialize in
  101977. * @returns the serialized object
  101978. */
  101979. serialize(parent: any): any;
  101980. }
  101981. }
  101982. declare module BABYLON {
  101983. /**
  101984. * Options allowed during the creation of a sound track.
  101985. */
  101986. export interface ISoundTrackOptions {
  101987. /**
  101988. * The volume the sound track should take during creation
  101989. */
  101990. volume?: number;
  101991. /**
  101992. * Define if the sound track is the main sound track of the scene
  101993. */
  101994. mainTrack?: boolean;
  101995. }
  101996. /**
  101997. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101998. * It will be also used in a future release to apply effects on a specific track.
  101999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102000. */
  102001. export class SoundTrack {
  102002. /**
  102003. * The unique identifier of the sound track in the scene.
  102004. */
  102005. id: number;
  102006. /**
  102007. * The list of sounds included in the sound track.
  102008. */
  102009. soundCollection: Array<Sound>;
  102010. private _outputAudioNode;
  102011. private _scene;
  102012. private _isMainTrack;
  102013. private _connectedAnalyser;
  102014. private _options;
  102015. private _isInitialized;
  102016. /**
  102017. * Creates a new sound track.
  102018. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102019. * @param scene Define the scene the sound track belongs to
  102020. * @param options
  102021. */
  102022. constructor(scene: Scene, options?: ISoundTrackOptions);
  102023. private _initializeSoundTrackAudioGraph;
  102024. /**
  102025. * Release the sound track and its associated resources
  102026. */
  102027. dispose(): void;
  102028. /**
  102029. * Adds a sound to this sound track
  102030. * @param sound define the cound to add
  102031. * @ignoreNaming
  102032. */
  102033. AddSound(sound: Sound): void;
  102034. /**
  102035. * Removes a sound to this sound track
  102036. * @param sound define the cound to remove
  102037. * @ignoreNaming
  102038. */
  102039. RemoveSound(sound: Sound): void;
  102040. /**
  102041. * Set a global volume for the full sound track.
  102042. * @param newVolume Define the new volume of the sound track
  102043. */
  102044. setVolume(newVolume: number): void;
  102045. /**
  102046. * Switch the panning model to HRTF:
  102047. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102049. */
  102050. switchPanningModelToHRTF(): void;
  102051. /**
  102052. * Switch the panning model to Equal Power:
  102053. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102054. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102055. */
  102056. switchPanningModelToEqualPower(): void;
  102057. /**
  102058. * Connect the sound track to an audio analyser allowing some amazing
  102059. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102060. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102061. * @param analyser The analyser to connect to the engine
  102062. */
  102063. connectToAnalyser(analyser: Analyser): void;
  102064. }
  102065. }
  102066. declare module BABYLON {
  102067. interface AbstractScene {
  102068. /**
  102069. * The list of sounds used in the scene.
  102070. */
  102071. sounds: Nullable<Array<Sound>>;
  102072. }
  102073. interface Scene {
  102074. /**
  102075. * @hidden
  102076. * Backing field
  102077. */
  102078. _mainSoundTrack: SoundTrack;
  102079. /**
  102080. * The main sound track played by the scene.
  102081. * It cotains your primary collection of sounds.
  102082. */
  102083. mainSoundTrack: SoundTrack;
  102084. /**
  102085. * The list of sound tracks added to the scene
  102086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102087. */
  102088. soundTracks: Nullable<Array<SoundTrack>>;
  102089. /**
  102090. * Gets a sound using a given name
  102091. * @param name defines the name to search for
  102092. * @return the found sound or null if not found at all.
  102093. */
  102094. getSoundByName(name: string): Nullable<Sound>;
  102095. /**
  102096. * Gets or sets if audio support is enabled
  102097. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102098. */
  102099. audioEnabled: boolean;
  102100. /**
  102101. * Gets or sets if audio will be output to headphones
  102102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102103. */
  102104. headphone: boolean;
  102105. /**
  102106. * Gets or sets custom audio listener position provider
  102107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102108. */
  102109. audioListenerPositionProvider: Nullable<() => Vector3>;
  102110. }
  102111. /**
  102112. * Defines the sound scene component responsible to manage any sounds
  102113. * in a given scene.
  102114. */
  102115. export class AudioSceneComponent implements ISceneSerializableComponent {
  102116. /**
  102117. * The component name helpfull to identify the component in the list of scene components.
  102118. */
  102119. readonly name: string;
  102120. /**
  102121. * The scene the component belongs to.
  102122. */
  102123. scene: Scene;
  102124. private _audioEnabled;
  102125. /**
  102126. * Gets whether audio is enabled or not.
  102127. * Please use related enable/disable method to switch state.
  102128. */
  102129. readonly audioEnabled: boolean;
  102130. private _headphone;
  102131. /**
  102132. * Gets whether audio is outputing to headphone or not.
  102133. * Please use the according Switch methods to change output.
  102134. */
  102135. readonly headphone: boolean;
  102136. private _audioListenerPositionProvider;
  102137. /**
  102138. * Gets the current audio listener position provider
  102139. */
  102140. /**
  102141. * Sets a custom listener position for all sounds in the scene
  102142. * By default, this is the position of the first active camera
  102143. */
  102144. audioListenerPositionProvider: Nullable<() => Vector3>;
  102145. /**
  102146. * Creates a new instance of the component for the given scene
  102147. * @param scene Defines the scene to register the component in
  102148. */
  102149. constructor(scene: Scene);
  102150. /**
  102151. * Registers the component in a given scene
  102152. */
  102153. register(): void;
  102154. /**
  102155. * Rebuilds the elements related to this component in case of
  102156. * context lost for instance.
  102157. */
  102158. rebuild(): void;
  102159. /**
  102160. * Serializes the component data to the specified json object
  102161. * @param serializationObject The object to serialize to
  102162. */
  102163. serialize(serializationObject: any): void;
  102164. /**
  102165. * Adds all the elements from the container to the scene
  102166. * @param container the container holding the elements
  102167. */
  102168. addFromContainer(container: AbstractScene): void;
  102169. /**
  102170. * Removes all the elements in the container from the scene
  102171. * @param container contains the elements to remove
  102172. * @param dispose if the removed element should be disposed (default: false)
  102173. */
  102174. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102175. /**
  102176. * Disposes the component and the associated ressources.
  102177. */
  102178. dispose(): void;
  102179. /**
  102180. * Disables audio in the associated scene.
  102181. */
  102182. disableAudio(): void;
  102183. /**
  102184. * Enables audio in the associated scene.
  102185. */
  102186. enableAudio(): void;
  102187. /**
  102188. * Switch audio to headphone output.
  102189. */
  102190. switchAudioModeForHeadphones(): void;
  102191. /**
  102192. * Switch audio to normal speakers.
  102193. */
  102194. switchAudioModeForNormalSpeakers(): void;
  102195. private _afterRender;
  102196. }
  102197. }
  102198. declare module BABYLON {
  102199. /**
  102200. * Wraps one or more Sound objects and selects one with random weight for playback.
  102201. */
  102202. export class WeightedSound {
  102203. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102204. loop: boolean;
  102205. private _coneInnerAngle;
  102206. private _coneOuterAngle;
  102207. private _volume;
  102208. /** A Sound is currently playing. */
  102209. isPlaying: boolean;
  102210. /** A Sound is currently paused. */
  102211. isPaused: boolean;
  102212. private _sounds;
  102213. private _weights;
  102214. private _currentIndex?;
  102215. /**
  102216. * Creates a new WeightedSound from the list of sounds given.
  102217. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102218. * @param sounds Array of Sounds that will be selected from.
  102219. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102220. */
  102221. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102222. /**
  102223. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102224. */
  102225. /**
  102226. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102227. */
  102228. directionalConeInnerAngle: number;
  102229. /**
  102230. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102231. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102232. */
  102233. /**
  102234. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102235. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102236. */
  102237. directionalConeOuterAngle: number;
  102238. /**
  102239. * Playback volume.
  102240. */
  102241. /**
  102242. * Playback volume.
  102243. */
  102244. volume: number;
  102245. private _onended;
  102246. /**
  102247. * Suspend playback
  102248. */
  102249. pause(): void;
  102250. /**
  102251. * Stop playback
  102252. */
  102253. stop(): void;
  102254. /**
  102255. * Start playback.
  102256. * @param startOffset Position the clip head at a specific time in seconds.
  102257. */
  102258. play(startOffset?: number): void;
  102259. }
  102260. }
  102261. declare module BABYLON {
  102262. /**
  102263. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102264. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102265. */
  102266. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102267. /**
  102268. * Gets the name of the behavior.
  102269. */
  102270. readonly name: string;
  102271. /**
  102272. * The easing function used by animations
  102273. */
  102274. static EasingFunction: BackEase;
  102275. /**
  102276. * The easing mode used by animations
  102277. */
  102278. static EasingMode: number;
  102279. /**
  102280. * The duration of the animation, in milliseconds
  102281. */
  102282. transitionDuration: number;
  102283. /**
  102284. * Length of the distance animated by the transition when lower radius is reached
  102285. */
  102286. lowerRadiusTransitionRange: number;
  102287. /**
  102288. * Length of the distance animated by the transition when upper radius is reached
  102289. */
  102290. upperRadiusTransitionRange: number;
  102291. private _autoTransitionRange;
  102292. /**
  102293. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102294. */
  102295. /**
  102296. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102297. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102298. */
  102299. autoTransitionRange: boolean;
  102300. private _attachedCamera;
  102301. private _onAfterCheckInputsObserver;
  102302. private _onMeshTargetChangedObserver;
  102303. /**
  102304. * Initializes the behavior.
  102305. */
  102306. init(): void;
  102307. /**
  102308. * Attaches the behavior to its arc rotate camera.
  102309. * @param camera Defines the camera to attach the behavior to
  102310. */
  102311. attach(camera: ArcRotateCamera): void;
  102312. /**
  102313. * Detaches the behavior from its current arc rotate camera.
  102314. */
  102315. detach(): void;
  102316. private _radiusIsAnimating;
  102317. private _radiusBounceTransition;
  102318. private _animatables;
  102319. private _cachedWheelPrecision;
  102320. /**
  102321. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102322. * @param radiusLimit The limit to check against.
  102323. * @return Bool to indicate if at limit.
  102324. */
  102325. private _isRadiusAtLimit;
  102326. /**
  102327. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102328. * @param radiusDelta The delta by which to animate to. Can be negative.
  102329. */
  102330. private _applyBoundRadiusAnimation;
  102331. /**
  102332. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102333. */
  102334. protected _clearAnimationLocks(): void;
  102335. /**
  102336. * Stops and removes all animations that have been applied to the camera
  102337. */
  102338. stopAllAnimations(): void;
  102339. }
  102340. }
  102341. declare module BABYLON {
  102342. /**
  102343. * 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.
  102344. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102345. */
  102346. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102347. /**
  102348. * Gets the name of the behavior.
  102349. */
  102350. readonly name: string;
  102351. private _mode;
  102352. private _radiusScale;
  102353. private _positionScale;
  102354. private _defaultElevation;
  102355. private _elevationReturnTime;
  102356. private _elevationReturnWaitTime;
  102357. private _zoomStopsAnimation;
  102358. private _framingTime;
  102359. /**
  102360. * The easing function used by animations
  102361. */
  102362. static EasingFunction: ExponentialEase;
  102363. /**
  102364. * The easing mode used by animations
  102365. */
  102366. static EasingMode: number;
  102367. /**
  102368. * Sets the current mode used by the behavior
  102369. */
  102370. /**
  102371. * Gets current mode used by the behavior.
  102372. */
  102373. mode: number;
  102374. /**
  102375. * Sets the scale applied to the radius (1 by default)
  102376. */
  102377. /**
  102378. * Gets the scale applied to the radius
  102379. */
  102380. radiusScale: number;
  102381. /**
  102382. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102383. */
  102384. /**
  102385. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102386. */
  102387. positionScale: number;
  102388. /**
  102389. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102390. * behaviour is triggered, in radians.
  102391. */
  102392. /**
  102393. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102394. * behaviour is triggered, in radians.
  102395. */
  102396. defaultElevation: number;
  102397. /**
  102398. * Sets the time (in milliseconds) taken to return to the default beta position.
  102399. * Negative value indicates camera should not return to default.
  102400. */
  102401. /**
  102402. * Gets the time (in milliseconds) taken to return to the default beta position.
  102403. * Negative value indicates camera should not return to default.
  102404. */
  102405. elevationReturnTime: number;
  102406. /**
  102407. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102408. */
  102409. /**
  102410. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102411. */
  102412. elevationReturnWaitTime: number;
  102413. /**
  102414. * Sets the flag that indicates if user zooming should stop animation.
  102415. */
  102416. /**
  102417. * Gets the flag that indicates if user zooming should stop animation.
  102418. */
  102419. zoomStopsAnimation: boolean;
  102420. /**
  102421. * Sets the transition time when framing the mesh, in milliseconds
  102422. */
  102423. /**
  102424. * Gets the transition time when framing the mesh, in milliseconds
  102425. */
  102426. framingTime: number;
  102427. /**
  102428. * Define if the behavior should automatically change the configured
  102429. * camera limits and sensibilities.
  102430. */
  102431. autoCorrectCameraLimitsAndSensibility: boolean;
  102432. private _onPrePointerObservableObserver;
  102433. private _onAfterCheckInputsObserver;
  102434. private _onMeshTargetChangedObserver;
  102435. private _attachedCamera;
  102436. private _isPointerDown;
  102437. private _lastInteractionTime;
  102438. /**
  102439. * Initializes the behavior.
  102440. */
  102441. init(): void;
  102442. /**
  102443. * Attaches the behavior to its arc rotate camera.
  102444. * @param camera Defines the camera to attach the behavior to
  102445. */
  102446. attach(camera: ArcRotateCamera): void;
  102447. /**
  102448. * Detaches the behavior from its current arc rotate camera.
  102449. */
  102450. detach(): void;
  102451. private _animatables;
  102452. private _betaIsAnimating;
  102453. private _betaTransition;
  102454. private _radiusTransition;
  102455. private _vectorTransition;
  102456. /**
  102457. * Targets the given mesh and updates zoom level accordingly.
  102458. * @param mesh The mesh to target.
  102459. * @param radius Optional. If a cached radius position already exists, overrides default.
  102460. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102461. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102462. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102463. */
  102464. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102465. /**
  102466. * Targets the given mesh with its children and updates zoom level accordingly.
  102467. * @param mesh The mesh to target.
  102468. * @param radius Optional. If a cached radius position already exists, overrides default.
  102469. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102470. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102471. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102472. */
  102473. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102474. /**
  102475. * Targets the given meshes with their children and updates zoom level accordingly.
  102476. * @param meshes The mesh to target.
  102477. * @param radius Optional. If a cached radius position already exists, overrides default.
  102478. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102479. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102480. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102481. */
  102482. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102483. /**
  102484. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102485. * @param minimumWorld Determines the smaller position of the bounding box extend
  102486. * @param maximumWorld Determines the bigger position of the bounding box extend
  102487. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102488. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102489. */
  102490. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102491. /**
  102492. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102493. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102494. * frustum width.
  102495. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102496. * to fully enclose the mesh in the viewing frustum.
  102497. */
  102498. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102499. /**
  102500. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102501. * is automatically returned to its default position (expected to be above ground plane).
  102502. */
  102503. private _maintainCameraAboveGround;
  102504. /**
  102505. * Returns the frustum slope based on the canvas ratio and camera FOV
  102506. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102507. */
  102508. private _getFrustumSlope;
  102509. /**
  102510. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102511. */
  102512. private _clearAnimationLocks;
  102513. /**
  102514. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102515. */
  102516. private _applyUserInteraction;
  102517. /**
  102518. * Stops and removes all animations that have been applied to the camera
  102519. */
  102520. stopAllAnimations(): void;
  102521. /**
  102522. * Gets a value indicating if the user is moving the camera
  102523. */
  102524. readonly isUserIsMoving: boolean;
  102525. /**
  102526. * The camera can move all the way towards the mesh.
  102527. */
  102528. static IgnoreBoundsSizeMode: number;
  102529. /**
  102530. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102531. */
  102532. static FitFrustumSidesMode: number;
  102533. }
  102534. }
  102535. declare module BABYLON {
  102536. /**
  102537. * Base class for Camera Pointer Inputs.
  102538. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102539. * for example usage.
  102540. */
  102541. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102542. /**
  102543. * Defines the camera the input is attached to.
  102544. */
  102545. abstract camera: Camera;
  102546. /**
  102547. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102548. */
  102549. protected _altKey: boolean;
  102550. protected _ctrlKey: boolean;
  102551. protected _metaKey: boolean;
  102552. protected _shiftKey: boolean;
  102553. /**
  102554. * Which mouse buttons were pressed at time of last mouse event.
  102555. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102556. */
  102557. protected _buttonsPressed: number;
  102558. /**
  102559. * Defines the buttons associated with the input to handle camera move.
  102560. */
  102561. buttons: number[];
  102562. /**
  102563. * Attach the input controls to a specific dom element to get the input from.
  102564. * @param element Defines the element the controls should be listened from
  102565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102566. */
  102567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102568. /**
  102569. * Detach the current controls from the specified dom element.
  102570. * @param element Defines the element to stop listening the inputs from
  102571. */
  102572. detachControl(element: Nullable<HTMLElement>): void;
  102573. /**
  102574. * Gets the class name of the current input.
  102575. * @returns the class name
  102576. */
  102577. getClassName(): string;
  102578. /**
  102579. * Get the friendly name associated with the input class.
  102580. * @returns the input friendly name
  102581. */
  102582. getSimpleName(): string;
  102583. /**
  102584. * Called on pointer POINTERDOUBLETAP event.
  102585. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102586. */
  102587. protected onDoubleTap(type: string): void;
  102588. /**
  102589. * Called on pointer POINTERMOVE event if only a single touch is active.
  102590. * Override this method to provide functionality.
  102591. */
  102592. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102593. /**
  102594. * Called on pointer POINTERMOVE event if multiple touches are active.
  102595. * Override this method to provide functionality.
  102596. */
  102597. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102598. /**
  102599. * Called on JS contextmenu event.
  102600. * Override this method to provide functionality.
  102601. */
  102602. protected onContextMenu(evt: PointerEvent): void;
  102603. /**
  102604. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102605. * press.
  102606. * Override this method to provide functionality.
  102607. */
  102608. protected onButtonDown(evt: PointerEvent): void;
  102609. /**
  102610. * Called each time a new POINTERUP event occurs. Ie, for each button
  102611. * release.
  102612. * Override this method to provide functionality.
  102613. */
  102614. protected onButtonUp(evt: PointerEvent): void;
  102615. /**
  102616. * Called when window becomes inactive.
  102617. * Override this method to provide functionality.
  102618. */
  102619. protected onLostFocus(): void;
  102620. private _pointerInput;
  102621. private _observer;
  102622. private _onLostFocus;
  102623. private pointA;
  102624. private pointB;
  102625. }
  102626. }
  102627. declare module BABYLON {
  102628. /**
  102629. * Manage the pointers inputs to control an arc rotate camera.
  102630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102631. */
  102632. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102633. /**
  102634. * Defines the camera the input is attached to.
  102635. */
  102636. camera: ArcRotateCamera;
  102637. /**
  102638. * Gets the class name of the current input.
  102639. * @returns the class name
  102640. */
  102641. getClassName(): string;
  102642. /**
  102643. * Defines the buttons associated with the input to handle camera move.
  102644. */
  102645. buttons: number[];
  102646. /**
  102647. * Defines the pointer angular sensibility along the X axis or how fast is
  102648. * the camera rotating.
  102649. */
  102650. angularSensibilityX: number;
  102651. /**
  102652. * Defines the pointer angular sensibility along the Y axis or how fast is
  102653. * the camera rotating.
  102654. */
  102655. angularSensibilityY: number;
  102656. /**
  102657. * Defines the pointer pinch precision or how fast is the camera zooming.
  102658. */
  102659. pinchPrecision: number;
  102660. /**
  102661. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102662. * from 0.
  102663. * It defines the percentage of current camera.radius to use as delta when
  102664. * pinch zoom is used.
  102665. */
  102666. pinchDeltaPercentage: number;
  102667. /**
  102668. * Defines the pointer panning sensibility or how fast is the camera moving.
  102669. */
  102670. panningSensibility: number;
  102671. /**
  102672. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102673. */
  102674. multiTouchPanning: boolean;
  102675. /**
  102676. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102677. * zoom (pinch) through multitouch.
  102678. */
  102679. multiTouchPanAndZoom: boolean;
  102680. /**
  102681. * Revers pinch action direction.
  102682. */
  102683. pinchInwards: boolean;
  102684. private _isPanClick;
  102685. private _twoFingerActivityCount;
  102686. private _isPinching;
  102687. /**
  102688. * Called on pointer POINTERMOVE event if only a single touch is active.
  102689. */
  102690. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102691. /**
  102692. * Called on pointer POINTERDOUBLETAP event.
  102693. */
  102694. protected onDoubleTap(type: string): void;
  102695. /**
  102696. * Called on pointer POINTERMOVE event if multiple touches are active.
  102697. */
  102698. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102699. /**
  102700. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102701. * press.
  102702. */
  102703. protected onButtonDown(evt: PointerEvent): void;
  102704. /**
  102705. * Called each time a new POINTERUP event occurs. Ie, for each button
  102706. * release.
  102707. */
  102708. protected onButtonUp(evt: PointerEvent): void;
  102709. /**
  102710. * Called when window becomes inactive.
  102711. */
  102712. protected onLostFocus(): void;
  102713. }
  102714. }
  102715. declare module BABYLON {
  102716. /**
  102717. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102718. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102719. */
  102720. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102721. /**
  102722. * Defines the camera the input is attached to.
  102723. */
  102724. camera: ArcRotateCamera;
  102725. /**
  102726. * Defines the list of key codes associated with the up action (increase alpha)
  102727. */
  102728. keysUp: number[];
  102729. /**
  102730. * Defines the list of key codes associated with the down action (decrease alpha)
  102731. */
  102732. keysDown: number[];
  102733. /**
  102734. * Defines the list of key codes associated with the left action (increase beta)
  102735. */
  102736. keysLeft: number[];
  102737. /**
  102738. * Defines the list of key codes associated with the right action (decrease beta)
  102739. */
  102740. keysRight: number[];
  102741. /**
  102742. * Defines the list of key codes associated with the reset action.
  102743. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102744. */
  102745. keysReset: number[];
  102746. /**
  102747. * Defines the panning sensibility of the inputs.
  102748. * (How fast is the camera paning)
  102749. */
  102750. panningSensibility: number;
  102751. /**
  102752. * Defines the zooming sensibility of the inputs.
  102753. * (How fast is the camera zooming)
  102754. */
  102755. zoomingSensibility: number;
  102756. /**
  102757. * Defines wether maintaining the alt key down switch the movement mode from
  102758. * orientation to zoom.
  102759. */
  102760. useAltToZoom: boolean;
  102761. /**
  102762. * Rotation speed of the camera
  102763. */
  102764. angularSpeed: number;
  102765. private _keys;
  102766. private _ctrlPressed;
  102767. private _altPressed;
  102768. private _onCanvasBlurObserver;
  102769. private _onKeyboardObserver;
  102770. private _engine;
  102771. private _scene;
  102772. /**
  102773. * Attach the input controls to a specific dom element to get the input from.
  102774. * @param element Defines the element the controls should be listened from
  102775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102776. */
  102777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102778. /**
  102779. * Detach the current controls from the specified dom element.
  102780. * @param element Defines the element to stop listening the inputs from
  102781. */
  102782. detachControl(element: Nullable<HTMLElement>): void;
  102783. /**
  102784. * Update the current camera state depending on the inputs that have been used this frame.
  102785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102786. */
  102787. checkInputs(): void;
  102788. /**
  102789. * Gets the class name of the current intput.
  102790. * @returns the class name
  102791. */
  102792. getClassName(): string;
  102793. /**
  102794. * Get the friendly name associated with the input class.
  102795. * @returns the input friendly name
  102796. */
  102797. getSimpleName(): string;
  102798. }
  102799. }
  102800. declare module BABYLON {
  102801. /**
  102802. * Manage the mouse wheel inputs to control an arc rotate camera.
  102803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102804. */
  102805. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102806. /**
  102807. * Defines the camera the input is attached to.
  102808. */
  102809. camera: ArcRotateCamera;
  102810. /**
  102811. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102812. */
  102813. wheelPrecision: number;
  102814. /**
  102815. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102816. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102817. */
  102818. wheelDeltaPercentage: number;
  102819. private _wheel;
  102820. private _observer;
  102821. private computeDeltaFromMouseWheelLegacyEvent;
  102822. /**
  102823. * Attach the input controls to a specific dom element to get the input from.
  102824. * @param element Defines the element the controls should be listened from
  102825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102826. */
  102827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102828. /**
  102829. * Detach the current controls from the specified dom element.
  102830. * @param element Defines the element to stop listening the inputs from
  102831. */
  102832. detachControl(element: Nullable<HTMLElement>): void;
  102833. /**
  102834. * Gets the class name of the current intput.
  102835. * @returns the class name
  102836. */
  102837. getClassName(): string;
  102838. /**
  102839. * Get the friendly name associated with the input class.
  102840. * @returns the input friendly name
  102841. */
  102842. getSimpleName(): string;
  102843. }
  102844. }
  102845. declare module BABYLON {
  102846. /**
  102847. * Default Inputs manager for the ArcRotateCamera.
  102848. * It groups all the default supported inputs for ease of use.
  102849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102850. */
  102851. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102852. /**
  102853. * Instantiates a new ArcRotateCameraInputsManager.
  102854. * @param camera Defines the camera the inputs belong to
  102855. */
  102856. constructor(camera: ArcRotateCamera);
  102857. /**
  102858. * Add mouse wheel input support to the input manager.
  102859. * @returns the current input manager
  102860. */
  102861. addMouseWheel(): ArcRotateCameraInputsManager;
  102862. /**
  102863. * Add pointers input support to the input manager.
  102864. * @returns the current input manager
  102865. */
  102866. addPointers(): ArcRotateCameraInputsManager;
  102867. /**
  102868. * Add keyboard input support to the input manager.
  102869. * @returns the current input manager
  102870. */
  102871. addKeyboard(): ArcRotateCameraInputsManager;
  102872. }
  102873. }
  102874. declare module BABYLON {
  102875. /**
  102876. * This represents an orbital type of camera.
  102877. *
  102878. * 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.
  102879. * 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.
  102880. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102881. */
  102882. export class ArcRotateCamera extends TargetCamera {
  102883. /**
  102884. * Defines the rotation angle of the camera along the longitudinal axis.
  102885. */
  102886. alpha: number;
  102887. /**
  102888. * Defines the rotation angle of the camera along the latitudinal axis.
  102889. */
  102890. beta: number;
  102891. /**
  102892. * Defines the radius of the camera from it s target point.
  102893. */
  102894. radius: number;
  102895. protected _target: Vector3;
  102896. protected _targetHost: Nullable<AbstractMesh>;
  102897. /**
  102898. * Defines the target point of the camera.
  102899. * The camera looks towards it form the radius distance.
  102900. */
  102901. target: Vector3;
  102902. /**
  102903. * Define the current local position of the camera in the scene
  102904. */
  102905. position: Vector3;
  102906. protected _upVector: Vector3;
  102907. protected _upToYMatrix: Matrix;
  102908. protected _YToUpMatrix: Matrix;
  102909. /**
  102910. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102911. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102912. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102913. */
  102914. upVector: Vector3;
  102915. /**
  102916. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102917. */
  102918. setMatUp(): void;
  102919. /**
  102920. * Current inertia value on the longitudinal axis.
  102921. * The bigger this number the longer it will take for the camera to stop.
  102922. */
  102923. inertialAlphaOffset: number;
  102924. /**
  102925. * Current inertia value on the latitudinal axis.
  102926. * The bigger this number the longer it will take for the camera to stop.
  102927. */
  102928. inertialBetaOffset: number;
  102929. /**
  102930. * Current inertia value on the radius axis.
  102931. * The bigger this number the longer it will take for the camera to stop.
  102932. */
  102933. inertialRadiusOffset: number;
  102934. /**
  102935. * Minimum allowed angle on the longitudinal axis.
  102936. * This can help limiting how the Camera is able to move in the scene.
  102937. */
  102938. lowerAlphaLimit: Nullable<number>;
  102939. /**
  102940. * Maximum allowed angle on the longitudinal axis.
  102941. * This can help limiting how the Camera is able to move in the scene.
  102942. */
  102943. upperAlphaLimit: Nullable<number>;
  102944. /**
  102945. * Minimum allowed angle on the latitudinal axis.
  102946. * This can help limiting how the Camera is able to move in the scene.
  102947. */
  102948. lowerBetaLimit: number;
  102949. /**
  102950. * Maximum allowed angle on the latitudinal axis.
  102951. * This can help limiting how the Camera is able to move in the scene.
  102952. */
  102953. upperBetaLimit: number;
  102954. /**
  102955. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102956. * This can help limiting how the Camera is able to move in the scene.
  102957. */
  102958. lowerRadiusLimit: Nullable<number>;
  102959. /**
  102960. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102961. * This can help limiting how the Camera is able to move in the scene.
  102962. */
  102963. upperRadiusLimit: Nullable<number>;
  102964. /**
  102965. * Defines the current inertia value used during panning of the camera along the X axis.
  102966. */
  102967. inertialPanningX: number;
  102968. /**
  102969. * Defines the current inertia value used during panning of the camera along the Y axis.
  102970. */
  102971. inertialPanningY: number;
  102972. /**
  102973. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102974. * Basically if your fingers moves away from more than this distance you will be considered
  102975. * in pinch mode.
  102976. */
  102977. pinchToPanMaxDistance: number;
  102978. /**
  102979. * Defines the maximum distance the camera can pan.
  102980. * This could help keeping the cammera always in your scene.
  102981. */
  102982. panningDistanceLimit: Nullable<number>;
  102983. /**
  102984. * Defines the target of the camera before paning.
  102985. */
  102986. panningOriginTarget: Vector3;
  102987. /**
  102988. * Defines the value of the inertia used during panning.
  102989. * 0 would mean stop inertia and one would mean no decelleration at all.
  102990. */
  102991. panningInertia: number;
  102992. /**
  102993. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102994. */
  102995. angularSensibilityX: number;
  102996. /**
  102997. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102998. */
  102999. angularSensibilityY: number;
  103000. /**
  103001. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103002. */
  103003. pinchPrecision: number;
  103004. /**
  103005. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103006. * It will be used instead of pinchDeltaPrecision if different from 0.
  103007. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103008. */
  103009. pinchDeltaPercentage: number;
  103010. /**
  103011. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103012. */
  103013. panningSensibility: number;
  103014. /**
  103015. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103016. */
  103017. keysUp: number[];
  103018. /**
  103019. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103020. */
  103021. keysDown: number[];
  103022. /**
  103023. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103024. */
  103025. keysLeft: number[];
  103026. /**
  103027. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103028. */
  103029. keysRight: number[];
  103030. /**
  103031. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103032. */
  103033. wheelPrecision: number;
  103034. /**
  103035. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103036. * It will be used instead of pinchDeltaPrecision if different from 0.
  103037. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103038. */
  103039. wheelDeltaPercentage: number;
  103040. /**
  103041. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103042. */
  103043. zoomOnFactor: number;
  103044. /**
  103045. * Defines a screen offset for the camera position.
  103046. */
  103047. targetScreenOffset: Vector2;
  103048. /**
  103049. * Allows the camera to be completely reversed.
  103050. * If false the camera can not arrive upside down.
  103051. */
  103052. allowUpsideDown: boolean;
  103053. /**
  103054. * Define if double tap/click is used to restore the previously saved state of the camera.
  103055. */
  103056. useInputToRestoreState: boolean;
  103057. /** @hidden */
  103058. _viewMatrix: Matrix;
  103059. /** @hidden */
  103060. _useCtrlForPanning: boolean;
  103061. /** @hidden */
  103062. _panningMouseButton: number;
  103063. /**
  103064. * Defines the input associated to the camera.
  103065. */
  103066. inputs: ArcRotateCameraInputsManager;
  103067. /** @hidden */
  103068. _reset: () => void;
  103069. /**
  103070. * Defines the allowed panning axis.
  103071. */
  103072. panningAxis: Vector3;
  103073. protected _localDirection: Vector3;
  103074. protected _transformedDirection: Vector3;
  103075. private _bouncingBehavior;
  103076. /**
  103077. * Gets the bouncing behavior of the camera if it has been enabled.
  103078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103079. */
  103080. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103081. /**
  103082. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103083. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103084. */
  103085. useBouncingBehavior: boolean;
  103086. private _framingBehavior;
  103087. /**
  103088. * Gets the framing behavior of the camera if it has been enabled.
  103089. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103090. */
  103091. readonly framingBehavior: Nullable<FramingBehavior>;
  103092. /**
  103093. * Defines if the framing behavior of the camera is enabled on the camera.
  103094. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103095. */
  103096. useFramingBehavior: boolean;
  103097. private _autoRotationBehavior;
  103098. /**
  103099. * Gets the auto rotation behavior of the camera if it has been enabled.
  103100. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103101. */
  103102. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103103. /**
  103104. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103105. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103106. */
  103107. useAutoRotationBehavior: boolean;
  103108. /**
  103109. * Observable triggered when the mesh target has been changed on the camera.
  103110. */
  103111. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103112. /**
  103113. * Event raised when the camera is colliding with a mesh.
  103114. */
  103115. onCollide: (collidedMesh: AbstractMesh) => void;
  103116. /**
  103117. * Defines whether the camera should check collision with the objects oh the scene.
  103118. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103119. */
  103120. checkCollisions: boolean;
  103121. /**
  103122. * Defines the collision radius of the camera.
  103123. * This simulates a sphere around the camera.
  103124. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103125. */
  103126. collisionRadius: Vector3;
  103127. protected _collider: Collider;
  103128. protected _previousPosition: Vector3;
  103129. protected _collisionVelocity: Vector3;
  103130. protected _newPosition: Vector3;
  103131. protected _previousAlpha: number;
  103132. protected _previousBeta: number;
  103133. protected _previousRadius: number;
  103134. protected _collisionTriggered: boolean;
  103135. protected _targetBoundingCenter: Nullable<Vector3>;
  103136. private _computationVector;
  103137. /**
  103138. * Instantiates a new ArcRotateCamera in a given scene
  103139. * @param name Defines the name of the camera
  103140. * @param alpha Defines the camera rotation along the logitudinal axis
  103141. * @param beta Defines the camera rotation along the latitudinal axis
  103142. * @param radius Defines the camera distance from its target
  103143. * @param target Defines the camera target
  103144. * @param scene Defines the scene the camera belongs to
  103145. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103146. */
  103147. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103148. /** @hidden */
  103149. _initCache(): void;
  103150. /** @hidden */
  103151. _updateCache(ignoreParentClass?: boolean): void;
  103152. protected _getTargetPosition(): Vector3;
  103153. private _storedAlpha;
  103154. private _storedBeta;
  103155. private _storedRadius;
  103156. private _storedTarget;
  103157. private _storedTargetScreenOffset;
  103158. /**
  103159. * Stores the current state of the camera (alpha, beta, radius and target)
  103160. * @returns the camera itself
  103161. */
  103162. storeState(): Camera;
  103163. /**
  103164. * @hidden
  103165. * Restored camera state. You must call storeState() first
  103166. */
  103167. _restoreStateValues(): boolean;
  103168. /** @hidden */
  103169. _isSynchronizedViewMatrix(): boolean;
  103170. /**
  103171. * Attached controls to the current camera.
  103172. * @param element Defines the element the controls should be listened from
  103173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103174. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103175. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103176. */
  103177. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103178. /**
  103179. * Detach the current controls from the camera.
  103180. * The camera will stop reacting to inputs.
  103181. * @param element Defines the element to stop listening the inputs from
  103182. */
  103183. detachControl(element: HTMLElement): void;
  103184. /** @hidden */
  103185. _checkInputs(): void;
  103186. protected _checkLimits(): void;
  103187. /**
  103188. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103189. */
  103190. rebuildAnglesAndRadius(): void;
  103191. /**
  103192. * Use a position to define the current camera related information like aplha, beta and radius
  103193. * @param position Defines the position to set the camera at
  103194. */
  103195. setPosition(position: Vector3): void;
  103196. /**
  103197. * Defines the target the camera should look at.
  103198. * This will automatically adapt alpha beta and radius to fit within the new target.
  103199. * @param target Defines the new target as a Vector or a mesh
  103200. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103201. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103202. */
  103203. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103204. /** @hidden */
  103205. _getViewMatrix(): Matrix;
  103206. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103207. /**
  103208. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103209. * @param meshes Defines the mesh to zoom on
  103210. * @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)
  103211. */
  103212. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103213. /**
  103214. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103215. * The target will be changed but the radius
  103216. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103217. * @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)
  103218. */
  103219. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103220. min: Vector3;
  103221. max: Vector3;
  103222. distance: number;
  103223. }, doNotUpdateMaxZ?: boolean): void;
  103224. /**
  103225. * @override
  103226. * Override Camera.createRigCamera
  103227. */
  103228. createRigCamera(name: string, cameraIndex: number): Camera;
  103229. /**
  103230. * @hidden
  103231. * @override
  103232. * Override Camera._updateRigCameras
  103233. */
  103234. _updateRigCameras(): void;
  103235. /**
  103236. * Destroy the camera and release the current resources hold by it.
  103237. */
  103238. dispose(): void;
  103239. /**
  103240. * Gets the current object class name.
  103241. * @return the class name
  103242. */
  103243. getClassName(): string;
  103244. }
  103245. }
  103246. declare module BABYLON {
  103247. /**
  103248. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103249. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103250. */
  103251. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103252. /**
  103253. * Gets the name of the behavior.
  103254. */
  103255. readonly name: string;
  103256. private _zoomStopsAnimation;
  103257. private _idleRotationSpeed;
  103258. private _idleRotationWaitTime;
  103259. private _idleRotationSpinupTime;
  103260. /**
  103261. * Sets the flag that indicates if user zooming should stop animation.
  103262. */
  103263. /**
  103264. * Gets the flag that indicates if user zooming should stop animation.
  103265. */
  103266. zoomStopsAnimation: boolean;
  103267. /**
  103268. * Sets the default speed at which the camera rotates around the model.
  103269. */
  103270. /**
  103271. * Gets the default speed at which the camera rotates around the model.
  103272. */
  103273. idleRotationSpeed: number;
  103274. /**
  103275. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103276. */
  103277. /**
  103278. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103279. */
  103280. idleRotationWaitTime: number;
  103281. /**
  103282. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103283. */
  103284. /**
  103285. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103286. */
  103287. idleRotationSpinupTime: number;
  103288. /**
  103289. * Gets a value indicating if the camera is currently rotating because of this behavior
  103290. */
  103291. readonly rotationInProgress: boolean;
  103292. private _onPrePointerObservableObserver;
  103293. private _onAfterCheckInputsObserver;
  103294. private _attachedCamera;
  103295. private _isPointerDown;
  103296. private _lastFrameTime;
  103297. private _lastInteractionTime;
  103298. private _cameraRotationSpeed;
  103299. /**
  103300. * Initializes the behavior.
  103301. */
  103302. init(): void;
  103303. /**
  103304. * Attaches the behavior to its arc rotate camera.
  103305. * @param camera Defines the camera to attach the behavior to
  103306. */
  103307. attach(camera: ArcRotateCamera): void;
  103308. /**
  103309. * Detaches the behavior from its current arc rotate camera.
  103310. */
  103311. detach(): void;
  103312. /**
  103313. * Returns true if user is scrolling.
  103314. * @return true if user is scrolling.
  103315. */
  103316. private _userIsZooming;
  103317. private _lastFrameRadius;
  103318. private _shouldAnimationStopForInteraction;
  103319. /**
  103320. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103321. */
  103322. private _applyUserInteraction;
  103323. private _userIsMoving;
  103324. }
  103325. }
  103326. declare module BABYLON {
  103327. /**
  103328. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103329. */
  103330. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103331. private ui;
  103332. /**
  103333. * The name of the behavior
  103334. */
  103335. name: string;
  103336. /**
  103337. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103338. */
  103339. distanceAwayFromFace: number;
  103340. /**
  103341. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103342. */
  103343. distanceAwayFromBottomOfFace: number;
  103344. private _faceVectors;
  103345. private _target;
  103346. private _scene;
  103347. private _onRenderObserver;
  103348. private _tmpMatrix;
  103349. private _tmpVector;
  103350. /**
  103351. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103352. * @param ui The transform node that should be attched to the mesh
  103353. */
  103354. constructor(ui: TransformNode);
  103355. /**
  103356. * Initializes the behavior
  103357. */
  103358. init(): void;
  103359. private _closestFace;
  103360. private _zeroVector;
  103361. private _lookAtTmpMatrix;
  103362. private _lookAtToRef;
  103363. /**
  103364. * Attaches the AttachToBoxBehavior to the passed in mesh
  103365. * @param target The mesh that the specified node will be attached to
  103366. */
  103367. attach(target: Mesh): void;
  103368. /**
  103369. * Detaches the behavior from the mesh
  103370. */
  103371. detach(): void;
  103372. }
  103373. }
  103374. declare module BABYLON {
  103375. /**
  103376. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103377. */
  103378. export class FadeInOutBehavior implements Behavior<Mesh> {
  103379. /**
  103380. * Time in milliseconds to delay before fading in (Default: 0)
  103381. */
  103382. delay: number;
  103383. /**
  103384. * Time in milliseconds for the mesh to fade in (Default: 300)
  103385. */
  103386. fadeInTime: number;
  103387. private _millisecondsPerFrame;
  103388. private _hovered;
  103389. private _hoverValue;
  103390. private _ownerNode;
  103391. /**
  103392. * Instatiates the FadeInOutBehavior
  103393. */
  103394. constructor();
  103395. /**
  103396. * The name of the behavior
  103397. */
  103398. readonly name: string;
  103399. /**
  103400. * Initializes the behavior
  103401. */
  103402. init(): void;
  103403. /**
  103404. * Attaches the fade behavior on the passed in mesh
  103405. * @param ownerNode The mesh that will be faded in/out once attached
  103406. */
  103407. attach(ownerNode: Mesh): void;
  103408. /**
  103409. * Detaches the behavior from the mesh
  103410. */
  103411. detach(): void;
  103412. /**
  103413. * Triggers the mesh to begin fading in or out
  103414. * @param value if the object should fade in or out (true to fade in)
  103415. */
  103416. fadeIn(value: boolean): void;
  103417. private _update;
  103418. private _setAllVisibility;
  103419. }
  103420. }
  103421. declare module BABYLON {
  103422. /**
  103423. * Class containing a set of static utilities functions for managing Pivots
  103424. * @hidden
  103425. */
  103426. export class PivotTools {
  103427. private static _PivotCached;
  103428. private static _OldPivotPoint;
  103429. private static _PivotTranslation;
  103430. private static _PivotTmpVector;
  103431. /** @hidden */
  103432. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103433. /** @hidden */
  103434. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103435. }
  103436. }
  103437. declare module BABYLON {
  103438. /**
  103439. * Class containing static functions to help procedurally build meshes
  103440. */
  103441. export class PlaneBuilder {
  103442. /**
  103443. * Creates a plane mesh
  103444. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103445. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103446. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103447. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103448. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103450. * @param name defines the name of the mesh
  103451. * @param options defines the options used to create the mesh
  103452. * @param scene defines the hosting scene
  103453. * @returns the plane mesh
  103454. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103455. */
  103456. static CreatePlane(name: string, options: {
  103457. size?: number;
  103458. width?: number;
  103459. height?: number;
  103460. sideOrientation?: number;
  103461. frontUVs?: Vector4;
  103462. backUVs?: Vector4;
  103463. updatable?: boolean;
  103464. sourcePlane?: Plane;
  103465. }, scene?: Nullable<Scene>): Mesh;
  103466. }
  103467. }
  103468. declare module BABYLON {
  103469. /**
  103470. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103471. */
  103472. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103473. private static _AnyMouseID;
  103474. /**
  103475. * Abstract mesh the behavior is set on
  103476. */
  103477. attachedNode: AbstractMesh;
  103478. private _dragPlane;
  103479. private _scene;
  103480. private _pointerObserver;
  103481. private _beforeRenderObserver;
  103482. private static _planeScene;
  103483. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103484. /**
  103485. * 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)
  103486. */
  103487. maxDragAngle: number;
  103488. /**
  103489. * @hidden
  103490. */
  103491. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103492. /**
  103493. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103494. */
  103495. currentDraggingPointerID: number;
  103496. /**
  103497. * The last position where the pointer hit the drag plane in world space
  103498. */
  103499. lastDragPosition: Vector3;
  103500. /**
  103501. * If the behavior is currently in a dragging state
  103502. */
  103503. dragging: boolean;
  103504. /**
  103505. * 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)
  103506. */
  103507. dragDeltaRatio: number;
  103508. /**
  103509. * If the drag plane orientation should be updated during the dragging (Default: true)
  103510. */
  103511. updateDragPlane: boolean;
  103512. private _debugMode;
  103513. private _moving;
  103514. /**
  103515. * Fires each time the attached mesh is dragged with the pointer
  103516. * * delta between last drag position and current drag position in world space
  103517. * * dragDistance along the drag axis
  103518. * * dragPlaneNormal normal of the current drag plane used during the drag
  103519. * * dragPlanePoint in world space where the drag intersects the drag plane
  103520. */
  103521. onDragObservable: Observable<{
  103522. delta: Vector3;
  103523. dragPlanePoint: Vector3;
  103524. dragPlaneNormal: Vector3;
  103525. dragDistance: number;
  103526. pointerId: number;
  103527. }>;
  103528. /**
  103529. * Fires each time a drag begins (eg. mouse down on mesh)
  103530. */
  103531. onDragStartObservable: Observable<{
  103532. dragPlanePoint: Vector3;
  103533. pointerId: number;
  103534. }>;
  103535. /**
  103536. * Fires each time a drag ends (eg. mouse release after drag)
  103537. */
  103538. onDragEndObservable: Observable<{
  103539. dragPlanePoint: Vector3;
  103540. pointerId: number;
  103541. }>;
  103542. /**
  103543. * If the attached mesh should be moved when dragged
  103544. */
  103545. moveAttached: boolean;
  103546. /**
  103547. * If the drag behavior will react to drag events (Default: true)
  103548. */
  103549. enabled: boolean;
  103550. /**
  103551. * If pointer events should start and release the drag (Default: true)
  103552. */
  103553. startAndReleaseDragOnPointerEvents: boolean;
  103554. /**
  103555. * If camera controls should be detached during the drag
  103556. */
  103557. detachCameraControls: boolean;
  103558. /**
  103559. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103560. */
  103561. useObjectOrienationForDragging: boolean;
  103562. private _options;
  103563. /**
  103564. * Creates a pointer drag behavior that can be attached to a mesh
  103565. * @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)
  103566. */
  103567. constructor(options?: {
  103568. dragAxis?: Vector3;
  103569. dragPlaneNormal?: Vector3;
  103570. });
  103571. /**
  103572. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103573. */
  103574. validateDrag: (targetPosition: Vector3) => boolean;
  103575. /**
  103576. * The name of the behavior
  103577. */
  103578. readonly name: string;
  103579. /**
  103580. * Initializes the behavior
  103581. */
  103582. init(): void;
  103583. private _tmpVector;
  103584. private _alternatePickedPoint;
  103585. private _worldDragAxis;
  103586. private _targetPosition;
  103587. private _attachedElement;
  103588. /**
  103589. * Attaches the drag behavior the passed in mesh
  103590. * @param ownerNode The mesh that will be dragged around once attached
  103591. * @param predicate Predicate to use for pick filtering
  103592. */
  103593. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103594. /**
  103595. * Force relase the drag action by code.
  103596. */
  103597. releaseDrag(): void;
  103598. private _startDragRay;
  103599. private _lastPointerRay;
  103600. /**
  103601. * Simulates the start of a pointer drag event on the behavior
  103602. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103603. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103604. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103605. */
  103606. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103607. private _startDrag;
  103608. private _dragDelta;
  103609. private _moveDrag;
  103610. private _pickWithRayOnDragPlane;
  103611. private _pointA;
  103612. private _pointB;
  103613. private _pointC;
  103614. private _lineA;
  103615. private _lineB;
  103616. private _localAxis;
  103617. private _lookAt;
  103618. private _updateDragPlanePosition;
  103619. /**
  103620. * Detaches the behavior from the mesh
  103621. */
  103622. detach(): void;
  103623. }
  103624. }
  103625. declare module BABYLON {
  103626. /**
  103627. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103628. */
  103629. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103630. private _dragBehaviorA;
  103631. private _dragBehaviorB;
  103632. private _startDistance;
  103633. private _initialScale;
  103634. private _targetScale;
  103635. private _ownerNode;
  103636. private _sceneRenderObserver;
  103637. /**
  103638. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103639. */
  103640. constructor();
  103641. /**
  103642. * The name of the behavior
  103643. */
  103644. readonly name: string;
  103645. /**
  103646. * Initializes the behavior
  103647. */
  103648. init(): void;
  103649. private _getCurrentDistance;
  103650. /**
  103651. * Attaches the scale behavior the passed in mesh
  103652. * @param ownerNode The mesh that will be scaled around once attached
  103653. */
  103654. attach(ownerNode: Mesh): void;
  103655. /**
  103656. * Detaches the behavior from the mesh
  103657. */
  103658. detach(): void;
  103659. }
  103660. }
  103661. declare module BABYLON {
  103662. /**
  103663. * 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
  103664. */
  103665. export class SixDofDragBehavior implements Behavior<Mesh> {
  103666. private static _virtualScene;
  103667. private _ownerNode;
  103668. private _sceneRenderObserver;
  103669. private _scene;
  103670. private _targetPosition;
  103671. private _virtualOriginMesh;
  103672. private _virtualDragMesh;
  103673. private _pointerObserver;
  103674. private _moving;
  103675. private _startingOrientation;
  103676. /**
  103677. * 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)
  103678. */
  103679. private zDragFactor;
  103680. /**
  103681. * If the object should rotate to face the drag origin
  103682. */
  103683. rotateDraggedObject: boolean;
  103684. /**
  103685. * If the behavior is currently in a dragging state
  103686. */
  103687. dragging: boolean;
  103688. /**
  103689. * 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)
  103690. */
  103691. dragDeltaRatio: number;
  103692. /**
  103693. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103694. */
  103695. currentDraggingPointerID: number;
  103696. /**
  103697. * If camera controls should be detached during the drag
  103698. */
  103699. detachCameraControls: boolean;
  103700. /**
  103701. * Fires each time a drag starts
  103702. */
  103703. onDragStartObservable: Observable<{}>;
  103704. /**
  103705. * Fires each time a drag ends (eg. mouse release after drag)
  103706. */
  103707. onDragEndObservable: Observable<{}>;
  103708. /**
  103709. * 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
  103710. */
  103711. constructor();
  103712. /**
  103713. * The name of the behavior
  103714. */
  103715. readonly name: string;
  103716. /**
  103717. * Initializes the behavior
  103718. */
  103719. init(): void;
  103720. /**
  103721. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103722. */
  103723. private readonly _pointerCamera;
  103724. /**
  103725. * Attaches the scale behavior the passed in mesh
  103726. * @param ownerNode The mesh that will be scaled around once attached
  103727. */
  103728. attach(ownerNode: Mesh): void;
  103729. /**
  103730. * Detaches the behavior from the mesh
  103731. */
  103732. detach(): void;
  103733. }
  103734. }
  103735. declare module BABYLON {
  103736. /**
  103737. * Class used to apply inverse kinematics to bones
  103738. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103739. */
  103740. export class BoneIKController {
  103741. private static _tmpVecs;
  103742. private static _tmpQuat;
  103743. private static _tmpMats;
  103744. /**
  103745. * Gets or sets the target mesh
  103746. */
  103747. targetMesh: AbstractMesh;
  103748. /** Gets or sets the mesh used as pole */
  103749. poleTargetMesh: AbstractMesh;
  103750. /**
  103751. * Gets or sets the bone used as pole
  103752. */
  103753. poleTargetBone: Nullable<Bone>;
  103754. /**
  103755. * Gets or sets the target position
  103756. */
  103757. targetPosition: Vector3;
  103758. /**
  103759. * Gets or sets the pole target position
  103760. */
  103761. poleTargetPosition: Vector3;
  103762. /**
  103763. * Gets or sets the pole target local offset
  103764. */
  103765. poleTargetLocalOffset: Vector3;
  103766. /**
  103767. * Gets or sets the pole angle
  103768. */
  103769. poleAngle: number;
  103770. /**
  103771. * Gets or sets the mesh associated with the controller
  103772. */
  103773. mesh: AbstractMesh;
  103774. /**
  103775. * 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)
  103776. */
  103777. slerpAmount: number;
  103778. private _bone1Quat;
  103779. private _bone1Mat;
  103780. private _bone2Ang;
  103781. private _bone1;
  103782. private _bone2;
  103783. private _bone1Length;
  103784. private _bone2Length;
  103785. private _maxAngle;
  103786. private _maxReach;
  103787. private _rightHandedSystem;
  103788. private _bendAxis;
  103789. private _slerping;
  103790. private _adjustRoll;
  103791. /**
  103792. * Gets or sets maximum allowed angle
  103793. */
  103794. maxAngle: number;
  103795. /**
  103796. * Creates a new BoneIKController
  103797. * @param mesh defines the mesh to control
  103798. * @param bone defines the bone to control
  103799. * @param options defines options to set up the controller
  103800. */
  103801. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103802. targetMesh?: AbstractMesh;
  103803. poleTargetMesh?: AbstractMesh;
  103804. poleTargetBone?: Bone;
  103805. poleTargetLocalOffset?: Vector3;
  103806. poleAngle?: number;
  103807. bendAxis?: Vector3;
  103808. maxAngle?: number;
  103809. slerpAmount?: number;
  103810. });
  103811. private _setMaxAngle;
  103812. /**
  103813. * Force the controller to update the bones
  103814. */
  103815. update(): void;
  103816. }
  103817. }
  103818. declare module BABYLON {
  103819. /**
  103820. * Class used to make a bone look toward a point in space
  103821. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103822. */
  103823. export class BoneLookController {
  103824. private static _tmpVecs;
  103825. private static _tmpQuat;
  103826. private static _tmpMats;
  103827. /**
  103828. * The target Vector3 that the bone will look at
  103829. */
  103830. target: Vector3;
  103831. /**
  103832. * The mesh that the bone is attached to
  103833. */
  103834. mesh: AbstractMesh;
  103835. /**
  103836. * The bone that will be looking to the target
  103837. */
  103838. bone: Bone;
  103839. /**
  103840. * The up axis of the coordinate system that is used when the bone is rotated
  103841. */
  103842. upAxis: Vector3;
  103843. /**
  103844. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103845. */
  103846. upAxisSpace: Space;
  103847. /**
  103848. * Used to make an adjustment to the yaw of the bone
  103849. */
  103850. adjustYaw: number;
  103851. /**
  103852. * Used to make an adjustment to the pitch of the bone
  103853. */
  103854. adjustPitch: number;
  103855. /**
  103856. * Used to make an adjustment to the roll of the bone
  103857. */
  103858. adjustRoll: number;
  103859. /**
  103860. * 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)
  103861. */
  103862. slerpAmount: number;
  103863. private _minYaw;
  103864. private _maxYaw;
  103865. private _minPitch;
  103866. private _maxPitch;
  103867. private _minYawSin;
  103868. private _minYawCos;
  103869. private _maxYawSin;
  103870. private _maxYawCos;
  103871. private _midYawConstraint;
  103872. private _minPitchTan;
  103873. private _maxPitchTan;
  103874. private _boneQuat;
  103875. private _slerping;
  103876. private _transformYawPitch;
  103877. private _transformYawPitchInv;
  103878. private _firstFrameSkipped;
  103879. private _yawRange;
  103880. private _fowardAxis;
  103881. /**
  103882. * Gets or sets the minimum yaw angle that the bone can look to
  103883. */
  103884. minYaw: number;
  103885. /**
  103886. * Gets or sets the maximum yaw angle that the bone can look to
  103887. */
  103888. maxYaw: number;
  103889. /**
  103890. * Gets or sets the minimum pitch angle that the bone can look to
  103891. */
  103892. minPitch: number;
  103893. /**
  103894. * Gets or sets the maximum pitch angle that the bone can look to
  103895. */
  103896. maxPitch: number;
  103897. /**
  103898. * Create a BoneLookController
  103899. * @param mesh the mesh that the bone belongs to
  103900. * @param bone the bone that will be looking to the target
  103901. * @param target the target Vector3 to look at
  103902. * @param options optional settings:
  103903. * * maxYaw: the maximum angle the bone will yaw to
  103904. * * minYaw: the minimum angle the bone will yaw to
  103905. * * maxPitch: the maximum angle the bone will pitch to
  103906. * * minPitch: the minimum angle the bone will yaw to
  103907. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103908. * * upAxis: the up axis of the coordinate system
  103909. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103910. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103911. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103912. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103913. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103914. * * adjustRoll: used to make an adjustment to the roll of the bone
  103915. **/
  103916. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103917. maxYaw?: number;
  103918. minYaw?: number;
  103919. maxPitch?: number;
  103920. minPitch?: number;
  103921. slerpAmount?: number;
  103922. upAxis?: Vector3;
  103923. upAxisSpace?: Space;
  103924. yawAxis?: Vector3;
  103925. pitchAxis?: Vector3;
  103926. adjustYaw?: number;
  103927. adjustPitch?: number;
  103928. adjustRoll?: number;
  103929. });
  103930. /**
  103931. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103932. */
  103933. update(): void;
  103934. private _getAngleDiff;
  103935. private _getAngleBetween;
  103936. private _isAngleBetween;
  103937. }
  103938. }
  103939. declare module BABYLON {
  103940. /**
  103941. * Manage the gamepad inputs to control an arc rotate camera.
  103942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103943. */
  103944. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103945. /**
  103946. * Defines the camera the input is attached to.
  103947. */
  103948. camera: ArcRotateCamera;
  103949. /**
  103950. * Defines the gamepad the input is gathering event from.
  103951. */
  103952. gamepad: Nullable<Gamepad>;
  103953. /**
  103954. * Defines the gamepad rotation sensiblity.
  103955. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103956. */
  103957. gamepadRotationSensibility: number;
  103958. /**
  103959. * Defines the gamepad move sensiblity.
  103960. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103961. */
  103962. gamepadMoveSensibility: number;
  103963. private _onGamepadConnectedObserver;
  103964. private _onGamepadDisconnectedObserver;
  103965. /**
  103966. * Attach the input controls to a specific dom element to get the input from.
  103967. * @param element Defines the element the controls should be listened from
  103968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103969. */
  103970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103971. /**
  103972. * Detach the current controls from the specified dom element.
  103973. * @param element Defines the element to stop listening the inputs from
  103974. */
  103975. detachControl(element: Nullable<HTMLElement>): void;
  103976. /**
  103977. * Update the current camera state depending on the inputs that have been used this frame.
  103978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103979. */
  103980. checkInputs(): void;
  103981. /**
  103982. * Gets the class name of the current intput.
  103983. * @returns the class name
  103984. */
  103985. getClassName(): string;
  103986. /**
  103987. * Get the friendly name associated with the input class.
  103988. * @returns the input friendly name
  103989. */
  103990. getSimpleName(): string;
  103991. }
  103992. }
  103993. declare module BABYLON {
  103994. interface ArcRotateCameraInputsManager {
  103995. /**
  103996. * Add orientation input support to the input manager.
  103997. * @returns the current input manager
  103998. */
  103999. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104000. }
  104001. /**
  104002. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104004. */
  104005. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104006. /**
  104007. * Defines the camera the input is attached to.
  104008. */
  104009. camera: ArcRotateCamera;
  104010. /**
  104011. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104012. */
  104013. alphaCorrection: number;
  104014. /**
  104015. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104016. */
  104017. gammaCorrection: number;
  104018. private _alpha;
  104019. private _gamma;
  104020. private _dirty;
  104021. private _deviceOrientationHandler;
  104022. /**
  104023. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104024. */
  104025. constructor();
  104026. /**
  104027. * Attach the input controls to a specific dom element to get the input from.
  104028. * @param element Defines the element the controls should be listened from
  104029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104030. */
  104031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104032. /** @hidden */
  104033. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104034. /**
  104035. * Update the current camera state depending on the inputs that have been used this frame.
  104036. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104037. */
  104038. checkInputs(): void;
  104039. /**
  104040. * Detach the current controls from the specified dom element.
  104041. * @param element Defines the element to stop listening the inputs from
  104042. */
  104043. detachControl(element: Nullable<HTMLElement>): void;
  104044. /**
  104045. * Gets the class name of the current intput.
  104046. * @returns the class name
  104047. */
  104048. getClassName(): string;
  104049. /**
  104050. * Get the friendly name associated with the input class.
  104051. * @returns the input friendly name
  104052. */
  104053. getSimpleName(): string;
  104054. }
  104055. }
  104056. declare module BABYLON {
  104057. /**
  104058. * Listen to mouse events to control the camera.
  104059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104060. */
  104061. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104062. /**
  104063. * Defines the camera the input is attached to.
  104064. */
  104065. camera: FlyCamera;
  104066. /**
  104067. * Defines if touch is enabled. (Default is true.)
  104068. */
  104069. touchEnabled: boolean;
  104070. /**
  104071. * Defines the buttons associated with the input to handle camera rotation.
  104072. */
  104073. buttons: number[];
  104074. /**
  104075. * Assign buttons for Yaw control.
  104076. */
  104077. buttonsYaw: number[];
  104078. /**
  104079. * Assign buttons for Pitch control.
  104080. */
  104081. buttonsPitch: number[];
  104082. /**
  104083. * Assign buttons for Roll control.
  104084. */
  104085. buttonsRoll: number[];
  104086. /**
  104087. * Detect if any button is being pressed while mouse is moved.
  104088. * -1 = Mouse locked.
  104089. * 0 = Left button.
  104090. * 1 = Middle Button.
  104091. * 2 = Right Button.
  104092. */
  104093. activeButton: number;
  104094. /**
  104095. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104096. * Higher values reduce its sensitivity.
  104097. */
  104098. angularSensibility: number;
  104099. private _mousemoveCallback;
  104100. private _observer;
  104101. private _rollObserver;
  104102. private previousPosition;
  104103. private noPreventDefault;
  104104. private element;
  104105. /**
  104106. * Listen to mouse events to control the camera.
  104107. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104109. */
  104110. constructor(touchEnabled?: boolean);
  104111. /**
  104112. * Attach the mouse control to the HTML DOM element.
  104113. * @param element Defines the element that listens to the input events.
  104114. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104115. */
  104116. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104117. /**
  104118. * Detach the current controls from the specified dom element.
  104119. * @param element Defines the element to stop listening the inputs from
  104120. */
  104121. detachControl(element: Nullable<HTMLElement>): void;
  104122. /**
  104123. * Gets the class name of the current input.
  104124. * @returns the class name.
  104125. */
  104126. getClassName(): string;
  104127. /**
  104128. * Get the friendly name associated with the input class.
  104129. * @returns the input's friendly name.
  104130. */
  104131. getSimpleName(): string;
  104132. private _pointerInput;
  104133. private _onMouseMove;
  104134. /**
  104135. * Rotate camera by mouse offset.
  104136. */
  104137. private rotateCamera;
  104138. }
  104139. }
  104140. declare module BABYLON {
  104141. /**
  104142. * Default Inputs manager for the FlyCamera.
  104143. * It groups all the default supported inputs for ease of use.
  104144. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104145. */
  104146. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104147. /**
  104148. * Instantiates a new FlyCameraInputsManager.
  104149. * @param camera Defines the camera the inputs belong to.
  104150. */
  104151. constructor(camera: FlyCamera);
  104152. /**
  104153. * Add keyboard input support to the input manager.
  104154. * @returns the new FlyCameraKeyboardMoveInput().
  104155. */
  104156. addKeyboard(): FlyCameraInputsManager;
  104157. /**
  104158. * Add mouse input support to the input manager.
  104159. * @param touchEnabled Enable touch screen support.
  104160. * @returns the new FlyCameraMouseInput().
  104161. */
  104162. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104163. }
  104164. }
  104165. declare module BABYLON {
  104166. /**
  104167. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104168. * such as in a 3D Space Shooter or a Flight Simulator.
  104169. */
  104170. export class FlyCamera extends TargetCamera {
  104171. /**
  104172. * Define the collision ellipsoid of the camera.
  104173. * This is helpful for simulating a camera body, like a player's body.
  104174. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104175. */
  104176. ellipsoid: Vector3;
  104177. /**
  104178. * Define an offset for the position of the ellipsoid around the camera.
  104179. * This can be helpful if the camera is attached away from the player's body center,
  104180. * such as at its head.
  104181. */
  104182. ellipsoidOffset: Vector3;
  104183. /**
  104184. * Enable or disable collisions of the camera with the rest of the scene objects.
  104185. */
  104186. checkCollisions: boolean;
  104187. /**
  104188. * Enable or disable gravity on the camera.
  104189. */
  104190. applyGravity: boolean;
  104191. /**
  104192. * Define the current direction the camera is moving to.
  104193. */
  104194. cameraDirection: Vector3;
  104195. /**
  104196. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104197. * This overrides and empties cameraRotation.
  104198. */
  104199. rotationQuaternion: Quaternion;
  104200. /**
  104201. * Track Roll to maintain the wanted Rolling when looking around.
  104202. */
  104203. _trackRoll: number;
  104204. /**
  104205. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104206. */
  104207. rollCorrect: number;
  104208. /**
  104209. * Mimic a banked turn, Rolling the camera when Yawing.
  104210. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104211. */
  104212. bankedTurn: boolean;
  104213. /**
  104214. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104215. */
  104216. bankedTurnLimit: number;
  104217. /**
  104218. * Value of 0 disables the banked Roll.
  104219. * Value of 1 is equal to the Yaw angle in radians.
  104220. */
  104221. bankedTurnMultiplier: number;
  104222. /**
  104223. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104224. */
  104225. inputs: FlyCameraInputsManager;
  104226. /**
  104227. * Gets the input sensibility for mouse input.
  104228. * Higher values reduce sensitivity.
  104229. */
  104230. /**
  104231. * Sets the input sensibility for a mouse input.
  104232. * Higher values reduce sensitivity.
  104233. */
  104234. angularSensibility: number;
  104235. /**
  104236. * Get the keys for camera movement forward.
  104237. */
  104238. /**
  104239. * Set the keys for camera movement forward.
  104240. */
  104241. keysForward: number[];
  104242. /**
  104243. * Get the keys for camera movement backward.
  104244. */
  104245. keysBackward: number[];
  104246. /**
  104247. * Get the keys for camera movement up.
  104248. */
  104249. /**
  104250. * Set the keys for camera movement up.
  104251. */
  104252. keysUp: number[];
  104253. /**
  104254. * Get the keys for camera movement down.
  104255. */
  104256. /**
  104257. * Set the keys for camera movement down.
  104258. */
  104259. keysDown: number[];
  104260. /**
  104261. * Get the keys for camera movement left.
  104262. */
  104263. /**
  104264. * Set the keys for camera movement left.
  104265. */
  104266. keysLeft: number[];
  104267. /**
  104268. * Set the keys for camera movement right.
  104269. */
  104270. /**
  104271. * Set the keys for camera movement right.
  104272. */
  104273. keysRight: number[];
  104274. /**
  104275. * Event raised when the camera collides with a mesh in the scene.
  104276. */
  104277. onCollide: (collidedMesh: AbstractMesh) => void;
  104278. private _collider;
  104279. private _needMoveForGravity;
  104280. private _oldPosition;
  104281. private _diffPosition;
  104282. private _newPosition;
  104283. /** @hidden */
  104284. _localDirection: Vector3;
  104285. /** @hidden */
  104286. _transformedDirection: Vector3;
  104287. /**
  104288. * Instantiates a FlyCamera.
  104289. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104290. * such as in a 3D Space Shooter or a Flight Simulator.
  104291. * @param name Define the name of the camera in the scene.
  104292. * @param position Define the starting position of the camera in the scene.
  104293. * @param scene Define the scene the camera belongs to.
  104294. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104295. */
  104296. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104297. /**
  104298. * Attach a control to the HTML DOM element.
  104299. * @param element Defines the element that listens to the input events.
  104300. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104301. */
  104302. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104303. /**
  104304. * Detach a control from the HTML DOM element.
  104305. * The camera will stop reacting to that input.
  104306. * @param element Defines the element that listens to the input events.
  104307. */
  104308. detachControl(element: HTMLElement): void;
  104309. private _collisionMask;
  104310. /**
  104311. * Get the mask that the camera ignores in collision events.
  104312. */
  104313. /**
  104314. * Set the mask that the camera ignores in collision events.
  104315. */
  104316. collisionMask: number;
  104317. /** @hidden */
  104318. _collideWithWorld(displacement: Vector3): void;
  104319. /** @hidden */
  104320. private _onCollisionPositionChange;
  104321. /** @hidden */
  104322. _checkInputs(): void;
  104323. /** @hidden */
  104324. _decideIfNeedsToMove(): boolean;
  104325. /** @hidden */
  104326. _updatePosition(): void;
  104327. /**
  104328. * Restore the Roll to its target value at the rate specified.
  104329. * @param rate - Higher means slower restoring.
  104330. * @hidden
  104331. */
  104332. restoreRoll(rate: number): void;
  104333. /**
  104334. * Destroy the camera and release the current resources held by it.
  104335. */
  104336. dispose(): void;
  104337. /**
  104338. * Get the current object class name.
  104339. * @returns the class name.
  104340. */
  104341. getClassName(): string;
  104342. }
  104343. }
  104344. declare module BABYLON {
  104345. /**
  104346. * Listen to keyboard events to control the camera.
  104347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104348. */
  104349. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104350. /**
  104351. * Defines the camera the input is attached to.
  104352. */
  104353. camera: FlyCamera;
  104354. /**
  104355. * The list of keyboard keys used to control the forward move of the camera.
  104356. */
  104357. keysForward: number[];
  104358. /**
  104359. * The list of keyboard keys used to control the backward move of the camera.
  104360. */
  104361. keysBackward: number[];
  104362. /**
  104363. * The list of keyboard keys used to control the forward move of the camera.
  104364. */
  104365. keysUp: number[];
  104366. /**
  104367. * The list of keyboard keys used to control the backward move of the camera.
  104368. */
  104369. keysDown: number[];
  104370. /**
  104371. * The list of keyboard keys used to control the right strafe move of the camera.
  104372. */
  104373. keysRight: number[];
  104374. /**
  104375. * The list of keyboard keys used to control the left strafe move of the camera.
  104376. */
  104377. keysLeft: number[];
  104378. private _keys;
  104379. private _onCanvasBlurObserver;
  104380. private _onKeyboardObserver;
  104381. private _engine;
  104382. private _scene;
  104383. /**
  104384. * Attach the input controls to a specific dom element to get the input from.
  104385. * @param element Defines the element the controls should be listened from
  104386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104387. */
  104388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104389. /**
  104390. * Detach the current controls from the specified dom element.
  104391. * @param element Defines the element to stop listening the inputs from
  104392. */
  104393. detachControl(element: Nullable<HTMLElement>): void;
  104394. /**
  104395. * Gets the class name of the current intput.
  104396. * @returns the class name
  104397. */
  104398. getClassName(): string;
  104399. /** @hidden */
  104400. _onLostFocus(e: FocusEvent): void;
  104401. /**
  104402. * Get the friendly name associated with the input class.
  104403. * @returns the input friendly name
  104404. */
  104405. getSimpleName(): string;
  104406. /**
  104407. * Update the current camera state depending on the inputs that have been used this frame.
  104408. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104409. */
  104410. checkInputs(): void;
  104411. }
  104412. }
  104413. declare module BABYLON {
  104414. /**
  104415. * Manage the mouse wheel inputs to control a follow camera.
  104416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104417. */
  104418. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104419. /**
  104420. * Defines the camera the input is attached to.
  104421. */
  104422. camera: FollowCamera;
  104423. /**
  104424. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104425. */
  104426. axisControlRadius: boolean;
  104427. /**
  104428. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104429. */
  104430. axisControlHeight: boolean;
  104431. /**
  104432. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104433. */
  104434. axisControlRotation: boolean;
  104435. /**
  104436. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104437. * relation to mouseWheel events.
  104438. */
  104439. wheelPrecision: number;
  104440. /**
  104441. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104442. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104443. */
  104444. wheelDeltaPercentage: number;
  104445. private _wheel;
  104446. private _observer;
  104447. /**
  104448. * Attach the input controls to a specific dom element to get the input from.
  104449. * @param element Defines the element the controls should be listened from
  104450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104451. */
  104452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104453. /**
  104454. * Detach the current controls from the specified dom element.
  104455. * @param element Defines the element to stop listening the inputs from
  104456. */
  104457. detachControl(element: Nullable<HTMLElement>): void;
  104458. /**
  104459. * Gets the class name of the current intput.
  104460. * @returns the class name
  104461. */
  104462. getClassName(): string;
  104463. /**
  104464. * Get the friendly name associated with the input class.
  104465. * @returns the input friendly name
  104466. */
  104467. getSimpleName(): string;
  104468. }
  104469. }
  104470. declare module BABYLON {
  104471. /**
  104472. * Manage the pointers inputs to control an follow camera.
  104473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104474. */
  104475. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104476. /**
  104477. * Defines the camera the input is attached to.
  104478. */
  104479. camera: FollowCamera;
  104480. /**
  104481. * Gets the class name of the current input.
  104482. * @returns the class name
  104483. */
  104484. getClassName(): string;
  104485. /**
  104486. * Defines the pointer angular sensibility along the X axis or how fast is
  104487. * the camera rotating.
  104488. * A negative number will reverse the axis direction.
  104489. */
  104490. angularSensibilityX: number;
  104491. /**
  104492. * Defines the pointer angular sensibility along the Y axis or how fast is
  104493. * the camera rotating.
  104494. * A negative number will reverse the axis direction.
  104495. */
  104496. angularSensibilityY: number;
  104497. /**
  104498. * Defines the pointer pinch precision or how fast is the camera zooming.
  104499. * A negative number will reverse the axis direction.
  104500. */
  104501. pinchPrecision: number;
  104502. /**
  104503. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104504. * from 0.
  104505. * It defines the percentage of current camera.radius to use as delta when
  104506. * pinch zoom is used.
  104507. */
  104508. pinchDeltaPercentage: number;
  104509. /**
  104510. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104511. */
  104512. axisXControlRadius: boolean;
  104513. /**
  104514. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104515. */
  104516. axisXControlHeight: boolean;
  104517. /**
  104518. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104519. */
  104520. axisXControlRotation: boolean;
  104521. /**
  104522. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104523. */
  104524. axisYControlRadius: boolean;
  104525. /**
  104526. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104527. */
  104528. axisYControlHeight: boolean;
  104529. /**
  104530. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104531. */
  104532. axisYControlRotation: boolean;
  104533. /**
  104534. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104535. */
  104536. axisPinchControlRadius: boolean;
  104537. /**
  104538. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104539. */
  104540. axisPinchControlHeight: boolean;
  104541. /**
  104542. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104543. */
  104544. axisPinchControlRotation: boolean;
  104545. /**
  104546. * Log error messages if basic misconfiguration has occurred.
  104547. */
  104548. warningEnable: boolean;
  104549. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104550. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104551. private _warningCounter;
  104552. private _warning;
  104553. }
  104554. }
  104555. declare module BABYLON {
  104556. /**
  104557. * Default Inputs manager for the FollowCamera.
  104558. * It groups all the default supported inputs for ease of use.
  104559. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104560. */
  104561. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104562. /**
  104563. * Instantiates a new FollowCameraInputsManager.
  104564. * @param camera Defines the camera the inputs belong to
  104565. */
  104566. constructor(camera: FollowCamera);
  104567. /**
  104568. * Add keyboard input support to the input manager.
  104569. * @returns the current input manager
  104570. */
  104571. addKeyboard(): FollowCameraInputsManager;
  104572. /**
  104573. * Add mouse wheel input support to the input manager.
  104574. * @returns the current input manager
  104575. */
  104576. addMouseWheel(): FollowCameraInputsManager;
  104577. /**
  104578. * Add pointers input support to the input manager.
  104579. * @returns the current input manager
  104580. */
  104581. addPointers(): FollowCameraInputsManager;
  104582. /**
  104583. * Add orientation input support to the input manager.
  104584. * @returns the current input manager
  104585. */
  104586. addVRDeviceOrientation(): FollowCameraInputsManager;
  104587. }
  104588. }
  104589. declare module BABYLON {
  104590. /**
  104591. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104592. * an arc rotate version arcFollowCamera are available.
  104593. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104594. */
  104595. export class FollowCamera extends TargetCamera {
  104596. /**
  104597. * Distance the follow camera should follow an object at
  104598. */
  104599. radius: number;
  104600. /**
  104601. * Minimum allowed distance of the camera to the axis of rotation
  104602. * (The camera can not get closer).
  104603. * This can help limiting how the Camera is able to move in the scene.
  104604. */
  104605. lowerRadiusLimit: Nullable<number>;
  104606. /**
  104607. * Maximum allowed distance of the camera to the axis of rotation
  104608. * (The camera can not get further).
  104609. * This can help limiting how the Camera is able to move in the scene.
  104610. */
  104611. upperRadiusLimit: Nullable<number>;
  104612. /**
  104613. * Define a rotation offset between the camera and the object it follows
  104614. */
  104615. rotationOffset: number;
  104616. /**
  104617. * Minimum allowed angle to camera position relative to target object.
  104618. * This can help limiting how the Camera is able to move in the scene.
  104619. */
  104620. lowerRotationOffsetLimit: Nullable<number>;
  104621. /**
  104622. * Maximum allowed angle to camera position relative to target object.
  104623. * This can help limiting how the Camera is able to move in the scene.
  104624. */
  104625. upperRotationOffsetLimit: Nullable<number>;
  104626. /**
  104627. * Define a height offset between the camera and the object it follows.
  104628. * It can help following an object from the top (like a car chaing a plane)
  104629. */
  104630. heightOffset: number;
  104631. /**
  104632. * Minimum allowed height of camera position relative to target object.
  104633. * This can help limiting how the Camera is able to move in the scene.
  104634. */
  104635. lowerHeightOffsetLimit: Nullable<number>;
  104636. /**
  104637. * Maximum allowed height of camera position relative to target object.
  104638. * This can help limiting how the Camera is able to move in the scene.
  104639. */
  104640. upperHeightOffsetLimit: Nullable<number>;
  104641. /**
  104642. * Define how fast the camera can accelerate to follow it s target.
  104643. */
  104644. cameraAcceleration: number;
  104645. /**
  104646. * Define the speed limit of the camera following an object.
  104647. */
  104648. maxCameraSpeed: number;
  104649. /**
  104650. * Define the target of the camera.
  104651. */
  104652. lockedTarget: Nullable<AbstractMesh>;
  104653. /**
  104654. * Defines the input associated with the camera.
  104655. */
  104656. inputs: FollowCameraInputsManager;
  104657. /**
  104658. * Instantiates the follow camera.
  104659. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104660. * @param name Define the name of the camera in the scene
  104661. * @param position Define the position of the camera
  104662. * @param scene Define the scene the camera belong to
  104663. * @param lockedTarget Define the target of the camera
  104664. */
  104665. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104666. private _follow;
  104667. /**
  104668. * Attached controls to the current camera.
  104669. * @param element Defines the element the controls should be listened from
  104670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104671. */
  104672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104673. /**
  104674. * Detach the current controls from the camera.
  104675. * The camera will stop reacting to inputs.
  104676. * @param element Defines the element to stop listening the inputs from
  104677. */
  104678. detachControl(element: HTMLElement): void;
  104679. /** @hidden */
  104680. _checkInputs(): void;
  104681. private _checkLimits;
  104682. /**
  104683. * Gets the camera class name.
  104684. * @returns the class name
  104685. */
  104686. getClassName(): string;
  104687. }
  104688. /**
  104689. * Arc Rotate version of the follow camera.
  104690. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104691. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104692. */
  104693. export class ArcFollowCamera extends TargetCamera {
  104694. /** The longitudinal angle of the camera */
  104695. alpha: number;
  104696. /** The latitudinal angle of the camera */
  104697. beta: number;
  104698. /** The radius of the camera from its target */
  104699. radius: number;
  104700. /** Define the camera target (the messh it should follow) */
  104701. target: Nullable<AbstractMesh>;
  104702. private _cartesianCoordinates;
  104703. /**
  104704. * Instantiates a new ArcFollowCamera
  104705. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104706. * @param name Define the name of the camera
  104707. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104708. * @param beta Define the rotation angle of the camera around the elevation axis
  104709. * @param radius Define the radius of the camera from its target point
  104710. * @param target Define the target of the camera
  104711. * @param scene Define the scene the camera belongs to
  104712. */
  104713. constructor(name: string,
  104714. /** The longitudinal angle of the camera */
  104715. alpha: number,
  104716. /** The latitudinal angle of the camera */
  104717. beta: number,
  104718. /** The radius of the camera from its target */
  104719. radius: number,
  104720. /** Define the camera target (the messh it should follow) */
  104721. target: Nullable<AbstractMesh>, scene: Scene);
  104722. private _follow;
  104723. /** @hidden */
  104724. _checkInputs(): void;
  104725. /**
  104726. * Returns the class name of the object.
  104727. * It is mostly used internally for serialization purposes.
  104728. */
  104729. getClassName(): string;
  104730. }
  104731. }
  104732. declare module BABYLON {
  104733. /**
  104734. * Manage the keyboard inputs to control the movement of a follow camera.
  104735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104736. */
  104737. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104738. /**
  104739. * Defines the camera the input is attached to.
  104740. */
  104741. camera: FollowCamera;
  104742. /**
  104743. * Defines the list of key codes associated with the up action (increase heightOffset)
  104744. */
  104745. keysHeightOffsetIncr: number[];
  104746. /**
  104747. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104748. */
  104749. keysHeightOffsetDecr: number[];
  104750. /**
  104751. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104752. */
  104753. keysHeightOffsetModifierAlt: boolean;
  104754. /**
  104755. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104756. */
  104757. keysHeightOffsetModifierCtrl: boolean;
  104758. /**
  104759. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104760. */
  104761. keysHeightOffsetModifierShift: boolean;
  104762. /**
  104763. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104764. */
  104765. keysRotationOffsetIncr: number[];
  104766. /**
  104767. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104768. */
  104769. keysRotationOffsetDecr: number[];
  104770. /**
  104771. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104772. */
  104773. keysRotationOffsetModifierAlt: boolean;
  104774. /**
  104775. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104776. */
  104777. keysRotationOffsetModifierCtrl: boolean;
  104778. /**
  104779. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104780. */
  104781. keysRotationOffsetModifierShift: boolean;
  104782. /**
  104783. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104784. */
  104785. keysRadiusIncr: number[];
  104786. /**
  104787. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104788. */
  104789. keysRadiusDecr: number[];
  104790. /**
  104791. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104792. */
  104793. keysRadiusModifierAlt: boolean;
  104794. /**
  104795. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104796. */
  104797. keysRadiusModifierCtrl: boolean;
  104798. /**
  104799. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104800. */
  104801. keysRadiusModifierShift: boolean;
  104802. /**
  104803. * Defines the rate of change of heightOffset.
  104804. */
  104805. heightSensibility: number;
  104806. /**
  104807. * Defines the rate of change of rotationOffset.
  104808. */
  104809. rotationSensibility: number;
  104810. /**
  104811. * Defines the rate of change of radius.
  104812. */
  104813. radiusSensibility: number;
  104814. private _keys;
  104815. private _ctrlPressed;
  104816. private _altPressed;
  104817. private _shiftPressed;
  104818. private _onCanvasBlurObserver;
  104819. private _onKeyboardObserver;
  104820. private _engine;
  104821. private _scene;
  104822. /**
  104823. * Attach the input controls to a specific dom element to get the input from.
  104824. * @param element Defines the element the controls should be listened from
  104825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104826. */
  104827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104828. /**
  104829. * Detach the current controls from the specified dom element.
  104830. * @param element Defines the element to stop listening the inputs from
  104831. */
  104832. detachControl(element: Nullable<HTMLElement>): void;
  104833. /**
  104834. * Update the current camera state depending on the inputs that have been used this frame.
  104835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104836. */
  104837. checkInputs(): void;
  104838. /**
  104839. * Gets the class name of the current input.
  104840. * @returns the class name
  104841. */
  104842. getClassName(): string;
  104843. /**
  104844. * Get the friendly name associated with the input class.
  104845. * @returns the input friendly name
  104846. */
  104847. getSimpleName(): string;
  104848. /**
  104849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104850. * allow modification of the heightOffset value.
  104851. */
  104852. private _modifierHeightOffset;
  104853. /**
  104854. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104855. * allow modification of the rotationOffset value.
  104856. */
  104857. private _modifierRotationOffset;
  104858. /**
  104859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104860. * allow modification of the radius value.
  104861. */
  104862. private _modifierRadius;
  104863. }
  104864. }
  104865. declare module BABYLON {
  104866. interface FreeCameraInputsManager {
  104867. /**
  104868. * @hidden
  104869. */
  104870. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104871. /**
  104872. * Add orientation input support to the input manager.
  104873. * @returns the current input manager
  104874. */
  104875. addDeviceOrientation(): FreeCameraInputsManager;
  104876. }
  104877. /**
  104878. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104879. * Screen rotation is taken into account.
  104880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104881. */
  104882. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104883. private _camera;
  104884. private _screenOrientationAngle;
  104885. private _constantTranform;
  104886. private _screenQuaternion;
  104887. private _alpha;
  104888. private _beta;
  104889. private _gamma;
  104890. /**
  104891. * Can be used to detect if a device orientation sensor is availible on a device
  104892. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104893. * @returns a promise that will resolve on orientation change
  104894. */
  104895. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104896. /**
  104897. * @hidden
  104898. */
  104899. _onDeviceOrientationChangedObservable: Observable<void>;
  104900. /**
  104901. * Instantiates a new input
  104902. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104903. */
  104904. constructor();
  104905. /**
  104906. * Define the camera controlled by the input.
  104907. */
  104908. camera: FreeCamera;
  104909. /**
  104910. * Attach the input controls to a specific dom element to get the input from.
  104911. * @param element Defines the element the controls should be listened from
  104912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104913. */
  104914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104915. private _orientationChanged;
  104916. private _deviceOrientation;
  104917. /**
  104918. * Detach the current controls from the specified dom element.
  104919. * @param element Defines the element to stop listening the inputs from
  104920. */
  104921. detachControl(element: Nullable<HTMLElement>): void;
  104922. /**
  104923. * Update the current camera state depending on the inputs that have been used this frame.
  104924. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104925. */
  104926. checkInputs(): void;
  104927. /**
  104928. * Gets the class name of the current intput.
  104929. * @returns the class name
  104930. */
  104931. getClassName(): string;
  104932. /**
  104933. * Get the friendly name associated with the input class.
  104934. * @returns the input friendly name
  104935. */
  104936. getSimpleName(): string;
  104937. }
  104938. }
  104939. declare module BABYLON {
  104940. /**
  104941. * Manage the gamepad inputs to control a free camera.
  104942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104943. */
  104944. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104945. /**
  104946. * Define the camera the input is attached to.
  104947. */
  104948. camera: FreeCamera;
  104949. /**
  104950. * Define the Gamepad controlling the input
  104951. */
  104952. gamepad: Nullable<Gamepad>;
  104953. /**
  104954. * Defines the gamepad rotation sensiblity.
  104955. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104956. */
  104957. gamepadAngularSensibility: number;
  104958. /**
  104959. * Defines the gamepad move sensiblity.
  104960. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104961. */
  104962. gamepadMoveSensibility: number;
  104963. private _onGamepadConnectedObserver;
  104964. private _onGamepadDisconnectedObserver;
  104965. private _cameraTransform;
  104966. private _deltaTransform;
  104967. private _vector3;
  104968. private _vector2;
  104969. /**
  104970. * Attach the input controls to a specific dom element to get the input from.
  104971. * @param element Defines the element the controls should be listened from
  104972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104973. */
  104974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104975. /**
  104976. * Detach the current controls from the specified dom element.
  104977. * @param element Defines the element to stop listening the inputs from
  104978. */
  104979. detachControl(element: Nullable<HTMLElement>): void;
  104980. /**
  104981. * Update the current camera state depending on the inputs that have been used this frame.
  104982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104983. */
  104984. checkInputs(): void;
  104985. /**
  104986. * Gets the class name of the current intput.
  104987. * @returns the class name
  104988. */
  104989. getClassName(): string;
  104990. /**
  104991. * Get the friendly name associated with the input class.
  104992. * @returns the input friendly name
  104993. */
  104994. getSimpleName(): string;
  104995. }
  104996. }
  104997. declare module BABYLON {
  104998. /**
  104999. * Defines the potential axis of a Joystick
  105000. */
  105001. export enum JoystickAxis {
  105002. /** X axis */
  105003. X = 0,
  105004. /** Y axis */
  105005. Y = 1,
  105006. /** Z axis */
  105007. Z = 2
  105008. }
  105009. /**
  105010. * Class used to define virtual joystick (used in touch mode)
  105011. */
  105012. export class VirtualJoystick {
  105013. /**
  105014. * Gets or sets a boolean indicating that left and right values must be inverted
  105015. */
  105016. reverseLeftRight: boolean;
  105017. /**
  105018. * Gets or sets a boolean indicating that up and down values must be inverted
  105019. */
  105020. reverseUpDown: boolean;
  105021. /**
  105022. * Gets the offset value for the position (ie. the change of the position value)
  105023. */
  105024. deltaPosition: Vector3;
  105025. /**
  105026. * Gets a boolean indicating if the virtual joystick was pressed
  105027. */
  105028. pressed: boolean;
  105029. /**
  105030. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105031. */
  105032. static Canvas: Nullable<HTMLCanvasElement>;
  105033. private static _globalJoystickIndex;
  105034. private static vjCanvasContext;
  105035. private static vjCanvasWidth;
  105036. private static vjCanvasHeight;
  105037. private static halfWidth;
  105038. private _action;
  105039. private _axisTargetedByLeftAndRight;
  105040. private _axisTargetedByUpAndDown;
  105041. private _joystickSensibility;
  105042. private _inversedSensibility;
  105043. private _joystickPointerID;
  105044. private _joystickColor;
  105045. private _joystickPointerPos;
  105046. private _joystickPreviousPointerPos;
  105047. private _joystickPointerStartPos;
  105048. private _deltaJoystickVector;
  105049. private _leftJoystick;
  105050. private _touches;
  105051. private _onPointerDownHandlerRef;
  105052. private _onPointerMoveHandlerRef;
  105053. private _onPointerUpHandlerRef;
  105054. private _onResize;
  105055. /**
  105056. * Creates a new virtual joystick
  105057. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105058. */
  105059. constructor(leftJoystick?: boolean);
  105060. /**
  105061. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105062. * @param newJoystickSensibility defines the new sensibility
  105063. */
  105064. setJoystickSensibility(newJoystickSensibility: number): void;
  105065. private _onPointerDown;
  105066. private _onPointerMove;
  105067. private _onPointerUp;
  105068. /**
  105069. * Change the color of the virtual joystick
  105070. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105071. */
  105072. setJoystickColor(newColor: string): void;
  105073. /**
  105074. * Defines a callback to call when the joystick is touched
  105075. * @param action defines the callback
  105076. */
  105077. setActionOnTouch(action: () => any): void;
  105078. /**
  105079. * Defines which axis you'd like to control for left & right
  105080. * @param axis defines the axis to use
  105081. */
  105082. setAxisForLeftRight(axis: JoystickAxis): void;
  105083. /**
  105084. * Defines which axis you'd like to control for up & down
  105085. * @param axis defines the axis to use
  105086. */
  105087. setAxisForUpDown(axis: JoystickAxis): void;
  105088. private _drawVirtualJoystick;
  105089. /**
  105090. * Release internal HTML canvas
  105091. */
  105092. releaseCanvas(): void;
  105093. }
  105094. }
  105095. declare module BABYLON {
  105096. interface FreeCameraInputsManager {
  105097. /**
  105098. * Add virtual joystick input support to the input manager.
  105099. * @returns the current input manager
  105100. */
  105101. addVirtualJoystick(): FreeCameraInputsManager;
  105102. }
  105103. /**
  105104. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105105. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105106. */
  105107. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105108. /**
  105109. * Defines the camera the input is attached to.
  105110. */
  105111. camera: FreeCamera;
  105112. private _leftjoystick;
  105113. private _rightjoystick;
  105114. /**
  105115. * Gets the left stick of the virtual joystick.
  105116. * @returns The virtual Joystick
  105117. */
  105118. getLeftJoystick(): VirtualJoystick;
  105119. /**
  105120. * Gets the right stick of the virtual joystick.
  105121. * @returns The virtual Joystick
  105122. */
  105123. getRightJoystick(): VirtualJoystick;
  105124. /**
  105125. * Update the current camera state depending on the inputs that have been used this frame.
  105126. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105127. */
  105128. checkInputs(): void;
  105129. /**
  105130. * Attach the input controls to a specific dom element to get the input from.
  105131. * @param element Defines the element the controls should be listened from
  105132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105133. */
  105134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105135. /**
  105136. * Detach the current controls from the specified dom element.
  105137. * @param element Defines the element to stop listening the inputs from
  105138. */
  105139. detachControl(element: Nullable<HTMLElement>): void;
  105140. /**
  105141. * Gets the class name of the current intput.
  105142. * @returns the class name
  105143. */
  105144. getClassName(): string;
  105145. /**
  105146. * Get the friendly name associated with the input class.
  105147. * @returns the input friendly name
  105148. */
  105149. getSimpleName(): string;
  105150. }
  105151. }
  105152. declare module BABYLON {
  105153. /**
  105154. * This represents a FPS type of camera controlled by touch.
  105155. * This is like a universal camera minus the Gamepad controls.
  105156. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105157. */
  105158. export class TouchCamera extends FreeCamera {
  105159. /**
  105160. * Defines the touch sensibility for rotation.
  105161. * The higher the faster.
  105162. */
  105163. touchAngularSensibility: number;
  105164. /**
  105165. * Defines the touch sensibility for move.
  105166. * The higher the faster.
  105167. */
  105168. touchMoveSensibility: number;
  105169. /**
  105170. * Instantiates a new touch camera.
  105171. * This represents a FPS type of camera controlled by touch.
  105172. * This is like a universal camera minus the Gamepad controls.
  105173. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105174. * @param name Define the name of the camera in the scene
  105175. * @param position Define the start position of the camera in the scene
  105176. * @param scene Define the scene the camera belongs to
  105177. */
  105178. constructor(name: string, position: Vector3, scene: Scene);
  105179. /**
  105180. * Gets the current object class name.
  105181. * @return the class name
  105182. */
  105183. getClassName(): string;
  105184. /** @hidden */
  105185. _setupInputs(): void;
  105186. }
  105187. }
  105188. declare module BABYLON {
  105189. /**
  105190. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105191. * being tilted forward or back and left or right.
  105192. */
  105193. export class DeviceOrientationCamera extends FreeCamera {
  105194. private _initialQuaternion;
  105195. private _quaternionCache;
  105196. private _tmpDragQuaternion;
  105197. private _disablePointerInputWhenUsingDeviceOrientation;
  105198. /**
  105199. * Creates a new device orientation camera
  105200. * @param name The name of the camera
  105201. * @param position The start position camera
  105202. * @param scene The scene the camera belongs to
  105203. */
  105204. constructor(name: string, position: Vector3, scene: Scene);
  105205. /**
  105206. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105207. */
  105208. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105209. private _dragFactor;
  105210. /**
  105211. * Enabled turning on the y axis when the orientation sensor is active
  105212. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105213. */
  105214. enableHorizontalDragging(dragFactor?: number): void;
  105215. /**
  105216. * Gets the current instance class name ("DeviceOrientationCamera").
  105217. * This helps avoiding instanceof at run time.
  105218. * @returns the class name
  105219. */
  105220. getClassName(): string;
  105221. /**
  105222. * @hidden
  105223. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105224. */
  105225. _checkInputs(): void;
  105226. /**
  105227. * Reset the camera to its default orientation on the specified axis only.
  105228. * @param axis The axis to reset
  105229. */
  105230. resetToCurrentRotation(axis?: Axis): void;
  105231. }
  105232. }
  105233. declare module BABYLON {
  105234. /**
  105235. * Defines supported buttons for XBox360 compatible gamepads
  105236. */
  105237. export enum Xbox360Button {
  105238. /** A */
  105239. A = 0,
  105240. /** B */
  105241. B = 1,
  105242. /** X */
  105243. X = 2,
  105244. /** Y */
  105245. Y = 3,
  105246. /** Start */
  105247. Start = 4,
  105248. /** Back */
  105249. Back = 5,
  105250. /** Left button */
  105251. LB = 6,
  105252. /** Right button */
  105253. RB = 7,
  105254. /** Left stick */
  105255. LeftStick = 8,
  105256. /** Right stick */
  105257. RightStick = 9
  105258. }
  105259. /** Defines values for XBox360 DPad */
  105260. export enum Xbox360Dpad {
  105261. /** Up */
  105262. Up = 0,
  105263. /** Down */
  105264. Down = 1,
  105265. /** Left */
  105266. Left = 2,
  105267. /** Right */
  105268. Right = 3
  105269. }
  105270. /**
  105271. * Defines a XBox360 gamepad
  105272. */
  105273. export class Xbox360Pad extends Gamepad {
  105274. private _leftTrigger;
  105275. private _rightTrigger;
  105276. private _onlefttriggerchanged;
  105277. private _onrighttriggerchanged;
  105278. private _onbuttondown;
  105279. private _onbuttonup;
  105280. private _ondpaddown;
  105281. private _ondpadup;
  105282. /** Observable raised when a button is pressed */
  105283. onButtonDownObservable: Observable<Xbox360Button>;
  105284. /** Observable raised when a button is released */
  105285. onButtonUpObservable: Observable<Xbox360Button>;
  105286. /** Observable raised when a pad is pressed */
  105287. onPadDownObservable: Observable<Xbox360Dpad>;
  105288. /** Observable raised when a pad is released */
  105289. onPadUpObservable: Observable<Xbox360Dpad>;
  105290. private _buttonA;
  105291. private _buttonB;
  105292. private _buttonX;
  105293. private _buttonY;
  105294. private _buttonBack;
  105295. private _buttonStart;
  105296. private _buttonLB;
  105297. private _buttonRB;
  105298. private _buttonLeftStick;
  105299. private _buttonRightStick;
  105300. private _dPadUp;
  105301. private _dPadDown;
  105302. private _dPadLeft;
  105303. private _dPadRight;
  105304. private _isXboxOnePad;
  105305. /**
  105306. * Creates a new XBox360 gamepad object
  105307. * @param id defines the id of this gamepad
  105308. * @param index defines its index
  105309. * @param gamepad defines the internal HTML gamepad object
  105310. * @param xboxOne defines if it is a XBox One gamepad
  105311. */
  105312. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105313. /**
  105314. * Defines the callback to call when left trigger is pressed
  105315. * @param callback defines the callback to use
  105316. */
  105317. onlefttriggerchanged(callback: (value: number) => void): void;
  105318. /**
  105319. * Defines the callback to call when right trigger is pressed
  105320. * @param callback defines the callback to use
  105321. */
  105322. onrighttriggerchanged(callback: (value: number) => void): void;
  105323. /**
  105324. * Gets the left trigger value
  105325. */
  105326. /**
  105327. * Sets the left trigger value
  105328. */
  105329. leftTrigger: number;
  105330. /**
  105331. * Gets the right trigger value
  105332. */
  105333. /**
  105334. * Sets the right trigger value
  105335. */
  105336. rightTrigger: number;
  105337. /**
  105338. * Defines the callback to call when a button is pressed
  105339. * @param callback defines the callback to use
  105340. */
  105341. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105342. /**
  105343. * Defines the callback to call when a button is released
  105344. * @param callback defines the callback to use
  105345. */
  105346. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105347. /**
  105348. * Defines the callback to call when a pad is pressed
  105349. * @param callback defines the callback to use
  105350. */
  105351. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105352. /**
  105353. * Defines the callback to call when a pad is released
  105354. * @param callback defines the callback to use
  105355. */
  105356. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105357. private _setButtonValue;
  105358. private _setDPadValue;
  105359. /**
  105360. * Gets the value of the `A` button
  105361. */
  105362. /**
  105363. * Sets the value of the `A` button
  105364. */
  105365. buttonA: number;
  105366. /**
  105367. * Gets the value of the `B` button
  105368. */
  105369. /**
  105370. * Sets the value of the `B` button
  105371. */
  105372. buttonB: number;
  105373. /**
  105374. * Gets the value of the `X` button
  105375. */
  105376. /**
  105377. * Sets the value of the `X` button
  105378. */
  105379. buttonX: number;
  105380. /**
  105381. * Gets the value of the `Y` button
  105382. */
  105383. /**
  105384. * Sets the value of the `Y` button
  105385. */
  105386. buttonY: number;
  105387. /**
  105388. * Gets the value of the `Start` button
  105389. */
  105390. /**
  105391. * Sets the value of the `Start` button
  105392. */
  105393. buttonStart: number;
  105394. /**
  105395. * Gets the value of the `Back` button
  105396. */
  105397. /**
  105398. * Sets the value of the `Back` button
  105399. */
  105400. buttonBack: number;
  105401. /**
  105402. * Gets the value of the `Left` button
  105403. */
  105404. /**
  105405. * Sets the value of the `Left` button
  105406. */
  105407. buttonLB: number;
  105408. /**
  105409. * Gets the value of the `Right` button
  105410. */
  105411. /**
  105412. * Sets the value of the `Right` button
  105413. */
  105414. buttonRB: number;
  105415. /**
  105416. * Gets the value of the Left joystick
  105417. */
  105418. /**
  105419. * Sets the value of the Left joystick
  105420. */
  105421. buttonLeftStick: number;
  105422. /**
  105423. * Gets the value of the Right joystick
  105424. */
  105425. /**
  105426. * Sets the value of the Right joystick
  105427. */
  105428. buttonRightStick: number;
  105429. /**
  105430. * Gets the value of D-pad up
  105431. */
  105432. /**
  105433. * Sets the value of D-pad up
  105434. */
  105435. dPadUp: number;
  105436. /**
  105437. * Gets the value of D-pad down
  105438. */
  105439. /**
  105440. * Sets the value of D-pad down
  105441. */
  105442. dPadDown: number;
  105443. /**
  105444. * Gets the value of D-pad left
  105445. */
  105446. /**
  105447. * Sets the value of D-pad left
  105448. */
  105449. dPadLeft: number;
  105450. /**
  105451. * Gets the value of D-pad right
  105452. */
  105453. /**
  105454. * Sets the value of D-pad right
  105455. */
  105456. dPadRight: number;
  105457. /**
  105458. * Force the gamepad to synchronize with device values
  105459. */
  105460. update(): void;
  105461. /**
  105462. * Disposes the gamepad
  105463. */
  105464. dispose(): void;
  105465. }
  105466. }
  105467. declare module BABYLON {
  105468. /**
  105469. * Defines supported buttons for DualShock compatible gamepads
  105470. */
  105471. export enum DualShockButton {
  105472. /** Cross */
  105473. Cross = 0,
  105474. /** Circle */
  105475. Circle = 1,
  105476. /** Square */
  105477. Square = 2,
  105478. /** Triangle */
  105479. Triangle = 3,
  105480. /** Options */
  105481. Options = 4,
  105482. /** Share */
  105483. Share = 5,
  105484. /** L1 */
  105485. L1 = 6,
  105486. /** R1 */
  105487. R1 = 7,
  105488. /** Left stick */
  105489. LeftStick = 8,
  105490. /** Right stick */
  105491. RightStick = 9
  105492. }
  105493. /** Defines values for DualShock DPad */
  105494. export enum DualShockDpad {
  105495. /** Up */
  105496. Up = 0,
  105497. /** Down */
  105498. Down = 1,
  105499. /** Left */
  105500. Left = 2,
  105501. /** Right */
  105502. Right = 3
  105503. }
  105504. /**
  105505. * Defines a DualShock gamepad
  105506. */
  105507. export class DualShockPad extends Gamepad {
  105508. private _leftTrigger;
  105509. private _rightTrigger;
  105510. private _onlefttriggerchanged;
  105511. private _onrighttriggerchanged;
  105512. private _onbuttondown;
  105513. private _onbuttonup;
  105514. private _ondpaddown;
  105515. private _ondpadup;
  105516. /** Observable raised when a button is pressed */
  105517. onButtonDownObservable: Observable<DualShockButton>;
  105518. /** Observable raised when a button is released */
  105519. onButtonUpObservable: Observable<DualShockButton>;
  105520. /** Observable raised when a pad is pressed */
  105521. onPadDownObservable: Observable<DualShockDpad>;
  105522. /** Observable raised when a pad is released */
  105523. onPadUpObservable: Observable<DualShockDpad>;
  105524. private _buttonCross;
  105525. private _buttonCircle;
  105526. private _buttonSquare;
  105527. private _buttonTriangle;
  105528. private _buttonShare;
  105529. private _buttonOptions;
  105530. private _buttonL1;
  105531. private _buttonR1;
  105532. private _buttonLeftStick;
  105533. private _buttonRightStick;
  105534. private _dPadUp;
  105535. private _dPadDown;
  105536. private _dPadLeft;
  105537. private _dPadRight;
  105538. /**
  105539. * Creates a new DualShock gamepad object
  105540. * @param id defines the id of this gamepad
  105541. * @param index defines its index
  105542. * @param gamepad defines the internal HTML gamepad object
  105543. */
  105544. constructor(id: string, index: number, gamepad: any);
  105545. /**
  105546. * Defines the callback to call when left trigger is pressed
  105547. * @param callback defines the callback to use
  105548. */
  105549. onlefttriggerchanged(callback: (value: number) => void): void;
  105550. /**
  105551. * Defines the callback to call when right trigger is pressed
  105552. * @param callback defines the callback to use
  105553. */
  105554. onrighttriggerchanged(callback: (value: number) => void): void;
  105555. /**
  105556. * Gets the left trigger value
  105557. */
  105558. /**
  105559. * Sets the left trigger value
  105560. */
  105561. leftTrigger: number;
  105562. /**
  105563. * Gets the right trigger value
  105564. */
  105565. /**
  105566. * Sets the right trigger value
  105567. */
  105568. rightTrigger: number;
  105569. /**
  105570. * Defines the callback to call when a button is pressed
  105571. * @param callback defines the callback to use
  105572. */
  105573. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105574. /**
  105575. * Defines the callback to call when a button is released
  105576. * @param callback defines the callback to use
  105577. */
  105578. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105579. /**
  105580. * Defines the callback to call when a pad is pressed
  105581. * @param callback defines the callback to use
  105582. */
  105583. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105584. /**
  105585. * Defines the callback to call when a pad is released
  105586. * @param callback defines the callback to use
  105587. */
  105588. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105589. private _setButtonValue;
  105590. private _setDPadValue;
  105591. /**
  105592. * Gets the value of the `Cross` button
  105593. */
  105594. /**
  105595. * Sets the value of the `Cross` button
  105596. */
  105597. buttonCross: number;
  105598. /**
  105599. * Gets the value of the `Circle` button
  105600. */
  105601. /**
  105602. * Sets the value of the `Circle` button
  105603. */
  105604. buttonCircle: number;
  105605. /**
  105606. * Gets the value of the `Square` button
  105607. */
  105608. /**
  105609. * Sets the value of the `Square` button
  105610. */
  105611. buttonSquare: number;
  105612. /**
  105613. * Gets the value of the `Triangle` button
  105614. */
  105615. /**
  105616. * Sets the value of the `Triangle` button
  105617. */
  105618. buttonTriangle: number;
  105619. /**
  105620. * Gets the value of the `Options` button
  105621. */
  105622. /**
  105623. * Sets the value of the `Options` button
  105624. */
  105625. buttonOptions: number;
  105626. /**
  105627. * Gets the value of the `Share` button
  105628. */
  105629. /**
  105630. * Sets the value of the `Share` button
  105631. */
  105632. buttonShare: number;
  105633. /**
  105634. * Gets the value of the `L1` button
  105635. */
  105636. /**
  105637. * Sets the value of the `L1` button
  105638. */
  105639. buttonL1: number;
  105640. /**
  105641. * Gets the value of the `R1` button
  105642. */
  105643. /**
  105644. * Sets the value of the `R1` button
  105645. */
  105646. buttonR1: number;
  105647. /**
  105648. * Gets the value of the Left joystick
  105649. */
  105650. /**
  105651. * Sets the value of the Left joystick
  105652. */
  105653. buttonLeftStick: number;
  105654. /**
  105655. * Gets the value of the Right joystick
  105656. */
  105657. /**
  105658. * Sets the value of the Right joystick
  105659. */
  105660. buttonRightStick: number;
  105661. /**
  105662. * Gets the value of D-pad up
  105663. */
  105664. /**
  105665. * Sets the value of D-pad up
  105666. */
  105667. dPadUp: number;
  105668. /**
  105669. * Gets the value of D-pad down
  105670. */
  105671. /**
  105672. * Sets the value of D-pad down
  105673. */
  105674. dPadDown: number;
  105675. /**
  105676. * Gets the value of D-pad left
  105677. */
  105678. /**
  105679. * Sets the value of D-pad left
  105680. */
  105681. dPadLeft: number;
  105682. /**
  105683. * Gets the value of D-pad right
  105684. */
  105685. /**
  105686. * Sets the value of D-pad right
  105687. */
  105688. dPadRight: number;
  105689. /**
  105690. * Force the gamepad to synchronize with device values
  105691. */
  105692. update(): void;
  105693. /**
  105694. * Disposes the gamepad
  105695. */
  105696. dispose(): void;
  105697. }
  105698. }
  105699. declare module BABYLON {
  105700. /**
  105701. * Manager for handling gamepads
  105702. */
  105703. export class GamepadManager {
  105704. private _scene?;
  105705. private _babylonGamepads;
  105706. private _oneGamepadConnected;
  105707. /** @hidden */
  105708. _isMonitoring: boolean;
  105709. private _gamepadEventSupported;
  105710. private _gamepadSupport;
  105711. /**
  105712. * observable to be triggered when the gamepad controller has been connected
  105713. */
  105714. onGamepadConnectedObservable: Observable<Gamepad>;
  105715. /**
  105716. * observable to be triggered when the gamepad controller has been disconnected
  105717. */
  105718. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105719. private _onGamepadConnectedEvent;
  105720. private _onGamepadDisconnectedEvent;
  105721. /**
  105722. * Initializes the gamepad manager
  105723. * @param _scene BabylonJS scene
  105724. */
  105725. constructor(_scene?: Scene | undefined);
  105726. /**
  105727. * The gamepads in the game pad manager
  105728. */
  105729. readonly gamepads: Gamepad[];
  105730. /**
  105731. * Get the gamepad controllers based on type
  105732. * @param type The type of gamepad controller
  105733. * @returns Nullable gamepad
  105734. */
  105735. getGamepadByType(type?: number): Nullable<Gamepad>;
  105736. /**
  105737. * Disposes the gamepad manager
  105738. */
  105739. dispose(): void;
  105740. private _addNewGamepad;
  105741. private _startMonitoringGamepads;
  105742. private _stopMonitoringGamepads;
  105743. /** @hidden */
  105744. _checkGamepadsStatus(): void;
  105745. private _updateGamepadObjects;
  105746. }
  105747. }
  105748. declare module BABYLON {
  105749. interface Scene {
  105750. /** @hidden */
  105751. _gamepadManager: Nullable<GamepadManager>;
  105752. /**
  105753. * Gets the gamepad manager associated with the scene
  105754. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105755. */
  105756. gamepadManager: GamepadManager;
  105757. }
  105758. /**
  105759. * Interface representing a free camera inputs manager
  105760. */
  105761. interface FreeCameraInputsManager {
  105762. /**
  105763. * Adds gamepad input support to the FreeCameraInputsManager.
  105764. * @returns the FreeCameraInputsManager
  105765. */
  105766. addGamepad(): FreeCameraInputsManager;
  105767. }
  105768. /**
  105769. * Interface representing an arc rotate camera inputs manager
  105770. */
  105771. interface ArcRotateCameraInputsManager {
  105772. /**
  105773. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105774. * @returns the camera inputs manager
  105775. */
  105776. addGamepad(): ArcRotateCameraInputsManager;
  105777. }
  105778. /**
  105779. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105780. */
  105781. export class GamepadSystemSceneComponent implements ISceneComponent {
  105782. /**
  105783. * The component name helpfull to identify the component in the list of scene components.
  105784. */
  105785. readonly name: string;
  105786. /**
  105787. * The scene the component belongs to.
  105788. */
  105789. scene: Scene;
  105790. /**
  105791. * Creates a new instance of the component for the given scene
  105792. * @param scene Defines the scene to register the component in
  105793. */
  105794. constructor(scene: Scene);
  105795. /**
  105796. * Registers the component in a given scene
  105797. */
  105798. register(): void;
  105799. /**
  105800. * Rebuilds the elements related to this component in case of
  105801. * context lost for instance.
  105802. */
  105803. rebuild(): void;
  105804. /**
  105805. * Disposes the component and the associated ressources
  105806. */
  105807. dispose(): void;
  105808. private _beforeCameraUpdate;
  105809. }
  105810. }
  105811. declare module BABYLON {
  105812. /**
  105813. * 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,
  105814. * which still works and will still be found in many Playgrounds.
  105815. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105816. */
  105817. export class UniversalCamera extends TouchCamera {
  105818. /**
  105819. * Defines the gamepad rotation sensiblity.
  105820. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105821. */
  105822. gamepadAngularSensibility: number;
  105823. /**
  105824. * Defines the gamepad move sensiblity.
  105825. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105826. */
  105827. gamepadMoveSensibility: number;
  105828. /**
  105829. * 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,
  105830. * which still works and will still be found in many Playgrounds.
  105831. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105832. * @param name Define the name of the camera in the scene
  105833. * @param position Define the start position of the camera in the scene
  105834. * @param scene Define the scene the camera belongs to
  105835. */
  105836. constructor(name: string, position: Vector3, scene: Scene);
  105837. /**
  105838. * Gets the current object class name.
  105839. * @return the class name
  105840. */
  105841. getClassName(): string;
  105842. }
  105843. }
  105844. declare module BABYLON {
  105845. /**
  105846. * This represents a FPS type of camera. This is only here for back compat purpose.
  105847. * Please use the UniversalCamera instead as both are identical.
  105848. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105849. */
  105850. export class GamepadCamera extends UniversalCamera {
  105851. /**
  105852. * Instantiates a new Gamepad Camera
  105853. * This represents a FPS type of camera. This is only here for back compat purpose.
  105854. * Please use the UniversalCamera instead as both are identical.
  105855. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105856. * @param name Define the name of the camera in the scene
  105857. * @param position Define the start position of the camera in the scene
  105858. * @param scene Define the scene the camera belongs to
  105859. */
  105860. constructor(name: string, position: Vector3, scene: Scene);
  105861. /**
  105862. * Gets the current object class name.
  105863. * @return the class name
  105864. */
  105865. getClassName(): string;
  105866. }
  105867. }
  105868. declare module BABYLON {
  105869. /** @hidden */
  105870. export var passPixelShader: {
  105871. name: string;
  105872. shader: string;
  105873. };
  105874. }
  105875. declare module BABYLON {
  105876. /** @hidden */
  105877. export var passCubePixelShader: {
  105878. name: string;
  105879. shader: string;
  105880. };
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * PassPostProcess which produces an output the same as it's input
  105885. */
  105886. export class PassPostProcess extends PostProcess {
  105887. /**
  105888. * Creates the PassPostProcess
  105889. * @param name The name of the effect.
  105890. * @param options The required width/height ratio to downsize to before computing the render pass.
  105891. * @param camera The camera to apply the render pass to.
  105892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105893. * @param engine The engine which the post process will be applied. (default: current engine)
  105894. * @param reusable If the post process can be reused on the same frame. (default: false)
  105895. * @param textureType The type of texture to be used when performing the post processing.
  105896. * @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)
  105897. */
  105898. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105899. }
  105900. /**
  105901. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105902. */
  105903. export class PassCubePostProcess extends PostProcess {
  105904. private _face;
  105905. /**
  105906. * Gets or sets the cube face to display.
  105907. * * 0 is +X
  105908. * * 1 is -X
  105909. * * 2 is +Y
  105910. * * 3 is -Y
  105911. * * 4 is +Z
  105912. * * 5 is -Z
  105913. */
  105914. face: number;
  105915. /**
  105916. * Creates the PassCubePostProcess
  105917. * @param name The name of the effect.
  105918. * @param options The required width/height ratio to downsize to before computing the render pass.
  105919. * @param camera The camera to apply the render pass to.
  105920. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105921. * @param engine The engine which the post process will be applied. (default: current engine)
  105922. * @param reusable If the post process can be reused on the same frame. (default: false)
  105923. * @param textureType The type of texture to be used when performing the post processing.
  105924. * @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)
  105925. */
  105926. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105927. }
  105928. }
  105929. declare module BABYLON {
  105930. /** @hidden */
  105931. export var anaglyphPixelShader: {
  105932. name: string;
  105933. shader: string;
  105934. };
  105935. }
  105936. declare module BABYLON {
  105937. /**
  105938. * Postprocess used to generate anaglyphic rendering
  105939. */
  105940. export class AnaglyphPostProcess extends PostProcess {
  105941. private _passedProcess;
  105942. /**
  105943. * Creates a new AnaglyphPostProcess
  105944. * @param name defines postprocess name
  105945. * @param options defines creation options or target ratio scale
  105946. * @param rigCameras defines cameras using this postprocess
  105947. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105948. * @param engine defines hosting engine
  105949. * @param reusable defines if the postprocess will be reused multiple times per frame
  105950. */
  105951. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105952. }
  105953. }
  105954. declare module BABYLON {
  105955. /**
  105956. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105957. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105958. */
  105959. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105960. /**
  105961. * Creates a new AnaglyphArcRotateCamera
  105962. * @param name defines camera name
  105963. * @param alpha defines alpha angle (in radians)
  105964. * @param beta defines beta angle (in radians)
  105965. * @param radius defines radius
  105966. * @param target defines camera target
  105967. * @param interaxialDistance defines distance between each color axis
  105968. * @param scene defines the hosting scene
  105969. */
  105970. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105971. /**
  105972. * Gets camera class name
  105973. * @returns AnaglyphArcRotateCamera
  105974. */
  105975. getClassName(): string;
  105976. }
  105977. }
  105978. declare module BABYLON {
  105979. /**
  105980. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105981. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105982. */
  105983. export class AnaglyphFreeCamera extends FreeCamera {
  105984. /**
  105985. * Creates a new AnaglyphFreeCamera
  105986. * @param name defines camera name
  105987. * @param position defines initial position
  105988. * @param interaxialDistance defines distance between each color axis
  105989. * @param scene defines the hosting scene
  105990. */
  105991. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105992. /**
  105993. * Gets camera class name
  105994. * @returns AnaglyphFreeCamera
  105995. */
  105996. getClassName(): string;
  105997. }
  105998. }
  105999. declare module BABYLON {
  106000. /**
  106001. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106002. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106003. */
  106004. export class AnaglyphGamepadCamera extends GamepadCamera {
  106005. /**
  106006. * Creates a new AnaglyphGamepadCamera
  106007. * @param name defines camera name
  106008. * @param position defines initial position
  106009. * @param interaxialDistance defines distance between each color axis
  106010. * @param scene defines the hosting scene
  106011. */
  106012. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106013. /**
  106014. * Gets camera class name
  106015. * @returns AnaglyphGamepadCamera
  106016. */
  106017. getClassName(): string;
  106018. }
  106019. }
  106020. declare module BABYLON {
  106021. /**
  106022. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106023. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106024. */
  106025. export class AnaglyphUniversalCamera extends UniversalCamera {
  106026. /**
  106027. * Creates a new AnaglyphUniversalCamera
  106028. * @param name defines camera name
  106029. * @param position defines initial position
  106030. * @param interaxialDistance defines distance between each color axis
  106031. * @param scene defines the hosting scene
  106032. */
  106033. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106034. /**
  106035. * Gets camera class name
  106036. * @returns AnaglyphUniversalCamera
  106037. */
  106038. getClassName(): string;
  106039. }
  106040. }
  106041. declare module BABYLON {
  106042. /** @hidden */
  106043. export var stereoscopicInterlacePixelShader: {
  106044. name: string;
  106045. shader: string;
  106046. };
  106047. }
  106048. declare module BABYLON {
  106049. /**
  106050. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106051. */
  106052. export class StereoscopicInterlacePostProcess extends PostProcess {
  106053. private _stepSize;
  106054. private _passedProcess;
  106055. /**
  106056. * Initializes a StereoscopicInterlacePostProcess
  106057. * @param name The name of the effect.
  106058. * @param rigCameras The rig cameras to be appled to the post process
  106059. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106061. * @param engine The engine which the post process will be applied. (default: current engine)
  106062. * @param reusable If the post process can be reused on the same frame. (default: false)
  106063. */
  106064. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106065. }
  106066. }
  106067. declare module BABYLON {
  106068. /**
  106069. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106070. * @see http://doc.babylonjs.com/features/cameras
  106071. */
  106072. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106073. /**
  106074. * Creates a new StereoscopicArcRotateCamera
  106075. * @param name defines camera name
  106076. * @param alpha defines alpha angle (in radians)
  106077. * @param beta defines beta angle (in radians)
  106078. * @param radius defines radius
  106079. * @param target defines camera target
  106080. * @param interaxialDistance defines distance between each color axis
  106081. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106082. * @param scene defines the hosting scene
  106083. */
  106084. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106085. /**
  106086. * Gets camera class name
  106087. * @returns StereoscopicArcRotateCamera
  106088. */
  106089. getClassName(): string;
  106090. }
  106091. }
  106092. declare module BABYLON {
  106093. /**
  106094. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106095. * @see http://doc.babylonjs.com/features/cameras
  106096. */
  106097. export class StereoscopicFreeCamera extends FreeCamera {
  106098. /**
  106099. * Creates a new StereoscopicFreeCamera
  106100. * @param name defines camera name
  106101. * @param position defines initial position
  106102. * @param interaxialDistance defines distance between each color axis
  106103. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106104. * @param scene defines the hosting scene
  106105. */
  106106. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106107. /**
  106108. * Gets camera class name
  106109. * @returns StereoscopicFreeCamera
  106110. */
  106111. getClassName(): string;
  106112. }
  106113. }
  106114. declare module BABYLON {
  106115. /**
  106116. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106117. * @see http://doc.babylonjs.com/features/cameras
  106118. */
  106119. export class StereoscopicGamepadCamera extends GamepadCamera {
  106120. /**
  106121. * Creates a new StereoscopicGamepadCamera
  106122. * @param name defines camera name
  106123. * @param position defines initial position
  106124. * @param interaxialDistance defines distance between each color axis
  106125. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106126. * @param scene defines the hosting scene
  106127. */
  106128. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106129. /**
  106130. * Gets camera class name
  106131. * @returns StereoscopicGamepadCamera
  106132. */
  106133. getClassName(): string;
  106134. }
  106135. }
  106136. declare module BABYLON {
  106137. /**
  106138. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106139. * @see http://doc.babylonjs.com/features/cameras
  106140. */
  106141. export class StereoscopicUniversalCamera extends UniversalCamera {
  106142. /**
  106143. * Creates a new StereoscopicUniversalCamera
  106144. * @param name defines camera name
  106145. * @param position defines initial position
  106146. * @param interaxialDistance defines distance between each color axis
  106147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106148. * @param scene defines the hosting scene
  106149. */
  106150. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106151. /**
  106152. * Gets camera class name
  106153. * @returns StereoscopicUniversalCamera
  106154. */
  106155. getClassName(): string;
  106156. }
  106157. }
  106158. declare module BABYLON {
  106159. /**
  106160. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106161. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106162. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106163. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106164. */
  106165. export class VirtualJoysticksCamera extends FreeCamera {
  106166. /**
  106167. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106168. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106169. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106170. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106171. * @param name Define the name of the camera in the scene
  106172. * @param position Define the start position of the camera in the scene
  106173. * @param scene Define the scene the camera belongs to
  106174. */
  106175. constructor(name: string, position: Vector3, scene: Scene);
  106176. /**
  106177. * Gets the current object class name.
  106178. * @return the class name
  106179. */
  106180. getClassName(): string;
  106181. }
  106182. }
  106183. declare module BABYLON {
  106184. /**
  106185. * This represents all the required metrics to create a VR camera.
  106186. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106187. */
  106188. export class VRCameraMetrics {
  106189. /**
  106190. * Define the horizontal resolution off the screen.
  106191. */
  106192. hResolution: number;
  106193. /**
  106194. * Define the vertical resolution off the screen.
  106195. */
  106196. vResolution: number;
  106197. /**
  106198. * Define the horizontal screen size.
  106199. */
  106200. hScreenSize: number;
  106201. /**
  106202. * Define the vertical screen size.
  106203. */
  106204. vScreenSize: number;
  106205. /**
  106206. * Define the vertical screen center position.
  106207. */
  106208. vScreenCenter: number;
  106209. /**
  106210. * Define the distance of the eyes to the screen.
  106211. */
  106212. eyeToScreenDistance: number;
  106213. /**
  106214. * Define the distance between both lenses
  106215. */
  106216. lensSeparationDistance: number;
  106217. /**
  106218. * Define the distance between both viewer's eyes.
  106219. */
  106220. interpupillaryDistance: number;
  106221. /**
  106222. * Define the distortion factor of the VR postprocess.
  106223. * Please, touch with care.
  106224. */
  106225. distortionK: number[];
  106226. /**
  106227. * Define the chromatic aberration correction factors for the VR post process.
  106228. */
  106229. chromaAbCorrection: number[];
  106230. /**
  106231. * Define the scale factor of the post process.
  106232. * The smaller the better but the slower.
  106233. */
  106234. postProcessScaleFactor: number;
  106235. /**
  106236. * Define an offset for the lens center.
  106237. */
  106238. lensCenterOffset: number;
  106239. /**
  106240. * Define if the current vr camera should compensate the distortion of the lense or not.
  106241. */
  106242. compensateDistortion: boolean;
  106243. /**
  106244. * Defines if multiview should be enabled when rendering (Default: false)
  106245. */
  106246. multiviewEnabled: boolean;
  106247. /**
  106248. * Gets the rendering aspect ratio based on the provided resolutions.
  106249. */
  106250. readonly aspectRatio: number;
  106251. /**
  106252. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106253. */
  106254. readonly aspectRatioFov: number;
  106255. /**
  106256. * @hidden
  106257. */
  106258. readonly leftHMatrix: Matrix;
  106259. /**
  106260. * @hidden
  106261. */
  106262. readonly rightHMatrix: Matrix;
  106263. /**
  106264. * @hidden
  106265. */
  106266. readonly leftPreViewMatrix: Matrix;
  106267. /**
  106268. * @hidden
  106269. */
  106270. readonly rightPreViewMatrix: Matrix;
  106271. /**
  106272. * Get the default VRMetrics based on the most generic setup.
  106273. * @returns the default vr metrics
  106274. */
  106275. static GetDefault(): VRCameraMetrics;
  106276. }
  106277. }
  106278. declare module BABYLON {
  106279. /** @hidden */
  106280. export var vrDistortionCorrectionPixelShader: {
  106281. name: string;
  106282. shader: string;
  106283. };
  106284. }
  106285. declare module BABYLON {
  106286. /**
  106287. * VRDistortionCorrectionPostProcess used for mobile VR
  106288. */
  106289. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106290. private _isRightEye;
  106291. private _distortionFactors;
  106292. private _postProcessScaleFactor;
  106293. private _lensCenterOffset;
  106294. private _scaleIn;
  106295. private _scaleFactor;
  106296. private _lensCenter;
  106297. /**
  106298. * Initializes the VRDistortionCorrectionPostProcess
  106299. * @param name The name of the effect.
  106300. * @param camera The camera to apply the render pass to.
  106301. * @param isRightEye If this is for the right eye distortion
  106302. * @param vrMetrics All the required metrics for the VR camera
  106303. */
  106304. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106305. }
  106306. }
  106307. declare module BABYLON {
  106308. /**
  106309. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106310. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106311. */
  106312. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106313. /**
  106314. * Creates a new VRDeviceOrientationArcRotateCamera
  106315. * @param name defines camera name
  106316. * @param alpha defines the camera rotation along the logitudinal axis
  106317. * @param beta defines the camera rotation along the latitudinal axis
  106318. * @param radius defines the camera distance from its target
  106319. * @param target defines the camera target
  106320. * @param scene defines the scene the camera belongs to
  106321. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106322. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106323. */
  106324. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106325. /**
  106326. * Gets camera class name
  106327. * @returns VRDeviceOrientationArcRotateCamera
  106328. */
  106329. getClassName(): string;
  106330. }
  106331. }
  106332. declare module BABYLON {
  106333. /**
  106334. * Camera used to simulate VR rendering (based on FreeCamera)
  106335. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106336. */
  106337. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106338. /**
  106339. * Creates a new VRDeviceOrientationFreeCamera
  106340. * @param name defines camera name
  106341. * @param position defines the start position of the camera
  106342. * @param scene defines the scene the camera belongs to
  106343. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106344. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106345. */
  106346. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106347. /**
  106348. * Gets camera class name
  106349. * @returns VRDeviceOrientationFreeCamera
  106350. */
  106351. getClassName(): string;
  106352. }
  106353. }
  106354. declare module BABYLON {
  106355. /**
  106356. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106357. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106358. */
  106359. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106360. /**
  106361. * Creates a new VRDeviceOrientationGamepadCamera
  106362. * @param name defines camera name
  106363. * @param position defines the start position of the camera
  106364. * @param scene defines the scene the camera belongs to
  106365. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106366. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106367. */
  106368. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106369. /**
  106370. * Gets camera class name
  106371. * @returns VRDeviceOrientationGamepadCamera
  106372. */
  106373. getClassName(): string;
  106374. }
  106375. }
  106376. declare module BABYLON {
  106377. /**
  106378. * Base class of materials working in push mode in babylon JS
  106379. * @hidden
  106380. */
  106381. export class PushMaterial extends Material {
  106382. protected _activeEffect: Effect;
  106383. protected _normalMatrix: Matrix;
  106384. /**
  106385. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106386. * This means that the material can keep using a previous shader while a new one is being compiled.
  106387. * This is mostly used when shader parallel compilation is supported (true by default)
  106388. */
  106389. allowShaderHotSwapping: boolean;
  106390. constructor(name: string, scene: Scene);
  106391. getEffect(): Effect;
  106392. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106393. /**
  106394. * Binds the given world matrix to the active effect
  106395. *
  106396. * @param world the matrix to bind
  106397. */
  106398. bindOnlyWorldMatrix(world: Matrix): void;
  106399. /**
  106400. * Binds the given normal matrix to the active effect
  106401. *
  106402. * @param normalMatrix the matrix to bind
  106403. */
  106404. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106405. bind(world: Matrix, mesh?: Mesh): void;
  106406. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106407. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106408. }
  106409. }
  106410. declare module BABYLON {
  106411. /**
  106412. * This groups all the flags used to control the materials channel.
  106413. */
  106414. export class MaterialFlags {
  106415. private static _DiffuseTextureEnabled;
  106416. /**
  106417. * Are diffuse textures enabled in the application.
  106418. */
  106419. static DiffuseTextureEnabled: boolean;
  106420. private static _AmbientTextureEnabled;
  106421. /**
  106422. * Are ambient textures enabled in the application.
  106423. */
  106424. static AmbientTextureEnabled: boolean;
  106425. private static _OpacityTextureEnabled;
  106426. /**
  106427. * Are opacity textures enabled in the application.
  106428. */
  106429. static OpacityTextureEnabled: boolean;
  106430. private static _ReflectionTextureEnabled;
  106431. /**
  106432. * Are reflection textures enabled in the application.
  106433. */
  106434. static ReflectionTextureEnabled: boolean;
  106435. private static _EmissiveTextureEnabled;
  106436. /**
  106437. * Are emissive textures enabled in the application.
  106438. */
  106439. static EmissiveTextureEnabled: boolean;
  106440. private static _SpecularTextureEnabled;
  106441. /**
  106442. * Are specular textures enabled in the application.
  106443. */
  106444. static SpecularTextureEnabled: boolean;
  106445. private static _BumpTextureEnabled;
  106446. /**
  106447. * Are bump textures enabled in the application.
  106448. */
  106449. static BumpTextureEnabled: boolean;
  106450. private static _LightmapTextureEnabled;
  106451. /**
  106452. * Are lightmap textures enabled in the application.
  106453. */
  106454. static LightmapTextureEnabled: boolean;
  106455. private static _RefractionTextureEnabled;
  106456. /**
  106457. * Are refraction textures enabled in the application.
  106458. */
  106459. static RefractionTextureEnabled: boolean;
  106460. private static _ColorGradingTextureEnabled;
  106461. /**
  106462. * Are color grading textures enabled in the application.
  106463. */
  106464. static ColorGradingTextureEnabled: boolean;
  106465. private static _FresnelEnabled;
  106466. /**
  106467. * Are fresnels enabled in the application.
  106468. */
  106469. static FresnelEnabled: boolean;
  106470. private static _ClearCoatTextureEnabled;
  106471. /**
  106472. * Are clear coat textures enabled in the application.
  106473. */
  106474. static ClearCoatTextureEnabled: boolean;
  106475. private static _ClearCoatBumpTextureEnabled;
  106476. /**
  106477. * Are clear coat bump textures enabled in the application.
  106478. */
  106479. static ClearCoatBumpTextureEnabled: boolean;
  106480. private static _ClearCoatTintTextureEnabled;
  106481. /**
  106482. * Are clear coat tint textures enabled in the application.
  106483. */
  106484. static ClearCoatTintTextureEnabled: boolean;
  106485. private static _SheenTextureEnabled;
  106486. /**
  106487. * Are sheen textures enabled in the application.
  106488. */
  106489. static SheenTextureEnabled: boolean;
  106490. private static _AnisotropicTextureEnabled;
  106491. /**
  106492. * Are anisotropic textures enabled in the application.
  106493. */
  106494. static AnisotropicTextureEnabled: boolean;
  106495. private static _ThicknessTextureEnabled;
  106496. /**
  106497. * Are thickness textures enabled in the application.
  106498. */
  106499. static ThicknessTextureEnabled: boolean;
  106500. }
  106501. }
  106502. declare module BABYLON {
  106503. /** @hidden */
  106504. export var defaultFragmentDeclaration: {
  106505. name: string;
  106506. shader: string;
  106507. };
  106508. }
  106509. declare module BABYLON {
  106510. /** @hidden */
  106511. export var defaultUboDeclaration: {
  106512. name: string;
  106513. shader: string;
  106514. };
  106515. }
  106516. declare module BABYLON {
  106517. /** @hidden */
  106518. export var lightFragmentDeclaration: {
  106519. name: string;
  106520. shader: string;
  106521. };
  106522. }
  106523. declare module BABYLON {
  106524. /** @hidden */
  106525. export var lightUboDeclaration: {
  106526. name: string;
  106527. shader: string;
  106528. };
  106529. }
  106530. declare module BABYLON {
  106531. /** @hidden */
  106532. export var lightsFragmentFunctions: {
  106533. name: string;
  106534. shader: string;
  106535. };
  106536. }
  106537. declare module BABYLON {
  106538. /** @hidden */
  106539. export var shadowsFragmentFunctions: {
  106540. name: string;
  106541. shader: string;
  106542. };
  106543. }
  106544. declare module BABYLON {
  106545. /** @hidden */
  106546. export var fresnelFunction: {
  106547. name: string;
  106548. shader: string;
  106549. };
  106550. }
  106551. declare module BABYLON {
  106552. /** @hidden */
  106553. export var reflectionFunction: {
  106554. name: string;
  106555. shader: string;
  106556. };
  106557. }
  106558. declare module BABYLON {
  106559. /** @hidden */
  106560. export var bumpFragmentFunctions: {
  106561. name: string;
  106562. shader: string;
  106563. };
  106564. }
  106565. declare module BABYLON {
  106566. /** @hidden */
  106567. export var logDepthDeclaration: {
  106568. name: string;
  106569. shader: string;
  106570. };
  106571. }
  106572. declare module BABYLON {
  106573. /** @hidden */
  106574. export var bumpFragment: {
  106575. name: string;
  106576. shader: string;
  106577. };
  106578. }
  106579. declare module BABYLON {
  106580. /** @hidden */
  106581. export var depthPrePass: {
  106582. name: string;
  106583. shader: string;
  106584. };
  106585. }
  106586. declare module BABYLON {
  106587. /** @hidden */
  106588. export var lightFragment: {
  106589. name: string;
  106590. shader: string;
  106591. };
  106592. }
  106593. declare module BABYLON {
  106594. /** @hidden */
  106595. export var logDepthFragment: {
  106596. name: string;
  106597. shader: string;
  106598. };
  106599. }
  106600. declare module BABYLON {
  106601. /** @hidden */
  106602. export var defaultPixelShader: {
  106603. name: string;
  106604. shader: string;
  106605. };
  106606. }
  106607. declare module BABYLON {
  106608. /** @hidden */
  106609. export var defaultVertexDeclaration: {
  106610. name: string;
  106611. shader: string;
  106612. };
  106613. }
  106614. declare module BABYLON {
  106615. /** @hidden */
  106616. export var bumpVertexDeclaration: {
  106617. name: string;
  106618. shader: string;
  106619. };
  106620. }
  106621. declare module BABYLON {
  106622. /** @hidden */
  106623. export var bumpVertex: {
  106624. name: string;
  106625. shader: string;
  106626. };
  106627. }
  106628. declare module BABYLON {
  106629. /** @hidden */
  106630. export var fogVertex: {
  106631. name: string;
  106632. shader: string;
  106633. };
  106634. }
  106635. declare module BABYLON {
  106636. /** @hidden */
  106637. export var shadowsVertex: {
  106638. name: string;
  106639. shader: string;
  106640. };
  106641. }
  106642. declare module BABYLON {
  106643. /** @hidden */
  106644. export var pointCloudVertex: {
  106645. name: string;
  106646. shader: string;
  106647. };
  106648. }
  106649. declare module BABYLON {
  106650. /** @hidden */
  106651. export var logDepthVertex: {
  106652. name: string;
  106653. shader: string;
  106654. };
  106655. }
  106656. declare module BABYLON {
  106657. /** @hidden */
  106658. export var defaultVertexShader: {
  106659. name: string;
  106660. shader: string;
  106661. };
  106662. }
  106663. declare module BABYLON {
  106664. /** @hidden */
  106665. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106666. MAINUV1: boolean;
  106667. MAINUV2: boolean;
  106668. DIFFUSE: boolean;
  106669. DIFFUSEDIRECTUV: number;
  106670. AMBIENT: boolean;
  106671. AMBIENTDIRECTUV: number;
  106672. OPACITY: boolean;
  106673. OPACITYDIRECTUV: number;
  106674. OPACITYRGB: boolean;
  106675. REFLECTION: boolean;
  106676. EMISSIVE: boolean;
  106677. EMISSIVEDIRECTUV: number;
  106678. SPECULAR: boolean;
  106679. SPECULARDIRECTUV: number;
  106680. BUMP: boolean;
  106681. BUMPDIRECTUV: number;
  106682. PARALLAX: boolean;
  106683. PARALLAXOCCLUSION: boolean;
  106684. SPECULAROVERALPHA: boolean;
  106685. CLIPPLANE: boolean;
  106686. CLIPPLANE2: boolean;
  106687. CLIPPLANE3: boolean;
  106688. CLIPPLANE4: boolean;
  106689. ALPHATEST: boolean;
  106690. DEPTHPREPASS: boolean;
  106691. ALPHAFROMDIFFUSE: boolean;
  106692. POINTSIZE: boolean;
  106693. FOG: boolean;
  106694. SPECULARTERM: boolean;
  106695. DIFFUSEFRESNEL: boolean;
  106696. OPACITYFRESNEL: boolean;
  106697. REFLECTIONFRESNEL: boolean;
  106698. REFRACTIONFRESNEL: boolean;
  106699. EMISSIVEFRESNEL: boolean;
  106700. FRESNEL: boolean;
  106701. NORMAL: boolean;
  106702. UV1: boolean;
  106703. UV2: boolean;
  106704. VERTEXCOLOR: boolean;
  106705. VERTEXALPHA: boolean;
  106706. NUM_BONE_INFLUENCERS: number;
  106707. BonesPerMesh: number;
  106708. BONETEXTURE: boolean;
  106709. INSTANCES: boolean;
  106710. GLOSSINESS: boolean;
  106711. ROUGHNESS: boolean;
  106712. EMISSIVEASILLUMINATION: boolean;
  106713. LINKEMISSIVEWITHDIFFUSE: boolean;
  106714. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106715. LIGHTMAP: boolean;
  106716. LIGHTMAPDIRECTUV: number;
  106717. OBJECTSPACE_NORMALMAP: boolean;
  106718. USELIGHTMAPASSHADOWMAP: boolean;
  106719. REFLECTIONMAP_3D: boolean;
  106720. REFLECTIONMAP_SPHERICAL: boolean;
  106721. REFLECTIONMAP_PLANAR: boolean;
  106722. REFLECTIONMAP_CUBIC: boolean;
  106723. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106724. REFLECTIONMAP_PROJECTION: boolean;
  106725. REFLECTIONMAP_SKYBOX: boolean;
  106726. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106727. REFLECTIONMAP_EXPLICIT: boolean;
  106728. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106729. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106730. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106731. INVERTCUBICMAP: boolean;
  106732. LOGARITHMICDEPTH: boolean;
  106733. REFRACTION: boolean;
  106734. REFRACTIONMAP_3D: boolean;
  106735. REFLECTIONOVERALPHA: boolean;
  106736. TWOSIDEDLIGHTING: boolean;
  106737. SHADOWFLOAT: boolean;
  106738. MORPHTARGETS: boolean;
  106739. MORPHTARGETS_NORMAL: boolean;
  106740. MORPHTARGETS_TANGENT: boolean;
  106741. MORPHTARGETS_UV: boolean;
  106742. NUM_MORPH_INFLUENCERS: number;
  106743. NONUNIFORMSCALING: boolean;
  106744. PREMULTIPLYALPHA: boolean;
  106745. IMAGEPROCESSING: boolean;
  106746. VIGNETTE: boolean;
  106747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106748. VIGNETTEBLENDMODEOPAQUE: boolean;
  106749. TONEMAPPING: boolean;
  106750. TONEMAPPING_ACES: boolean;
  106751. CONTRAST: boolean;
  106752. COLORCURVES: boolean;
  106753. COLORGRADING: boolean;
  106754. COLORGRADING3D: boolean;
  106755. SAMPLER3DGREENDEPTH: boolean;
  106756. SAMPLER3DBGRMAP: boolean;
  106757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106758. MULTIVIEW: boolean;
  106759. /**
  106760. * If the reflection texture on this material is in linear color space
  106761. * @hidden
  106762. */
  106763. IS_REFLECTION_LINEAR: boolean;
  106764. /**
  106765. * If the refraction texture on this material is in linear color space
  106766. * @hidden
  106767. */
  106768. IS_REFRACTION_LINEAR: boolean;
  106769. EXPOSURE: boolean;
  106770. constructor();
  106771. setReflectionMode(modeToEnable: string): void;
  106772. }
  106773. /**
  106774. * This is the default material used in Babylon. It is the best trade off between quality
  106775. * and performances.
  106776. * @see http://doc.babylonjs.com/babylon101/materials
  106777. */
  106778. export class StandardMaterial extends PushMaterial {
  106779. private _diffuseTexture;
  106780. /**
  106781. * The basic texture of the material as viewed under a light.
  106782. */
  106783. diffuseTexture: Nullable<BaseTexture>;
  106784. private _ambientTexture;
  106785. /**
  106786. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106787. */
  106788. ambientTexture: Nullable<BaseTexture>;
  106789. private _opacityTexture;
  106790. /**
  106791. * Define the transparency of the material from a texture.
  106792. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106793. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106794. */
  106795. opacityTexture: Nullable<BaseTexture>;
  106796. private _reflectionTexture;
  106797. /**
  106798. * Define the texture used to display the reflection.
  106799. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106800. */
  106801. reflectionTexture: Nullable<BaseTexture>;
  106802. private _emissiveTexture;
  106803. /**
  106804. * Define texture of the material as if self lit.
  106805. * This will be mixed in the final result even in the absence of light.
  106806. */
  106807. emissiveTexture: Nullable<BaseTexture>;
  106808. private _specularTexture;
  106809. /**
  106810. * Define how the color and intensity of the highlight given by the light in the material.
  106811. */
  106812. specularTexture: Nullable<BaseTexture>;
  106813. private _bumpTexture;
  106814. /**
  106815. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106816. * 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.
  106817. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106818. */
  106819. bumpTexture: Nullable<BaseTexture>;
  106820. private _lightmapTexture;
  106821. /**
  106822. * Complex lighting can be computationally expensive to compute at runtime.
  106823. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106824. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106825. */
  106826. lightmapTexture: Nullable<BaseTexture>;
  106827. private _refractionTexture;
  106828. /**
  106829. * Define the texture used to display the refraction.
  106830. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106831. */
  106832. refractionTexture: Nullable<BaseTexture>;
  106833. /**
  106834. * The color of the material lit by the environmental background lighting.
  106835. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106836. */
  106837. ambientColor: Color3;
  106838. /**
  106839. * The basic color of the material as viewed under a light.
  106840. */
  106841. diffuseColor: Color3;
  106842. /**
  106843. * Define how the color and intensity of the highlight given by the light in the material.
  106844. */
  106845. specularColor: Color3;
  106846. /**
  106847. * Define the color of the material as if self lit.
  106848. * This will be mixed in the final result even in the absence of light.
  106849. */
  106850. emissiveColor: Color3;
  106851. /**
  106852. * Defines how sharp are the highlights in the material.
  106853. * The bigger the value the sharper giving a more glossy feeling to the result.
  106854. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106855. */
  106856. specularPower: number;
  106857. private _useAlphaFromDiffuseTexture;
  106858. /**
  106859. * Does the transparency come from the diffuse texture alpha channel.
  106860. */
  106861. useAlphaFromDiffuseTexture: boolean;
  106862. private _useEmissiveAsIllumination;
  106863. /**
  106864. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106865. */
  106866. useEmissiveAsIllumination: boolean;
  106867. private _linkEmissiveWithDiffuse;
  106868. /**
  106869. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106870. * the emissive level when the final color is close to one.
  106871. */
  106872. linkEmissiveWithDiffuse: boolean;
  106873. private _useSpecularOverAlpha;
  106874. /**
  106875. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106876. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106877. */
  106878. useSpecularOverAlpha: boolean;
  106879. private _useReflectionOverAlpha;
  106880. /**
  106881. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106882. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106883. */
  106884. useReflectionOverAlpha: boolean;
  106885. private _disableLighting;
  106886. /**
  106887. * Does lights from the scene impacts this material.
  106888. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106889. */
  106890. disableLighting: boolean;
  106891. private _useObjectSpaceNormalMap;
  106892. /**
  106893. * Allows using an object space normal map (instead of tangent space).
  106894. */
  106895. useObjectSpaceNormalMap: boolean;
  106896. private _useParallax;
  106897. /**
  106898. * Is parallax enabled or not.
  106899. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106900. */
  106901. useParallax: boolean;
  106902. private _useParallaxOcclusion;
  106903. /**
  106904. * Is parallax occlusion enabled or not.
  106905. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106906. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106907. */
  106908. useParallaxOcclusion: boolean;
  106909. /**
  106910. * 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.
  106911. */
  106912. parallaxScaleBias: number;
  106913. private _roughness;
  106914. /**
  106915. * Helps to define how blurry the reflections should appears in the material.
  106916. */
  106917. roughness: number;
  106918. /**
  106919. * In case of refraction, define the value of the index of refraction.
  106920. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106921. */
  106922. indexOfRefraction: number;
  106923. /**
  106924. * Invert the refraction texture alongside the y axis.
  106925. * It can be useful with procedural textures or probe for instance.
  106926. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106927. */
  106928. invertRefractionY: boolean;
  106929. /**
  106930. * Defines the alpha limits in alpha test mode.
  106931. */
  106932. alphaCutOff: number;
  106933. private _useLightmapAsShadowmap;
  106934. /**
  106935. * In case of light mapping, define whether the map contains light or shadow informations.
  106936. */
  106937. useLightmapAsShadowmap: boolean;
  106938. private _diffuseFresnelParameters;
  106939. /**
  106940. * Define the diffuse fresnel parameters of the material.
  106941. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106942. */
  106943. diffuseFresnelParameters: FresnelParameters;
  106944. private _opacityFresnelParameters;
  106945. /**
  106946. * Define the opacity fresnel parameters of the material.
  106947. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106948. */
  106949. opacityFresnelParameters: FresnelParameters;
  106950. private _reflectionFresnelParameters;
  106951. /**
  106952. * Define the reflection fresnel parameters of the material.
  106953. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106954. */
  106955. reflectionFresnelParameters: FresnelParameters;
  106956. private _refractionFresnelParameters;
  106957. /**
  106958. * Define the refraction fresnel parameters of the material.
  106959. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106960. */
  106961. refractionFresnelParameters: FresnelParameters;
  106962. private _emissiveFresnelParameters;
  106963. /**
  106964. * Define the emissive fresnel parameters of the material.
  106965. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106966. */
  106967. emissiveFresnelParameters: FresnelParameters;
  106968. private _useReflectionFresnelFromSpecular;
  106969. /**
  106970. * If true automatically deducts the fresnels values from the material specularity.
  106971. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106972. */
  106973. useReflectionFresnelFromSpecular: boolean;
  106974. private _useGlossinessFromSpecularMapAlpha;
  106975. /**
  106976. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106977. */
  106978. useGlossinessFromSpecularMapAlpha: boolean;
  106979. private _maxSimultaneousLights;
  106980. /**
  106981. * Defines the maximum number of lights that can be used in the material
  106982. */
  106983. maxSimultaneousLights: number;
  106984. private _invertNormalMapX;
  106985. /**
  106986. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106987. */
  106988. invertNormalMapX: boolean;
  106989. private _invertNormalMapY;
  106990. /**
  106991. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106992. */
  106993. invertNormalMapY: boolean;
  106994. private _twoSidedLighting;
  106995. /**
  106996. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106997. */
  106998. twoSidedLighting: boolean;
  106999. /**
  107000. * Default configuration related to image processing available in the standard Material.
  107001. */
  107002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107003. /**
  107004. * Gets the image processing configuration used either in this material.
  107005. */
  107006. /**
  107007. * Sets the Default image processing configuration used either in the this material.
  107008. *
  107009. * If sets to null, the scene one is in use.
  107010. */
  107011. imageProcessingConfiguration: ImageProcessingConfiguration;
  107012. /**
  107013. * Keep track of the image processing observer to allow dispose and replace.
  107014. */
  107015. private _imageProcessingObserver;
  107016. /**
  107017. * Attaches a new image processing configuration to the Standard Material.
  107018. * @param configuration
  107019. */
  107020. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107021. /**
  107022. * Gets wether the color curves effect is enabled.
  107023. */
  107024. /**
  107025. * Sets wether the color curves effect is enabled.
  107026. */
  107027. cameraColorCurvesEnabled: boolean;
  107028. /**
  107029. * Gets wether the color grading effect is enabled.
  107030. */
  107031. /**
  107032. * Gets wether the color grading effect is enabled.
  107033. */
  107034. cameraColorGradingEnabled: boolean;
  107035. /**
  107036. * Gets wether tonemapping is enabled or not.
  107037. */
  107038. /**
  107039. * Sets wether tonemapping is enabled or not
  107040. */
  107041. cameraToneMappingEnabled: boolean;
  107042. /**
  107043. * The camera exposure used on this material.
  107044. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107045. * This corresponds to a photographic exposure.
  107046. */
  107047. /**
  107048. * The camera exposure used on this material.
  107049. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107050. * This corresponds to a photographic exposure.
  107051. */
  107052. cameraExposure: number;
  107053. /**
  107054. * Gets The camera contrast used on this material.
  107055. */
  107056. /**
  107057. * Sets The camera contrast used on this material.
  107058. */
  107059. cameraContrast: number;
  107060. /**
  107061. * Gets the Color Grading 2D Lookup Texture.
  107062. */
  107063. /**
  107064. * Sets the Color Grading 2D Lookup Texture.
  107065. */
  107066. cameraColorGradingTexture: Nullable<BaseTexture>;
  107067. /**
  107068. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107069. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107070. * 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;
  107071. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107072. */
  107073. /**
  107074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107076. * 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;
  107077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107078. */
  107079. cameraColorCurves: Nullable<ColorCurves>;
  107080. /**
  107081. * Custom callback helping to override the default shader used in the material.
  107082. */
  107083. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107084. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107085. protected _worldViewProjectionMatrix: Matrix;
  107086. protected _globalAmbientColor: Color3;
  107087. protected _useLogarithmicDepth: boolean;
  107088. protected _rebuildInParallel: boolean;
  107089. /**
  107090. * Instantiates a new standard material.
  107091. * This is the default material used in Babylon. It is the best trade off between quality
  107092. * and performances.
  107093. * @see http://doc.babylonjs.com/babylon101/materials
  107094. * @param name Define the name of the material in the scene
  107095. * @param scene Define the scene the material belong to
  107096. */
  107097. constructor(name: string, scene: Scene);
  107098. /**
  107099. * Gets a boolean indicating that current material needs to register RTT
  107100. */
  107101. readonly hasRenderTargetTextures: boolean;
  107102. /**
  107103. * Gets the current class name of the material e.g. "StandardMaterial"
  107104. * Mainly use in serialization.
  107105. * @returns the class name
  107106. */
  107107. getClassName(): string;
  107108. /**
  107109. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107110. * You can try switching to logarithmic depth.
  107111. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107112. */
  107113. useLogarithmicDepth: boolean;
  107114. /**
  107115. * Specifies if the material will require alpha blending
  107116. * @returns a boolean specifying if alpha blending is needed
  107117. */
  107118. needAlphaBlending(): boolean;
  107119. /**
  107120. * Specifies if this material should be rendered in alpha test mode
  107121. * @returns a boolean specifying if an alpha test is needed.
  107122. */
  107123. needAlphaTesting(): boolean;
  107124. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107125. /**
  107126. * Get the texture used for alpha test purpose.
  107127. * @returns the diffuse texture in case of the standard material.
  107128. */
  107129. getAlphaTestTexture(): Nullable<BaseTexture>;
  107130. /**
  107131. * Get if the submesh is ready to be used and all its information available.
  107132. * Child classes can use it to update shaders
  107133. * @param mesh defines the mesh to check
  107134. * @param subMesh defines which submesh to check
  107135. * @param useInstances specifies that instances should be used
  107136. * @returns a boolean indicating that the submesh is ready or not
  107137. */
  107138. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107139. /**
  107140. * Builds the material UBO layouts.
  107141. * Used internally during the effect preparation.
  107142. */
  107143. buildUniformLayout(): void;
  107144. /**
  107145. * Unbinds the material from the mesh
  107146. */
  107147. unbind(): void;
  107148. /**
  107149. * Binds the submesh to this material by preparing the effect and shader to draw
  107150. * @param world defines the world transformation matrix
  107151. * @param mesh defines the mesh containing the submesh
  107152. * @param subMesh defines the submesh to bind the material to
  107153. */
  107154. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107155. /**
  107156. * Get the list of animatables in the material.
  107157. * @returns the list of animatables object used in the material
  107158. */
  107159. getAnimatables(): IAnimatable[];
  107160. /**
  107161. * Gets the active textures from the material
  107162. * @returns an array of textures
  107163. */
  107164. getActiveTextures(): BaseTexture[];
  107165. /**
  107166. * Specifies if the material uses a texture
  107167. * @param texture defines the texture to check against the material
  107168. * @returns a boolean specifying if the material uses the texture
  107169. */
  107170. hasTexture(texture: BaseTexture): boolean;
  107171. /**
  107172. * Disposes the material
  107173. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107174. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107175. */
  107176. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107177. /**
  107178. * Makes a duplicate of the material, and gives it a new name
  107179. * @param name defines the new name for the duplicated material
  107180. * @returns the cloned material
  107181. */
  107182. clone(name: string): StandardMaterial;
  107183. /**
  107184. * Serializes this material in a JSON representation
  107185. * @returns the serialized material object
  107186. */
  107187. serialize(): any;
  107188. /**
  107189. * Creates a standard material from parsed material data
  107190. * @param source defines the JSON representation of the material
  107191. * @param scene defines the hosting scene
  107192. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107193. * @returns a new standard material
  107194. */
  107195. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107196. /**
  107197. * Are diffuse textures enabled in the application.
  107198. */
  107199. static DiffuseTextureEnabled: boolean;
  107200. /**
  107201. * Are ambient textures enabled in the application.
  107202. */
  107203. static AmbientTextureEnabled: boolean;
  107204. /**
  107205. * Are opacity textures enabled in the application.
  107206. */
  107207. static OpacityTextureEnabled: boolean;
  107208. /**
  107209. * Are reflection textures enabled in the application.
  107210. */
  107211. static ReflectionTextureEnabled: boolean;
  107212. /**
  107213. * Are emissive textures enabled in the application.
  107214. */
  107215. static EmissiveTextureEnabled: boolean;
  107216. /**
  107217. * Are specular textures enabled in the application.
  107218. */
  107219. static SpecularTextureEnabled: boolean;
  107220. /**
  107221. * Are bump textures enabled in the application.
  107222. */
  107223. static BumpTextureEnabled: boolean;
  107224. /**
  107225. * Are lightmap textures enabled in the application.
  107226. */
  107227. static LightmapTextureEnabled: boolean;
  107228. /**
  107229. * Are refraction textures enabled in the application.
  107230. */
  107231. static RefractionTextureEnabled: boolean;
  107232. /**
  107233. * Are color grading textures enabled in the application.
  107234. */
  107235. static ColorGradingTextureEnabled: boolean;
  107236. /**
  107237. * Are fresnels enabled in the application.
  107238. */
  107239. static FresnelEnabled: boolean;
  107240. }
  107241. }
  107242. declare module BABYLON {
  107243. /** @hidden */
  107244. export var imageProcessingPixelShader: {
  107245. name: string;
  107246. shader: string;
  107247. };
  107248. }
  107249. declare module BABYLON {
  107250. /**
  107251. * ImageProcessingPostProcess
  107252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107253. */
  107254. export class ImageProcessingPostProcess extends PostProcess {
  107255. /**
  107256. * Default configuration related to image processing available in the PBR Material.
  107257. */
  107258. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107259. /**
  107260. * Gets the image processing configuration used either in this material.
  107261. */
  107262. /**
  107263. * Sets the Default image processing configuration used either in the this material.
  107264. *
  107265. * If sets to null, the scene one is in use.
  107266. */
  107267. imageProcessingConfiguration: ImageProcessingConfiguration;
  107268. /**
  107269. * Keep track of the image processing observer to allow dispose and replace.
  107270. */
  107271. private _imageProcessingObserver;
  107272. /**
  107273. * Attaches a new image processing configuration to the PBR Material.
  107274. * @param configuration
  107275. */
  107276. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107277. /**
  107278. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107279. */
  107280. /**
  107281. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107282. */
  107283. colorCurves: Nullable<ColorCurves>;
  107284. /**
  107285. * Gets wether the color curves effect is enabled.
  107286. */
  107287. /**
  107288. * Sets wether the color curves effect is enabled.
  107289. */
  107290. colorCurvesEnabled: boolean;
  107291. /**
  107292. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107293. */
  107294. /**
  107295. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107296. */
  107297. colorGradingTexture: Nullable<BaseTexture>;
  107298. /**
  107299. * Gets wether the color grading effect is enabled.
  107300. */
  107301. /**
  107302. * Gets wether the color grading effect is enabled.
  107303. */
  107304. colorGradingEnabled: boolean;
  107305. /**
  107306. * Gets exposure used in the effect.
  107307. */
  107308. /**
  107309. * Sets exposure used in the effect.
  107310. */
  107311. exposure: number;
  107312. /**
  107313. * Gets wether tonemapping is enabled or not.
  107314. */
  107315. /**
  107316. * Sets wether tonemapping is enabled or not
  107317. */
  107318. toneMappingEnabled: boolean;
  107319. /**
  107320. * Gets the type of tone mapping effect.
  107321. */
  107322. /**
  107323. * Sets the type of tone mapping effect.
  107324. */
  107325. toneMappingType: number;
  107326. /**
  107327. * Gets contrast used in the effect.
  107328. */
  107329. /**
  107330. * Sets contrast used in the effect.
  107331. */
  107332. contrast: number;
  107333. /**
  107334. * Gets Vignette stretch size.
  107335. */
  107336. /**
  107337. * Sets Vignette stretch size.
  107338. */
  107339. vignetteStretch: number;
  107340. /**
  107341. * Gets Vignette centre X Offset.
  107342. */
  107343. /**
  107344. * Sets Vignette centre X Offset.
  107345. */
  107346. vignetteCentreX: number;
  107347. /**
  107348. * Gets Vignette centre Y Offset.
  107349. */
  107350. /**
  107351. * Sets Vignette centre Y Offset.
  107352. */
  107353. vignetteCentreY: number;
  107354. /**
  107355. * Gets Vignette weight or intensity of the vignette effect.
  107356. */
  107357. /**
  107358. * Sets Vignette weight or intensity of the vignette effect.
  107359. */
  107360. vignetteWeight: number;
  107361. /**
  107362. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107363. * if vignetteEnabled is set to true.
  107364. */
  107365. /**
  107366. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107367. * if vignetteEnabled is set to true.
  107368. */
  107369. vignetteColor: Color4;
  107370. /**
  107371. * Gets Camera field of view used by the Vignette effect.
  107372. */
  107373. /**
  107374. * Sets Camera field of view used by the Vignette effect.
  107375. */
  107376. vignetteCameraFov: number;
  107377. /**
  107378. * Gets the vignette blend mode allowing different kind of effect.
  107379. */
  107380. /**
  107381. * Sets the vignette blend mode allowing different kind of effect.
  107382. */
  107383. vignetteBlendMode: number;
  107384. /**
  107385. * Gets wether the vignette effect is enabled.
  107386. */
  107387. /**
  107388. * Sets wether the vignette effect is enabled.
  107389. */
  107390. vignetteEnabled: boolean;
  107391. private _fromLinearSpace;
  107392. /**
  107393. * Gets wether the input of the processing is in Gamma or Linear Space.
  107394. */
  107395. /**
  107396. * Sets wether the input of the processing is in Gamma or Linear Space.
  107397. */
  107398. fromLinearSpace: boolean;
  107399. /**
  107400. * Defines cache preventing GC.
  107401. */
  107402. private _defines;
  107403. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107404. /**
  107405. * "ImageProcessingPostProcess"
  107406. * @returns "ImageProcessingPostProcess"
  107407. */
  107408. getClassName(): string;
  107409. protected _updateParameters(): void;
  107410. dispose(camera?: Camera): void;
  107411. }
  107412. }
  107413. declare module BABYLON {
  107414. /**
  107415. * Class containing static functions to help procedurally build meshes
  107416. */
  107417. export class GroundBuilder {
  107418. /**
  107419. * Creates a ground mesh
  107420. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107421. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107423. * @param name defines the name of the mesh
  107424. * @param options defines the options used to create the mesh
  107425. * @param scene defines the hosting scene
  107426. * @returns the ground mesh
  107427. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107428. */
  107429. static CreateGround(name: string, options: {
  107430. width?: number;
  107431. height?: number;
  107432. subdivisions?: number;
  107433. subdivisionsX?: number;
  107434. subdivisionsY?: number;
  107435. updatable?: boolean;
  107436. }, scene: any): Mesh;
  107437. /**
  107438. * Creates a tiled ground mesh
  107439. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107440. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107441. * * 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
  107442. * * 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
  107443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107444. * @param name defines the name of the mesh
  107445. * @param options defines the options used to create the mesh
  107446. * @param scene defines the hosting scene
  107447. * @returns the tiled ground mesh
  107448. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107449. */
  107450. static CreateTiledGround(name: string, options: {
  107451. xmin: number;
  107452. zmin: number;
  107453. xmax: number;
  107454. zmax: number;
  107455. subdivisions?: {
  107456. w: number;
  107457. h: number;
  107458. };
  107459. precision?: {
  107460. w: number;
  107461. h: number;
  107462. };
  107463. updatable?: boolean;
  107464. }, scene?: Nullable<Scene>): Mesh;
  107465. /**
  107466. * Creates a ground mesh from a height map
  107467. * * The parameter `url` sets the URL of the height map image resource.
  107468. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107469. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107470. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107471. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107472. * * 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.
  107473. * * 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).
  107474. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107476. * @param name defines the name of the mesh
  107477. * @param url defines the url to the height map
  107478. * @param options defines the options used to create the mesh
  107479. * @param scene defines the hosting scene
  107480. * @returns the ground mesh
  107481. * @see https://doc.babylonjs.com/babylon101/height_map
  107482. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107483. */
  107484. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107485. width?: number;
  107486. height?: number;
  107487. subdivisions?: number;
  107488. minHeight?: number;
  107489. maxHeight?: number;
  107490. colorFilter?: Color3;
  107491. alphaFilter?: number;
  107492. updatable?: boolean;
  107493. onReady?: (mesh: GroundMesh) => void;
  107494. }, scene?: Nullable<Scene>): GroundMesh;
  107495. }
  107496. }
  107497. declare module BABYLON {
  107498. /**
  107499. * Class containing static functions to help procedurally build meshes
  107500. */
  107501. export class TorusBuilder {
  107502. /**
  107503. * Creates a torus mesh
  107504. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107505. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107506. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107510. * @param name defines the name of the mesh
  107511. * @param options defines the options used to create the mesh
  107512. * @param scene defines the hosting scene
  107513. * @returns the torus mesh
  107514. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107515. */
  107516. static CreateTorus(name: string, options: {
  107517. diameter?: number;
  107518. thickness?: number;
  107519. tessellation?: number;
  107520. updatable?: boolean;
  107521. sideOrientation?: number;
  107522. frontUVs?: Vector4;
  107523. backUVs?: Vector4;
  107524. }, scene: any): Mesh;
  107525. }
  107526. }
  107527. declare module BABYLON {
  107528. /**
  107529. * Class containing static functions to help procedurally build meshes
  107530. */
  107531. export class CylinderBuilder {
  107532. /**
  107533. * Creates a cylinder or a cone mesh
  107534. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107535. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107536. * * 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.
  107537. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107538. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107539. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107540. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107541. * * 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).
  107542. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107543. * * 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).
  107544. * * 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
  107545. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107546. * * 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
  107547. * * 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.
  107548. * * If `enclose` is false, a ring surface is one element.
  107549. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107550. * * 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
  107551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107554. * @param name defines the name of the mesh
  107555. * @param options defines the options used to create the mesh
  107556. * @param scene defines the hosting scene
  107557. * @returns the cylinder mesh
  107558. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107559. */
  107560. static CreateCylinder(name: string, options: {
  107561. height?: number;
  107562. diameterTop?: number;
  107563. diameterBottom?: number;
  107564. diameter?: number;
  107565. tessellation?: number;
  107566. subdivisions?: number;
  107567. arc?: number;
  107568. faceColors?: Color4[];
  107569. faceUV?: Vector4[];
  107570. updatable?: boolean;
  107571. hasRings?: boolean;
  107572. enclose?: boolean;
  107573. cap?: number;
  107574. sideOrientation?: number;
  107575. frontUVs?: Vector4;
  107576. backUVs?: Vector4;
  107577. }, scene: any): Mesh;
  107578. }
  107579. }
  107580. declare module BABYLON {
  107581. /**
  107582. * Options to modify the vr teleportation behavior.
  107583. */
  107584. export interface VRTeleportationOptions {
  107585. /**
  107586. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107587. */
  107588. floorMeshName?: string;
  107589. /**
  107590. * A list of meshes to be used as the teleportation floor. (default: empty)
  107591. */
  107592. floorMeshes?: Mesh[];
  107593. }
  107594. /**
  107595. * Options to modify the vr experience helper's behavior.
  107596. */
  107597. export interface VRExperienceHelperOptions extends WebVROptions {
  107598. /**
  107599. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107600. */
  107601. createDeviceOrientationCamera?: boolean;
  107602. /**
  107603. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107604. */
  107605. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107606. /**
  107607. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107608. */
  107609. laserToggle?: boolean;
  107610. /**
  107611. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107612. */
  107613. floorMeshes?: Mesh[];
  107614. /**
  107615. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107616. */
  107617. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107618. }
  107619. /**
  107620. * Event containing information after VR has been entered
  107621. */
  107622. export class OnAfterEnteringVRObservableEvent {
  107623. /**
  107624. * If entering vr was successful
  107625. */
  107626. success: boolean;
  107627. }
  107628. /**
  107629. * Helps to quickly add VR support to an existing scene.
  107630. * See http://doc.babylonjs.com/how_to/webvr_helper
  107631. */
  107632. export class VRExperienceHelper {
  107633. /** Options to modify the vr experience helper's behavior. */
  107634. webVROptions: VRExperienceHelperOptions;
  107635. private _scene;
  107636. private _position;
  107637. private _btnVR;
  107638. private _btnVRDisplayed;
  107639. private _webVRsupported;
  107640. private _webVRready;
  107641. private _webVRrequesting;
  107642. private _webVRpresenting;
  107643. private _hasEnteredVR;
  107644. private _fullscreenVRpresenting;
  107645. private _canvas;
  107646. private _webVRCamera;
  107647. private _vrDeviceOrientationCamera;
  107648. private _deviceOrientationCamera;
  107649. private _existingCamera;
  107650. private _onKeyDown;
  107651. private _onVrDisplayPresentChange;
  107652. private _onVRDisplayChanged;
  107653. private _onVRRequestPresentStart;
  107654. private _onVRRequestPresentComplete;
  107655. /**
  107656. * 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)
  107657. */
  107658. enableGazeEvenWhenNoPointerLock: boolean;
  107659. /**
  107660. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107661. */
  107662. exitVROnDoubleTap: boolean;
  107663. /**
  107664. * Observable raised right before entering VR.
  107665. */
  107666. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107667. /**
  107668. * Observable raised when entering VR has completed.
  107669. */
  107670. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107671. /**
  107672. * Observable raised when exiting VR.
  107673. */
  107674. onExitingVRObservable: Observable<VRExperienceHelper>;
  107675. /**
  107676. * Observable raised when controller mesh is loaded.
  107677. */
  107678. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107679. /** Return this.onEnteringVRObservable
  107680. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107681. */
  107682. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107683. /** Return this.onExitingVRObservable
  107684. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107685. */
  107686. readonly onExitingVR: Observable<VRExperienceHelper>;
  107687. /** Return this.onControllerMeshLoadedObservable
  107688. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107689. */
  107690. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107691. private _rayLength;
  107692. private _useCustomVRButton;
  107693. private _teleportationRequested;
  107694. private _teleportActive;
  107695. private _floorMeshName;
  107696. private _floorMeshesCollection;
  107697. private _rotationAllowed;
  107698. private _teleportBackwardsVector;
  107699. private _teleportationTarget;
  107700. private _isDefaultTeleportationTarget;
  107701. private _postProcessMove;
  107702. private _teleportationFillColor;
  107703. private _teleportationBorderColor;
  107704. private _rotationAngle;
  107705. private _haloCenter;
  107706. private _cameraGazer;
  107707. private _padSensibilityUp;
  107708. private _padSensibilityDown;
  107709. private _leftController;
  107710. private _rightController;
  107711. /**
  107712. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107713. */
  107714. onNewMeshSelected: Observable<AbstractMesh>;
  107715. /**
  107716. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107717. * This observable will provide the mesh and the controller used to select the mesh
  107718. */
  107719. onMeshSelectedWithController: Observable<{
  107720. mesh: AbstractMesh;
  107721. controller: WebVRController;
  107722. }>;
  107723. /**
  107724. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107725. */
  107726. onNewMeshPicked: Observable<PickingInfo>;
  107727. private _circleEase;
  107728. /**
  107729. * Observable raised before camera teleportation
  107730. */
  107731. onBeforeCameraTeleport: Observable<Vector3>;
  107732. /**
  107733. * Observable raised after camera teleportation
  107734. */
  107735. onAfterCameraTeleport: Observable<Vector3>;
  107736. /**
  107737. * Observable raised when current selected mesh gets unselected
  107738. */
  107739. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107740. private _raySelectionPredicate;
  107741. /**
  107742. * To be optionaly changed by user to define custom ray selection
  107743. */
  107744. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107745. /**
  107746. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107747. */
  107748. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107749. /**
  107750. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107751. */
  107752. teleportationEnabled: boolean;
  107753. private _defaultHeight;
  107754. private _teleportationInitialized;
  107755. private _interactionsEnabled;
  107756. private _interactionsRequested;
  107757. private _displayGaze;
  107758. private _displayLaserPointer;
  107759. /**
  107760. * The mesh used to display where the user is going to teleport.
  107761. */
  107762. /**
  107763. * Sets the mesh to be used to display where the user is going to teleport.
  107764. */
  107765. teleportationTarget: Mesh;
  107766. /**
  107767. * 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
  107768. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107769. * See http://doc.babylonjs.com/resources/baking_transformations
  107770. */
  107771. gazeTrackerMesh: Mesh;
  107772. /**
  107773. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107774. */
  107775. updateGazeTrackerScale: boolean;
  107776. /**
  107777. * If the gaze trackers color should be updated when selecting meshes
  107778. */
  107779. updateGazeTrackerColor: boolean;
  107780. /**
  107781. * If the controller laser color should be updated when selecting meshes
  107782. */
  107783. updateControllerLaserColor: boolean;
  107784. /**
  107785. * The gaze tracking mesh corresponding to the left controller
  107786. */
  107787. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107788. /**
  107789. * The gaze tracking mesh corresponding to the right controller
  107790. */
  107791. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107792. /**
  107793. * If the ray of the gaze should be displayed.
  107794. */
  107795. /**
  107796. * Sets if the ray of the gaze should be displayed.
  107797. */
  107798. displayGaze: boolean;
  107799. /**
  107800. * If the ray of the LaserPointer should be displayed.
  107801. */
  107802. /**
  107803. * Sets if the ray of the LaserPointer should be displayed.
  107804. */
  107805. displayLaserPointer: boolean;
  107806. /**
  107807. * The deviceOrientationCamera used as the camera when not in VR.
  107808. */
  107809. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107810. /**
  107811. * Based on the current WebVR support, returns the current VR camera used.
  107812. */
  107813. readonly currentVRCamera: Nullable<Camera>;
  107814. /**
  107815. * The webVRCamera which is used when in VR.
  107816. */
  107817. readonly webVRCamera: WebVRFreeCamera;
  107818. /**
  107819. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107820. */
  107821. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107822. /**
  107823. * The html button that is used to trigger entering into VR.
  107824. */
  107825. readonly vrButton: Nullable<HTMLButtonElement>;
  107826. private readonly _teleportationRequestInitiated;
  107827. /**
  107828. * Defines wether or not Pointer lock should be requested when switching to
  107829. * full screen.
  107830. */
  107831. requestPointerLockOnFullScreen: boolean;
  107832. /**
  107833. * Instantiates a VRExperienceHelper.
  107834. * Helps to quickly add VR support to an existing scene.
  107835. * @param scene The scene the VRExperienceHelper belongs to.
  107836. * @param webVROptions Options to modify the vr experience helper's behavior.
  107837. */
  107838. constructor(scene: Scene,
  107839. /** Options to modify the vr experience helper's behavior. */
  107840. webVROptions?: VRExperienceHelperOptions);
  107841. private _onDefaultMeshLoaded;
  107842. private _onResize;
  107843. private _onFullscreenChange;
  107844. /**
  107845. * Gets a value indicating if we are currently in VR mode.
  107846. */
  107847. readonly isInVRMode: boolean;
  107848. private onVrDisplayPresentChange;
  107849. private onVRDisplayChanged;
  107850. private moveButtonToBottomRight;
  107851. private displayVRButton;
  107852. private updateButtonVisibility;
  107853. private _cachedAngularSensibility;
  107854. /**
  107855. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107856. * Otherwise, will use the fullscreen API.
  107857. */
  107858. enterVR(): void;
  107859. /**
  107860. * Attempt to exit VR, or fullscreen.
  107861. */
  107862. exitVR(): void;
  107863. /**
  107864. * The position of the vr experience helper.
  107865. */
  107866. /**
  107867. * Sets the position of the vr experience helper.
  107868. */
  107869. position: Vector3;
  107870. /**
  107871. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107872. */
  107873. enableInteractions(): void;
  107874. private readonly _noControllerIsActive;
  107875. private beforeRender;
  107876. private _isTeleportationFloor;
  107877. /**
  107878. * Adds a floor mesh to be used for teleportation.
  107879. * @param floorMesh the mesh to be used for teleportation.
  107880. */
  107881. addFloorMesh(floorMesh: Mesh): void;
  107882. /**
  107883. * Removes a floor mesh from being used for teleportation.
  107884. * @param floorMesh the mesh to be removed.
  107885. */
  107886. removeFloorMesh(floorMesh: Mesh): void;
  107887. /**
  107888. * Enables interactions and teleportation using the VR controllers and gaze.
  107889. * @param vrTeleportationOptions options to modify teleportation behavior.
  107890. */
  107891. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107892. private _onNewGamepadConnected;
  107893. private _tryEnableInteractionOnController;
  107894. private _onNewGamepadDisconnected;
  107895. private _enableInteractionOnController;
  107896. private _checkTeleportWithRay;
  107897. private _checkRotate;
  107898. private _checkTeleportBackwards;
  107899. private _enableTeleportationOnController;
  107900. private _createTeleportationCircles;
  107901. private _displayTeleportationTarget;
  107902. private _hideTeleportationTarget;
  107903. private _rotateCamera;
  107904. private _moveTeleportationSelectorTo;
  107905. private _workingVector;
  107906. private _workingQuaternion;
  107907. private _workingMatrix;
  107908. /**
  107909. * Teleports the users feet to the desired location
  107910. * @param location The location where the user's feet should be placed
  107911. */
  107912. teleportCamera(location: Vector3): void;
  107913. private _convertNormalToDirectionOfRay;
  107914. private _castRayAndSelectObject;
  107915. private _notifySelectedMeshUnselected;
  107916. /**
  107917. * Sets the color of the laser ray from the vr controllers.
  107918. * @param color new color for the ray.
  107919. */
  107920. changeLaserColor(color: Color3): void;
  107921. /**
  107922. * Sets the color of the ray from the vr headsets gaze.
  107923. * @param color new color for the ray.
  107924. */
  107925. changeGazeColor(color: Color3): void;
  107926. /**
  107927. * Exits VR and disposes of the vr experience helper
  107928. */
  107929. dispose(): void;
  107930. /**
  107931. * Gets the name of the VRExperienceHelper class
  107932. * @returns "VRExperienceHelper"
  107933. */
  107934. getClassName(): string;
  107935. }
  107936. }
  107937. declare module BABYLON {
  107938. /**
  107939. * Manages an XRSession to work with Babylon's engine
  107940. * @see https://doc.babylonjs.com/how_to/webxr
  107941. */
  107942. export class WebXRSessionManager implements IDisposable {
  107943. private scene;
  107944. /**
  107945. * Fires every time a new xrFrame arrives which can be used to update the camera
  107946. */
  107947. onXRFrameObservable: Observable<any>;
  107948. /**
  107949. * Fires when the xr session is ended either by the device or manually done
  107950. */
  107951. onXRSessionEnded: Observable<any>;
  107952. /**
  107953. * Underlying xr session
  107954. */
  107955. session: XRSession;
  107956. /**
  107957. * Type of reference space used when creating the session
  107958. */
  107959. referenceSpace: XRReferenceSpace;
  107960. /** @hidden */
  107961. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107962. /**
  107963. * Current XR frame
  107964. */
  107965. currentFrame: Nullable<XRFrame>;
  107966. private _xrNavigator;
  107967. private baseLayer;
  107968. /**
  107969. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107970. * @param scene The scene which the session should be created for
  107971. */
  107972. constructor(scene: Scene);
  107973. /**
  107974. * Initializes the manager
  107975. * After initialization enterXR can be called to start an XR session
  107976. * @returns Promise which resolves after it is initialized
  107977. */
  107978. initializeAsync(): Promise<void>;
  107979. /**
  107980. * Initializes an xr session
  107981. * @param xrSessionMode mode to initialize
  107982. * @returns a promise which will resolve once the session has been initialized
  107983. */
  107984. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107985. /**
  107986. * Sets the reference space on the xr session
  107987. * @param referenceSpace space to set
  107988. * @returns a promise that will resolve once the reference space has been set
  107989. */
  107990. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107991. /**
  107992. * Updates the render state of the session
  107993. * @param state state to set
  107994. * @returns a promise that resolves once the render state has been updated
  107995. */
  107996. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107997. /**
  107998. * Starts rendering to the xr layer
  107999. * @returns a promise that will resolve once rendering has started
  108000. */
  108001. startRenderingToXRAsync(): Promise<void>;
  108002. /**
  108003. * Stops the xrSession and restores the renderloop
  108004. * @returns Promise which resolves after it exits XR
  108005. */
  108006. exitXRAsync(): Promise<unknown>;
  108007. /**
  108008. * Checks if a session would be supported for the creation options specified
  108009. * @param sessionMode session mode to check if supported eg. immersive-vr
  108010. * @returns true if supported
  108011. */
  108012. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108013. /**
  108014. * @hidden
  108015. * Converts the render layer of xrSession to a render target
  108016. * @param session session to create render target for
  108017. * @param scene scene the new render target should be created for
  108018. */
  108019. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108020. /**
  108021. * Disposes of the session manager
  108022. */
  108023. dispose(): void;
  108024. }
  108025. }
  108026. declare module BABYLON {
  108027. /**
  108028. * WebXR Camera which holds the views for the xrSession
  108029. * @see https://doc.babylonjs.com/how_to/webxr
  108030. */
  108031. export class WebXRCamera extends FreeCamera {
  108032. private static _TmpMatrix;
  108033. /**
  108034. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108035. * @param name the name of the camera
  108036. * @param scene the scene to add the camera to
  108037. */
  108038. constructor(name: string, scene: Scene);
  108039. private _updateNumberOfRigCameras;
  108040. /** @hidden */
  108041. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108042. /**
  108043. * Updates the cameras position from the current pose information of the XR session
  108044. * @param xrSessionManager the session containing pose information
  108045. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108046. */
  108047. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108048. }
  108049. }
  108050. declare module BABYLON {
  108051. /**
  108052. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108053. */
  108054. export class WebXRManagedOutputCanvas implements IDisposable {
  108055. private helper;
  108056. private _canvas;
  108057. /**
  108058. * xrpresent context of the canvas which can be used to display/mirror xr content
  108059. */
  108060. canvasContext: WebGLRenderingContext;
  108061. /**
  108062. * xr layer for the canvas
  108063. */
  108064. xrLayer: Nullable<XRWebGLLayer>;
  108065. /**
  108066. * Initializes the xr layer for the session
  108067. * @param xrSession xr session
  108068. * @returns a promise that will resolve once the XR Layer has been created
  108069. */
  108070. initializeXRLayerAsync(xrSession: any): any;
  108071. /**
  108072. * Initializes the canvas to be added/removed upon entering/exiting xr
  108073. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108074. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108075. */
  108076. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108077. /**
  108078. * Disposes of the object
  108079. */
  108080. dispose(): void;
  108081. private _setManagedOutputCanvas;
  108082. private _addCanvas;
  108083. private _removeCanvas;
  108084. }
  108085. }
  108086. declare module BABYLON {
  108087. /**
  108088. * States of the webXR experience
  108089. */
  108090. export enum WebXRState {
  108091. /**
  108092. * Transitioning to being in XR mode
  108093. */
  108094. ENTERING_XR = 0,
  108095. /**
  108096. * Transitioning to non XR mode
  108097. */
  108098. EXITING_XR = 1,
  108099. /**
  108100. * In XR mode and presenting
  108101. */
  108102. IN_XR = 2,
  108103. /**
  108104. * Not entered XR mode
  108105. */
  108106. NOT_IN_XR = 3
  108107. }
  108108. /**
  108109. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108110. * @see https://doc.babylonjs.com/how_to/webxr
  108111. */
  108112. export class WebXRExperienceHelper implements IDisposable {
  108113. private scene;
  108114. /**
  108115. * 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
  108116. */
  108117. container: AbstractMesh;
  108118. /**
  108119. * Camera used to render xr content
  108120. */
  108121. camera: WebXRCamera;
  108122. /**
  108123. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108124. */
  108125. state: WebXRState;
  108126. private _setState;
  108127. private static _TmpVector;
  108128. /**
  108129. * Fires when the state of the experience helper has changed
  108130. */
  108131. onStateChangedObservable: Observable<WebXRState>;
  108132. /** Session manager used to keep track of xr session */
  108133. sessionManager: WebXRSessionManager;
  108134. private _nonVRCamera;
  108135. private _originalSceneAutoClear;
  108136. private _supported;
  108137. /**
  108138. * Creates the experience helper
  108139. * @param scene the scene to attach the experience helper to
  108140. * @returns a promise for the experience helper
  108141. */
  108142. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108143. /**
  108144. * Creates a WebXRExperienceHelper
  108145. * @param scene The scene the helper should be created in
  108146. */
  108147. private constructor();
  108148. /**
  108149. * Exits XR mode and returns the scene to its original state
  108150. * @returns promise that resolves after xr mode has exited
  108151. */
  108152. exitXRAsync(): Promise<unknown>;
  108153. /**
  108154. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108155. * @param sessionCreationOptions options for the XR session
  108156. * @param referenceSpaceType frame of reference of the XR session
  108157. * @param outputCanvas the output canvas that will be used to enter XR mode
  108158. * @returns promise that resolves after xr mode has entered
  108159. */
  108160. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108161. /**
  108162. * Updates the global position of the camera by moving the camera's container
  108163. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108164. * @param position The desired global position of the camera
  108165. */
  108166. setPositionOfCameraUsingContainer(position: Vector3): void;
  108167. /**
  108168. * Rotates the xr camera by rotating the camera's container around the camera's position
  108169. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108170. * @param rotation the desired quaternion rotation to apply to the camera
  108171. */
  108172. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108173. /**
  108174. * Disposes of the experience helper
  108175. */
  108176. dispose(): void;
  108177. }
  108178. }
  108179. declare module BABYLON {
  108180. /**
  108181. * Button which can be used to enter a different mode of XR
  108182. */
  108183. export class WebXREnterExitUIButton {
  108184. /** button element */
  108185. element: HTMLElement;
  108186. /** XR initialization options for the button */
  108187. sessionMode: XRSessionMode;
  108188. /** Reference space type */
  108189. referenceSpaceType: XRReferenceSpaceType;
  108190. /**
  108191. * Creates a WebXREnterExitUIButton
  108192. * @param element button element
  108193. * @param sessionMode XR initialization session mode
  108194. * @param referenceSpaceType the type of reference space to be used
  108195. */
  108196. constructor(
  108197. /** button element */
  108198. element: HTMLElement,
  108199. /** XR initialization options for the button */
  108200. sessionMode: XRSessionMode,
  108201. /** Reference space type */
  108202. referenceSpaceType: XRReferenceSpaceType);
  108203. /**
  108204. * Overwritable function which can be used to update the button's visuals when the state changes
  108205. * @param activeButton the current active button in the UI
  108206. */
  108207. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108208. }
  108209. /**
  108210. * Options to create the webXR UI
  108211. */
  108212. export class WebXREnterExitUIOptions {
  108213. /**
  108214. * Context to enter xr with
  108215. */
  108216. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108217. /**
  108218. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108219. */
  108220. customButtons?: Array<WebXREnterExitUIButton>;
  108221. }
  108222. /**
  108223. * UI to allow the user to enter/exit XR mode
  108224. */
  108225. export class WebXREnterExitUI implements IDisposable {
  108226. private scene;
  108227. private _overlay;
  108228. private _buttons;
  108229. private _activeButton;
  108230. /**
  108231. * Fired every time the active button is changed.
  108232. *
  108233. * When xr is entered via a button that launches xr that button will be the callback parameter
  108234. *
  108235. * When exiting xr the callback parameter will be null)
  108236. */
  108237. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108238. /**
  108239. * Creates UI to allow the user to enter/exit XR mode
  108240. * @param scene the scene to add the ui to
  108241. * @param helper the xr experience helper to enter/exit xr with
  108242. * @param options options to configure the UI
  108243. * @returns the created ui
  108244. */
  108245. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108246. private constructor();
  108247. private _updateButtons;
  108248. /**
  108249. * Disposes of the object
  108250. */
  108251. dispose(): void;
  108252. }
  108253. }
  108254. declare module BABYLON {
  108255. /**
  108256. * Represents an XR input
  108257. */
  108258. export class WebXRController {
  108259. private scene;
  108260. /** The underlying input source for the controller */
  108261. inputSource: XRInputSource;
  108262. private parentContainer;
  108263. /**
  108264. * 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
  108265. */
  108266. grip?: AbstractMesh;
  108267. /**
  108268. * Pointer which can be used to select objects or attach a visible laser to
  108269. */
  108270. pointer: AbstractMesh;
  108271. /**
  108272. * Event that fires when the controller is removed/disposed
  108273. */
  108274. onDisposeObservable: Observable<{}>;
  108275. private _tmpMatrix;
  108276. private _tmpQuaternion;
  108277. private _tmpVector;
  108278. /**
  108279. * Creates the controller
  108280. * @see https://doc.babylonjs.com/how_to/webxr
  108281. * @param scene the scene which the controller should be associated to
  108282. * @param inputSource the underlying input source for the controller
  108283. * @param parentContainer parent that the controller meshes should be children of
  108284. */
  108285. constructor(scene: Scene,
  108286. /** The underlying input source for the controller */
  108287. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108288. /**
  108289. * Updates the controller pose based on the given XRFrame
  108290. * @param xrFrame xr frame to update the pose with
  108291. * @param referenceSpace reference space to use
  108292. */
  108293. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108294. /**
  108295. * Gets a world space ray coming from the controller
  108296. * @param result the resulting ray
  108297. */
  108298. getWorldPointerRayToRef(result: Ray): void;
  108299. /**
  108300. * Disposes of the object
  108301. */
  108302. dispose(): void;
  108303. }
  108304. }
  108305. declare module BABYLON {
  108306. /**
  108307. * XR input used to track XR inputs such as controllers/rays
  108308. */
  108309. export class WebXRInput implements IDisposable {
  108310. /**
  108311. * Base experience the input listens to
  108312. */
  108313. baseExperience: WebXRExperienceHelper;
  108314. /**
  108315. * XR controllers being tracked
  108316. */
  108317. controllers: Array<WebXRController>;
  108318. private _frameObserver;
  108319. private _stateObserver;
  108320. /**
  108321. * Event when a controller has been connected/added
  108322. */
  108323. onControllerAddedObservable: Observable<WebXRController>;
  108324. /**
  108325. * Event when a controller has been removed/disconnected
  108326. */
  108327. onControllerRemovedObservable: Observable<WebXRController>;
  108328. /**
  108329. * Initializes the WebXRInput
  108330. * @param baseExperience experience helper which the input should be created for
  108331. */
  108332. constructor(
  108333. /**
  108334. * Base experience the input listens to
  108335. */
  108336. baseExperience: WebXRExperienceHelper);
  108337. private _onInputSourcesChange;
  108338. private _addAndRemoveControllers;
  108339. /**
  108340. * Disposes of the object
  108341. */
  108342. dispose(): void;
  108343. }
  108344. }
  108345. declare module BABYLON {
  108346. /**
  108347. * Enables teleportation
  108348. */
  108349. export class WebXRControllerTeleportation {
  108350. private _teleportationFillColor;
  108351. private _teleportationBorderColor;
  108352. private _tmpRay;
  108353. private _tmpVector;
  108354. /**
  108355. * Creates a WebXRControllerTeleportation
  108356. * @param input input manager to add teleportation to
  108357. * @param floorMeshes floormeshes which can be teleported to
  108358. */
  108359. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108360. }
  108361. }
  108362. declare module BABYLON {
  108363. /**
  108364. * Handles pointer input automatically for the pointer of XR controllers
  108365. */
  108366. export class WebXRControllerPointerSelection {
  108367. private static _idCounter;
  108368. private _tmpRay;
  108369. /**
  108370. * Creates a WebXRControllerPointerSelection
  108371. * @param input input manager to setup pointer selection
  108372. */
  108373. constructor(input: WebXRInput);
  108374. private _convertNormalToDirectionOfRay;
  108375. private _updatePointerDistance;
  108376. }
  108377. }
  108378. declare module BABYLON {
  108379. /**
  108380. * Class used to represent data loading progression
  108381. */
  108382. export class SceneLoaderProgressEvent {
  108383. /** defines if data length to load can be evaluated */
  108384. readonly lengthComputable: boolean;
  108385. /** defines the loaded data length */
  108386. readonly loaded: number;
  108387. /** defines the data length to load */
  108388. readonly total: number;
  108389. /**
  108390. * Create a new progress event
  108391. * @param lengthComputable defines if data length to load can be evaluated
  108392. * @param loaded defines the loaded data length
  108393. * @param total defines the data length to load
  108394. */
  108395. constructor(
  108396. /** defines if data length to load can be evaluated */
  108397. lengthComputable: boolean,
  108398. /** defines the loaded data length */
  108399. loaded: number,
  108400. /** defines the data length to load */
  108401. total: number);
  108402. /**
  108403. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108404. * @param event defines the source event
  108405. * @returns a new SceneLoaderProgressEvent
  108406. */
  108407. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108408. }
  108409. /**
  108410. * Interface used by SceneLoader plugins to define supported file extensions
  108411. */
  108412. export interface ISceneLoaderPluginExtensions {
  108413. /**
  108414. * Defines the list of supported extensions
  108415. */
  108416. [extension: string]: {
  108417. isBinary: boolean;
  108418. };
  108419. }
  108420. /**
  108421. * Interface used by SceneLoader plugin factory
  108422. */
  108423. export interface ISceneLoaderPluginFactory {
  108424. /**
  108425. * Defines the name of the factory
  108426. */
  108427. name: string;
  108428. /**
  108429. * Function called to create a new plugin
  108430. * @return the new plugin
  108431. */
  108432. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108433. /**
  108434. * Boolean indicating if the plugin can direct load specific data
  108435. */
  108436. canDirectLoad?: (data: string) => boolean;
  108437. }
  108438. /**
  108439. * Interface used to define a SceneLoader plugin
  108440. */
  108441. export interface ISceneLoaderPlugin {
  108442. /**
  108443. * The friendly name of this plugin.
  108444. */
  108445. name: string;
  108446. /**
  108447. * The file extensions supported by this plugin.
  108448. */
  108449. extensions: string | ISceneLoaderPluginExtensions;
  108450. /**
  108451. * Import meshes into a scene.
  108452. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108453. * @param scene The scene to import into
  108454. * @param data The data to import
  108455. * @param rootUrl The root url for scene and resources
  108456. * @param meshes The meshes array to import into
  108457. * @param particleSystems The particle systems array to import into
  108458. * @param skeletons The skeletons array to import into
  108459. * @param onError The callback when import fails
  108460. * @returns True if successful or false otherwise
  108461. */
  108462. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108463. /**
  108464. * Load into a scene.
  108465. * @param scene The scene to load into
  108466. * @param data The data to import
  108467. * @param rootUrl The root url for scene and resources
  108468. * @param onError The callback when import fails
  108469. * @returns true if successful or false otherwise
  108470. */
  108471. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108472. /**
  108473. * The callback that returns true if the data can be directly loaded.
  108474. */
  108475. canDirectLoad?: (data: string) => boolean;
  108476. /**
  108477. * The callback that allows custom handling of the root url based on the response url.
  108478. */
  108479. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108480. /**
  108481. * Load into an asset container.
  108482. * @param scene The scene to load into
  108483. * @param data The data to import
  108484. * @param rootUrl The root url for scene and resources
  108485. * @param onError The callback when import fails
  108486. * @returns The loaded asset container
  108487. */
  108488. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108489. }
  108490. /**
  108491. * Interface used to define an async SceneLoader plugin
  108492. */
  108493. export interface ISceneLoaderPluginAsync {
  108494. /**
  108495. * The friendly name of this plugin.
  108496. */
  108497. name: string;
  108498. /**
  108499. * The file extensions supported by this plugin.
  108500. */
  108501. extensions: string | ISceneLoaderPluginExtensions;
  108502. /**
  108503. * Import meshes into a scene.
  108504. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108505. * @param scene The scene to import into
  108506. * @param data The data to import
  108507. * @param rootUrl The root url for scene and resources
  108508. * @param onProgress The callback when the load progresses
  108509. * @param fileName Defines the name of the file to load
  108510. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108511. */
  108512. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108513. meshes: AbstractMesh[];
  108514. particleSystems: IParticleSystem[];
  108515. skeletons: Skeleton[];
  108516. animationGroups: AnimationGroup[];
  108517. }>;
  108518. /**
  108519. * Load into a scene.
  108520. * @param scene The scene to load into
  108521. * @param data The data to import
  108522. * @param rootUrl The root url for scene and resources
  108523. * @param onProgress The callback when the load progresses
  108524. * @param fileName Defines the name of the file to load
  108525. * @returns Nothing
  108526. */
  108527. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108528. /**
  108529. * The callback that returns true if the data can be directly loaded.
  108530. */
  108531. canDirectLoad?: (data: string) => boolean;
  108532. /**
  108533. * The callback that allows custom handling of the root url based on the response url.
  108534. */
  108535. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108536. /**
  108537. * Load into an asset container.
  108538. * @param scene The scene to load into
  108539. * @param data The data to import
  108540. * @param rootUrl The root url for scene and resources
  108541. * @param onProgress The callback when the load progresses
  108542. * @param fileName Defines the name of the file to load
  108543. * @returns The loaded asset container
  108544. */
  108545. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108546. }
  108547. /**
  108548. * Class used to load scene from various file formats using registered plugins
  108549. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108550. */
  108551. export class SceneLoader {
  108552. /**
  108553. * No logging while loading
  108554. */
  108555. static readonly NO_LOGGING: number;
  108556. /**
  108557. * Minimal logging while loading
  108558. */
  108559. static readonly MINIMAL_LOGGING: number;
  108560. /**
  108561. * Summary logging while loading
  108562. */
  108563. static readonly SUMMARY_LOGGING: number;
  108564. /**
  108565. * Detailled logging while loading
  108566. */
  108567. static readonly DETAILED_LOGGING: number;
  108568. /**
  108569. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108570. */
  108571. static ForceFullSceneLoadingForIncremental: boolean;
  108572. /**
  108573. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108574. */
  108575. static ShowLoadingScreen: boolean;
  108576. /**
  108577. * Defines the current logging level (while loading the scene)
  108578. * @ignorenaming
  108579. */
  108580. static loggingLevel: number;
  108581. /**
  108582. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108583. */
  108584. static CleanBoneMatrixWeights: boolean;
  108585. /**
  108586. * Event raised when a plugin is used to load a scene
  108587. */
  108588. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108589. private static _registeredPlugins;
  108590. private static _getDefaultPlugin;
  108591. private static _getPluginForExtension;
  108592. private static _getPluginForDirectLoad;
  108593. private static _getPluginForFilename;
  108594. private static _getDirectLoad;
  108595. private static _loadData;
  108596. private static _getFileInfo;
  108597. /**
  108598. * Gets a plugin that can load the given extension
  108599. * @param extension defines the extension to load
  108600. * @returns a plugin or null if none works
  108601. */
  108602. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108603. /**
  108604. * Gets a boolean indicating that the given extension can be loaded
  108605. * @param extension defines the extension to load
  108606. * @returns true if the extension is supported
  108607. */
  108608. static IsPluginForExtensionAvailable(extension: string): boolean;
  108609. /**
  108610. * Adds a new plugin to the list of registered plugins
  108611. * @param plugin defines the plugin to add
  108612. */
  108613. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108614. /**
  108615. * Import meshes into a scene
  108616. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108617. * @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)
  108618. * @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)
  108619. * @param scene the instance of BABYLON.Scene to append to
  108620. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108621. * @param onProgress a callback with a progress event for each file being loaded
  108622. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108623. * @param pluginExtension the extension used to determine the plugin
  108624. * @returns The loaded plugin
  108625. */
  108626. 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>;
  108627. /**
  108628. * Import meshes into a scene
  108629. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108630. * @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)
  108631. * @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)
  108632. * @param scene the instance of BABYLON.Scene to append to
  108633. * @param onProgress a callback with a progress event for each file being loaded
  108634. * @param pluginExtension the extension used to determine the plugin
  108635. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108636. */
  108637. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108638. meshes: AbstractMesh[];
  108639. particleSystems: IParticleSystem[];
  108640. skeletons: Skeleton[];
  108641. animationGroups: AnimationGroup[];
  108642. }>;
  108643. /**
  108644. * Load a scene
  108645. * @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)
  108646. * @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)
  108647. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108648. * @param onSuccess a callback with the scene when import succeeds
  108649. * @param onProgress a callback with a progress event for each file being loaded
  108650. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108651. * @param pluginExtension the extension used to determine the plugin
  108652. * @returns The loaded plugin
  108653. */
  108654. 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>;
  108655. /**
  108656. * Load a scene
  108657. * @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)
  108658. * @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)
  108659. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108660. * @param onProgress a callback with a progress event for each file being loaded
  108661. * @param pluginExtension the extension used to determine the plugin
  108662. * @returns The loaded scene
  108663. */
  108664. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108665. /**
  108666. * Append a scene
  108667. * @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)
  108668. * @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)
  108669. * @param scene is the instance of BABYLON.Scene to append to
  108670. * @param onSuccess a callback with the scene when import succeeds
  108671. * @param onProgress a callback with a progress event for each file being loaded
  108672. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108673. * @param pluginExtension the extension used to determine the plugin
  108674. * @returns The loaded plugin
  108675. */
  108676. 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>;
  108677. /**
  108678. * Append a scene
  108679. * @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)
  108680. * @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)
  108681. * @param scene is the instance of BABYLON.Scene to append to
  108682. * @param onProgress a callback with a progress event for each file being loaded
  108683. * @param pluginExtension the extension used to determine the plugin
  108684. * @returns The given scene
  108685. */
  108686. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108687. /**
  108688. * Load a scene into an asset container
  108689. * @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)
  108690. * @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)
  108691. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108692. * @param onSuccess a callback with the scene when import succeeds
  108693. * @param onProgress a callback with a progress event for each file being loaded
  108694. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108695. * @param pluginExtension the extension used to determine the plugin
  108696. * @returns The loaded plugin
  108697. */
  108698. 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>;
  108699. /**
  108700. * Load a scene into an asset container
  108701. * @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)
  108702. * @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)
  108703. * @param scene is the instance of Scene to append to
  108704. * @param onProgress a callback with a progress event for each file being loaded
  108705. * @param pluginExtension the extension used to determine the plugin
  108706. * @returns The loaded asset container
  108707. */
  108708. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108709. }
  108710. }
  108711. declare module BABYLON {
  108712. /**
  108713. * Generic Controller
  108714. */
  108715. export class GenericController extends WebVRController {
  108716. /**
  108717. * Base Url for the controller model.
  108718. */
  108719. static readonly MODEL_BASE_URL: string;
  108720. /**
  108721. * File name for the controller model.
  108722. */
  108723. static readonly MODEL_FILENAME: string;
  108724. /**
  108725. * Creates a new GenericController from a gamepad
  108726. * @param vrGamepad the gamepad that the controller should be created from
  108727. */
  108728. constructor(vrGamepad: any);
  108729. /**
  108730. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108731. * @param scene scene in which to add meshes
  108732. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108733. */
  108734. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108735. /**
  108736. * Called once for each button that changed state since the last frame
  108737. * @param buttonIdx Which button index changed
  108738. * @param state New state of the button
  108739. * @param changes Which properties on the state changed since last frame
  108740. */
  108741. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108742. }
  108743. }
  108744. declare module BABYLON {
  108745. /**
  108746. * Defines the WindowsMotionController object that the state of the windows motion controller
  108747. */
  108748. export class WindowsMotionController extends WebVRController {
  108749. /**
  108750. * The base url used to load the left and right controller models
  108751. */
  108752. static MODEL_BASE_URL: string;
  108753. /**
  108754. * The name of the left controller model file
  108755. */
  108756. static MODEL_LEFT_FILENAME: string;
  108757. /**
  108758. * The name of the right controller model file
  108759. */
  108760. static MODEL_RIGHT_FILENAME: string;
  108761. /**
  108762. * The controller name prefix for this controller type
  108763. */
  108764. static readonly GAMEPAD_ID_PREFIX: string;
  108765. /**
  108766. * The controller id pattern for this controller type
  108767. */
  108768. private static readonly GAMEPAD_ID_PATTERN;
  108769. private _loadedMeshInfo;
  108770. private readonly _mapping;
  108771. /**
  108772. * Fired when the trackpad on this controller is clicked
  108773. */
  108774. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108775. /**
  108776. * Fired when the trackpad on this controller is modified
  108777. */
  108778. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108779. /**
  108780. * The current x and y values of this controller's trackpad
  108781. */
  108782. trackpad: StickValues;
  108783. /**
  108784. * Creates a new WindowsMotionController from a gamepad
  108785. * @param vrGamepad the gamepad that the controller should be created from
  108786. */
  108787. constructor(vrGamepad: any);
  108788. /**
  108789. * Fired when the trigger on this controller is modified
  108790. */
  108791. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108792. /**
  108793. * Fired when the menu button on this controller is modified
  108794. */
  108795. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108796. /**
  108797. * Fired when the grip button on this controller is modified
  108798. */
  108799. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108800. /**
  108801. * Fired when the thumbstick button on this controller is modified
  108802. */
  108803. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108804. /**
  108805. * Fired when the touchpad button on this controller is modified
  108806. */
  108807. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108808. /**
  108809. * Fired when the touchpad values on this controller are modified
  108810. */
  108811. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108812. private _updateTrackpad;
  108813. /**
  108814. * Called once per frame by the engine.
  108815. */
  108816. update(): void;
  108817. /**
  108818. * Called once for each button that changed state since the last frame
  108819. * @param buttonIdx Which button index changed
  108820. * @param state New state of the button
  108821. * @param changes Which properties on the state changed since last frame
  108822. */
  108823. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108824. /**
  108825. * Moves the buttons on the controller mesh based on their current state
  108826. * @param buttonName the name of the button to move
  108827. * @param buttonValue the value of the button which determines the buttons new position
  108828. */
  108829. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108830. /**
  108831. * Moves the axis on the controller mesh based on its current state
  108832. * @param axis the index of the axis
  108833. * @param axisValue the value of the axis which determines the meshes new position
  108834. * @hidden
  108835. */
  108836. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108837. /**
  108838. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108839. * @param scene scene in which to add meshes
  108840. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108841. */
  108842. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108843. /**
  108844. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108845. * can be transformed by button presses and axes values, based on this._mapping.
  108846. *
  108847. * @param scene scene in which the meshes exist
  108848. * @param meshes list of meshes that make up the controller model to process
  108849. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108850. */
  108851. private processModel;
  108852. private createMeshInfo;
  108853. /**
  108854. * Gets the ray of the controller in the direction the controller is pointing
  108855. * @param length the length the resulting ray should be
  108856. * @returns a ray in the direction the controller is pointing
  108857. */
  108858. getForwardRay(length?: number): Ray;
  108859. /**
  108860. * Disposes of the controller
  108861. */
  108862. dispose(): void;
  108863. }
  108864. }
  108865. declare module BABYLON {
  108866. /**
  108867. * Oculus Touch Controller
  108868. */
  108869. export class OculusTouchController extends WebVRController {
  108870. /**
  108871. * Base Url for the controller model.
  108872. */
  108873. static MODEL_BASE_URL: string;
  108874. /**
  108875. * File name for the left controller model.
  108876. */
  108877. static MODEL_LEFT_FILENAME: string;
  108878. /**
  108879. * File name for the right controller model.
  108880. */
  108881. static MODEL_RIGHT_FILENAME: string;
  108882. /**
  108883. * Base Url for the Quest controller model.
  108884. */
  108885. static QUEST_MODEL_BASE_URL: string;
  108886. /**
  108887. * @hidden
  108888. * If the controllers are running on a device that needs the updated Quest controller models
  108889. */
  108890. static _IsQuest: boolean;
  108891. /**
  108892. * Fired when the secondary trigger on this controller is modified
  108893. */
  108894. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108895. /**
  108896. * Fired when the thumb rest on this controller is modified
  108897. */
  108898. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108899. /**
  108900. * Creates a new OculusTouchController from a gamepad
  108901. * @param vrGamepad the gamepad that the controller should be created from
  108902. */
  108903. constructor(vrGamepad: any);
  108904. /**
  108905. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108906. * @param scene scene in which to add meshes
  108907. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108908. */
  108909. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108910. /**
  108911. * Fired when the A button on this controller is modified
  108912. */
  108913. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108914. /**
  108915. * Fired when the B button on this controller is modified
  108916. */
  108917. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108918. /**
  108919. * Fired when the X button on this controller is modified
  108920. */
  108921. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108922. /**
  108923. * Fired when the Y button on this controller is modified
  108924. */
  108925. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108926. /**
  108927. * Called once for each button that changed state since the last frame
  108928. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108929. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108930. * 2) secondary trigger (same)
  108931. * 3) A (right) X (left), touch, pressed = value
  108932. * 4) B / Y
  108933. * 5) thumb rest
  108934. * @param buttonIdx Which button index changed
  108935. * @param state New state of the button
  108936. * @param changes Which properties on the state changed since last frame
  108937. */
  108938. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108939. }
  108940. }
  108941. declare module BABYLON {
  108942. /**
  108943. * Vive Controller
  108944. */
  108945. export class ViveController extends WebVRController {
  108946. /**
  108947. * Base Url for the controller model.
  108948. */
  108949. static MODEL_BASE_URL: string;
  108950. /**
  108951. * File name for the controller model.
  108952. */
  108953. static MODEL_FILENAME: string;
  108954. /**
  108955. * Creates a new ViveController from a gamepad
  108956. * @param vrGamepad the gamepad that the controller should be created from
  108957. */
  108958. constructor(vrGamepad: any);
  108959. /**
  108960. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108961. * @param scene scene in which to add meshes
  108962. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108963. */
  108964. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108965. /**
  108966. * Fired when the left button on this controller is modified
  108967. */
  108968. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108969. /**
  108970. * Fired when the right button on this controller is modified
  108971. */
  108972. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108973. /**
  108974. * Fired when the menu button on this controller is modified
  108975. */
  108976. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108977. /**
  108978. * Called once for each button that changed state since the last frame
  108979. * Vive mapping:
  108980. * 0: touchpad
  108981. * 1: trigger
  108982. * 2: left AND right buttons
  108983. * 3: menu button
  108984. * @param buttonIdx Which button index changed
  108985. * @param state New state of the button
  108986. * @param changes Which properties on the state changed since last frame
  108987. */
  108988. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108989. }
  108990. }
  108991. declare module BABYLON {
  108992. /**
  108993. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108994. */
  108995. export class WebXRControllerModelLoader {
  108996. /**
  108997. * Creates the WebXRControllerModelLoader
  108998. * @param input xr input that creates the controllers
  108999. */
  109000. constructor(input: WebXRInput);
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * Contains an array of blocks representing the octree
  109006. */
  109007. export interface IOctreeContainer<T> {
  109008. /**
  109009. * Blocks within the octree
  109010. */
  109011. blocks: Array<OctreeBlock<T>>;
  109012. }
  109013. /**
  109014. * Class used to store a cell in an octree
  109015. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109016. */
  109017. export class OctreeBlock<T> {
  109018. /**
  109019. * Gets the content of the current block
  109020. */
  109021. entries: T[];
  109022. /**
  109023. * Gets the list of block children
  109024. */
  109025. blocks: Array<OctreeBlock<T>>;
  109026. private _depth;
  109027. private _maxDepth;
  109028. private _capacity;
  109029. private _minPoint;
  109030. private _maxPoint;
  109031. private _boundingVectors;
  109032. private _creationFunc;
  109033. /**
  109034. * Creates a new block
  109035. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109036. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109037. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109038. * @param depth defines the current depth of this block in the octree
  109039. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109040. * @param creationFunc defines a callback to call when an element is added to the block
  109041. */
  109042. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109043. /**
  109044. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109045. */
  109046. readonly capacity: number;
  109047. /**
  109048. * Gets the minimum vector (in world space) of the block's bounding box
  109049. */
  109050. readonly minPoint: Vector3;
  109051. /**
  109052. * Gets the maximum vector (in world space) of the block's bounding box
  109053. */
  109054. readonly maxPoint: Vector3;
  109055. /**
  109056. * Add a new element to this block
  109057. * @param entry defines the element to add
  109058. */
  109059. addEntry(entry: T): void;
  109060. /**
  109061. * Remove an element from this block
  109062. * @param entry defines the element to remove
  109063. */
  109064. removeEntry(entry: T): void;
  109065. /**
  109066. * Add an array of elements to this block
  109067. * @param entries defines the array of elements to add
  109068. */
  109069. addEntries(entries: T[]): void;
  109070. /**
  109071. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109072. * @param frustumPlanes defines the frustum planes to test
  109073. * @param selection defines the array to store current content if selection is positive
  109074. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109075. */
  109076. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109077. /**
  109078. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109079. * @param sphereCenter defines the bounding sphere center
  109080. * @param sphereRadius defines the bounding sphere radius
  109081. * @param selection defines the array to store current content if selection is positive
  109082. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109083. */
  109084. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109085. /**
  109086. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109087. * @param ray defines the ray to test with
  109088. * @param selection defines the array to store current content if selection is positive
  109089. */
  109090. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109091. /**
  109092. * Subdivide the content into child blocks (this block will then be empty)
  109093. */
  109094. createInnerBlocks(): void;
  109095. /**
  109096. * @hidden
  109097. */
  109098. 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;
  109099. }
  109100. }
  109101. declare module BABYLON {
  109102. /**
  109103. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109104. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109105. */
  109106. export class Octree<T> {
  109107. /** 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.) */
  109108. maxDepth: number;
  109109. /**
  109110. * Blocks within the octree containing objects
  109111. */
  109112. blocks: Array<OctreeBlock<T>>;
  109113. /**
  109114. * Content stored in the octree
  109115. */
  109116. dynamicContent: T[];
  109117. private _maxBlockCapacity;
  109118. private _selectionContent;
  109119. private _creationFunc;
  109120. /**
  109121. * Creates a octree
  109122. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109123. * @param creationFunc function to be used to instatiate the octree
  109124. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109125. * @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.)
  109126. */
  109127. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109128. /** 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.) */
  109129. maxDepth?: number);
  109130. /**
  109131. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109132. * @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);
  109133. * @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);
  109134. * @param entries meshes to be added to the octree blocks
  109135. */
  109136. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109137. /**
  109138. * Adds a mesh to the octree
  109139. * @param entry Mesh to add to the octree
  109140. */
  109141. addMesh(entry: T): void;
  109142. /**
  109143. * Remove an element from the octree
  109144. * @param entry defines the element to remove
  109145. */
  109146. removeMesh(entry: T): void;
  109147. /**
  109148. * Selects an array of meshes within the frustum
  109149. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109150. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109151. * @returns array of meshes within the frustum
  109152. */
  109153. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109154. /**
  109155. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109156. * @param sphereCenter defines the bounding sphere center
  109157. * @param sphereRadius defines the bounding sphere radius
  109158. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109159. * @returns an array of objects that intersect the sphere
  109160. */
  109161. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109162. /**
  109163. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109164. * @param ray defines the ray to test with
  109165. * @returns array of intersected objects
  109166. */
  109167. intersectsRay(ray: Ray): SmartArray<T>;
  109168. /**
  109169. * Adds a mesh into the octree block if it intersects the block
  109170. */
  109171. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109172. /**
  109173. * Adds a submesh into the octree block if it intersects the block
  109174. */
  109175. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109176. }
  109177. }
  109178. declare module BABYLON {
  109179. interface Scene {
  109180. /**
  109181. * @hidden
  109182. * Backing Filed
  109183. */
  109184. _selectionOctree: Octree<AbstractMesh>;
  109185. /**
  109186. * Gets the octree used to boost mesh selection (picking)
  109187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109188. */
  109189. selectionOctree: Octree<AbstractMesh>;
  109190. /**
  109191. * Creates or updates the octree used to boost selection (picking)
  109192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109193. * @param maxCapacity defines the maximum capacity per leaf
  109194. * @param maxDepth defines the maximum depth of the octree
  109195. * @returns an octree of AbstractMesh
  109196. */
  109197. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109198. }
  109199. interface AbstractMesh {
  109200. /**
  109201. * @hidden
  109202. * Backing Field
  109203. */
  109204. _submeshesOctree: Octree<SubMesh>;
  109205. /**
  109206. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109207. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109208. * @param maxCapacity defines the maximum size of each block (64 by default)
  109209. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109210. * @returns the new octree
  109211. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109213. */
  109214. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109215. }
  109216. /**
  109217. * Defines the octree scene component responsible to manage any octrees
  109218. * in a given scene.
  109219. */
  109220. export class OctreeSceneComponent {
  109221. /**
  109222. * The component name help to identify the component in the list of scene components.
  109223. */
  109224. readonly name: string;
  109225. /**
  109226. * The scene the component belongs to.
  109227. */
  109228. scene: Scene;
  109229. /**
  109230. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109231. */
  109232. readonly checksIsEnabled: boolean;
  109233. /**
  109234. * Creates a new instance of the component for the given scene
  109235. * @param scene Defines the scene to register the component in
  109236. */
  109237. constructor(scene: Scene);
  109238. /**
  109239. * Registers the component in a given scene
  109240. */
  109241. register(): void;
  109242. /**
  109243. * Return the list of active meshes
  109244. * @returns the list of active meshes
  109245. */
  109246. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109247. /**
  109248. * Return the list of active sub meshes
  109249. * @param mesh The mesh to get the candidates sub meshes from
  109250. * @returns the list of active sub meshes
  109251. */
  109252. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109253. private _tempRay;
  109254. /**
  109255. * Return the list of sub meshes intersecting with a given local ray
  109256. * @param mesh defines the mesh to find the submesh for
  109257. * @param localRay defines the ray in local space
  109258. * @returns the list of intersecting sub meshes
  109259. */
  109260. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109261. /**
  109262. * Return the list of sub meshes colliding with a collider
  109263. * @param mesh defines the mesh to find the submesh for
  109264. * @param collider defines the collider to evaluate the collision against
  109265. * @returns the list of colliding sub meshes
  109266. */
  109267. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109268. /**
  109269. * Rebuilds the elements related to this component in case of
  109270. * context lost for instance.
  109271. */
  109272. rebuild(): void;
  109273. /**
  109274. * Disposes the component and the associated ressources.
  109275. */
  109276. dispose(): void;
  109277. }
  109278. }
  109279. declare module BABYLON {
  109280. /**
  109281. * Renders a layer on top of an existing scene
  109282. */
  109283. export class UtilityLayerRenderer implements IDisposable {
  109284. /** the original scene that will be rendered on top of */
  109285. originalScene: Scene;
  109286. private _pointerCaptures;
  109287. private _lastPointerEvents;
  109288. private static _DefaultUtilityLayer;
  109289. private static _DefaultKeepDepthUtilityLayer;
  109290. private _sharedGizmoLight;
  109291. private _renderCamera;
  109292. /**
  109293. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109294. * @returns the camera that is used when rendering the utility layer
  109295. */
  109296. getRenderCamera(): Nullable<Camera>;
  109297. /**
  109298. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109299. * @param cam the camera that should be used when rendering the utility layer
  109300. */
  109301. setRenderCamera(cam: Nullable<Camera>): void;
  109302. /**
  109303. * @hidden
  109304. * Light which used by gizmos to get light shading
  109305. */
  109306. _getSharedGizmoLight(): HemisphericLight;
  109307. /**
  109308. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109309. */
  109310. pickUtilitySceneFirst: boolean;
  109311. /**
  109312. * 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)
  109313. */
  109314. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109315. /**
  109316. * 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)
  109317. */
  109318. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109319. /**
  109320. * The scene that is rendered on top of the original scene
  109321. */
  109322. utilityLayerScene: Scene;
  109323. /**
  109324. * If the utility layer should automatically be rendered on top of existing scene
  109325. */
  109326. shouldRender: boolean;
  109327. /**
  109328. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109329. */
  109330. onlyCheckPointerDownEvents: boolean;
  109331. /**
  109332. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109333. */
  109334. processAllEvents: boolean;
  109335. /**
  109336. * Observable raised when the pointer move from the utility layer scene to the main scene
  109337. */
  109338. onPointerOutObservable: Observable<number>;
  109339. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109340. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109341. private _afterRenderObserver;
  109342. private _sceneDisposeObserver;
  109343. private _originalPointerObserver;
  109344. /**
  109345. * Instantiates a UtilityLayerRenderer
  109346. * @param originalScene the original scene that will be rendered on top of
  109347. * @param handleEvents boolean indicating if the utility layer should handle events
  109348. */
  109349. constructor(
  109350. /** the original scene that will be rendered on top of */
  109351. originalScene: Scene, handleEvents?: boolean);
  109352. private _notifyObservers;
  109353. /**
  109354. * Renders the utility layers scene on top of the original scene
  109355. */
  109356. render(): void;
  109357. /**
  109358. * Disposes of the renderer
  109359. */
  109360. dispose(): void;
  109361. private _updateCamera;
  109362. }
  109363. }
  109364. declare module BABYLON {
  109365. /**
  109366. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109367. */
  109368. export class Gizmo implements IDisposable {
  109369. /** The utility layer the gizmo will be added to */
  109370. gizmoLayer: UtilityLayerRenderer;
  109371. /**
  109372. * The root mesh of the gizmo
  109373. */
  109374. _rootMesh: Mesh;
  109375. private _attachedMesh;
  109376. /**
  109377. * Ratio for the scale of the gizmo (Default: 1)
  109378. */
  109379. scaleRatio: number;
  109380. /**
  109381. * If a custom mesh has been set (Default: false)
  109382. */
  109383. protected _customMeshSet: boolean;
  109384. /**
  109385. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109386. * * When set, interactions will be enabled
  109387. */
  109388. attachedMesh: Nullable<AbstractMesh>;
  109389. /**
  109390. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109391. * @param mesh The mesh to replace the default mesh of the gizmo
  109392. */
  109393. setCustomMesh(mesh: Mesh): void;
  109394. /**
  109395. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109396. */
  109397. updateGizmoRotationToMatchAttachedMesh: boolean;
  109398. /**
  109399. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109400. */
  109401. updateGizmoPositionToMatchAttachedMesh: boolean;
  109402. /**
  109403. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109404. */
  109405. updateScale: boolean;
  109406. protected _interactionsEnabled: boolean;
  109407. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109408. private _beforeRenderObserver;
  109409. private _tempVector;
  109410. /**
  109411. * Creates a gizmo
  109412. * @param gizmoLayer The utility layer the gizmo will be added to
  109413. */
  109414. constructor(
  109415. /** The utility layer the gizmo will be added to */
  109416. gizmoLayer?: UtilityLayerRenderer);
  109417. /**
  109418. * Updates the gizmo to match the attached mesh's position/rotation
  109419. */
  109420. protected _update(): void;
  109421. /**
  109422. * Disposes of the gizmo
  109423. */
  109424. dispose(): void;
  109425. }
  109426. }
  109427. declare module BABYLON {
  109428. /**
  109429. * Single plane drag gizmo
  109430. */
  109431. export class PlaneDragGizmo extends Gizmo {
  109432. /**
  109433. * Drag behavior responsible for the gizmos dragging interactions
  109434. */
  109435. dragBehavior: PointerDragBehavior;
  109436. private _pointerObserver;
  109437. /**
  109438. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109439. */
  109440. snapDistance: number;
  109441. /**
  109442. * Event that fires each time the gizmo snaps to a new location.
  109443. * * snapDistance is the the change in distance
  109444. */
  109445. onSnapObservable: Observable<{
  109446. snapDistance: number;
  109447. }>;
  109448. private _plane;
  109449. private _coloredMaterial;
  109450. private _hoverMaterial;
  109451. private _isEnabled;
  109452. private _parent;
  109453. /** @hidden */
  109454. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109455. /** @hidden */
  109456. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109457. /**
  109458. * Creates a PlaneDragGizmo
  109459. * @param gizmoLayer The utility layer the gizmo will be added to
  109460. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109461. * @param color The color of the gizmo
  109462. */
  109463. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109464. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109465. /**
  109466. * If the gizmo is enabled
  109467. */
  109468. isEnabled: boolean;
  109469. /**
  109470. * Disposes of the gizmo
  109471. */
  109472. dispose(): void;
  109473. }
  109474. }
  109475. declare module BABYLON {
  109476. /**
  109477. * Gizmo that enables dragging a mesh along 3 axis
  109478. */
  109479. export class PositionGizmo extends Gizmo {
  109480. /**
  109481. * Internal gizmo used for interactions on the x axis
  109482. */
  109483. xGizmo: AxisDragGizmo;
  109484. /**
  109485. * Internal gizmo used for interactions on the y axis
  109486. */
  109487. yGizmo: AxisDragGizmo;
  109488. /**
  109489. * Internal gizmo used for interactions on the z axis
  109490. */
  109491. zGizmo: AxisDragGizmo;
  109492. /**
  109493. * Internal gizmo used for interactions on the yz plane
  109494. */
  109495. xPlaneGizmo: PlaneDragGizmo;
  109496. /**
  109497. * Internal gizmo used for interactions on the xz plane
  109498. */
  109499. yPlaneGizmo: PlaneDragGizmo;
  109500. /**
  109501. * Internal gizmo used for interactions on the xy plane
  109502. */
  109503. zPlaneGizmo: PlaneDragGizmo;
  109504. /**
  109505. * private variables
  109506. */
  109507. private _meshAttached;
  109508. private _updateGizmoRotationToMatchAttachedMesh;
  109509. private _snapDistance;
  109510. private _scaleRatio;
  109511. /** Fires an event when any of it's sub gizmos are dragged */
  109512. onDragStartObservable: Observable<unknown>;
  109513. /** Fires an event when any of it's sub gizmos are released from dragging */
  109514. onDragEndObservable: Observable<unknown>;
  109515. /**
  109516. * If set to true, planar drag is enabled
  109517. */
  109518. private _planarGizmoEnabled;
  109519. attachedMesh: Nullable<AbstractMesh>;
  109520. /**
  109521. * Creates a PositionGizmo
  109522. * @param gizmoLayer The utility layer the gizmo will be added to
  109523. */
  109524. constructor(gizmoLayer?: UtilityLayerRenderer);
  109525. /**
  109526. * If the planar drag gizmo is enabled
  109527. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109528. */
  109529. planarGizmoEnabled: boolean;
  109530. updateGizmoRotationToMatchAttachedMesh: boolean;
  109531. /**
  109532. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109533. */
  109534. snapDistance: number;
  109535. /**
  109536. * Ratio for the scale of the gizmo (Default: 1)
  109537. */
  109538. scaleRatio: number;
  109539. /**
  109540. * Disposes of the gizmo
  109541. */
  109542. dispose(): void;
  109543. /**
  109544. * CustomMeshes are not supported by this gizmo
  109545. * @param mesh The mesh to replace the default mesh of the gizmo
  109546. */
  109547. setCustomMesh(mesh: Mesh): void;
  109548. }
  109549. }
  109550. declare module BABYLON {
  109551. /**
  109552. * Single axis drag gizmo
  109553. */
  109554. export class AxisDragGizmo extends Gizmo {
  109555. /**
  109556. * Drag behavior responsible for the gizmos dragging interactions
  109557. */
  109558. dragBehavior: PointerDragBehavior;
  109559. private _pointerObserver;
  109560. /**
  109561. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109562. */
  109563. snapDistance: number;
  109564. /**
  109565. * Event that fires each time the gizmo snaps to a new location.
  109566. * * snapDistance is the the change in distance
  109567. */
  109568. onSnapObservable: Observable<{
  109569. snapDistance: number;
  109570. }>;
  109571. private _isEnabled;
  109572. private _parent;
  109573. private _arrow;
  109574. private _coloredMaterial;
  109575. private _hoverMaterial;
  109576. /** @hidden */
  109577. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109578. /** @hidden */
  109579. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109580. /**
  109581. * Creates an AxisDragGizmo
  109582. * @param gizmoLayer The utility layer the gizmo will be added to
  109583. * @param dragAxis The axis which the gizmo will be able to drag on
  109584. * @param color The color of the gizmo
  109585. */
  109586. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109587. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109588. /**
  109589. * If the gizmo is enabled
  109590. */
  109591. isEnabled: boolean;
  109592. /**
  109593. * Disposes of the gizmo
  109594. */
  109595. dispose(): void;
  109596. }
  109597. }
  109598. declare module BABYLON.Debug {
  109599. /**
  109600. * The Axes viewer will show 3 axes in a specific point in space
  109601. */
  109602. export class AxesViewer {
  109603. private _xAxis;
  109604. private _yAxis;
  109605. private _zAxis;
  109606. private _scaleLinesFactor;
  109607. private _instanced;
  109608. /**
  109609. * Gets the hosting scene
  109610. */
  109611. scene: Scene;
  109612. /**
  109613. * Gets or sets a number used to scale line length
  109614. */
  109615. scaleLines: number;
  109616. /** Gets the node hierarchy used to render x-axis */
  109617. readonly xAxis: TransformNode;
  109618. /** Gets the node hierarchy used to render y-axis */
  109619. readonly yAxis: TransformNode;
  109620. /** Gets the node hierarchy used to render z-axis */
  109621. readonly zAxis: TransformNode;
  109622. /**
  109623. * Creates a new AxesViewer
  109624. * @param scene defines the hosting scene
  109625. * @param scaleLines defines a number used to scale line length (1 by default)
  109626. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109627. * @param xAxis defines the node hierarchy used to render the x-axis
  109628. * @param yAxis defines the node hierarchy used to render the y-axis
  109629. * @param zAxis defines the node hierarchy used to render the z-axis
  109630. */
  109631. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109632. /**
  109633. * Force the viewer to update
  109634. * @param position defines the position of the viewer
  109635. * @param xaxis defines the x axis of the viewer
  109636. * @param yaxis defines the y axis of the viewer
  109637. * @param zaxis defines the z axis of the viewer
  109638. */
  109639. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109640. /**
  109641. * Creates an instance of this axes viewer.
  109642. * @returns a new axes viewer with instanced meshes
  109643. */
  109644. createInstance(): AxesViewer;
  109645. /** Releases resources */
  109646. dispose(): void;
  109647. private static _SetRenderingGroupId;
  109648. }
  109649. }
  109650. declare module BABYLON.Debug {
  109651. /**
  109652. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109653. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109654. */
  109655. export class BoneAxesViewer extends AxesViewer {
  109656. /**
  109657. * Gets or sets the target mesh where to display the axes viewer
  109658. */
  109659. mesh: Nullable<Mesh>;
  109660. /**
  109661. * Gets or sets the target bone where to display the axes viewer
  109662. */
  109663. bone: Nullable<Bone>;
  109664. /** Gets current position */
  109665. pos: Vector3;
  109666. /** Gets direction of X axis */
  109667. xaxis: Vector3;
  109668. /** Gets direction of Y axis */
  109669. yaxis: Vector3;
  109670. /** Gets direction of Z axis */
  109671. zaxis: Vector3;
  109672. /**
  109673. * Creates a new BoneAxesViewer
  109674. * @param scene defines the hosting scene
  109675. * @param bone defines the target bone
  109676. * @param mesh defines the target mesh
  109677. * @param scaleLines defines a scaling factor for line length (1 by default)
  109678. */
  109679. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109680. /**
  109681. * Force the viewer to update
  109682. */
  109683. update(): void;
  109684. /** Releases resources */
  109685. dispose(): void;
  109686. }
  109687. }
  109688. declare module BABYLON {
  109689. /**
  109690. * Interface used to define scene explorer extensibility option
  109691. */
  109692. export interface IExplorerExtensibilityOption {
  109693. /**
  109694. * Define the option label
  109695. */
  109696. label: string;
  109697. /**
  109698. * Defines the action to execute on click
  109699. */
  109700. action: (entity: any) => void;
  109701. }
  109702. /**
  109703. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109704. */
  109705. export interface IExplorerExtensibilityGroup {
  109706. /**
  109707. * Defines a predicate to test if a given type mut be extended
  109708. */
  109709. predicate: (entity: any) => boolean;
  109710. /**
  109711. * Gets the list of options added to a type
  109712. */
  109713. entries: IExplorerExtensibilityOption[];
  109714. }
  109715. /**
  109716. * Interface used to define the options to use to create the Inspector
  109717. */
  109718. export interface IInspectorOptions {
  109719. /**
  109720. * Display in overlay mode (default: false)
  109721. */
  109722. overlay?: boolean;
  109723. /**
  109724. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109725. */
  109726. globalRoot?: HTMLElement;
  109727. /**
  109728. * Display the Scene explorer
  109729. */
  109730. showExplorer?: boolean;
  109731. /**
  109732. * Display the property inspector
  109733. */
  109734. showInspector?: boolean;
  109735. /**
  109736. * Display in embed mode (both panes on the right)
  109737. */
  109738. embedMode?: boolean;
  109739. /**
  109740. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109741. */
  109742. handleResize?: boolean;
  109743. /**
  109744. * Allow the panes to popup (default: true)
  109745. */
  109746. enablePopup?: boolean;
  109747. /**
  109748. * Allow the panes to be closed by users (default: true)
  109749. */
  109750. enableClose?: boolean;
  109751. /**
  109752. * Optional list of extensibility entries
  109753. */
  109754. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109755. /**
  109756. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109757. */
  109758. inspectorURL?: string;
  109759. }
  109760. interface Scene {
  109761. /**
  109762. * @hidden
  109763. * Backing field
  109764. */
  109765. _debugLayer: DebugLayer;
  109766. /**
  109767. * Gets the debug layer (aka Inspector) associated with the scene
  109768. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109769. */
  109770. debugLayer: DebugLayer;
  109771. }
  109772. /**
  109773. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109774. * what is happening in your scene
  109775. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109776. */
  109777. export class DebugLayer {
  109778. /**
  109779. * Define the url to get the inspector script from.
  109780. * By default it uses the babylonjs CDN.
  109781. * @ignoreNaming
  109782. */
  109783. static InspectorURL: string;
  109784. private _scene;
  109785. private BJSINSPECTOR;
  109786. private _onPropertyChangedObservable?;
  109787. /**
  109788. * Observable triggered when a property is changed through the inspector.
  109789. */
  109790. readonly onPropertyChangedObservable: any;
  109791. /**
  109792. * Instantiates a new debug layer.
  109793. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109794. * what is happening in your scene
  109795. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109796. * @param scene Defines the scene to inspect
  109797. */
  109798. constructor(scene: Scene);
  109799. /** Creates the inspector window. */
  109800. private _createInspector;
  109801. /**
  109802. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109803. * @param entity defines the entity to select
  109804. * @param lineContainerTitle defines the specific block to highlight
  109805. */
  109806. select(entity: any, lineContainerTitle?: string): void;
  109807. /** Get the inspector from bundle or global */
  109808. private _getGlobalInspector;
  109809. /**
  109810. * Get if the inspector is visible or not.
  109811. * @returns true if visible otherwise, false
  109812. */
  109813. isVisible(): boolean;
  109814. /**
  109815. * Hide the inspector and close its window.
  109816. */
  109817. hide(): void;
  109818. /**
  109819. * Launch the debugLayer.
  109820. * @param config Define the configuration of the inspector
  109821. * @return a promise fulfilled when the debug layer is visible
  109822. */
  109823. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109824. }
  109825. }
  109826. declare module BABYLON {
  109827. /**
  109828. * Class containing static functions to help procedurally build meshes
  109829. */
  109830. export class BoxBuilder {
  109831. /**
  109832. * Creates a box mesh
  109833. * * The parameter `size` sets the size (float) of each box side (default 1)
  109834. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109835. * * 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)
  109836. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109840. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109841. * @param name defines the name of the mesh
  109842. * @param options defines the options used to create the mesh
  109843. * @param scene defines the hosting scene
  109844. * @returns the box mesh
  109845. */
  109846. static CreateBox(name: string, options: {
  109847. size?: number;
  109848. width?: number;
  109849. height?: number;
  109850. depth?: number;
  109851. faceUV?: Vector4[];
  109852. faceColors?: Color4[];
  109853. sideOrientation?: number;
  109854. frontUVs?: Vector4;
  109855. backUVs?: Vector4;
  109856. wrap?: boolean;
  109857. topBaseAt?: number;
  109858. bottomBaseAt?: number;
  109859. updatable?: boolean;
  109860. }, scene?: Nullable<Scene>): Mesh;
  109861. }
  109862. }
  109863. declare module BABYLON {
  109864. /**
  109865. * Class containing static functions to help procedurally build meshes
  109866. */
  109867. export class SphereBuilder {
  109868. /**
  109869. * Creates a sphere mesh
  109870. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109871. * * 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`)
  109872. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109873. * * 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
  109874. * * 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)
  109875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109876. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109878. * @param name defines the name of the mesh
  109879. * @param options defines the options used to create the mesh
  109880. * @param scene defines the hosting scene
  109881. * @returns the sphere mesh
  109882. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109883. */
  109884. static CreateSphere(name: string, options: {
  109885. segments?: number;
  109886. diameter?: number;
  109887. diameterX?: number;
  109888. diameterY?: number;
  109889. diameterZ?: number;
  109890. arc?: number;
  109891. slice?: number;
  109892. sideOrientation?: number;
  109893. frontUVs?: Vector4;
  109894. backUVs?: Vector4;
  109895. updatable?: boolean;
  109896. }, scene?: Nullable<Scene>): Mesh;
  109897. }
  109898. }
  109899. declare module BABYLON.Debug {
  109900. /**
  109901. * Used to show the physics impostor around the specific mesh
  109902. */
  109903. export class PhysicsViewer {
  109904. /** @hidden */
  109905. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109906. /** @hidden */
  109907. protected _meshes: Array<Nullable<AbstractMesh>>;
  109908. /** @hidden */
  109909. protected _scene: Nullable<Scene>;
  109910. /** @hidden */
  109911. protected _numMeshes: number;
  109912. /** @hidden */
  109913. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109914. private _renderFunction;
  109915. private _utilityLayer;
  109916. private _debugBoxMesh;
  109917. private _debugSphereMesh;
  109918. private _debugCylinderMesh;
  109919. private _debugMaterial;
  109920. private _debugMeshMeshes;
  109921. /**
  109922. * Creates a new PhysicsViewer
  109923. * @param scene defines the hosting scene
  109924. */
  109925. constructor(scene: Scene);
  109926. /** @hidden */
  109927. protected _updateDebugMeshes(): void;
  109928. /**
  109929. * Renders a specified physic impostor
  109930. * @param impostor defines the impostor to render
  109931. * @param targetMesh defines the mesh represented by the impostor
  109932. * @returns the new debug mesh used to render the impostor
  109933. */
  109934. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109935. /**
  109936. * Hides a specified physic impostor
  109937. * @param impostor defines the impostor to hide
  109938. */
  109939. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109940. private _getDebugMaterial;
  109941. private _getDebugBoxMesh;
  109942. private _getDebugSphereMesh;
  109943. private _getDebugCylinderMesh;
  109944. private _getDebugMeshMesh;
  109945. private _getDebugMesh;
  109946. /** Releases all resources */
  109947. dispose(): void;
  109948. }
  109949. }
  109950. declare module BABYLON {
  109951. /**
  109952. * Class containing static functions to help procedurally build meshes
  109953. */
  109954. export class LinesBuilder {
  109955. /**
  109956. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109957. * * 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
  109958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109959. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109960. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109961. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109963. * * 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
  109964. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109966. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109967. * @param name defines the name of the new line system
  109968. * @param options defines the options used to create the line system
  109969. * @param scene defines the hosting scene
  109970. * @returns a new line system mesh
  109971. */
  109972. static CreateLineSystem(name: string, options: {
  109973. lines: Vector3[][];
  109974. updatable?: boolean;
  109975. instance?: Nullable<LinesMesh>;
  109976. colors?: Nullable<Color4[][]>;
  109977. useVertexAlpha?: boolean;
  109978. }, scene: Nullable<Scene>): LinesMesh;
  109979. /**
  109980. * Creates a line mesh
  109981. * 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
  109982. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109983. * * The parameter `points` is an array successive Vector3
  109984. * * 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
  109985. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109986. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109987. * * When updating an instance, remember that only point positions can change, not the number of points
  109988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109990. * @param name defines the name of the new line system
  109991. * @param options defines the options used to create the line system
  109992. * @param scene defines the hosting scene
  109993. * @returns a new line mesh
  109994. */
  109995. static CreateLines(name: string, options: {
  109996. points: Vector3[];
  109997. updatable?: boolean;
  109998. instance?: Nullable<LinesMesh>;
  109999. colors?: Color4[];
  110000. useVertexAlpha?: boolean;
  110001. }, scene?: Nullable<Scene>): LinesMesh;
  110002. /**
  110003. * Creates a dashed line mesh
  110004. * * 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
  110005. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110006. * * The parameter `points` is an array successive Vector3
  110007. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110008. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110009. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110010. * * 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
  110011. * * When updating an instance, remember that only point positions can change, not the number of points
  110012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110013. * @param name defines the name of the mesh
  110014. * @param options defines the options used to create the mesh
  110015. * @param scene defines the hosting scene
  110016. * @returns the dashed line mesh
  110017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110018. */
  110019. static CreateDashedLines(name: string, options: {
  110020. points: Vector3[];
  110021. dashSize?: number;
  110022. gapSize?: number;
  110023. dashNb?: number;
  110024. updatable?: boolean;
  110025. instance?: LinesMesh;
  110026. }, scene?: Nullable<Scene>): LinesMesh;
  110027. }
  110028. }
  110029. declare module BABYLON {
  110030. /**
  110031. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110032. * in order to better appreciate the issue one might have.
  110033. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110034. */
  110035. export class RayHelper {
  110036. /**
  110037. * Defines the ray we are currently tryin to visualize.
  110038. */
  110039. ray: Nullable<Ray>;
  110040. private _renderPoints;
  110041. private _renderLine;
  110042. private _renderFunction;
  110043. private _scene;
  110044. private _updateToMeshFunction;
  110045. private _attachedToMesh;
  110046. private _meshSpaceDirection;
  110047. private _meshSpaceOrigin;
  110048. /**
  110049. * Helper function to create a colored helper in a scene in one line.
  110050. * @param ray Defines the ray we are currently tryin to visualize
  110051. * @param scene Defines the scene the ray is used in
  110052. * @param color Defines the color we want to see the ray in
  110053. * @returns The newly created ray helper.
  110054. */
  110055. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110056. /**
  110057. * Instantiate a new ray helper.
  110058. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110059. * in order to better appreciate the issue one might have.
  110060. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110061. * @param ray Defines the ray we are currently tryin to visualize
  110062. */
  110063. constructor(ray: Ray);
  110064. /**
  110065. * Shows the ray we are willing to debug.
  110066. * @param scene Defines the scene the ray needs to be rendered in
  110067. * @param color Defines the color the ray needs to be rendered in
  110068. */
  110069. show(scene: Scene, color?: Color3): void;
  110070. /**
  110071. * Hides the ray we are debugging.
  110072. */
  110073. hide(): void;
  110074. private _render;
  110075. /**
  110076. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110077. * @param mesh Defines the mesh we want the helper attached to
  110078. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110079. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110080. * @param length Defines the length of the ray
  110081. */
  110082. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110083. /**
  110084. * Detach the ray helper from the mesh it has previously been attached to.
  110085. */
  110086. detachFromMesh(): void;
  110087. private _updateToMesh;
  110088. /**
  110089. * Dispose the helper and release its associated resources.
  110090. */
  110091. dispose(): void;
  110092. }
  110093. }
  110094. declare module BABYLON.Debug {
  110095. /**
  110096. * Class used to render a debug view of a given skeleton
  110097. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110098. */
  110099. export class SkeletonViewer {
  110100. /** defines the skeleton to render */
  110101. skeleton: Skeleton;
  110102. /** defines the mesh attached to the skeleton */
  110103. mesh: AbstractMesh;
  110104. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110105. autoUpdateBonesMatrices: boolean;
  110106. /** defines the rendering group id to use with the viewer */
  110107. renderingGroupId: number;
  110108. /** Gets or sets the color used to render the skeleton */
  110109. color: Color3;
  110110. private _scene;
  110111. private _debugLines;
  110112. private _debugMesh;
  110113. private _isEnabled;
  110114. private _renderFunction;
  110115. private _utilityLayer;
  110116. /**
  110117. * Returns the mesh used to render the bones
  110118. */
  110119. readonly debugMesh: Nullable<LinesMesh>;
  110120. /**
  110121. * Creates a new SkeletonViewer
  110122. * @param skeleton defines the skeleton to render
  110123. * @param mesh defines the mesh attached to the skeleton
  110124. * @param scene defines the hosting scene
  110125. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110126. * @param renderingGroupId defines the rendering group id to use with the viewer
  110127. */
  110128. constructor(
  110129. /** defines the skeleton to render */
  110130. skeleton: Skeleton,
  110131. /** defines the mesh attached to the skeleton */
  110132. mesh: AbstractMesh, scene: Scene,
  110133. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110134. autoUpdateBonesMatrices?: boolean,
  110135. /** defines the rendering group id to use with the viewer */
  110136. renderingGroupId?: number);
  110137. /** Gets or sets a boolean indicating if the viewer is enabled */
  110138. isEnabled: boolean;
  110139. private _getBonePosition;
  110140. private _getLinesForBonesWithLength;
  110141. private _getLinesForBonesNoLength;
  110142. /** Update the viewer to sync with current skeleton state */
  110143. update(): void;
  110144. /** Release associated resources */
  110145. dispose(): void;
  110146. }
  110147. }
  110148. declare module BABYLON {
  110149. /**
  110150. * Options to create the null engine
  110151. */
  110152. export class NullEngineOptions {
  110153. /**
  110154. * Render width (Default: 512)
  110155. */
  110156. renderWidth: number;
  110157. /**
  110158. * Render height (Default: 256)
  110159. */
  110160. renderHeight: number;
  110161. /**
  110162. * Texture size (Default: 512)
  110163. */
  110164. textureSize: number;
  110165. /**
  110166. * If delta time between frames should be constant
  110167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110168. */
  110169. deterministicLockstep: boolean;
  110170. /**
  110171. * Maximum about of steps between frames (Default: 4)
  110172. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110173. */
  110174. lockstepMaxSteps: number;
  110175. }
  110176. /**
  110177. * The null engine class provides support for headless version of babylon.js.
  110178. * This can be used in server side scenario or for testing purposes
  110179. */
  110180. export class NullEngine extends Engine {
  110181. private _options;
  110182. /**
  110183. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110184. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110185. * @returns true if engine is in deterministic lock step mode
  110186. */
  110187. isDeterministicLockStep(): boolean;
  110188. /**
  110189. * Gets the max steps when engine is running in deterministic lock step
  110190. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110191. * @returns the max steps
  110192. */
  110193. getLockstepMaxSteps(): number;
  110194. /**
  110195. * Gets the current hardware scaling level.
  110196. * By default the hardware scaling level is computed from the window device ratio.
  110197. * 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.
  110198. * @returns a number indicating the current hardware scaling level
  110199. */
  110200. getHardwareScalingLevel(): number;
  110201. constructor(options?: NullEngineOptions);
  110202. /**
  110203. * Creates a vertex buffer
  110204. * @param vertices the data for the vertex buffer
  110205. * @returns the new WebGL static buffer
  110206. */
  110207. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110208. /**
  110209. * Creates a new index buffer
  110210. * @param indices defines the content of the index buffer
  110211. * @param updatable defines if the index buffer must be updatable
  110212. * @returns a new webGL buffer
  110213. */
  110214. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110215. /**
  110216. * Clear the current render buffer or the current render target (if any is set up)
  110217. * @param color defines the color to use
  110218. * @param backBuffer defines if the back buffer must be cleared
  110219. * @param depth defines if the depth buffer must be cleared
  110220. * @param stencil defines if the stencil buffer must be cleared
  110221. */
  110222. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110223. /**
  110224. * Gets the current render width
  110225. * @param useScreen defines if screen size must be used (or the current render target if any)
  110226. * @returns a number defining the current render width
  110227. */
  110228. getRenderWidth(useScreen?: boolean): number;
  110229. /**
  110230. * Gets the current render height
  110231. * @param useScreen defines if screen size must be used (or the current render target if any)
  110232. * @returns a number defining the current render height
  110233. */
  110234. getRenderHeight(useScreen?: boolean): number;
  110235. /**
  110236. * Set the WebGL's viewport
  110237. * @param viewport defines the viewport element to be used
  110238. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110239. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110240. */
  110241. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110242. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110243. /**
  110244. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110245. * @param pipelineContext defines the pipeline context to use
  110246. * @param uniformsNames defines the list of uniform names
  110247. * @returns an array of webGL uniform locations
  110248. */
  110249. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110250. /**
  110251. * Gets the lsit of active attributes for a given webGL program
  110252. * @param pipelineContext defines the pipeline context to use
  110253. * @param attributesNames defines the list of attribute names to get
  110254. * @returns an array of indices indicating the offset of each attribute
  110255. */
  110256. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110257. /**
  110258. * Binds an effect to the webGL context
  110259. * @param effect defines the effect to bind
  110260. */
  110261. bindSamplers(effect: Effect): void;
  110262. /**
  110263. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110264. * @param effect defines the effect to activate
  110265. */
  110266. enableEffect(effect: Effect): void;
  110267. /**
  110268. * Set various states to the webGL context
  110269. * @param culling defines backface culling state
  110270. * @param zOffset defines the value to apply to zOffset (0 by default)
  110271. * @param force defines if states must be applied even if cache is up to date
  110272. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110273. */
  110274. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110275. /**
  110276. * Set the value of an uniform to an array of int32
  110277. * @param uniform defines the webGL uniform location where to store the value
  110278. * @param array defines the array of int32 to store
  110279. */
  110280. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110281. /**
  110282. * Set the value of an uniform to an array of int32 (stored as vec2)
  110283. * @param uniform defines the webGL uniform location where to store the value
  110284. * @param array defines the array of int32 to store
  110285. */
  110286. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110287. /**
  110288. * Set the value of an uniform to an array of int32 (stored as vec3)
  110289. * @param uniform defines the webGL uniform location where to store the value
  110290. * @param array defines the array of int32 to store
  110291. */
  110292. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110293. /**
  110294. * Set the value of an uniform to an array of int32 (stored as vec4)
  110295. * @param uniform defines the webGL uniform location where to store the value
  110296. * @param array defines the array of int32 to store
  110297. */
  110298. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110299. /**
  110300. * Set the value of an uniform to an array of float32
  110301. * @param uniform defines the webGL uniform location where to store the value
  110302. * @param array defines the array of float32 to store
  110303. */
  110304. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110305. /**
  110306. * Set the value of an uniform to an array of float32 (stored as vec2)
  110307. * @param uniform defines the webGL uniform location where to store the value
  110308. * @param array defines the array of float32 to store
  110309. */
  110310. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110311. /**
  110312. * Set the value of an uniform to an array of float32 (stored as vec3)
  110313. * @param uniform defines the webGL uniform location where to store the value
  110314. * @param array defines the array of float32 to store
  110315. */
  110316. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110317. /**
  110318. * Set the value of an uniform to an array of float32 (stored as vec4)
  110319. * @param uniform defines the webGL uniform location where to store the value
  110320. * @param array defines the array of float32 to store
  110321. */
  110322. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110323. /**
  110324. * Set the value of an uniform to an array of number
  110325. * @param uniform defines the webGL uniform location where to store the value
  110326. * @param array defines the array of number to store
  110327. */
  110328. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110329. /**
  110330. * Set the value of an uniform to an array of number (stored as vec2)
  110331. * @param uniform defines the webGL uniform location where to store the value
  110332. * @param array defines the array of number to store
  110333. */
  110334. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110335. /**
  110336. * Set the value of an uniform to an array of number (stored as vec3)
  110337. * @param uniform defines the webGL uniform location where to store the value
  110338. * @param array defines the array of number to store
  110339. */
  110340. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110341. /**
  110342. * Set the value of an uniform to an array of number (stored as vec4)
  110343. * @param uniform defines the webGL uniform location where to store the value
  110344. * @param array defines the array of number to store
  110345. */
  110346. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110347. /**
  110348. * Set the value of an uniform to an array of float32 (stored as matrices)
  110349. * @param uniform defines the webGL uniform location where to store the value
  110350. * @param matrices defines the array of float32 to store
  110351. */
  110352. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110353. /**
  110354. * Set the value of an uniform to a matrix (3x3)
  110355. * @param uniform defines the webGL uniform location where to store the value
  110356. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110357. */
  110358. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110359. /**
  110360. * Set the value of an uniform to a matrix (2x2)
  110361. * @param uniform defines the webGL uniform location where to store the value
  110362. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110363. */
  110364. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110365. /**
  110366. * Set the value of an uniform to a number (float)
  110367. * @param uniform defines the webGL uniform location where to store the value
  110368. * @param value defines the float number to store
  110369. */
  110370. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110371. /**
  110372. * Set the value of an uniform to a vec2
  110373. * @param uniform defines the webGL uniform location where to store the value
  110374. * @param x defines the 1st component of the value
  110375. * @param y defines the 2nd component of the value
  110376. */
  110377. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110378. /**
  110379. * Set the value of an uniform to a vec3
  110380. * @param uniform defines the webGL uniform location where to store the value
  110381. * @param x defines the 1st component of the value
  110382. * @param y defines the 2nd component of the value
  110383. * @param z defines the 3rd component of the value
  110384. */
  110385. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110386. /**
  110387. * Set the value of an uniform to a boolean
  110388. * @param uniform defines the webGL uniform location where to store the value
  110389. * @param bool defines the boolean to store
  110390. */
  110391. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110392. /**
  110393. * Set the value of an uniform to a vec4
  110394. * @param uniform defines the webGL uniform location where to store the value
  110395. * @param x defines the 1st component of the value
  110396. * @param y defines the 2nd component of the value
  110397. * @param z defines the 3rd component of the value
  110398. * @param w defines the 4th component of the value
  110399. */
  110400. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110401. /**
  110402. * Sets the current alpha mode
  110403. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110404. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110405. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110406. */
  110407. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110408. /**
  110409. * Bind webGl buffers directly to the webGL context
  110410. * @param vertexBuffers defines the vertex buffer to bind
  110411. * @param indexBuffer defines the index buffer to bind
  110412. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110413. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110414. * @param effect defines the effect associated with the vertex buffer
  110415. */
  110416. bindBuffers(vertexBuffers: {
  110417. [key: string]: VertexBuffer;
  110418. }, indexBuffer: DataBuffer, effect: Effect): void;
  110419. /**
  110420. * Force the entire cache to be cleared
  110421. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110422. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110423. */
  110424. wipeCaches(bruteForce?: boolean): void;
  110425. /**
  110426. * Send a draw order
  110427. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110428. * @param indexStart defines the starting index
  110429. * @param indexCount defines the number of index to draw
  110430. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110431. */
  110432. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110433. /**
  110434. * Draw a list of indexed primitives
  110435. * @param fillMode defines the primitive to use
  110436. * @param indexStart defines the starting index
  110437. * @param indexCount defines the number of index to draw
  110438. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110439. */
  110440. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110441. /**
  110442. * Draw a list of unindexed primitives
  110443. * @param fillMode defines the primitive to use
  110444. * @param verticesStart defines the index of first vertex to draw
  110445. * @param verticesCount defines the count of vertices to draw
  110446. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110447. */
  110448. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110449. /** @hidden */
  110450. _createTexture(): WebGLTexture;
  110451. /** @hidden */
  110452. _releaseTexture(texture: InternalTexture): void;
  110453. /**
  110454. * Usually called from Texture.ts.
  110455. * Passed information to create a WebGLTexture
  110456. * @param urlArg defines a value which contains one of the following:
  110457. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110458. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110459. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110460. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110461. * @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)
  110462. * @param scene needed for loading to the correct scene
  110463. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110464. * @param onLoad optional callback to be called upon successful completion
  110465. * @param onError optional callback to be called upon failure
  110466. * @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
  110467. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110468. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110469. * @param forcedExtension defines the extension to use to pick the right loader
  110470. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110471. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110472. */
  110473. 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;
  110474. /**
  110475. * Creates a new render target texture
  110476. * @param size defines the size of the texture
  110477. * @param options defines the options used to create the texture
  110478. * @returns a new render target texture stored in an InternalTexture
  110479. */
  110480. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110481. /**
  110482. * Update the sampling mode of a given texture
  110483. * @param samplingMode defines the required sampling mode
  110484. * @param texture defines the texture to update
  110485. */
  110486. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110487. /**
  110488. * Binds the frame buffer to the specified texture.
  110489. * @param texture The texture to render to or null for the default canvas
  110490. * @param faceIndex The face of the texture to render to in case of cube texture
  110491. * @param requiredWidth The width of the target to render to
  110492. * @param requiredHeight The height of the target to render to
  110493. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110494. * @param depthStencilTexture The depth stencil texture to use to render
  110495. * @param lodLevel defines le lod level to bind to the frame buffer
  110496. */
  110497. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110498. /**
  110499. * Unbind the current render target texture from the webGL context
  110500. * @param texture defines the render target texture to unbind
  110501. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110502. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110503. */
  110504. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110505. /**
  110506. * Creates a dynamic vertex buffer
  110507. * @param vertices the data for the dynamic vertex buffer
  110508. * @returns the new WebGL dynamic buffer
  110509. */
  110510. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110511. /**
  110512. * Update the content of a dynamic texture
  110513. * @param texture defines the texture to update
  110514. * @param canvas defines the canvas containing the source
  110515. * @param invertY defines if data must be stored with Y axis inverted
  110516. * @param premulAlpha defines if alpha is stored as premultiplied
  110517. * @param format defines the format of the data
  110518. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110519. */
  110520. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110521. /**
  110522. * Gets a boolean indicating if all created effects are ready
  110523. * @returns true if all effects are ready
  110524. */
  110525. areAllEffectsReady(): boolean;
  110526. /**
  110527. * @hidden
  110528. * Get the current error code of the webGL context
  110529. * @returns the error code
  110530. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110531. */
  110532. getError(): number;
  110533. /** @hidden */
  110534. _getUnpackAlignement(): number;
  110535. /** @hidden */
  110536. _unpackFlipY(value: boolean): void;
  110537. /**
  110538. * Update a dynamic index buffer
  110539. * @param indexBuffer defines the target index buffer
  110540. * @param indices defines the data to update
  110541. * @param offset defines the offset in the target index buffer where update should start
  110542. */
  110543. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110544. /**
  110545. * Updates a dynamic vertex buffer.
  110546. * @param vertexBuffer the vertex buffer to update
  110547. * @param vertices the data used to update the vertex buffer
  110548. * @param byteOffset the byte offset of the data (optional)
  110549. * @param byteLength the byte length of the data (optional)
  110550. */
  110551. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110552. /** @hidden */
  110553. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110554. /** @hidden */
  110555. _bindTexture(channel: number, texture: InternalTexture): void;
  110556. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110557. /**
  110558. * 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
  110559. */
  110560. releaseEffects(): void;
  110561. displayLoadingUI(): void;
  110562. hideLoadingUI(): void;
  110563. /** @hidden */
  110564. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110565. /** @hidden */
  110566. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110567. /** @hidden */
  110568. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110569. /** @hidden */
  110570. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110571. }
  110572. }
  110573. declare module BABYLON {
  110574. /** @hidden */
  110575. export class _OcclusionDataStorage {
  110576. /** @hidden */
  110577. occlusionInternalRetryCounter: number;
  110578. /** @hidden */
  110579. isOcclusionQueryInProgress: boolean;
  110580. /** @hidden */
  110581. isOccluded: boolean;
  110582. /** @hidden */
  110583. occlusionRetryCount: number;
  110584. /** @hidden */
  110585. occlusionType: number;
  110586. /** @hidden */
  110587. occlusionQueryAlgorithmType: number;
  110588. }
  110589. interface Engine {
  110590. /**
  110591. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110592. * @return the new query
  110593. */
  110594. createQuery(): WebGLQuery;
  110595. /**
  110596. * Delete and release a webGL query
  110597. * @param query defines the query to delete
  110598. * @return the current engine
  110599. */
  110600. deleteQuery(query: WebGLQuery): Engine;
  110601. /**
  110602. * Check if a given query has resolved and got its value
  110603. * @param query defines the query to check
  110604. * @returns true if the query got its value
  110605. */
  110606. isQueryResultAvailable(query: WebGLQuery): boolean;
  110607. /**
  110608. * Gets the value of a given query
  110609. * @param query defines the query to check
  110610. * @returns the value of the query
  110611. */
  110612. getQueryResult(query: WebGLQuery): number;
  110613. /**
  110614. * Initiates an occlusion query
  110615. * @param algorithmType defines the algorithm to use
  110616. * @param query defines the query to use
  110617. * @returns the current engine
  110618. * @see http://doc.babylonjs.com/features/occlusionquery
  110619. */
  110620. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110621. /**
  110622. * Ends an occlusion query
  110623. * @see http://doc.babylonjs.com/features/occlusionquery
  110624. * @param algorithmType defines the algorithm to use
  110625. * @returns the current engine
  110626. */
  110627. endOcclusionQuery(algorithmType: number): Engine;
  110628. /**
  110629. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110630. * Please note that only one query can be issued at a time
  110631. * @returns a time token used to track the time span
  110632. */
  110633. startTimeQuery(): Nullable<_TimeToken>;
  110634. /**
  110635. * Ends a time query
  110636. * @param token defines the token used to measure the time span
  110637. * @returns the time spent (in ns)
  110638. */
  110639. endTimeQuery(token: _TimeToken): int;
  110640. /** @hidden */
  110641. _currentNonTimestampToken: Nullable<_TimeToken>;
  110642. /** @hidden */
  110643. _createTimeQuery(): WebGLQuery;
  110644. /** @hidden */
  110645. _deleteTimeQuery(query: WebGLQuery): void;
  110646. /** @hidden */
  110647. _getGlAlgorithmType(algorithmType: number): number;
  110648. /** @hidden */
  110649. _getTimeQueryResult(query: WebGLQuery): any;
  110650. /** @hidden */
  110651. _getTimeQueryAvailability(query: WebGLQuery): any;
  110652. }
  110653. interface AbstractMesh {
  110654. /**
  110655. * Backing filed
  110656. * @hidden
  110657. */
  110658. __occlusionDataStorage: _OcclusionDataStorage;
  110659. /**
  110660. * Access property
  110661. * @hidden
  110662. */
  110663. _occlusionDataStorage: _OcclusionDataStorage;
  110664. /**
  110665. * 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.
  110666. * The default value is -1 which means don't break the query and wait till the result
  110667. * @see http://doc.babylonjs.com/features/occlusionquery
  110668. */
  110669. occlusionRetryCount: number;
  110670. /**
  110671. * 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:
  110672. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110673. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110674. * * 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.
  110675. * @see http://doc.babylonjs.com/features/occlusionquery
  110676. */
  110677. occlusionType: number;
  110678. /**
  110679. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110680. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110681. * * 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.
  110682. * @see http://doc.babylonjs.com/features/occlusionquery
  110683. */
  110684. occlusionQueryAlgorithmType: number;
  110685. /**
  110686. * 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
  110687. * @see http://doc.babylonjs.com/features/occlusionquery
  110688. */
  110689. isOccluded: boolean;
  110690. /**
  110691. * Flag to check the progress status of the query
  110692. * @see http://doc.babylonjs.com/features/occlusionquery
  110693. */
  110694. isOcclusionQueryInProgress: boolean;
  110695. }
  110696. }
  110697. declare module BABYLON {
  110698. /** @hidden */
  110699. export var _forceTransformFeedbackToBundle: boolean;
  110700. interface Engine {
  110701. /**
  110702. * Creates a webGL transform feedback object
  110703. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110704. * @returns the webGL transform feedback object
  110705. */
  110706. createTransformFeedback(): WebGLTransformFeedback;
  110707. /**
  110708. * Delete a webGL transform feedback object
  110709. * @param value defines the webGL transform feedback object to delete
  110710. */
  110711. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110712. /**
  110713. * Bind a webGL transform feedback object to the webgl context
  110714. * @param value defines the webGL transform feedback object to bind
  110715. */
  110716. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110717. /**
  110718. * Begins a transform feedback operation
  110719. * @param usePoints defines if points or triangles must be used
  110720. */
  110721. beginTransformFeedback(usePoints: boolean): void;
  110722. /**
  110723. * Ends a transform feedback operation
  110724. */
  110725. endTransformFeedback(): void;
  110726. /**
  110727. * Specify the varyings to use with transform feedback
  110728. * @param program defines the associated webGL program
  110729. * @param value defines the list of strings representing the varying names
  110730. */
  110731. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110732. /**
  110733. * Bind a webGL buffer for a transform feedback operation
  110734. * @param value defines the webGL buffer to bind
  110735. */
  110736. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110737. }
  110738. }
  110739. declare module BABYLON {
  110740. /**
  110741. * Creation options of the multi render target texture.
  110742. */
  110743. export interface IMultiRenderTargetOptions {
  110744. /**
  110745. * Define if the texture needs to create mip maps after render.
  110746. */
  110747. generateMipMaps?: boolean;
  110748. /**
  110749. * Define the types of all the draw buffers we want to create
  110750. */
  110751. types?: number[];
  110752. /**
  110753. * Define the sampling modes of all the draw buffers we want to create
  110754. */
  110755. samplingModes?: number[];
  110756. /**
  110757. * Define if a depth buffer is required
  110758. */
  110759. generateDepthBuffer?: boolean;
  110760. /**
  110761. * Define if a stencil buffer is required
  110762. */
  110763. generateStencilBuffer?: boolean;
  110764. /**
  110765. * Define if a depth texture is required instead of a depth buffer
  110766. */
  110767. generateDepthTexture?: boolean;
  110768. /**
  110769. * Define the number of desired draw buffers
  110770. */
  110771. textureCount?: number;
  110772. /**
  110773. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110774. */
  110775. doNotChangeAspectRatio?: boolean;
  110776. /**
  110777. * Define the default type of the buffers we are creating
  110778. */
  110779. defaultType?: number;
  110780. }
  110781. /**
  110782. * A multi render target, like a render target provides the ability to render to a texture.
  110783. * Unlike the render target, it can render to several draw buffers in one draw.
  110784. * This is specially interesting in deferred rendering or for any effects requiring more than
  110785. * just one color from a single pass.
  110786. */
  110787. export class MultiRenderTarget extends RenderTargetTexture {
  110788. private _internalTextures;
  110789. private _textures;
  110790. private _multiRenderTargetOptions;
  110791. /**
  110792. * Get if draw buffers are currently supported by the used hardware and browser.
  110793. */
  110794. readonly isSupported: boolean;
  110795. /**
  110796. * Get the list of textures generated by the multi render target.
  110797. */
  110798. readonly textures: Texture[];
  110799. /**
  110800. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  110801. */
  110802. readonly depthTexture: Texture;
  110803. /**
  110804. * Set the wrapping mode on U of all the textures we are rendering to.
  110805. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110806. */
  110807. wrapU: number;
  110808. /**
  110809. * Set the wrapping mode on V of all the textures we are rendering to.
  110810. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110811. */
  110812. wrapV: number;
  110813. /**
  110814. * Instantiate a new multi render target texture.
  110815. * A multi render target, like a render target provides the ability to render to a texture.
  110816. * Unlike the render target, it can render to several draw buffers in one draw.
  110817. * This is specially interesting in deferred rendering or for any effects requiring more than
  110818. * just one color from a single pass.
  110819. * @param name Define the name of the texture
  110820. * @param size Define the size of the buffers to render to
  110821. * @param count Define the number of target we are rendering into
  110822. * @param scene Define the scene the texture belongs to
  110823. * @param options Define the options used to create the multi render target
  110824. */
  110825. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110826. /** @hidden */
  110827. _rebuild(): void;
  110828. private _createInternalTextures;
  110829. private _createTextures;
  110830. /**
  110831. * Define the number of samples used if MSAA is enabled.
  110832. */
  110833. samples: number;
  110834. /**
  110835. * Resize all the textures in the multi render target.
  110836. * Be carrefull as it will recreate all the data in the new texture.
  110837. * @param size Define the new size
  110838. */
  110839. resize(size: any): void;
  110840. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110841. /**
  110842. * Dispose the render targets and their associated resources
  110843. */
  110844. dispose(): void;
  110845. /**
  110846. * Release all the underlying texture used as draw buffers.
  110847. */
  110848. releaseInternalTextures(): void;
  110849. }
  110850. }
  110851. declare module BABYLON {
  110852. interface ThinEngine {
  110853. /**
  110854. * Unbind a list of render target textures from the webGL context
  110855. * This is used only when drawBuffer extension or webGL2 are active
  110856. * @param textures defines the render target textures to unbind
  110857. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110858. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110859. */
  110860. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  110861. /**
  110862. * Create a multi render target texture
  110863. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  110864. * @param size defines the size of the texture
  110865. * @param options defines the creation options
  110866. * @returns the cube texture as an InternalTexture
  110867. */
  110868. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  110869. /**
  110870. * Update the sample count for a given multiple render target texture
  110871. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  110872. * @param textures defines the textures to update
  110873. * @param samples defines the sample count to set
  110874. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  110875. */
  110876. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  110877. }
  110878. }
  110879. declare module BABYLON {
  110880. /** @hidden */
  110881. export var rgbdEncodePixelShader: {
  110882. name: string;
  110883. shader: string;
  110884. };
  110885. }
  110886. declare module BABYLON {
  110887. /** @hidden */
  110888. export var rgbdDecodePixelShader: {
  110889. name: string;
  110890. shader: string;
  110891. };
  110892. }
  110893. declare module BABYLON {
  110894. /**
  110895. * Raw texture data and descriptor sufficient for WebGL texture upload
  110896. */
  110897. export interface EnvironmentTextureInfo {
  110898. /**
  110899. * Version of the environment map
  110900. */
  110901. version: number;
  110902. /**
  110903. * Width of image
  110904. */
  110905. width: number;
  110906. /**
  110907. * Irradiance information stored in the file.
  110908. */
  110909. irradiance: any;
  110910. /**
  110911. * Specular information stored in the file.
  110912. */
  110913. specular: any;
  110914. }
  110915. /**
  110916. * Defines One Image in the file. It requires only the position in the file
  110917. * as well as the length.
  110918. */
  110919. interface BufferImageData {
  110920. /**
  110921. * Length of the image data.
  110922. */
  110923. length: number;
  110924. /**
  110925. * Position of the data from the null terminator delimiting the end of the JSON.
  110926. */
  110927. position: number;
  110928. }
  110929. /**
  110930. * Defines the specular data enclosed in the file.
  110931. * This corresponds to the version 1 of the data.
  110932. */
  110933. export interface EnvironmentTextureSpecularInfoV1 {
  110934. /**
  110935. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  110936. */
  110937. specularDataPosition?: number;
  110938. /**
  110939. * This contains all the images data needed to reconstruct the cubemap.
  110940. */
  110941. mipmaps: Array<BufferImageData>;
  110942. /**
  110943. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  110944. */
  110945. lodGenerationScale: number;
  110946. }
  110947. /**
  110948. * Sets of helpers addressing the serialization and deserialization of environment texture
  110949. * stored in a BabylonJS env file.
  110950. * Those files are usually stored as .env files.
  110951. */
  110952. export class EnvironmentTextureTools {
  110953. /**
  110954. * Magic number identifying the env file.
  110955. */
  110956. private static _MagicBytes;
  110957. /**
  110958. * Gets the environment info from an env file.
  110959. * @param data The array buffer containing the .env bytes.
  110960. * @returns the environment file info (the json header) if successfully parsed.
  110961. */
  110962. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110963. /**
  110964. * Creates an environment texture from a loaded cube texture.
  110965. * @param texture defines the cube texture to convert in env file
  110966. * @return a promise containing the environment data if succesfull.
  110967. */
  110968. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110969. /**
  110970. * Creates a JSON representation of the spherical data.
  110971. * @param texture defines the texture containing the polynomials
  110972. * @return the JSON representation of the spherical info
  110973. */
  110974. private static _CreateEnvTextureIrradiance;
  110975. /**
  110976. * Creates the ArrayBufferViews used for initializing environment texture image data.
  110977. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  110978. * @param info parameters that determine what views will be created for accessing the underlying buffer
  110979. * @return the views described by info providing access to the underlying buffer
  110980. */
  110981. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  110982. /**
  110983. * Uploads the texture info contained in the env file to the GPU.
  110984. * @param texture defines the internal texture to upload to
  110985. * @param arrayBuffer defines the buffer cotaining the data to load
  110986. * @param info defines the texture info retrieved through the GetEnvInfo method
  110987. * @returns a promise
  110988. */
  110989. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110990. /**
  110991. * Uploads the levels of image data to the GPU.
  110992. * @param texture defines the internal texture to upload to
  110993. * @param imageData defines the array buffer views of image data [mipmap][face]
  110994. * @returns a promise
  110995. */
  110996. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  110997. /**
  110998. * Uploads spherical polynomials information to the texture.
  110999. * @param texture defines the texture we are trying to upload the information to
  111000. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111001. */
  111002. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111003. /** @hidden */
  111004. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111005. }
  111006. }
  111007. declare module BABYLON {
  111008. /**
  111009. * Contains position and normal vectors for a vertex
  111010. */
  111011. export class PositionNormalVertex {
  111012. /** the position of the vertex (defaut: 0,0,0) */
  111013. position: Vector3;
  111014. /** the normal of the vertex (defaut: 0,1,0) */
  111015. normal: Vector3;
  111016. /**
  111017. * Creates a PositionNormalVertex
  111018. * @param position the position of the vertex (defaut: 0,0,0)
  111019. * @param normal the normal of the vertex (defaut: 0,1,0)
  111020. */
  111021. constructor(
  111022. /** the position of the vertex (defaut: 0,0,0) */
  111023. position?: Vector3,
  111024. /** the normal of the vertex (defaut: 0,1,0) */
  111025. normal?: Vector3);
  111026. /**
  111027. * Clones the PositionNormalVertex
  111028. * @returns the cloned PositionNormalVertex
  111029. */
  111030. clone(): PositionNormalVertex;
  111031. }
  111032. /**
  111033. * Contains position, normal and uv vectors for a vertex
  111034. */
  111035. export class PositionNormalTextureVertex {
  111036. /** the position of the vertex (defaut: 0,0,0) */
  111037. position: Vector3;
  111038. /** the normal of the vertex (defaut: 0,1,0) */
  111039. normal: Vector3;
  111040. /** the uv of the vertex (default: 0,0) */
  111041. uv: Vector2;
  111042. /**
  111043. * Creates a PositionNormalTextureVertex
  111044. * @param position the position of the vertex (defaut: 0,0,0)
  111045. * @param normal the normal of the vertex (defaut: 0,1,0)
  111046. * @param uv the uv of the vertex (default: 0,0)
  111047. */
  111048. constructor(
  111049. /** the position of the vertex (defaut: 0,0,0) */
  111050. position?: Vector3,
  111051. /** the normal of the vertex (defaut: 0,1,0) */
  111052. normal?: Vector3,
  111053. /** the uv of the vertex (default: 0,0) */
  111054. uv?: Vector2);
  111055. /**
  111056. * Clones the PositionNormalTextureVertex
  111057. * @returns the cloned PositionNormalTextureVertex
  111058. */
  111059. clone(): PositionNormalTextureVertex;
  111060. }
  111061. }
  111062. declare module BABYLON {
  111063. /** @hidden */
  111064. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111065. private _genericAttributeLocation;
  111066. private _varyingLocationCount;
  111067. private _varyingLocationMap;
  111068. private _replacements;
  111069. private _textureCount;
  111070. private _uniforms;
  111071. lineProcessor(line: string): string;
  111072. attributeProcessor(attribute: string): string;
  111073. varyingProcessor(varying: string, isFragment: boolean): string;
  111074. uniformProcessor(uniform: string): string;
  111075. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111076. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111077. }
  111078. }
  111079. declare module BABYLON {
  111080. /**
  111081. * Container for accessors for natively-stored mesh data buffers.
  111082. */
  111083. class NativeDataBuffer extends DataBuffer {
  111084. /**
  111085. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111086. */
  111087. nativeIndexBuffer?: any;
  111088. /**
  111089. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111090. */
  111091. nativeVertexBuffer?: any;
  111092. }
  111093. /** @hidden */
  111094. export class NativeEngine extends Engine {
  111095. private readonly _native;
  111096. getHardwareScalingLevel(): number;
  111097. constructor();
  111098. /**
  111099. * Can be used to override the current requestAnimationFrame requester.
  111100. * @hidden
  111101. */
  111102. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111103. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111104. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111105. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111106. recordVertexArrayObject(vertexBuffers: {
  111107. [key: string]: VertexBuffer;
  111108. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111109. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111110. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111111. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111112. /**
  111113. * Draw a list of indexed primitives
  111114. * @param fillMode defines the primitive to use
  111115. * @param indexStart defines the starting index
  111116. * @param indexCount defines the number of index to draw
  111117. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111118. */
  111119. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111120. /**
  111121. * Draw a list of unindexed primitives
  111122. * @param fillMode defines the primitive to use
  111123. * @param verticesStart defines the index of first vertex to draw
  111124. * @param verticesCount defines the count of vertices to draw
  111125. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111126. */
  111127. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111128. createPipelineContext(): IPipelineContext;
  111129. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111130. /** @hidden */
  111131. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111132. /** @hidden */
  111133. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111134. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111135. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111136. protected _setProgram(program: WebGLProgram): void;
  111137. _releaseEffect(effect: Effect): void;
  111138. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111139. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111140. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111141. bindSamplers(effect: Effect): void;
  111142. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111143. getRenderWidth(useScreen?: boolean): number;
  111144. getRenderHeight(useScreen?: boolean): number;
  111145. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111146. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111147. /**
  111148. * Set the z offset to apply to current rendering
  111149. * @param value defines the offset to apply
  111150. */
  111151. setZOffset(value: number): void;
  111152. /**
  111153. * Gets the current value of the zOffset
  111154. * @returns the current zOffset state
  111155. */
  111156. getZOffset(): number;
  111157. /**
  111158. * Enable or disable depth buffering
  111159. * @param enable defines the state to set
  111160. */
  111161. setDepthBuffer(enable: boolean): void;
  111162. /**
  111163. * Gets a boolean indicating if depth writing is enabled
  111164. * @returns the current depth writing state
  111165. */
  111166. getDepthWrite(): boolean;
  111167. /**
  111168. * Enable or disable depth writing
  111169. * @param enable defines the state to set
  111170. */
  111171. setDepthWrite(enable: boolean): void;
  111172. /**
  111173. * Enable or disable color writing
  111174. * @param enable defines the state to set
  111175. */
  111176. setColorWrite(enable: boolean): void;
  111177. /**
  111178. * Gets a boolean indicating if color writing is enabled
  111179. * @returns the current color writing state
  111180. */
  111181. getColorWrite(): boolean;
  111182. /**
  111183. * Sets alpha constants used by some alpha blending modes
  111184. * @param r defines the red component
  111185. * @param g defines the green component
  111186. * @param b defines the blue component
  111187. * @param a defines the alpha component
  111188. */
  111189. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111190. /**
  111191. * Sets the current alpha mode
  111192. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111193. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111194. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111195. */
  111196. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111197. /**
  111198. * Gets the current alpha mode
  111199. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111200. * @returns the current alpha mode
  111201. */
  111202. getAlphaMode(): number;
  111203. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111204. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111205. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111206. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111207. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111208. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111209. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111210. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111211. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111212. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111213. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111214. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111215. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111216. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111217. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111218. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111219. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111220. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111221. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111222. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111223. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111224. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111225. wipeCaches(bruteForce?: boolean): void;
  111226. _createTexture(): WebGLTexture;
  111227. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111228. /**
  111229. * Usually called from BABYLON.Texture.ts.
  111230. * Passed information to create a WebGLTexture
  111231. * @param urlArg defines a value which contains one of the following:
  111232. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111233. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111234. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111235. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111236. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111237. * @param scene needed for loading to the correct scene
  111238. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111239. * @param onLoad optional callback to be called upon successful completion
  111240. * @param onError optional callback to be called upon failure
  111241. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111242. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111243. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111244. * @param forcedExtension defines the extension to use to pick the right loader
  111245. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111246. */
  111247. 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;
  111248. /**
  111249. * Creates a cube texture
  111250. * @param rootUrl defines the url where the files to load is located
  111251. * @param scene defines the current scene
  111252. * @param files defines the list of files to load (1 per face)
  111253. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111254. * @param onLoad defines an optional callback raised when the texture is loaded
  111255. * @param onError defines an optional callback raised if there is an issue to load the texture
  111256. * @param format defines the format of the data
  111257. * @param forcedExtension defines the extension to use to pick the right loader
  111258. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111259. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111260. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111261. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111262. * @returns the cube texture as an InternalTexture
  111263. */
  111264. 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;
  111265. private _getSamplingFilter;
  111266. private static _GetNativeTextureFormat;
  111267. createRenderTargetTexture(size: number | {
  111268. width: number;
  111269. height: number;
  111270. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111271. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111272. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111273. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111274. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111275. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111276. /**
  111277. * Updates a dynamic vertex buffer.
  111278. * @param vertexBuffer the vertex buffer to update
  111279. * @param data the data used to update the vertex buffer
  111280. * @param byteOffset the byte offset of the data (optional)
  111281. * @param byteLength the byte length of the data (optional)
  111282. */
  111283. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111284. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111285. private _updateAnisotropicLevel;
  111286. private _getAddressMode;
  111287. /** @hidden */
  111288. _bindTexture(channel: number, texture: InternalTexture): void;
  111289. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111290. releaseEffects(): void;
  111291. /** @hidden */
  111292. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111293. /** @hidden */
  111294. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111295. /** @hidden */
  111296. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111297. /** @hidden */
  111298. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111299. }
  111300. }
  111301. declare module BABYLON {
  111302. /**
  111303. * Gather the list of clipboard event types as constants.
  111304. */
  111305. export class ClipboardEventTypes {
  111306. /**
  111307. * The clipboard event is fired when a copy command is active (pressed).
  111308. */
  111309. static readonly COPY: number;
  111310. /**
  111311. * The clipboard event is fired when a cut command is active (pressed).
  111312. */
  111313. static readonly CUT: number;
  111314. /**
  111315. * The clipboard event is fired when a paste command is active (pressed).
  111316. */
  111317. static readonly PASTE: number;
  111318. }
  111319. /**
  111320. * This class is used to store clipboard related info for the onClipboardObservable event.
  111321. */
  111322. export class ClipboardInfo {
  111323. /**
  111324. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111325. */
  111326. type: number;
  111327. /**
  111328. * Defines the related dom event
  111329. */
  111330. event: ClipboardEvent;
  111331. /**
  111332. *Creates an instance of ClipboardInfo.
  111333. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111334. * @param event Defines the related dom event
  111335. */
  111336. constructor(
  111337. /**
  111338. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111339. */
  111340. type: number,
  111341. /**
  111342. * Defines the related dom event
  111343. */
  111344. event: ClipboardEvent);
  111345. /**
  111346. * Get the clipboard event's type from the keycode.
  111347. * @param keyCode Defines the keyCode for the current keyboard event.
  111348. * @return {number}
  111349. */
  111350. static GetTypeFromCharacter(keyCode: number): number;
  111351. }
  111352. }
  111353. declare module BABYLON {
  111354. /**
  111355. * Google Daydream controller
  111356. */
  111357. export class DaydreamController extends WebVRController {
  111358. /**
  111359. * Base Url for the controller model.
  111360. */
  111361. static MODEL_BASE_URL: string;
  111362. /**
  111363. * File name for the controller model.
  111364. */
  111365. static MODEL_FILENAME: string;
  111366. /**
  111367. * Gamepad Id prefix used to identify Daydream Controller.
  111368. */
  111369. static readonly GAMEPAD_ID_PREFIX: string;
  111370. /**
  111371. * Creates a new DaydreamController from a gamepad
  111372. * @param vrGamepad the gamepad that the controller should be created from
  111373. */
  111374. constructor(vrGamepad: any);
  111375. /**
  111376. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111377. * @param scene scene in which to add meshes
  111378. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111379. */
  111380. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111381. /**
  111382. * Called once for each button that changed state since the last frame
  111383. * @param buttonIdx Which button index changed
  111384. * @param state New state of the button
  111385. * @param changes Which properties on the state changed since last frame
  111386. */
  111387. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111388. }
  111389. }
  111390. declare module BABYLON {
  111391. /**
  111392. * Gear VR Controller
  111393. */
  111394. export class GearVRController extends WebVRController {
  111395. /**
  111396. * Base Url for the controller model.
  111397. */
  111398. static MODEL_BASE_URL: string;
  111399. /**
  111400. * File name for the controller model.
  111401. */
  111402. static MODEL_FILENAME: string;
  111403. /**
  111404. * Gamepad Id prefix used to identify this controller.
  111405. */
  111406. static readonly GAMEPAD_ID_PREFIX: string;
  111407. private readonly _buttonIndexToObservableNameMap;
  111408. /**
  111409. * Creates a new GearVRController from a gamepad
  111410. * @param vrGamepad the gamepad that the controller should be created from
  111411. */
  111412. constructor(vrGamepad: any);
  111413. /**
  111414. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111415. * @param scene scene in which to add meshes
  111416. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111417. */
  111418. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111419. /**
  111420. * Called once for each button that changed state since the last frame
  111421. * @param buttonIdx Which button index changed
  111422. * @param state New state of the button
  111423. * @param changes Which properties on the state changed since last frame
  111424. */
  111425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111426. }
  111427. }
  111428. declare module BABYLON {
  111429. /**
  111430. * Class containing static functions to help procedurally build meshes
  111431. */
  111432. export class PolyhedronBuilder {
  111433. /**
  111434. * Creates a polyhedron mesh
  111435. * * 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
  111436. * * The parameter `size` (positive float, default 1) sets the polygon size
  111437. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111438. * * 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`
  111439. * * 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
  111440. * * 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)`)
  111441. * * 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
  111442. * * 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
  111443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111446. * @param name defines the name of the mesh
  111447. * @param options defines the options used to create the mesh
  111448. * @param scene defines the hosting scene
  111449. * @returns the polyhedron mesh
  111450. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111451. */
  111452. static CreatePolyhedron(name: string, options: {
  111453. type?: number;
  111454. size?: number;
  111455. sizeX?: number;
  111456. sizeY?: number;
  111457. sizeZ?: number;
  111458. custom?: any;
  111459. faceUV?: Vector4[];
  111460. faceColors?: Color4[];
  111461. flat?: boolean;
  111462. updatable?: boolean;
  111463. sideOrientation?: number;
  111464. frontUVs?: Vector4;
  111465. backUVs?: Vector4;
  111466. }, scene?: Nullable<Scene>): Mesh;
  111467. }
  111468. }
  111469. declare module BABYLON {
  111470. /**
  111471. * Gizmo that enables scaling a mesh along 3 axis
  111472. */
  111473. export class ScaleGizmo extends Gizmo {
  111474. /**
  111475. * Internal gizmo used for interactions on the x axis
  111476. */
  111477. xGizmo: AxisScaleGizmo;
  111478. /**
  111479. * Internal gizmo used for interactions on the y axis
  111480. */
  111481. yGizmo: AxisScaleGizmo;
  111482. /**
  111483. * Internal gizmo used for interactions on the z axis
  111484. */
  111485. zGizmo: AxisScaleGizmo;
  111486. /**
  111487. * Internal gizmo used to scale all axis equally
  111488. */
  111489. uniformScaleGizmo: AxisScaleGizmo;
  111490. private _meshAttached;
  111491. private _updateGizmoRotationToMatchAttachedMesh;
  111492. private _snapDistance;
  111493. private _scaleRatio;
  111494. private _uniformScalingMesh;
  111495. private _octahedron;
  111496. /** Fires an event when any of it's sub gizmos are dragged */
  111497. onDragStartObservable: Observable<unknown>;
  111498. /** Fires an event when any of it's sub gizmos are released from dragging */
  111499. onDragEndObservable: Observable<unknown>;
  111500. attachedMesh: Nullable<AbstractMesh>;
  111501. /**
  111502. * Creates a ScaleGizmo
  111503. * @param gizmoLayer The utility layer the gizmo will be added to
  111504. */
  111505. constructor(gizmoLayer?: UtilityLayerRenderer);
  111506. updateGizmoRotationToMatchAttachedMesh: boolean;
  111507. /**
  111508. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111509. */
  111510. snapDistance: number;
  111511. /**
  111512. * Ratio for the scale of the gizmo (Default: 1)
  111513. */
  111514. scaleRatio: number;
  111515. /**
  111516. * Disposes of the gizmo
  111517. */
  111518. dispose(): void;
  111519. }
  111520. }
  111521. declare module BABYLON {
  111522. /**
  111523. * Single axis scale gizmo
  111524. */
  111525. export class AxisScaleGizmo extends Gizmo {
  111526. /**
  111527. * Drag behavior responsible for the gizmos dragging interactions
  111528. */
  111529. dragBehavior: PointerDragBehavior;
  111530. private _pointerObserver;
  111531. /**
  111532. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111533. */
  111534. snapDistance: number;
  111535. /**
  111536. * Event that fires each time the gizmo snaps to a new location.
  111537. * * snapDistance is the the change in distance
  111538. */
  111539. onSnapObservable: Observable<{
  111540. snapDistance: number;
  111541. }>;
  111542. /**
  111543. * If the scaling operation should be done on all axis (default: false)
  111544. */
  111545. uniformScaling: boolean;
  111546. private _isEnabled;
  111547. private _parent;
  111548. private _arrow;
  111549. private _coloredMaterial;
  111550. private _hoverMaterial;
  111551. /**
  111552. * Creates an AxisScaleGizmo
  111553. * @param gizmoLayer The utility layer the gizmo will be added to
  111554. * @param dragAxis The axis which the gizmo will be able to scale on
  111555. * @param color The color of the gizmo
  111556. */
  111557. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111558. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111559. /**
  111560. * If the gizmo is enabled
  111561. */
  111562. isEnabled: boolean;
  111563. /**
  111564. * Disposes of the gizmo
  111565. */
  111566. dispose(): void;
  111567. /**
  111568. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111569. * @param mesh The mesh to replace the default mesh of the gizmo
  111570. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111571. */
  111572. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111573. }
  111574. }
  111575. declare module BABYLON {
  111576. /**
  111577. * Bounding box gizmo
  111578. */
  111579. export class BoundingBoxGizmo extends Gizmo {
  111580. private _lineBoundingBox;
  111581. private _rotateSpheresParent;
  111582. private _scaleBoxesParent;
  111583. private _boundingDimensions;
  111584. private _renderObserver;
  111585. private _pointerObserver;
  111586. private _scaleDragSpeed;
  111587. private _tmpQuaternion;
  111588. private _tmpVector;
  111589. private _tmpRotationMatrix;
  111590. /**
  111591. * 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)
  111592. */
  111593. ignoreChildren: boolean;
  111594. /**
  111595. * 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)
  111596. */
  111597. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111598. /**
  111599. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111600. */
  111601. rotationSphereSize: number;
  111602. /**
  111603. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111604. */
  111605. scaleBoxSize: number;
  111606. /**
  111607. * 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)
  111608. */
  111609. fixedDragMeshScreenSize: boolean;
  111610. /**
  111611. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111612. */
  111613. fixedDragMeshScreenSizeDistanceFactor: number;
  111614. /**
  111615. * Fired when a rotation sphere or scale box is dragged
  111616. */
  111617. onDragStartObservable: Observable<{}>;
  111618. /**
  111619. * Fired when a scale box is dragged
  111620. */
  111621. onScaleBoxDragObservable: Observable<{}>;
  111622. /**
  111623. * Fired when a scale box drag is ended
  111624. */
  111625. onScaleBoxDragEndObservable: Observable<{}>;
  111626. /**
  111627. * Fired when a rotation sphere is dragged
  111628. */
  111629. onRotationSphereDragObservable: Observable<{}>;
  111630. /**
  111631. * Fired when a rotation sphere drag is ended
  111632. */
  111633. onRotationSphereDragEndObservable: Observable<{}>;
  111634. /**
  111635. * 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)
  111636. */
  111637. scalePivot: Nullable<Vector3>;
  111638. /**
  111639. * Mesh used as a pivot to rotate the attached mesh
  111640. */
  111641. private _anchorMesh;
  111642. private _existingMeshScale;
  111643. private _dragMesh;
  111644. private pointerDragBehavior;
  111645. private coloredMaterial;
  111646. private hoverColoredMaterial;
  111647. /**
  111648. * Sets the color of the bounding box gizmo
  111649. * @param color the color to set
  111650. */
  111651. setColor(color: Color3): void;
  111652. /**
  111653. * Creates an BoundingBoxGizmo
  111654. * @param gizmoLayer The utility layer the gizmo will be added to
  111655. * @param color The color of the gizmo
  111656. */
  111657. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111658. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111659. private _selectNode;
  111660. /**
  111661. * Updates the bounding box information for the Gizmo
  111662. */
  111663. updateBoundingBox(): void;
  111664. private _updateRotationSpheres;
  111665. private _updateScaleBoxes;
  111666. /**
  111667. * Enables rotation on the specified axis and disables rotation on the others
  111668. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111669. */
  111670. setEnabledRotationAxis(axis: string): void;
  111671. /**
  111672. * Enables/disables scaling
  111673. * @param enable if scaling should be enabled
  111674. */
  111675. setEnabledScaling(enable: boolean): void;
  111676. private _updateDummy;
  111677. /**
  111678. * Enables a pointer drag behavior on the bounding box of the gizmo
  111679. */
  111680. enableDragBehavior(): void;
  111681. /**
  111682. * Disposes of the gizmo
  111683. */
  111684. dispose(): void;
  111685. /**
  111686. * 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)
  111687. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111688. * @returns the bounding box mesh with the passed in mesh as a child
  111689. */
  111690. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111691. /**
  111692. * CustomMeshes are not supported by this gizmo
  111693. * @param mesh The mesh to replace the default mesh of the gizmo
  111694. */
  111695. setCustomMesh(mesh: Mesh): void;
  111696. }
  111697. }
  111698. declare module BABYLON {
  111699. /**
  111700. * Single plane rotation gizmo
  111701. */
  111702. export class PlaneRotationGizmo extends Gizmo {
  111703. /**
  111704. * Drag behavior responsible for the gizmos dragging interactions
  111705. */
  111706. dragBehavior: PointerDragBehavior;
  111707. private _pointerObserver;
  111708. /**
  111709. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111710. */
  111711. snapDistance: number;
  111712. /**
  111713. * Event that fires each time the gizmo snaps to a new location.
  111714. * * snapDistance is the the change in distance
  111715. */
  111716. onSnapObservable: Observable<{
  111717. snapDistance: number;
  111718. }>;
  111719. private _isEnabled;
  111720. private _parent;
  111721. /**
  111722. * Creates a PlaneRotationGizmo
  111723. * @param gizmoLayer The utility layer the gizmo will be added to
  111724. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111725. * @param color The color of the gizmo
  111726. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111727. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111728. */
  111729. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111730. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111731. /**
  111732. * If the gizmo is enabled
  111733. */
  111734. isEnabled: boolean;
  111735. /**
  111736. * Disposes of the gizmo
  111737. */
  111738. dispose(): void;
  111739. }
  111740. }
  111741. declare module BABYLON {
  111742. /**
  111743. * Gizmo that enables rotating a mesh along 3 axis
  111744. */
  111745. export class RotationGizmo extends Gizmo {
  111746. /**
  111747. * Internal gizmo used for interactions on the x axis
  111748. */
  111749. xGizmo: PlaneRotationGizmo;
  111750. /**
  111751. * Internal gizmo used for interactions on the y axis
  111752. */
  111753. yGizmo: PlaneRotationGizmo;
  111754. /**
  111755. * Internal gizmo used for interactions on the z axis
  111756. */
  111757. zGizmo: PlaneRotationGizmo;
  111758. /** Fires an event when any of it's sub gizmos are dragged */
  111759. onDragStartObservable: Observable<unknown>;
  111760. /** Fires an event when any of it's sub gizmos are released from dragging */
  111761. onDragEndObservable: Observable<unknown>;
  111762. private _meshAttached;
  111763. attachedMesh: Nullable<AbstractMesh>;
  111764. /**
  111765. * Creates a RotationGizmo
  111766. * @param gizmoLayer The utility layer the gizmo will be added to
  111767. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111768. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111769. */
  111770. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111771. updateGizmoRotationToMatchAttachedMesh: boolean;
  111772. /**
  111773. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111774. */
  111775. snapDistance: number;
  111776. /**
  111777. * Ratio for the scale of the gizmo (Default: 1)
  111778. */
  111779. scaleRatio: number;
  111780. /**
  111781. * Disposes of the gizmo
  111782. */
  111783. dispose(): void;
  111784. /**
  111785. * CustomMeshes are not supported by this gizmo
  111786. * @param mesh The mesh to replace the default mesh of the gizmo
  111787. */
  111788. setCustomMesh(mesh: Mesh): void;
  111789. }
  111790. }
  111791. declare module BABYLON {
  111792. /**
  111793. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  111794. */
  111795. export class GizmoManager implements IDisposable {
  111796. private scene;
  111797. /**
  111798. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  111799. */
  111800. gizmos: {
  111801. positionGizmo: Nullable<PositionGizmo>;
  111802. rotationGizmo: Nullable<RotationGizmo>;
  111803. scaleGizmo: Nullable<ScaleGizmo>;
  111804. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111805. };
  111806. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111807. clearGizmoOnEmptyPointerEvent: boolean;
  111808. /** Fires an event when the manager is attached to a mesh */
  111809. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111810. private _gizmosEnabled;
  111811. private _pointerObserver;
  111812. private _attachedMesh;
  111813. private _boundingBoxColor;
  111814. private _defaultUtilityLayer;
  111815. private _defaultKeepDepthUtilityLayer;
  111816. /**
  111817. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111818. */
  111819. boundingBoxDragBehavior: SixDofDragBehavior;
  111820. /**
  111821. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111822. */
  111823. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111824. /**
  111825. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111826. */
  111827. usePointerToAttachGizmos: boolean;
  111828. /**
  111829. * Utility layer that the bounding box gizmo belongs to
  111830. */
  111831. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111832. /**
  111833. * Utility layer that all gizmos besides bounding box belong to
  111834. */
  111835. readonly utilityLayer: UtilityLayerRenderer;
  111836. /**
  111837. * Instatiates a gizmo manager
  111838. * @param scene the scene to overlay the gizmos on top of
  111839. */
  111840. constructor(scene: Scene);
  111841. /**
  111842. * Attaches a set of gizmos to the specified mesh
  111843. * @param mesh The mesh the gizmo's should be attached to
  111844. */
  111845. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111846. /**
  111847. * If the position gizmo is enabled
  111848. */
  111849. positionGizmoEnabled: boolean;
  111850. /**
  111851. * If the rotation gizmo is enabled
  111852. */
  111853. rotationGizmoEnabled: boolean;
  111854. /**
  111855. * If the scale gizmo is enabled
  111856. */
  111857. scaleGizmoEnabled: boolean;
  111858. /**
  111859. * If the boundingBox gizmo is enabled
  111860. */
  111861. boundingBoxGizmoEnabled: boolean;
  111862. /**
  111863. * Disposes of the gizmo manager
  111864. */
  111865. dispose(): void;
  111866. }
  111867. }
  111868. declare module BABYLON {
  111869. /**
  111870. * A directional light is defined by a direction (what a surprise!).
  111871. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  111872. * 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.
  111873. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111874. */
  111875. export class DirectionalLight extends ShadowLight {
  111876. private _shadowFrustumSize;
  111877. /**
  111878. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  111879. */
  111880. /**
  111881. * Specifies a fix frustum size for the shadow generation.
  111882. */
  111883. shadowFrustumSize: number;
  111884. private _shadowOrthoScale;
  111885. /**
  111886. * Gets the shadow projection scale against the optimal computed one.
  111887. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111888. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111889. */
  111890. /**
  111891. * Sets the shadow projection scale against the optimal computed one.
  111892. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  111893. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  111894. */
  111895. shadowOrthoScale: number;
  111896. /**
  111897. * Automatically compute the projection matrix to best fit (including all the casters)
  111898. * on each frame.
  111899. */
  111900. autoUpdateExtends: boolean;
  111901. private _orthoLeft;
  111902. private _orthoRight;
  111903. private _orthoTop;
  111904. private _orthoBottom;
  111905. /**
  111906. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  111907. * The directional light is emitted from everywhere in the given direction.
  111908. * It can cast shadows.
  111909. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111910. * @param name The friendly name of the light
  111911. * @param direction The direction of the light
  111912. * @param scene The scene the light belongs to
  111913. */
  111914. constructor(name: string, direction: Vector3, scene: Scene);
  111915. /**
  111916. * Returns the string "DirectionalLight".
  111917. * @return The class name
  111918. */
  111919. getClassName(): string;
  111920. /**
  111921. * Returns the integer 1.
  111922. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111923. */
  111924. getTypeID(): number;
  111925. /**
  111926. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  111927. * Returns the DirectionalLight Shadow projection matrix.
  111928. */
  111929. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111930. /**
  111931. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  111932. * Returns the DirectionalLight Shadow projection matrix.
  111933. */
  111934. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  111935. /**
  111936. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  111937. * Returns the DirectionalLight Shadow projection matrix.
  111938. */
  111939. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111940. protected _buildUniformLayout(): void;
  111941. /**
  111942. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  111943. * @param effect The effect to update
  111944. * @param lightIndex The index of the light in the effect to update
  111945. * @returns The directional light
  111946. */
  111947. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  111948. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  111949. /**
  111950. * Gets the minZ used for shadow according to both the scene and the light.
  111951. *
  111952. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111953. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111954. * @param activeCamera The camera we are returning the min for
  111955. * @returns the depth min z
  111956. */
  111957. getDepthMinZ(activeCamera: Camera): number;
  111958. /**
  111959. * Gets the maxZ used for shadow according to both the scene and the light.
  111960. *
  111961. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  111962. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  111963. * @param activeCamera The camera we are returning the max for
  111964. * @returns the depth max z
  111965. */
  111966. getDepthMaxZ(activeCamera: Camera): number;
  111967. /**
  111968. * Prepares the list of defines specific to the light type.
  111969. * @param defines the list of defines
  111970. * @param lightIndex defines the index of the light for the effect
  111971. */
  111972. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111973. }
  111974. }
  111975. declare module BABYLON {
  111976. /**
  111977. * Class containing static functions to help procedurally build meshes
  111978. */
  111979. export class HemisphereBuilder {
  111980. /**
  111981. * Creates a hemisphere mesh
  111982. * @param name defines the name of the mesh
  111983. * @param options defines the options used to create the mesh
  111984. * @param scene defines the hosting scene
  111985. * @returns the hemisphere mesh
  111986. */
  111987. static CreateHemisphere(name: string, options: {
  111988. segments?: number;
  111989. diameter?: number;
  111990. sideOrientation?: number;
  111991. }, scene: any): Mesh;
  111992. }
  111993. }
  111994. declare module BABYLON {
  111995. /**
  111996. * A spot light is defined by a position, a direction, an angle, and an exponent.
  111997. * These values define a cone of light starting from the position, emitting toward the direction.
  111998. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  111999. * and the exponent defines the speed of the decay of the light with distance (reach).
  112000. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112001. */
  112002. export class SpotLight extends ShadowLight {
  112003. private _angle;
  112004. private _innerAngle;
  112005. private _cosHalfAngle;
  112006. private _lightAngleScale;
  112007. private _lightAngleOffset;
  112008. /**
  112009. * Gets the cone angle of the spot light in Radians.
  112010. */
  112011. /**
  112012. * Sets the cone angle of the spot light in Radians.
  112013. */
  112014. angle: number;
  112015. /**
  112016. * Only used in gltf falloff mode, this defines the angle where
  112017. * the directional falloff will start before cutting at angle which could be seen
  112018. * as outer angle.
  112019. */
  112020. /**
  112021. * Only used in gltf falloff mode, this defines the angle where
  112022. * the directional falloff will start before cutting at angle which could be seen
  112023. * as outer angle.
  112024. */
  112025. innerAngle: number;
  112026. private _shadowAngleScale;
  112027. /**
  112028. * Allows scaling the angle of the light for shadow generation only.
  112029. */
  112030. /**
  112031. * Allows scaling the angle of the light for shadow generation only.
  112032. */
  112033. shadowAngleScale: number;
  112034. /**
  112035. * The light decay speed with the distance from the emission spot.
  112036. */
  112037. exponent: number;
  112038. private _projectionTextureMatrix;
  112039. /**
  112040. * Allows reading the projecton texture
  112041. */
  112042. readonly projectionTextureMatrix: Matrix;
  112043. protected _projectionTextureLightNear: number;
  112044. /**
  112045. * Gets the near clip of the Spotlight for texture projection.
  112046. */
  112047. /**
  112048. * Sets the near clip of the Spotlight for texture projection.
  112049. */
  112050. projectionTextureLightNear: number;
  112051. protected _projectionTextureLightFar: number;
  112052. /**
  112053. * Gets the far clip of the Spotlight for texture projection.
  112054. */
  112055. /**
  112056. * Sets the far clip of the Spotlight for texture projection.
  112057. */
  112058. projectionTextureLightFar: number;
  112059. protected _projectionTextureUpDirection: Vector3;
  112060. /**
  112061. * Gets the Up vector of the Spotlight for texture projection.
  112062. */
  112063. /**
  112064. * Sets the Up vector of the Spotlight for texture projection.
  112065. */
  112066. projectionTextureUpDirection: Vector3;
  112067. private _projectionTexture;
  112068. /**
  112069. * Gets the projection texture of the light.
  112070. */
  112071. /**
  112072. * Sets the projection texture of the light.
  112073. */
  112074. projectionTexture: Nullable<BaseTexture>;
  112075. private _projectionTextureViewLightDirty;
  112076. private _projectionTextureProjectionLightDirty;
  112077. private _projectionTextureDirty;
  112078. private _projectionTextureViewTargetVector;
  112079. private _projectionTextureViewLightMatrix;
  112080. private _projectionTextureProjectionLightMatrix;
  112081. private _projectionTextureScalingMatrix;
  112082. /**
  112083. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112084. * It can cast shadows.
  112085. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112086. * @param name The light friendly name
  112087. * @param position The position of the spot light in the scene
  112088. * @param direction The direction of the light in the scene
  112089. * @param angle The cone angle of the light in Radians
  112090. * @param exponent The light decay speed with the distance from the emission spot
  112091. * @param scene The scene the lights belongs to
  112092. */
  112093. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112094. /**
  112095. * Returns the string "SpotLight".
  112096. * @returns the class name
  112097. */
  112098. getClassName(): string;
  112099. /**
  112100. * Returns the integer 2.
  112101. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112102. */
  112103. getTypeID(): number;
  112104. /**
  112105. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112106. */
  112107. protected _setDirection(value: Vector3): void;
  112108. /**
  112109. * Overrides the position setter to recompute the projection texture view light Matrix.
  112110. */
  112111. protected _setPosition(value: Vector3): void;
  112112. /**
  112113. * 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.
  112114. * Returns the SpotLight.
  112115. */
  112116. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112117. protected _computeProjectionTextureViewLightMatrix(): void;
  112118. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112119. /**
  112120. * Main function for light texture projection matrix computing.
  112121. */
  112122. protected _computeProjectionTextureMatrix(): void;
  112123. protected _buildUniformLayout(): void;
  112124. private _computeAngleValues;
  112125. /**
  112126. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112127. * @param effect The effect to update
  112128. * @param lightIndex The index of the light in the effect to update
  112129. * @returns The spot light
  112130. */
  112131. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112132. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112133. /**
  112134. * Disposes the light and the associated resources.
  112135. */
  112136. dispose(): void;
  112137. /**
  112138. * Prepares the list of defines specific to the light type.
  112139. * @param defines the list of defines
  112140. * @param lightIndex defines the index of the light for the effect
  112141. */
  112142. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112143. }
  112144. }
  112145. declare module BABYLON {
  112146. /**
  112147. * Gizmo that enables viewing a light
  112148. */
  112149. export class LightGizmo extends Gizmo {
  112150. private _lightMesh;
  112151. private _material;
  112152. private cachedPosition;
  112153. private cachedForward;
  112154. /**
  112155. * Creates a LightGizmo
  112156. * @param gizmoLayer The utility layer the gizmo will be added to
  112157. */
  112158. constructor(gizmoLayer?: UtilityLayerRenderer);
  112159. private _light;
  112160. /**
  112161. * The light that the gizmo is attached to
  112162. */
  112163. light: Nullable<Light>;
  112164. /**
  112165. * Gets the material used to render the light gizmo
  112166. */
  112167. readonly material: StandardMaterial;
  112168. /**
  112169. * @hidden
  112170. * Updates the gizmo to match the attached mesh's position/rotation
  112171. */
  112172. protected _update(): void;
  112173. private static _Scale;
  112174. /**
  112175. * Creates the lines for a light mesh
  112176. */
  112177. private static _createLightLines;
  112178. /**
  112179. * Disposes of the light gizmo
  112180. */
  112181. dispose(): void;
  112182. private static _CreateHemisphericLightMesh;
  112183. private static _CreatePointLightMesh;
  112184. private static _CreateSpotLightMesh;
  112185. private static _CreateDirectionalLightMesh;
  112186. }
  112187. }
  112188. declare module BABYLON {
  112189. /** @hidden */
  112190. export var backgroundFragmentDeclaration: {
  112191. name: string;
  112192. shader: string;
  112193. };
  112194. }
  112195. declare module BABYLON {
  112196. /** @hidden */
  112197. export var backgroundUboDeclaration: {
  112198. name: string;
  112199. shader: string;
  112200. };
  112201. }
  112202. declare module BABYLON {
  112203. /** @hidden */
  112204. export var backgroundPixelShader: {
  112205. name: string;
  112206. shader: string;
  112207. };
  112208. }
  112209. declare module BABYLON {
  112210. /** @hidden */
  112211. export var backgroundVertexDeclaration: {
  112212. name: string;
  112213. shader: string;
  112214. };
  112215. }
  112216. declare module BABYLON {
  112217. /** @hidden */
  112218. export var backgroundVertexShader: {
  112219. name: string;
  112220. shader: string;
  112221. };
  112222. }
  112223. declare module BABYLON {
  112224. /**
  112225. * Background material used to create an efficient environement around your scene.
  112226. */
  112227. export class BackgroundMaterial extends PushMaterial {
  112228. /**
  112229. * Standard reflectance value at parallel view angle.
  112230. */
  112231. static StandardReflectance0: number;
  112232. /**
  112233. * Standard reflectance value at grazing angle.
  112234. */
  112235. static StandardReflectance90: number;
  112236. protected _primaryColor: Color3;
  112237. /**
  112238. * Key light Color (multiply against the environement texture)
  112239. */
  112240. primaryColor: Color3;
  112241. protected __perceptualColor: Nullable<Color3>;
  112242. /**
  112243. * Experimental Internal Use Only.
  112244. *
  112245. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112246. * This acts as a helper to set the primary color to a more "human friendly" value.
  112247. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112248. * output color as close as possible from the chosen value.
  112249. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112250. * part of lighting setup.)
  112251. */
  112252. _perceptualColor: Nullable<Color3>;
  112253. protected _primaryColorShadowLevel: float;
  112254. /**
  112255. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112256. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112257. */
  112258. primaryColorShadowLevel: float;
  112259. protected _primaryColorHighlightLevel: float;
  112260. /**
  112261. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112262. * The primary color is used at the level chosen to define what the white area would look.
  112263. */
  112264. primaryColorHighlightLevel: float;
  112265. protected _reflectionTexture: Nullable<BaseTexture>;
  112266. /**
  112267. * Reflection Texture used in the material.
  112268. * Should be author in a specific way for the best result (refer to the documentation).
  112269. */
  112270. reflectionTexture: Nullable<BaseTexture>;
  112271. protected _reflectionBlur: float;
  112272. /**
  112273. * Reflection Texture level of blur.
  112274. *
  112275. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112276. * texture twice.
  112277. */
  112278. reflectionBlur: float;
  112279. protected _diffuseTexture: Nullable<BaseTexture>;
  112280. /**
  112281. * Diffuse Texture used in the material.
  112282. * Should be author in a specific way for the best result (refer to the documentation).
  112283. */
  112284. diffuseTexture: Nullable<BaseTexture>;
  112285. protected _shadowLights: Nullable<IShadowLight[]>;
  112286. /**
  112287. * Specify the list of lights casting shadow on the material.
  112288. * All scene shadow lights will be included if null.
  112289. */
  112290. shadowLights: Nullable<IShadowLight[]>;
  112291. protected _shadowLevel: float;
  112292. /**
  112293. * Helps adjusting the shadow to a softer level if required.
  112294. * 0 means black shadows and 1 means no shadows.
  112295. */
  112296. shadowLevel: float;
  112297. protected _sceneCenter: Vector3;
  112298. /**
  112299. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112300. * It is usually zero but might be interesting to modify according to your setup.
  112301. */
  112302. sceneCenter: Vector3;
  112303. protected _opacityFresnel: boolean;
  112304. /**
  112305. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112306. * This helps ensuring a nice transition when the camera goes under the ground.
  112307. */
  112308. opacityFresnel: boolean;
  112309. protected _reflectionFresnel: boolean;
  112310. /**
  112311. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112312. * This helps adding a mirror texture on the ground.
  112313. */
  112314. reflectionFresnel: boolean;
  112315. protected _reflectionFalloffDistance: number;
  112316. /**
  112317. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112318. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112319. */
  112320. reflectionFalloffDistance: number;
  112321. protected _reflectionAmount: number;
  112322. /**
  112323. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112324. */
  112325. reflectionAmount: number;
  112326. protected _reflectionReflectance0: number;
  112327. /**
  112328. * This specifies the weight of the reflection at grazing angle.
  112329. */
  112330. reflectionReflectance0: number;
  112331. protected _reflectionReflectance90: number;
  112332. /**
  112333. * This specifies the weight of the reflection at a perpendicular point of view.
  112334. */
  112335. reflectionReflectance90: number;
  112336. /**
  112337. * Sets the reflection reflectance fresnel values according to the default standard
  112338. * empirically know to work well :-)
  112339. */
  112340. reflectionStandardFresnelWeight: number;
  112341. protected _useRGBColor: boolean;
  112342. /**
  112343. * Helps to directly use the maps channels instead of their level.
  112344. */
  112345. useRGBColor: boolean;
  112346. protected _enableNoise: boolean;
  112347. /**
  112348. * This helps reducing the banding effect that could occur on the background.
  112349. */
  112350. enableNoise: boolean;
  112351. /**
  112352. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112353. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112354. * Recommended to be keep at 1.0 except for special cases.
  112355. */
  112356. fovMultiplier: number;
  112357. private _fovMultiplier;
  112358. /**
  112359. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112360. */
  112361. useEquirectangularFOV: boolean;
  112362. private _maxSimultaneousLights;
  112363. /**
  112364. * Number of Simultaneous lights allowed on the material.
  112365. */
  112366. maxSimultaneousLights: int;
  112367. /**
  112368. * Default configuration related to image processing available in the Background Material.
  112369. */
  112370. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112371. /**
  112372. * Keep track of the image processing observer to allow dispose and replace.
  112373. */
  112374. private _imageProcessingObserver;
  112375. /**
  112376. * Attaches a new image processing configuration to the PBR Material.
  112377. * @param configuration (if null the scene configuration will be use)
  112378. */
  112379. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112380. /**
  112381. * Gets the image processing configuration used either in this material.
  112382. */
  112383. /**
  112384. * Sets the Default image processing configuration used either in the this material.
  112385. *
  112386. * If sets to null, the scene one is in use.
  112387. */
  112388. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112389. /**
  112390. * Gets wether the color curves effect is enabled.
  112391. */
  112392. /**
  112393. * Sets wether the color curves effect is enabled.
  112394. */
  112395. cameraColorCurvesEnabled: boolean;
  112396. /**
  112397. * Gets wether the color grading effect is enabled.
  112398. */
  112399. /**
  112400. * Gets wether the color grading effect is enabled.
  112401. */
  112402. cameraColorGradingEnabled: boolean;
  112403. /**
  112404. * Gets wether tonemapping is enabled or not.
  112405. */
  112406. /**
  112407. * Sets wether tonemapping is enabled or not
  112408. */
  112409. cameraToneMappingEnabled: boolean;
  112410. /**
  112411. * The camera exposure used on this material.
  112412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112413. * This corresponds to a photographic exposure.
  112414. */
  112415. /**
  112416. * The camera exposure used on this material.
  112417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112418. * This corresponds to a photographic exposure.
  112419. */
  112420. cameraExposure: float;
  112421. /**
  112422. * Gets The camera contrast used on this material.
  112423. */
  112424. /**
  112425. * Sets The camera contrast used on this material.
  112426. */
  112427. cameraContrast: float;
  112428. /**
  112429. * Gets the Color Grading 2D Lookup Texture.
  112430. */
  112431. /**
  112432. * Sets the Color Grading 2D Lookup Texture.
  112433. */
  112434. cameraColorGradingTexture: Nullable<BaseTexture>;
  112435. /**
  112436. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112437. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112438. * 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;
  112439. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112440. */
  112441. /**
  112442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112444. * 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;
  112445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112446. */
  112447. cameraColorCurves: Nullable<ColorCurves>;
  112448. /**
  112449. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112450. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112451. */
  112452. switchToBGR: boolean;
  112453. private _renderTargets;
  112454. private _reflectionControls;
  112455. private _white;
  112456. private _primaryShadowColor;
  112457. private _primaryHighlightColor;
  112458. /**
  112459. * Instantiates a Background Material in the given scene
  112460. * @param name The friendly name of the material
  112461. * @param scene The scene to add the material to
  112462. */
  112463. constructor(name: string, scene: Scene);
  112464. /**
  112465. * Gets a boolean indicating that current material needs to register RTT
  112466. */
  112467. readonly hasRenderTargetTextures: boolean;
  112468. /**
  112469. * The entire material has been created in order to prevent overdraw.
  112470. * @returns false
  112471. */
  112472. needAlphaTesting(): boolean;
  112473. /**
  112474. * The entire material has been created in order to prevent overdraw.
  112475. * @returns true if blending is enable
  112476. */
  112477. needAlphaBlending(): boolean;
  112478. /**
  112479. * Checks wether the material is ready to be rendered for a given mesh.
  112480. * @param mesh The mesh to render
  112481. * @param subMesh The submesh to check against
  112482. * @param useInstances Specify wether or not the material is used with instances
  112483. * @returns true if all the dependencies are ready (Textures, Effects...)
  112484. */
  112485. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112486. /**
  112487. * Compute the primary color according to the chosen perceptual color.
  112488. */
  112489. private _computePrimaryColorFromPerceptualColor;
  112490. /**
  112491. * Compute the highlights and shadow colors according to their chosen levels.
  112492. */
  112493. private _computePrimaryColors;
  112494. /**
  112495. * Build the uniform buffer used in the material.
  112496. */
  112497. buildUniformLayout(): void;
  112498. /**
  112499. * Unbind the material.
  112500. */
  112501. unbind(): void;
  112502. /**
  112503. * Bind only the world matrix to the material.
  112504. * @param world The world matrix to bind.
  112505. */
  112506. bindOnlyWorldMatrix(world: Matrix): void;
  112507. /**
  112508. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112509. * @param world The world matrix to bind.
  112510. * @param subMesh The submesh to bind for.
  112511. */
  112512. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112513. /**
  112514. * Checks to see if a texture is used in the material.
  112515. * @param texture - Base texture to use.
  112516. * @returns - Boolean specifying if a texture is used in the material.
  112517. */
  112518. hasTexture(texture: BaseTexture): boolean;
  112519. /**
  112520. * Dispose the material.
  112521. * @param forceDisposeEffect Force disposal of the associated effect.
  112522. * @param forceDisposeTextures Force disposal of the associated textures.
  112523. */
  112524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112525. /**
  112526. * Clones the material.
  112527. * @param name The cloned name.
  112528. * @returns The cloned material.
  112529. */
  112530. clone(name: string): BackgroundMaterial;
  112531. /**
  112532. * Serializes the current material to its JSON representation.
  112533. * @returns The JSON representation.
  112534. */
  112535. serialize(): any;
  112536. /**
  112537. * Gets the class name of the material
  112538. * @returns "BackgroundMaterial"
  112539. */
  112540. getClassName(): string;
  112541. /**
  112542. * Parse a JSON input to create back a background material.
  112543. * @param source The JSON data to parse
  112544. * @param scene The scene to create the parsed material in
  112545. * @param rootUrl The root url of the assets the material depends upon
  112546. * @returns the instantiated BackgroundMaterial.
  112547. */
  112548. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112549. }
  112550. }
  112551. declare module BABYLON {
  112552. /**
  112553. * Represents the different options available during the creation of
  112554. * a Environment helper.
  112555. *
  112556. * This can control the default ground, skybox and image processing setup of your scene.
  112557. */
  112558. export interface IEnvironmentHelperOptions {
  112559. /**
  112560. * Specifies wether or not to create a ground.
  112561. * True by default.
  112562. */
  112563. createGround: boolean;
  112564. /**
  112565. * Specifies the ground size.
  112566. * 15 by default.
  112567. */
  112568. groundSize: number;
  112569. /**
  112570. * The texture used on the ground for the main color.
  112571. * Comes from the BabylonJS CDN by default.
  112572. *
  112573. * Remarks: Can be either a texture or a url.
  112574. */
  112575. groundTexture: string | BaseTexture;
  112576. /**
  112577. * The color mixed in the ground texture by default.
  112578. * BabylonJS clearColor by default.
  112579. */
  112580. groundColor: Color3;
  112581. /**
  112582. * Specifies the ground opacity.
  112583. * 1 by default.
  112584. */
  112585. groundOpacity: number;
  112586. /**
  112587. * Enables the ground to receive shadows.
  112588. * True by default.
  112589. */
  112590. enableGroundShadow: boolean;
  112591. /**
  112592. * Helps preventing the shadow to be fully black on the ground.
  112593. * 0.5 by default.
  112594. */
  112595. groundShadowLevel: number;
  112596. /**
  112597. * Creates a mirror texture attach to the ground.
  112598. * false by default.
  112599. */
  112600. enableGroundMirror: boolean;
  112601. /**
  112602. * Specifies the ground mirror size ratio.
  112603. * 0.3 by default as the default kernel is 64.
  112604. */
  112605. groundMirrorSizeRatio: number;
  112606. /**
  112607. * Specifies the ground mirror blur kernel size.
  112608. * 64 by default.
  112609. */
  112610. groundMirrorBlurKernel: number;
  112611. /**
  112612. * Specifies the ground mirror visibility amount.
  112613. * 1 by default
  112614. */
  112615. groundMirrorAmount: number;
  112616. /**
  112617. * Specifies the ground mirror reflectance weight.
  112618. * This uses the standard weight of the background material to setup the fresnel effect
  112619. * of the mirror.
  112620. * 1 by default.
  112621. */
  112622. groundMirrorFresnelWeight: number;
  112623. /**
  112624. * Specifies the ground mirror Falloff distance.
  112625. * This can helps reducing the size of the reflection.
  112626. * 0 by Default.
  112627. */
  112628. groundMirrorFallOffDistance: number;
  112629. /**
  112630. * Specifies the ground mirror texture type.
  112631. * Unsigned Int by Default.
  112632. */
  112633. groundMirrorTextureType: number;
  112634. /**
  112635. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112636. * the shown objects.
  112637. */
  112638. groundYBias: number;
  112639. /**
  112640. * Specifies wether or not to create a skybox.
  112641. * True by default.
  112642. */
  112643. createSkybox: boolean;
  112644. /**
  112645. * Specifies the skybox size.
  112646. * 20 by default.
  112647. */
  112648. skyboxSize: number;
  112649. /**
  112650. * The texture used on the skybox for the main color.
  112651. * Comes from the BabylonJS CDN by default.
  112652. *
  112653. * Remarks: Can be either a texture or a url.
  112654. */
  112655. skyboxTexture: string | BaseTexture;
  112656. /**
  112657. * The color mixed in the skybox texture by default.
  112658. * BabylonJS clearColor by default.
  112659. */
  112660. skyboxColor: Color3;
  112661. /**
  112662. * The background rotation around the Y axis of the scene.
  112663. * This helps aligning the key lights of your scene with the background.
  112664. * 0 by default.
  112665. */
  112666. backgroundYRotation: number;
  112667. /**
  112668. * Compute automatically the size of the elements to best fit with the scene.
  112669. */
  112670. sizeAuto: boolean;
  112671. /**
  112672. * Default position of the rootMesh if autoSize is not true.
  112673. */
  112674. rootPosition: Vector3;
  112675. /**
  112676. * Sets up the image processing in the scene.
  112677. * true by default.
  112678. */
  112679. setupImageProcessing: boolean;
  112680. /**
  112681. * The texture used as your environment texture in the scene.
  112682. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112683. *
  112684. * Remarks: Can be either a texture or a url.
  112685. */
  112686. environmentTexture: string | BaseTexture;
  112687. /**
  112688. * The value of the exposure to apply to the scene.
  112689. * 0.6 by default if setupImageProcessing is true.
  112690. */
  112691. cameraExposure: number;
  112692. /**
  112693. * The value of the contrast to apply to the scene.
  112694. * 1.6 by default if setupImageProcessing is true.
  112695. */
  112696. cameraContrast: number;
  112697. /**
  112698. * Specifies wether or not tonemapping should be enabled in the scene.
  112699. * true by default if setupImageProcessing is true.
  112700. */
  112701. toneMappingEnabled: boolean;
  112702. }
  112703. /**
  112704. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112705. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112706. * It also helps with the default setup of your imageProcessing configuration.
  112707. */
  112708. export class EnvironmentHelper {
  112709. /**
  112710. * Default ground texture URL.
  112711. */
  112712. private static _groundTextureCDNUrl;
  112713. /**
  112714. * Default skybox texture URL.
  112715. */
  112716. private static _skyboxTextureCDNUrl;
  112717. /**
  112718. * Default environment texture URL.
  112719. */
  112720. private static _environmentTextureCDNUrl;
  112721. /**
  112722. * Creates the default options for the helper.
  112723. */
  112724. private static _getDefaultOptions;
  112725. private _rootMesh;
  112726. /**
  112727. * Gets the root mesh created by the helper.
  112728. */
  112729. readonly rootMesh: Mesh;
  112730. private _skybox;
  112731. /**
  112732. * Gets the skybox created by the helper.
  112733. */
  112734. readonly skybox: Nullable<Mesh>;
  112735. private _skyboxTexture;
  112736. /**
  112737. * Gets the skybox texture created by the helper.
  112738. */
  112739. readonly skyboxTexture: Nullable<BaseTexture>;
  112740. private _skyboxMaterial;
  112741. /**
  112742. * Gets the skybox material created by the helper.
  112743. */
  112744. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112745. private _ground;
  112746. /**
  112747. * Gets the ground mesh created by the helper.
  112748. */
  112749. readonly ground: Nullable<Mesh>;
  112750. private _groundTexture;
  112751. /**
  112752. * Gets the ground texture created by the helper.
  112753. */
  112754. readonly groundTexture: Nullable<BaseTexture>;
  112755. private _groundMirror;
  112756. /**
  112757. * Gets the ground mirror created by the helper.
  112758. */
  112759. readonly groundMirror: Nullable<MirrorTexture>;
  112760. /**
  112761. * Gets the ground mirror render list to helps pushing the meshes
  112762. * you wish in the ground reflection.
  112763. */
  112764. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112765. private _groundMaterial;
  112766. /**
  112767. * Gets the ground material created by the helper.
  112768. */
  112769. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112770. /**
  112771. * Stores the creation options.
  112772. */
  112773. private readonly _scene;
  112774. private _options;
  112775. /**
  112776. * This observable will be notified with any error during the creation of the environment,
  112777. * mainly texture creation errors.
  112778. */
  112779. onErrorObservable: Observable<{
  112780. message?: string;
  112781. exception?: any;
  112782. }>;
  112783. /**
  112784. * constructor
  112785. * @param options Defines the options we want to customize the helper
  112786. * @param scene The scene to add the material to
  112787. */
  112788. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  112789. /**
  112790. * Updates the background according to the new options
  112791. * @param options
  112792. */
  112793. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  112794. /**
  112795. * Sets the primary color of all the available elements.
  112796. * @param color the main color to affect to the ground and the background
  112797. */
  112798. setMainColor(color: Color3): void;
  112799. /**
  112800. * Setup the image processing according to the specified options.
  112801. */
  112802. private _setupImageProcessing;
  112803. /**
  112804. * Setup the environment texture according to the specified options.
  112805. */
  112806. private _setupEnvironmentTexture;
  112807. /**
  112808. * Setup the background according to the specified options.
  112809. */
  112810. private _setupBackground;
  112811. /**
  112812. * Get the scene sizes according to the setup.
  112813. */
  112814. private _getSceneSize;
  112815. /**
  112816. * Setup the ground according to the specified options.
  112817. */
  112818. private _setupGround;
  112819. /**
  112820. * Setup the ground material according to the specified options.
  112821. */
  112822. private _setupGroundMaterial;
  112823. /**
  112824. * Setup the ground diffuse texture according to the specified options.
  112825. */
  112826. private _setupGroundDiffuseTexture;
  112827. /**
  112828. * Setup the ground mirror texture according to the specified options.
  112829. */
  112830. private _setupGroundMirrorTexture;
  112831. /**
  112832. * Setup the ground to receive the mirror texture.
  112833. */
  112834. private _setupMirrorInGroundMaterial;
  112835. /**
  112836. * Setup the skybox according to the specified options.
  112837. */
  112838. private _setupSkybox;
  112839. /**
  112840. * Setup the skybox material according to the specified options.
  112841. */
  112842. private _setupSkyboxMaterial;
  112843. /**
  112844. * Setup the skybox reflection texture according to the specified options.
  112845. */
  112846. private _setupSkyboxReflectionTexture;
  112847. private _errorHandler;
  112848. /**
  112849. * Dispose all the elements created by the Helper.
  112850. */
  112851. dispose(): void;
  112852. }
  112853. }
  112854. declare module BABYLON {
  112855. /**
  112856. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  112857. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  112858. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  112859. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  112860. */
  112861. export class PhotoDome extends TransformNode {
  112862. /**
  112863. * Define the image as a Monoscopic panoramic 360 image.
  112864. */
  112865. static readonly MODE_MONOSCOPIC: number;
  112866. /**
  112867. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112868. */
  112869. static readonly MODE_TOPBOTTOM: number;
  112870. /**
  112871. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112872. */
  112873. static readonly MODE_SIDEBYSIDE: number;
  112874. private _useDirectMapping;
  112875. /**
  112876. * The texture being displayed on the sphere
  112877. */
  112878. protected _photoTexture: Texture;
  112879. /**
  112880. * Gets or sets the texture being displayed on the sphere
  112881. */
  112882. photoTexture: Texture;
  112883. /**
  112884. * Observable raised when an error occured while loading the 360 image
  112885. */
  112886. onLoadErrorObservable: Observable<string>;
  112887. /**
  112888. * The skybox material
  112889. */
  112890. protected _material: BackgroundMaterial;
  112891. /**
  112892. * The surface used for the skybox
  112893. */
  112894. protected _mesh: Mesh;
  112895. /**
  112896. * Gets the mesh used for the skybox.
  112897. */
  112898. readonly mesh: Mesh;
  112899. /**
  112900. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112901. * Also see the options.resolution property.
  112902. */
  112903. fovMultiplier: number;
  112904. private _imageMode;
  112905. /**
  112906. * Gets or set the current video mode for the video. It can be:
  112907. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  112908. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  112909. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  112910. */
  112911. imageMode: number;
  112912. /**
  112913. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  112914. * @param name Element's name, child elements will append suffixes for their own names.
  112915. * @param urlsOfPhoto defines the url of the photo to display
  112916. * @param options defines an object containing optional or exposed sub element properties
  112917. * @param onError defines a callback called when an error occured while loading the texture
  112918. */
  112919. constructor(name: string, urlOfPhoto: string, options: {
  112920. resolution?: number;
  112921. size?: number;
  112922. useDirectMapping?: boolean;
  112923. faceForward?: boolean;
  112924. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  112925. private _onBeforeCameraRenderObserver;
  112926. private _changeImageMode;
  112927. /**
  112928. * Releases resources associated with this node.
  112929. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112930. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112931. */
  112932. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112933. }
  112934. }
  112935. declare module BABYLON {
  112936. /**
  112937. * Class used to host RGBD texture specific utilities
  112938. */
  112939. export class RGBDTextureTools {
  112940. /**
  112941. * Expand the RGBD Texture from RGBD to Half Float if possible.
  112942. * @param texture the texture to expand.
  112943. */
  112944. static ExpandRGBDTexture(texture: Texture): void;
  112945. }
  112946. }
  112947. declare module BABYLON {
  112948. /**
  112949. * Class used to host texture specific utilities
  112950. */
  112951. export class BRDFTextureTools {
  112952. /**
  112953. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  112954. * @param scene defines the hosting scene
  112955. * @returns the environment BRDF texture
  112956. */
  112957. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  112958. private static _environmentBRDFBase64Texture;
  112959. }
  112960. }
  112961. declare module BABYLON {
  112962. /**
  112963. * @hidden
  112964. */
  112965. export interface IMaterialClearCoatDefines {
  112966. CLEARCOAT: boolean;
  112967. CLEARCOAT_DEFAULTIOR: boolean;
  112968. CLEARCOAT_TEXTURE: boolean;
  112969. CLEARCOAT_TEXTUREDIRECTUV: number;
  112970. CLEARCOAT_BUMP: boolean;
  112971. CLEARCOAT_BUMPDIRECTUV: number;
  112972. CLEARCOAT_TINT: boolean;
  112973. CLEARCOAT_TINT_TEXTURE: boolean;
  112974. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112975. /** @hidden */
  112976. _areTexturesDirty: boolean;
  112977. }
  112978. /**
  112979. * Define the code related to the clear coat parameters of the pbr material.
  112980. */
  112981. export class PBRClearCoatConfiguration {
  112982. /**
  112983. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  112984. * The default fits with a polyurethane material.
  112985. */
  112986. private static readonly _DefaultIndexOfRefraction;
  112987. private _isEnabled;
  112988. /**
  112989. * Defines if the clear coat is enabled in the material.
  112990. */
  112991. isEnabled: boolean;
  112992. /**
  112993. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  112994. */
  112995. intensity: number;
  112996. /**
  112997. * Defines the clear coat layer roughness.
  112998. */
  112999. roughness: number;
  113000. private _indexOfRefraction;
  113001. /**
  113002. * Defines the index of refraction of the clear coat.
  113003. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113004. * The default fits with a polyurethane material.
  113005. * Changing the default value is more performance intensive.
  113006. */
  113007. indexOfRefraction: number;
  113008. private _texture;
  113009. /**
  113010. * Stores the clear coat values in a texture.
  113011. */
  113012. texture: Nullable<BaseTexture>;
  113013. private _bumpTexture;
  113014. /**
  113015. * Define the clear coat specific bump texture.
  113016. */
  113017. bumpTexture: Nullable<BaseTexture>;
  113018. private _isTintEnabled;
  113019. /**
  113020. * Defines if the clear coat tint is enabled in the material.
  113021. */
  113022. isTintEnabled: boolean;
  113023. /**
  113024. * Defines the clear coat tint of the material.
  113025. * This is only use if tint is enabled
  113026. */
  113027. tintColor: Color3;
  113028. /**
  113029. * Defines the distance at which the tint color should be found in the
  113030. * clear coat media.
  113031. * This is only use if tint is enabled
  113032. */
  113033. tintColorAtDistance: number;
  113034. /**
  113035. * Defines the clear coat layer thickness.
  113036. * This is only use if tint is enabled
  113037. */
  113038. tintThickness: number;
  113039. private _tintTexture;
  113040. /**
  113041. * Stores the clear tint values in a texture.
  113042. * rgb is tint
  113043. * a is a thickness factor
  113044. */
  113045. tintTexture: Nullable<BaseTexture>;
  113046. /** @hidden */
  113047. private _internalMarkAllSubMeshesAsTexturesDirty;
  113048. /** @hidden */
  113049. _markAllSubMeshesAsTexturesDirty(): void;
  113050. /**
  113051. * Instantiate a new istance of clear coat configuration.
  113052. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113053. */
  113054. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113055. /**
  113056. * Gets wehter the submesh is ready to be used or not.
  113057. * @param defines the list of "defines" to update.
  113058. * @param scene defines the scene the material belongs to.
  113059. * @param engine defines the engine the material belongs to.
  113060. * @param disableBumpMap defines wether the material disables bump or not.
  113061. * @returns - boolean indicating that the submesh is ready or not.
  113062. */
  113063. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113064. /**
  113065. * Checks to see if a texture is used in the material.
  113066. * @param defines the list of "defines" to update.
  113067. * @param scene defines the scene to the material belongs to.
  113068. */
  113069. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113070. /**
  113071. * Binds the material data.
  113072. * @param uniformBuffer defines the Uniform buffer to fill in.
  113073. * @param scene defines the scene the material belongs to.
  113074. * @param engine defines the engine the material belongs to.
  113075. * @param disableBumpMap defines wether the material disables bump or not.
  113076. * @param isFrozen defines wether the material is frozen or not.
  113077. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113078. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113079. */
  113080. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113081. /**
  113082. * Checks to see if a texture is used in the material.
  113083. * @param texture - Base texture to use.
  113084. * @returns - Boolean specifying if a texture is used in the material.
  113085. */
  113086. hasTexture(texture: BaseTexture): boolean;
  113087. /**
  113088. * Returns an array of the actively used textures.
  113089. * @param activeTextures Array of BaseTextures
  113090. */
  113091. getActiveTextures(activeTextures: BaseTexture[]): void;
  113092. /**
  113093. * Returns the animatable textures.
  113094. * @param animatables Array of animatable textures.
  113095. */
  113096. getAnimatables(animatables: IAnimatable[]): void;
  113097. /**
  113098. * Disposes the resources of the material.
  113099. * @param forceDisposeTextures - Forces the disposal of all textures.
  113100. */
  113101. dispose(forceDisposeTextures?: boolean): void;
  113102. /**
  113103. * Get the current class name of the texture useful for serialization or dynamic coding.
  113104. * @returns "PBRClearCoatConfiguration"
  113105. */
  113106. getClassName(): string;
  113107. /**
  113108. * Add fallbacks to the effect fallbacks list.
  113109. * @param defines defines the Base texture to use.
  113110. * @param fallbacks defines the current fallback list.
  113111. * @param currentRank defines the current fallback rank.
  113112. * @returns the new fallback rank.
  113113. */
  113114. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113115. /**
  113116. * Add the required uniforms to the current list.
  113117. * @param uniforms defines the current uniform list.
  113118. */
  113119. static AddUniforms(uniforms: string[]): void;
  113120. /**
  113121. * Add the required samplers to the current list.
  113122. * @param samplers defines the current sampler list.
  113123. */
  113124. static AddSamplers(samplers: string[]): void;
  113125. /**
  113126. * Add the required uniforms to the current buffer.
  113127. * @param uniformBuffer defines the current uniform buffer.
  113128. */
  113129. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113130. /**
  113131. * Makes a duplicate of the current configuration into another one.
  113132. * @param clearCoatConfiguration define the config where to copy the info
  113133. */
  113134. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113135. /**
  113136. * Serializes this clear coat configuration.
  113137. * @returns - An object with the serialized config.
  113138. */
  113139. serialize(): any;
  113140. /**
  113141. * Parses a anisotropy Configuration from a serialized object.
  113142. * @param source - Serialized object.
  113143. * @param scene Defines the scene we are parsing for
  113144. * @param rootUrl Defines the rootUrl to load from
  113145. */
  113146. parse(source: any, scene: Scene, rootUrl: string): void;
  113147. }
  113148. }
  113149. declare module BABYLON {
  113150. /**
  113151. * @hidden
  113152. */
  113153. export interface IMaterialAnisotropicDefines {
  113154. ANISOTROPIC: boolean;
  113155. ANISOTROPIC_TEXTURE: boolean;
  113156. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113157. MAINUV1: boolean;
  113158. _areTexturesDirty: boolean;
  113159. _needUVs: boolean;
  113160. }
  113161. /**
  113162. * Define the code related to the anisotropic parameters of the pbr material.
  113163. */
  113164. export class PBRAnisotropicConfiguration {
  113165. private _isEnabled;
  113166. /**
  113167. * Defines if the anisotropy is enabled in the material.
  113168. */
  113169. isEnabled: boolean;
  113170. /**
  113171. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113172. */
  113173. intensity: number;
  113174. /**
  113175. * Defines if the effect is along the tangents, bitangents or in between.
  113176. * By default, the effect is "strectching" the highlights along the tangents.
  113177. */
  113178. direction: Vector2;
  113179. private _texture;
  113180. /**
  113181. * Stores the anisotropy values in a texture.
  113182. * rg is direction (like normal from -1 to 1)
  113183. * b is a intensity
  113184. */
  113185. texture: Nullable<BaseTexture>;
  113186. /** @hidden */
  113187. private _internalMarkAllSubMeshesAsTexturesDirty;
  113188. /** @hidden */
  113189. _markAllSubMeshesAsTexturesDirty(): void;
  113190. /**
  113191. * Instantiate a new istance of anisotropy configuration.
  113192. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113193. */
  113194. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113195. /**
  113196. * Specifies that the submesh is ready to be used.
  113197. * @param defines the list of "defines" to update.
  113198. * @param scene defines the scene the material belongs to.
  113199. * @returns - boolean indicating that the submesh is ready or not.
  113200. */
  113201. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113202. /**
  113203. * Checks to see if a texture is used in the material.
  113204. * @param defines the list of "defines" to update.
  113205. * @param mesh the mesh we are preparing the defines for.
  113206. * @param scene defines the scene the material belongs to.
  113207. */
  113208. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113209. /**
  113210. * Binds the material data.
  113211. * @param uniformBuffer defines the Uniform buffer to fill in.
  113212. * @param scene defines the scene the material belongs to.
  113213. * @param isFrozen defines wether the material is frozen or not.
  113214. */
  113215. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113216. /**
  113217. * Checks to see if a texture is used in the material.
  113218. * @param texture - Base texture to use.
  113219. * @returns - Boolean specifying if a texture is used in the material.
  113220. */
  113221. hasTexture(texture: BaseTexture): boolean;
  113222. /**
  113223. * Returns an array of the actively used textures.
  113224. * @param activeTextures Array of BaseTextures
  113225. */
  113226. getActiveTextures(activeTextures: BaseTexture[]): void;
  113227. /**
  113228. * Returns the animatable textures.
  113229. * @param animatables Array of animatable textures.
  113230. */
  113231. getAnimatables(animatables: IAnimatable[]): void;
  113232. /**
  113233. * Disposes the resources of the material.
  113234. * @param forceDisposeTextures - Forces the disposal of all textures.
  113235. */
  113236. dispose(forceDisposeTextures?: boolean): void;
  113237. /**
  113238. * Get the current class name of the texture useful for serialization or dynamic coding.
  113239. * @returns "PBRAnisotropicConfiguration"
  113240. */
  113241. getClassName(): string;
  113242. /**
  113243. * Add fallbacks to the effect fallbacks list.
  113244. * @param defines defines the Base texture to use.
  113245. * @param fallbacks defines the current fallback list.
  113246. * @param currentRank defines the current fallback rank.
  113247. * @returns the new fallback rank.
  113248. */
  113249. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113250. /**
  113251. * Add the required uniforms to the current list.
  113252. * @param uniforms defines the current uniform list.
  113253. */
  113254. static AddUniforms(uniforms: string[]): void;
  113255. /**
  113256. * Add the required uniforms to the current buffer.
  113257. * @param uniformBuffer defines the current uniform buffer.
  113258. */
  113259. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113260. /**
  113261. * Add the required samplers to the current list.
  113262. * @param samplers defines the current sampler list.
  113263. */
  113264. static AddSamplers(samplers: string[]): void;
  113265. /**
  113266. * Makes a duplicate of the current configuration into another one.
  113267. * @param anisotropicConfiguration define the config where to copy the info
  113268. */
  113269. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113270. /**
  113271. * Serializes this anisotropy configuration.
  113272. * @returns - An object with the serialized config.
  113273. */
  113274. serialize(): any;
  113275. /**
  113276. * Parses a anisotropy Configuration from a serialized object.
  113277. * @param source - Serialized object.
  113278. * @param scene Defines the scene we are parsing for
  113279. * @param rootUrl Defines the rootUrl to load from
  113280. */
  113281. parse(source: any, scene: Scene, rootUrl: string): void;
  113282. }
  113283. }
  113284. declare module BABYLON {
  113285. /**
  113286. * @hidden
  113287. */
  113288. export interface IMaterialBRDFDefines {
  113289. BRDF_V_HEIGHT_CORRELATED: boolean;
  113290. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113291. SPHERICAL_HARMONICS: boolean;
  113292. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113293. /** @hidden */
  113294. _areMiscDirty: boolean;
  113295. }
  113296. /**
  113297. * Define the code related to the BRDF parameters of the pbr material.
  113298. */
  113299. export class PBRBRDFConfiguration {
  113300. /**
  113301. * Default value used for the energy conservation.
  113302. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113303. */
  113304. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113305. /**
  113306. * Default value used for the Smith Visibility Height Correlated mode.
  113307. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113308. */
  113309. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113310. /**
  113311. * Default value used for the IBL diffuse part.
  113312. * This can help switching back to the polynomials mode globally which is a tiny bit
  113313. * less GPU intensive at the drawback of a lower quality.
  113314. */
  113315. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113316. /**
  113317. * Default value used for activating energy conservation for the specular workflow.
  113318. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113319. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113320. */
  113321. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113322. private _useEnergyConservation;
  113323. /**
  113324. * Defines if the material uses energy conservation.
  113325. */
  113326. useEnergyConservation: boolean;
  113327. private _useSmithVisibilityHeightCorrelated;
  113328. /**
  113329. * LEGACY Mode set to false
  113330. * Defines if the material uses height smith correlated visibility term.
  113331. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113332. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113333. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113334. * Not relying on height correlated will also disable energy conservation.
  113335. */
  113336. useSmithVisibilityHeightCorrelated: boolean;
  113337. private _useSphericalHarmonics;
  113338. /**
  113339. * LEGACY Mode set to false
  113340. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113341. * diffuse part of the IBL.
  113342. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113343. * to the ground truth.
  113344. */
  113345. useSphericalHarmonics: boolean;
  113346. private _useSpecularGlossinessInputEnergyConservation;
  113347. /**
  113348. * Defines if the material uses energy conservation, when the specular workflow is active.
  113349. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113350. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113351. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113352. */
  113353. useSpecularGlossinessInputEnergyConservation: boolean;
  113354. /** @hidden */
  113355. private _internalMarkAllSubMeshesAsMiscDirty;
  113356. /** @hidden */
  113357. _markAllSubMeshesAsMiscDirty(): void;
  113358. /**
  113359. * Instantiate a new istance of clear coat configuration.
  113360. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113361. */
  113362. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113363. /**
  113364. * Checks to see if a texture is used in the material.
  113365. * @param defines the list of "defines" to update.
  113366. */
  113367. prepareDefines(defines: IMaterialBRDFDefines): void;
  113368. /**
  113369. * Get the current class name of the texture useful for serialization or dynamic coding.
  113370. * @returns "PBRClearCoatConfiguration"
  113371. */
  113372. getClassName(): string;
  113373. /**
  113374. * Makes a duplicate of the current configuration into another one.
  113375. * @param brdfConfiguration define the config where to copy the info
  113376. */
  113377. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113378. /**
  113379. * Serializes this BRDF configuration.
  113380. * @returns - An object with the serialized config.
  113381. */
  113382. serialize(): any;
  113383. /**
  113384. * Parses a anisotropy Configuration from a serialized object.
  113385. * @param source - Serialized object.
  113386. * @param scene Defines the scene we are parsing for
  113387. * @param rootUrl Defines the rootUrl to load from
  113388. */
  113389. parse(source: any, scene: Scene, rootUrl: string): void;
  113390. }
  113391. }
  113392. declare module BABYLON {
  113393. /**
  113394. * @hidden
  113395. */
  113396. export interface IMaterialSheenDefines {
  113397. SHEEN: boolean;
  113398. SHEEN_TEXTURE: boolean;
  113399. SHEEN_TEXTUREDIRECTUV: number;
  113400. SHEEN_LINKWITHALBEDO: boolean;
  113401. /** @hidden */
  113402. _areTexturesDirty: boolean;
  113403. }
  113404. /**
  113405. * Define the code related to the Sheen parameters of the pbr material.
  113406. */
  113407. export class PBRSheenConfiguration {
  113408. private _isEnabled;
  113409. /**
  113410. * Defines if the material uses sheen.
  113411. */
  113412. isEnabled: boolean;
  113413. private _linkSheenWithAlbedo;
  113414. /**
  113415. * Defines if the sheen is linked to the sheen color.
  113416. */
  113417. linkSheenWithAlbedo: boolean;
  113418. /**
  113419. * Defines the sheen intensity.
  113420. */
  113421. intensity: number;
  113422. /**
  113423. * Defines the sheen color.
  113424. */
  113425. color: Color3;
  113426. private _texture;
  113427. /**
  113428. * Stores the sheen tint values in a texture.
  113429. * rgb is tint
  113430. * a is a intensity
  113431. */
  113432. texture: Nullable<BaseTexture>;
  113433. /** @hidden */
  113434. private _internalMarkAllSubMeshesAsTexturesDirty;
  113435. /** @hidden */
  113436. _markAllSubMeshesAsTexturesDirty(): void;
  113437. /**
  113438. * Instantiate a new istance of clear coat configuration.
  113439. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113440. */
  113441. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113442. /**
  113443. * Specifies that the submesh is ready to be used.
  113444. * @param defines the list of "defines" to update.
  113445. * @param scene defines the scene the material belongs to.
  113446. * @returns - boolean indicating that the submesh is ready or not.
  113447. */
  113448. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113449. /**
  113450. * Checks to see if a texture is used in the material.
  113451. * @param defines the list of "defines" to update.
  113452. * @param scene defines the scene the material belongs to.
  113453. */
  113454. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113455. /**
  113456. * Binds the material data.
  113457. * @param uniformBuffer defines the Uniform buffer to fill in.
  113458. * @param scene defines the scene the material belongs to.
  113459. * @param isFrozen defines wether the material is frozen or not.
  113460. */
  113461. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113462. /**
  113463. * Checks to see if a texture is used in the material.
  113464. * @param texture - Base texture to use.
  113465. * @returns - Boolean specifying if a texture is used in the material.
  113466. */
  113467. hasTexture(texture: BaseTexture): boolean;
  113468. /**
  113469. * Returns an array of the actively used textures.
  113470. * @param activeTextures Array of BaseTextures
  113471. */
  113472. getActiveTextures(activeTextures: BaseTexture[]): void;
  113473. /**
  113474. * Returns the animatable textures.
  113475. * @param animatables Array of animatable textures.
  113476. */
  113477. getAnimatables(animatables: IAnimatable[]): void;
  113478. /**
  113479. * Disposes the resources of the material.
  113480. * @param forceDisposeTextures - Forces the disposal of all textures.
  113481. */
  113482. dispose(forceDisposeTextures?: boolean): void;
  113483. /**
  113484. * Get the current class name of the texture useful for serialization or dynamic coding.
  113485. * @returns "PBRSheenConfiguration"
  113486. */
  113487. getClassName(): string;
  113488. /**
  113489. * Add fallbacks to the effect fallbacks list.
  113490. * @param defines defines the Base texture to use.
  113491. * @param fallbacks defines the current fallback list.
  113492. * @param currentRank defines the current fallback rank.
  113493. * @returns the new fallback rank.
  113494. */
  113495. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113496. /**
  113497. * Add the required uniforms to the current list.
  113498. * @param uniforms defines the current uniform list.
  113499. */
  113500. static AddUniforms(uniforms: string[]): void;
  113501. /**
  113502. * Add the required uniforms to the current buffer.
  113503. * @param uniformBuffer defines the current uniform buffer.
  113504. */
  113505. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113506. /**
  113507. * Add the required samplers to the current list.
  113508. * @param samplers defines the current sampler list.
  113509. */
  113510. static AddSamplers(samplers: string[]): void;
  113511. /**
  113512. * Makes a duplicate of the current configuration into another one.
  113513. * @param sheenConfiguration define the config where to copy the info
  113514. */
  113515. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113516. /**
  113517. * Serializes this BRDF configuration.
  113518. * @returns - An object with the serialized config.
  113519. */
  113520. serialize(): any;
  113521. /**
  113522. * Parses a anisotropy Configuration from a serialized object.
  113523. * @param source - Serialized object.
  113524. * @param scene Defines the scene we are parsing for
  113525. * @param rootUrl Defines the rootUrl to load from
  113526. */
  113527. parse(source: any, scene: Scene, rootUrl: string): void;
  113528. }
  113529. }
  113530. declare module BABYLON {
  113531. /**
  113532. * @hidden
  113533. */
  113534. export interface IMaterialSubSurfaceDefines {
  113535. SUBSURFACE: boolean;
  113536. SS_REFRACTION: boolean;
  113537. SS_TRANSLUCENCY: boolean;
  113538. SS_SCATERRING: boolean;
  113539. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113540. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113541. SS_REFRACTIONMAP_3D: boolean;
  113542. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113543. SS_LODINREFRACTIONALPHA: boolean;
  113544. SS_GAMMAREFRACTION: boolean;
  113545. SS_RGBDREFRACTION: boolean;
  113546. SS_LINEARSPECULARREFRACTION: boolean;
  113547. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113548. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113549. /** @hidden */
  113550. _areTexturesDirty: boolean;
  113551. }
  113552. /**
  113553. * Define the code related to the sub surface parameters of the pbr material.
  113554. */
  113555. export class PBRSubSurfaceConfiguration {
  113556. private _isRefractionEnabled;
  113557. /**
  113558. * Defines if the refraction is enabled in the material.
  113559. */
  113560. isRefractionEnabled: boolean;
  113561. private _isTranslucencyEnabled;
  113562. /**
  113563. * Defines if the translucency is enabled in the material.
  113564. */
  113565. isTranslucencyEnabled: boolean;
  113566. private _isScatteringEnabled;
  113567. /**
  113568. * Defines the refraction intensity of the material.
  113569. * The refraction when enabled replaces the Diffuse part of the material.
  113570. * The intensity helps transitionning between diffuse and refraction.
  113571. */
  113572. refractionIntensity: number;
  113573. /**
  113574. * Defines the translucency intensity of the material.
  113575. * When translucency has been enabled, this defines how much of the "translucency"
  113576. * is addded to the diffuse part of the material.
  113577. */
  113578. translucencyIntensity: number;
  113579. /**
  113580. * Defines the scattering intensity of the material.
  113581. * When scattering has been enabled, this defines how much of the "scattered light"
  113582. * is addded to the diffuse part of the material.
  113583. */
  113584. scatteringIntensity: number;
  113585. private _thicknessTexture;
  113586. /**
  113587. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113588. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113589. * 0 would mean minimumThickness
  113590. * 1 would mean maximumThickness
  113591. * The other channels might be use as a mask to vary the different effects intensity.
  113592. */
  113593. thicknessTexture: Nullable<BaseTexture>;
  113594. private _refractionTexture;
  113595. /**
  113596. * Defines the texture to use for refraction.
  113597. */
  113598. refractionTexture: Nullable<BaseTexture>;
  113599. private _indexOfRefraction;
  113600. /**
  113601. * Defines the index of refraction used in the material.
  113602. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113603. */
  113604. indexOfRefraction: number;
  113605. private _invertRefractionY;
  113606. /**
  113607. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113608. */
  113609. invertRefractionY: boolean;
  113610. private _linkRefractionWithTransparency;
  113611. /**
  113612. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113613. * Materials half opaque for instance using refraction could benefit from this control.
  113614. */
  113615. linkRefractionWithTransparency: boolean;
  113616. /**
  113617. * Defines the minimum thickness stored in the thickness map.
  113618. * If no thickness map is defined, this value will be used to simulate thickness.
  113619. */
  113620. minimumThickness: number;
  113621. /**
  113622. * Defines the maximum thickness stored in the thickness map.
  113623. */
  113624. maximumThickness: number;
  113625. /**
  113626. * Defines the volume tint of the material.
  113627. * This is used for both translucency and scattering.
  113628. */
  113629. tintColor: Color3;
  113630. /**
  113631. * Defines the distance at which the tint color should be found in the media.
  113632. * This is used for refraction only.
  113633. */
  113634. tintColorAtDistance: number;
  113635. /**
  113636. * Defines how far each channel transmit through the media.
  113637. * It is defined as a color to simplify it selection.
  113638. */
  113639. diffusionDistance: Color3;
  113640. private _useMaskFromThicknessTexture;
  113641. /**
  113642. * Stores the intensity of the different subsurface effects in the thickness texture.
  113643. * * the green channel is the translucency intensity.
  113644. * * the blue channel is the scattering intensity.
  113645. * * the alpha channel is the refraction intensity.
  113646. */
  113647. useMaskFromThicknessTexture: boolean;
  113648. /** @hidden */
  113649. private _internalMarkAllSubMeshesAsTexturesDirty;
  113650. /** @hidden */
  113651. _markAllSubMeshesAsTexturesDirty(): void;
  113652. /**
  113653. * Instantiate a new istance of sub surface configuration.
  113654. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113655. */
  113656. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113657. /**
  113658. * Gets wehter the submesh is ready to be used or not.
  113659. * @param defines the list of "defines" to update.
  113660. * @param scene defines the scene the material belongs to.
  113661. * @returns - boolean indicating that the submesh is ready or not.
  113662. */
  113663. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113664. /**
  113665. * Checks to see if a texture is used in the material.
  113666. * @param defines the list of "defines" to update.
  113667. * @param scene defines the scene to the material belongs to.
  113668. */
  113669. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113670. /**
  113671. * Binds the material data.
  113672. * @param uniformBuffer defines the Uniform buffer to fill in.
  113673. * @param scene defines the scene the material belongs to.
  113674. * @param engine defines the engine the material belongs to.
  113675. * @param isFrozen defines wether the material is frozen or not.
  113676. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113677. */
  113678. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113679. /**
  113680. * Unbinds the material from the mesh.
  113681. * @param activeEffect defines the effect that should be unbound from.
  113682. * @returns true if unbound, otherwise false
  113683. */
  113684. unbind(activeEffect: Effect): boolean;
  113685. /**
  113686. * Returns the texture used for refraction or null if none is used.
  113687. * @param scene defines the scene the material belongs to.
  113688. * @returns - Refraction texture if present. If no refraction texture and refraction
  113689. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113690. */
  113691. private _getRefractionTexture;
  113692. /**
  113693. * Returns true if alpha blending should be disabled.
  113694. */
  113695. readonly disableAlphaBlending: boolean;
  113696. /**
  113697. * Fills the list of render target textures.
  113698. * @param renderTargets the list of render targets to update
  113699. */
  113700. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113701. /**
  113702. * Checks to see if a texture is used in the material.
  113703. * @param texture - Base texture to use.
  113704. * @returns - Boolean specifying if a texture is used in the material.
  113705. */
  113706. hasTexture(texture: BaseTexture): boolean;
  113707. /**
  113708. * Gets a boolean indicating that current material needs to register RTT
  113709. * @returns true if this uses a render target otherwise false.
  113710. */
  113711. hasRenderTargetTextures(): boolean;
  113712. /**
  113713. * Returns an array of the actively used textures.
  113714. * @param activeTextures Array of BaseTextures
  113715. */
  113716. getActiveTextures(activeTextures: BaseTexture[]): void;
  113717. /**
  113718. * Returns the animatable textures.
  113719. * @param animatables Array of animatable textures.
  113720. */
  113721. getAnimatables(animatables: IAnimatable[]): void;
  113722. /**
  113723. * Disposes the resources of the material.
  113724. * @param forceDisposeTextures - Forces the disposal of all textures.
  113725. */
  113726. dispose(forceDisposeTextures?: boolean): void;
  113727. /**
  113728. * Get the current class name of the texture useful for serialization or dynamic coding.
  113729. * @returns "PBRSubSurfaceConfiguration"
  113730. */
  113731. getClassName(): string;
  113732. /**
  113733. * Add fallbacks to the effect fallbacks list.
  113734. * @param defines defines the Base texture to use.
  113735. * @param fallbacks defines the current fallback list.
  113736. * @param currentRank defines the current fallback rank.
  113737. * @returns the new fallback rank.
  113738. */
  113739. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113740. /**
  113741. * Add the required uniforms to the current list.
  113742. * @param uniforms defines the current uniform list.
  113743. */
  113744. static AddUniforms(uniforms: string[]): void;
  113745. /**
  113746. * Add the required samplers to the current list.
  113747. * @param samplers defines the current sampler list.
  113748. */
  113749. static AddSamplers(samplers: string[]): void;
  113750. /**
  113751. * Add the required uniforms to the current buffer.
  113752. * @param uniformBuffer defines the current uniform buffer.
  113753. */
  113754. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113755. /**
  113756. * Makes a duplicate of the current configuration into another one.
  113757. * @param configuration define the config where to copy the info
  113758. */
  113759. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113760. /**
  113761. * Serializes this Sub Surface configuration.
  113762. * @returns - An object with the serialized config.
  113763. */
  113764. serialize(): any;
  113765. /**
  113766. * Parses a anisotropy Configuration from a serialized object.
  113767. * @param source - Serialized object.
  113768. * @param scene Defines the scene we are parsing for
  113769. * @param rootUrl Defines the rootUrl to load from
  113770. */
  113771. parse(source: any, scene: Scene, rootUrl: string): void;
  113772. }
  113773. }
  113774. declare module BABYLON {
  113775. /** @hidden */
  113776. export var pbrFragmentDeclaration: {
  113777. name: string;
  113778. shader: string;
  113779. };
  113780. }
  113781. declare module BABYLON {
  113782. /** @hidden */
  113783. export var pbrUboDeclaration: {
  113784. name: string;
  113785. shader: string;
  113786. };
  113787. }
  113788. declare module BABYLON {
  113789. /** @hidden */
  113790. export var pbrFragmentExtraDeclaration: {
  113791. name: string;
  113792. shader: string;
  113793. };
  113794. }
  113795. declare module BABYLON {
  113796. /** @hidden */
  113797. export var pbrFragmentSamplersDeclaration: {
  113798. name: string;
  113799. shader: string;
  113800. };
  113801. }
  113802. declare module BABYLON {
  113803. /** @hidden */
  113804. export var pbrHelperFunctions: {
  113805. name: string;
  113806. shader: string;
  113807. };
  113808. }
  113809. declare module BABYLON {
  113810. /** @hidden */
  113811. export var harmonicsFunctions: {
  113812. name: string;
  113813. shader: string;
  113814. };
  113815. }
  113816. declare module BABYLON {
  113817. /** @hidden */
  113818. export var pbrDirectLightingSetupFunctions: {
  113819. name: string;
  113820. shader: string;
  113821. };
  113822. }
  113823. declare module BABYLON {
  113824. /** @hidden */
  113825. export var pbrDirectLightingFalloffFunctions: {
  113826. name: string;
  113827. shader: string;
  113828. };
  113829. }
  113830. declare module BABYLON {
  113831. /** @hidden */
  113832. export var pbrBRDFFunctions: {
  113833. name: string;
  113834. shader: string;
  113835. };
  113836. }
  113837. declare module BABYLON {
  113838. /** @hidden */
  113839. export var pbrDirectLightingFunctions: {
  113840. name: string;
  113841. shader: string;
  113842. };
  113843. }
  113844. declare module BABYLON {
  113845. /** @hidden */
  113846. export var pbrIBLFunctions: {
  113847. name: string;
  113848. shader: string;
  113849. };
  113850. }
  113851. declare module BABYLON {
  113852. /** @hidden */
  113853. export var pbrDebug: {
  113854. name: string;
  113855. shader: string;
  113856. };
  113857. }
  113858. declare module BABYLON {
  113859. /** @hidden */
  113860. export var pbrPixelShader: {
  113861. name: string;
  113862. shader: string;
  113863. };
  113864. }
  113865. declare module BABYLON {
  113866. /** @hidden */
  113867. export var pbrVertexDeclaration: {
  113868. name: string;
  113869. shader: string;
  113870. };
  113871. }
  113872. declare module BABYLON {
  113873. /** @hidden */
  113874. export var pbrVertexShader: {
  113875. name: string;
  113876. shader: string;
  113877. };
  113878. }
  113879. declare module BABYLON {
  113880. /**
  113881. * Manages the defines for the PBR Material.
  113882. * @hidden
  113883. */
  113884. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  113885. PBR: boolean;
  113886. MAINUV1: boolean;
  113887. MAINUV2: boolean;
  113888. UV1: boolean;
  113889. UV2: boolean;
  113890. ALBEDO: boolean;
  113891. ALBEDODIRECTUV: number;
  113892. VERTEXCOLOR: boolean;
  113893. AMBIENT: boolean;
  113894. AMBIENTDIRECTUV: number;
  113895. AMBIENTINGRAYSCALE: boolean;
  113896. OPACITY: boolean;
  113897. VERTEXALPHA: boolean;
  113898. OPACITYDIRECTUV: number;
  113899. OPACITYRGB: boolean;
  113900. ALPHATEST: boolean;
  113901. DEPTHPREPASS: boolean;
  113902. ALPHABLEND: boolean;
  113903. ALPHAFROMALBEDO: boolean;
  113904. ALPHATESTVALUE: string;
  113905. SPECULAROVERALPHA: boolean;
  113906. RADIANCEOVERALPHA: boolean;
  113907. ALPHAFRESNEL: boolean;
  113908. LINEARALPHAFRESNEL: boolean;
  113909. PREMULTIPLYALPHA: boolean;
  113910. EMISSIVE: boolean;
  113911. EMISSIVEDIRECTUV: number;
  113912. REFLECTIVITY: boolean;
  113913. REFLECTIVITYDIRECTUV: number;
  113914. SPECULARTERM: boolean;
  113915. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  113916. MICROSURFACEAUTOMATIC: boolean;
  113917. LODBASEDMICROSFURACE: boolean;
  113918. MICROSURFACEMAP: boolean;
  113919. MICROSURFACEMAPDIRECTUV: number;
  113920. METALLICWORKFLOW: boolean;
  113921. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  113922. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  113923. METALLNESSSTOREINMETALMAPBLUE: boolean;
  113924. AOSTOREINMETALMAPRED: boolean;
  113925. ENVIRONMENTBRDF: boolean;
  113926. ENVIRONMENTBRDF_RGBD: boolean;
  113927. NORMAL: boolean;
  113928. TANGENT: boolean;
  113929. BUMP: boolean;
  113930. BUMPDIRECTUV: number;
  113931. OBJECTSPACE_NORMALMAP: boolean;
  113932. PARALLAX: boolean;
  113933. PARALLAXOCCLUSION: boolean;
  113934. NORMALXYSCALE: boolean;
  113935. LIGHTMAP: boolean;
  113936. LIGHTMAPDIRECTUV: number;
  113937. USELIGHTMAPASSHADOWMAP: boolean;
  113938. GAMMALIGHTMAP: boolean;
  113939. RGBDLIGHTMAP: boolean;
  113940. REFLECTION: boolean;
  113941. REFLECTIONMAP_3D: boolean;
  113942. REFLECTIONMAP_SPHERICAL: boolean;
  113943. REFLECTIONMAP_PLANAR: boolean;
  113944. REFLECTIONMAP_CUBIC: boolean;
  113945. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  113946. REFLECTIONMAP_PROJECTION: boolean;
  113947. REFLECTIONMAP_SKYBOX: boolean;
  113948. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  113949. REFLECTIONMAP_EXPLICIT: boolean;
  113950. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  113951. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  113952. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  113953. INVERTCUBICMAP: boolean;
  113954. USESPHERICALFROMREFLECTIONMAP: boolean;
  113955. USEIRRADIANCEMAP: boolean;
  113956. SPHERICAL_HARMONICS: boolean;
  113957. USESPHERICALINVERTEX: boolean;
  113958. REFLECTIONMAP_OPPOSITEZ: boolean;
  113959. LODINREFLECTIONALPHA: boolean;
  113960. GAMMAREFLECTION: boolean;
  113961. RGBDREFLECTION: boolean;
  113962. LINEARSPECULARREFLECTION: boolean;
  113963. RADIANCEOCCLUSION: boolean;
  113964. HORIZONOCCLUSION: boolean;
  113965. INSTANCES: boolean;
  113966. NUM_BONE_INFLUENCERS: number;
  113967. BonesPerMesh: number;
  113968. BONETEXTURE: boolean;
  113969. NONUNIFORMSCALING: boolean;
  113970. MORPHTARGETS: boolean;
  113971. MORPHTARGETS_NORMAL: boolean;
  113972. MORPHTARGETS_TANGENT: boolean;
  113973. MORPHTARGETS_UV: boolean;
  113974. NUM_MORPH_INFLUENCERS: number;
  113975. IMAGEPROCESSING: boolean;
  113976. VIGNETTE: boolean;
  113977. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113978. VIGNETTEBLENDMODEOPAQUE: boolean;
  113979. TONEMAPPING: boolean;
  113980. TONEMAPPING_ACES: boolean;
  113981. CONTRAST: boolean;
  113982. COLORCURVES: boolean;
  113983. COLORGRADING: boolean;
  113984. COLORGRADING3D: boolean;
  113985. SAMPLER3DGREENDEPTH: boolean;
  113986. SAMPLER3DBGRMAP: boolean;
  113987. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113988. EXPOSURE: boolean;
  113989. MULTIVIEW: boolean;
  113990. USEPHYSICALLIGHTFALLOFF: boolean;
  113991. USEGLTFLIGHTFALLOFF: boolean;
  113992. TWOSIDEDLIGHTING: boolean;
  113993. SHADOWFLOAT: boolean;
  113994. CLIPPLANE: boolean;
  113995. CLIPPLANE2: boolean;
  113996. CLIPPLANE3: boolean;
  113997. CLIPPLANE4: boolean;
  113998. POINTSIZE: boolean;
  113999. FOG: boolean;
  114000. LOGARITHMICDEPTH: boolean;
  114001. FORCENORMALFORWARD: boolean;
  114002. SPECULARAA: boolean;
  114003. CLEARCOAT: boolean;
  114004. CLEARCOAT_DEFAULTIOR: boolean;
  114005. CLEARCOAT_TEXTURE: boolean;
  114006. CLEARCOAT_TEXTUREDIRECTUV: number;
  114007. CLEARCOAT_BUMP: boolean;
  114008. CLEARCOAT_BUMPDIRECTUV: number;
  114009. CLEARCOAT_TINT: boolean;
  114010. CLEARCOAT_TINT_TEXTURE: boolean;
  114011. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114012. ANISOTROPIC: boolean;
  114013. ANISOTROPIC_TEXTURE: boolean;
  114014. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114015. BRDF_V_HEIGHT_CORRELATED: boolean;
  114016. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114017. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114018. SHEEN: boolean;
  114019. SHEEN_TEXTURE: boolean;
  114020. SHEEN_TEXTUREDIRECTUV: number;
  114021. SHEEN_LINKWITHALBEDO: boolean;
  114022. SUBSURFACE: boolean;
  114023. SS_REFRACTION: boolean;
  114024. SS_TRANSLUCENCY: boolean;
  114025. SS_SCATERRING: boolean;
  114026. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114027. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114028. SS_REFRACTIONMAP_3D: boolean;
  114029. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114030. SS_LODINREFRACTIONALPHA: boolean;
  114031. SS_GAMMAREFRACTION: boolean;
  114032. SS_RGBDREFRACTION: boolean;
  114033. SS_LINEARSPECULARREFRACTION: boolean;
  114034. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114035. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114036. UNLIT: boolean;
  114037. DEBUGMODE: number;
  114038. /**
  114039. * Initializes the PBR Material defines.
  114040. */
  114041. constructor();
  114042. /**
  114043. * Resets the PBR Material defines.
  114044. */
  114045. reset(): void;
  114046. }
  114047. /**
  114048. * The Physically based material base class of BJS.
  114049. *
  114050. * This offers the main features of a standard PBR material.
  114051. * For more information, please refer to the documentation :
  114052. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114053. */
  114054. export abstract class PBRBaseMaterial extends PushMaterial {
  114055. /**
  114056. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114057. */
  114058. static readonly PBRMATERIAL_OPAQUE: number;
  114059. /**
  114060. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114061. */
  114062. static readonly PBRMATERIAL_ALPHATEST: number;
  114063. /**
  114064. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114065. */
  114066. static readonly PBRMATERIAL_ALPHABLEND: number;
  114067. /**
  114068. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114069. * They are also discarded below the alpha cutoff threshold to improve performances.
  114070. */
  114071. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114072. /**
  114073. * Defines the default value of how much AO map is occluding the analytical lights
  114074. * (point spot...).
  114075. */
  114076. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114077. /**
  114078. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114079. */
  114080. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114081. /**
  114082. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114083. * to enhance interoperability with other engines.
  114084. */
  114085. static readonly LIGHTFALLOFF_GLTF: number;
  114086. /**
  114087. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114088. * to enhance interoperability with other materials.
  114089. */
  114090. static readonly LIGHTFALLOFF_STANDARD: number;
  114091. /**
  114092. * Intensity of the direct lights e.g. the four lights available in your scene.
  114093. * This impacts both the direct diffuse and specular highlights.
  114094. */
  114095. protected _directIntensity: number;
  114096. /**
  114097. * Intensity of the emissive part of the material.
  114098. * This helps controlling the emissive effect without modifying the emissive color.
  114099. */
  114100. protected _emissiveIntensity: number;
  114101. /**
  114102. * Intensity of the environment e.g. how much the environment will light the object
  114103. * either through harmonics for rough material or through the refelction for shiny ones.
  114104. */
  114105. protected _environmentIntensity: number;
  114106. /**
  114107. * This is a special control allowing the reduction of the specular highlights coming from the
  114108. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114109. */
  114110. protected _specularIntensity: number;
  114111. /**
  114112. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114113. */
  114114. private _lightingInfos;
  114115. /**
  114116. * Debug Control allowing disabling the bump map on this material.
  114117. */
  114118. protected _disableBumpMap: boolean;
  114119. /**
  114120. * AKA Diffuse Texture in standard nomenclature.
  114121. */
  114122. protected _albedoTexture: Nullable<BaseTexture>;
  114123. /**
  114124. * AKA Occlusion Texture in other nomenclature.
  114125. */
  114126. protected _ambientTexture: Nullable<BaseTexture>;
  114127. /**
  114128. * AKA Occlusion Texture Intensity in other nomenclature.
  114129. */
  114130. protected _ambientTextureStrength: number;
  114131. /**
  114132. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114133. * 1 means it completely occludes it
  114134. * 0 mean it has no impact
  114135. */
  114136. protected _ambientTextureImpactOnAnalyticalLights: number;
  114137. /**
  114138. * Stores the alpha values in a texture.
  114139. */
  114140. protected _opacityTexture: Nullable<BaseTexture>;
  114141. /**
  114142. * Stores the reflection values in a texture.
  114143. */
  114144. protected _reflectionTexture: Nullable<BaseTexture>;
  114145. /**
  114146. * Stores the emissive values in a texture.
  114147. */
  114148. protected _emissiveTexture: Nullable<BaseTexture>;
  114149. /**
  114150. * AKA Specular texture in other nomenclature.
  114151. */
  114152. protected _reflectivityTexture: Nullable<BaseTexture>;
  114153. /**
  114154. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114155. */
  114156. protected _metallicTexture: Nullable<BaseTexture>;
  114157. /**
  114158. * Specifies the metallic scalar of the metallic/roughness workflow.
  114159. * Can also be used to scale the metalness values of the metallic texture.
  114160. */
  114161. protected _metallic: Nullable<number>;
  114162. /**
  114163. * Specifies the roughness scalar of the metallic/roughness workflow.
  114164. * Can also be used to scale the roughness values of the metallic texture.
  114165. */
  114166. protected _roughness: Nullable<number>;
  114167. /**
  114168. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114169. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114170. */
  114171. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114172. /**
  114173. * Stores surface normal data used to displace a mesh in a texture.
  114174. */
  114175. protected _bumpTexture: Nullable<BaseTexture>;
  114176. /**
  114177. * Stores the pre-calculated light information of a mesh in a texture.
  114178. */
  114179. protected _lightmapTexture: Nullable<BaseTexture>;
  114180. /**
  114181. * The color of a material in ambient lighting.
  114182. */
  114183. protected _ambientColor: Color3;
  114184. /**
  114185. * AKA Diffuse Color in other nomenclature.
  114186. */
  114187. protected _albedoColor: Color3;
  114188. /**
  114189. * AKA Specular Color in other nomenclature.
  114190. */
  114191. protected _reflectivityColor: Color3;
  114192. /**
  114193. * The color applied when light is reflected from a material.
  114194. */
  114195. protected _reflectionColor: Color3;
  114196. /**
  114197. * The color applied when light is emitted from a material.
  114198. */
  114199. protected _emissiveColor: Color3;
  114200. /**
  114201. * AKA Glossiness in other nomenclature.
  114202. */
  114203. protected _microSurface: number;
  114204. /**
  114205. * Specifies that the material will use the light map as a show map.
  114206. */
  114207. protected _useLightmapAsShadowmap: boolean;
  114208. /**
  114209. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114210. * makes the reflect vector face the model (under horizon).
  114211. */
  114212. protected _useHorizonOcclusion: boolean;
  114213. /**
  114214. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114215. * too much the area relying on ambient texture to define their ambient occlusion.
  114216. */
  114217. protected _useRadianceOcclusion: boolean;
  114218. /**
  114219. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114220. */
  114221. protected _useAlphaFromAlbedoTexture: boolean;
  114222. /**
  114223. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114224. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114225. */
  114226. protected _useSpecularOverAlpha: boolean;
  114227. /**
  114228. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114229. */
  114230. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114231. /**
  114232. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114233. */
  114234. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114235. /**
  114236. * Specifies if the metallic texture contains the roughness information in its green channel.
  114237. */
  114238. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114239. /**
  114240. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114241. */
  114242. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114243. /**
  114244. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114245. */
  114246. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114247. /**
  114248. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114249. */
  114250. protected _useAmbientInGrayScale: boolean;
  114251. /**
  114252. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114253. * The material will try to infer what glossiness each pixel should be.
  114254. */
  114255. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114256. /**
  114257. * Defines the falloff type used in this material.
  114258. * It by default is Physical.
  114259. */
  114260. protected _lightFalloff: number;
  114261. /**
  114262. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114263. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114264. */
  114265. protected _useRadianceOverAlpha: boolean;
  114266. /**
  114267. * Allows using an object space normal map (instead of tangent space).
  114268. */
  114269. protected _useObjectSpaceNormalMap: boolean;
  114270. /**
  114271. * Allows using the bump map in parallax mode.
  114272. */
  114273. protected _useParallax: boolean;
  114274. /**
  114275. * Allows using the bump map in parallax occlusion mode.
  114276. */
  114277. protected _useParallaxOcclusion: boolean;
  114278. /**
  114279. * Controls the scale bias of the parallax mode.
  114280. */
  114281. protected _parallaxScaleBias: number;
  114282. /**
  114283. * If sets to true, disables all the lights affecting the material.
  114284. */
  114285. protected _disableLighting: boolean;
  114286. /**
  114287. * Number of Simultaneous lights allowed on the material.
  114288. */
  114289. protected _maxSimultaneousLights: number;
  114290. /**
  114291. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114292. */
  114293. protected _invertNormalMapX: boolean;
  114294. /**
  114295. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114296. */
  114297. protected _invertNormalMapY: boolean;
  114298. /**
  114299. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114300. */
  114301. protected _twoSidedLighting: boolean;
  114302. /**
  114303. * Defines the alpha limits in alpha test mode.
  114304. */
  114305. protected _alphaCutOff: number;
  114306. /**
  114307. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114308. */
  114309. protected _forceAlphaTest: boolean;
  114310. /**
  114311. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114312. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114313. */
  114314. protected _useAlphaFresnel: boolean;
  114315. /**
  114316. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114317. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114318. */
  114319. protected _useLinearAlphaFresnel: boolean;
  114320. /**
  114321. * The transparency mode of the material.
  114322. */
  114323. protected _transparencyMode: Nullable<number>;
  114324. /**
  114325. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114326. * from cos thetav and roughness:
  114327. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114328. */
  114329. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114330. /**
  114331. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114332. */
  114333. protected _forceIrradianceInFragment: boolean;
  114334. /**
  114335. * Force normal to face away from face.
  114336. */
  114337. protected _forceNormalForward: boolean;
  114338. /**
  114339. * Enables specular anti aliasing in the PBR shader.
  114340. * It will both interacts on the Geometry for analytical and IBL lighting.
  114341. * It also prefilter the roughness map based on the bump values.
  114342. */
  114343. protected _enableSpecularAntiAliasing: boolean;
  114344. /**
  114345. * Default configuration related to image processing available in the PBR Material.
  114346. */
  114347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114348. /**
  114349. * Keep track of the image processing observer to allow dispose and replace.
  114350. */
  114351. private _imageProcessingObserver;
  114352. /**
  114353. * Attaches a new image processing configuration to the PBR Material.
  114354. * @param configuration
  114355. */
  114356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114357. /**
  114358. * Stores the available render targets.
  114359. */
  114360. private _renderTargets;
  114361. /**
  114362. * Sets the global ambient color for the material used in lighting calculations.
  114363. */
  114364. private _globalAmbientColor;
  114365. /**
  114366. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114367. */
  114368. private _useLogarithmicDepth;
  114369. /**
  114370. * If set to true, no lighting calculations will be applied.
  114371. */
  114372. private _unlit;
  114373. private _debugMode;
  114374. /**
  114375. * @hidden
  114376. * This is reserved for the inspector.
  114377. * Defines the material debug mode.
  114378. * It helps seeing only some components of the material while troubleshooting.
  114379. */
  114380. debugMode: number;
  114381. /**
  114382. * @hidden
  114383. * This is reserved for the inspector.
  114384. * Specify from where on screen the debug mode should start.
  114385. * The value goes from -1 (full screen) to 1 (not visible)
  114386. * It helps with side by side comparison against the final render
  114387. * This defaults to -1
  114388. */
  114389. private debugLimit;
  114390. /**
  114391. * @hidden
  114392. * This is reserved for the inspector.
  114393. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114394. * You can use the factor to better multiply the final value.
  114395. */
  114396. private debugFactor;
  114397. /**
  114398. * Defines the clear coat layer parameters for the material.
  114399. */
  114400. readonly clearCoat: PBRClearCoatConfiguration;
  114401. /**
  114402. * Defines the anisotropic parameters for the material.
  114403. */
  114404. readonly anisotropy: PBRAnisotropicConfiguration;
  114405. /**
  114406. * Defines the BRDF parameters for the material.
  114407. */
  114408. readonly brdf: PBRBRDFConfiguration;
  114409. /**
  114410. * Defines the Sheen parameters for the material.
  114411. */
  114412. readonly sheen: PBRSheenConfiguration;
  114413. /**
  114414. * Defines the SubSurface parameters for the material.
  114415. */
  114416. readonly subSurface: PBRSubSurfaceConfiguration;
  114417. /**
  114418. * Custom callback helping to override the default shader used in the material.
  114419. */
  114420. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114421. protected _rebuildInParallel: boolean;
  114422. /**
  114423. * Instantiates a new PBRMaterial instance.
  114424. *
  114425. * @param name The material name
  114426. * @param scene The scene the material will be use in.
  114427. */
  114428. constructor(name: string, scene: Scene);
  114429. /**
  114430. * Gets a boolean indicating that current material needs to register RTT
  114431. */
  114432. readonly hasRenderTargetTextures: boolean;
  114433. /**
  114434. * Gets the name of the material class.
  114435. */
  114436. getClassName(): string;
  114437. /**
  114438. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114439. */
  114440. /**
  114441. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114442. */
  114443. useLogarithmicDepth: boolean;
  114444. /**
  114445. * Gets the current transparency mode.
  114446. */
  114447. /**
  114448. * Sets the transparency mode of the material.
  114449. *
  114450. * | Value | Type | Description |
  114451. * | ----- | ----------------------------------- | ----------- |
  114452. * | 0 | OPAQUE | |
  114453. * | 1 | ALPHATEST | |
  114454. * | 2 | ALPHABLEND | |
  114455. * | 3 | ALPHATESTANDBLEND | |
  114456. *
  114457. */
  114458. transparencyMode: Nullable<number>;
  114459. /**
  114460. * Returns true if alpha blending should be disabled.
  114461. */
  114462. private readonly _disableAlphaBlending;
  114463. /**
  114464. * Specifies whether or not this material should be rendered in alpha blend mode.
  114465. */
  114466. needAlphaBlending(): boolean;
  114467. /**
  114468. * Specifies if the mesh will require alpha blending.
  114469. * @param mesh - BJS mesh.
  114470. */
  114471. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114472. /**
  114473. * Specifies whether or not this material should be rendered in alpha test mode.
  114474. */
  114475. needAlphaTesting(): boolean;
  114476. /**
  114477. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114478. */
  114479. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114480. /**
  114481. * Gets the texture used for the alpha test.
  114482. */
  114483. getAlphaTestTexture(): Nullable<BaseTexture>;
  114484. /**
  114485. * Specifies that the submesh is ready to be used.
  114486. * @param mesh - BJS mesh.
  114487. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114488. * @param useInstances - Specifies that instances should be used.
  114489. * @returns - boolean indicating that the submesh is ready or not.
  114490. */
  114491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114492. /**
  114493. * Specifies if the material uses metallic roughness workflow.
  114494. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114495. */
  114496. isMetallicWorkflow(): boolean;
  114497. private _prepareEffect;
  114498. private _prepareDefines;
  114499. /**
  114500. * Force shader compilation
  114501. */
  114502. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114503. clipPlane: boolean;
  114504. }>): void;
  114505. /**
  114506. * Initializes the uniform buffer layout for the shader.
  114507. */
  114508. buildUniformLayout(): void;
  114509. /**
  114510. * Unbinds the material from the mesh
  114511. */
  114512. unbind(): void;
  114513. /**
  114514. * Binds the submesh data.
  114515. * @param world - The world matrix.
  114516. * @param mesh - The BJS mesh.
  114517. * @param subMesh - A submesh of the BJS mesh.
  114518. */
  114519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114520. /**
  114521. * Returns the animatable textures.
  114522. * @returns - Array of animatable textures.
  114523. */
  114524. getAnimatables(): IAnimatable[];
  114525. /**
  114526. * Returns the texture used for reflections.
  114527. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114528. */
  114529. private _getReflectionTexture;
  114530. /**
  114531. * Returns an array of the actively used textures.
  114532. * @returns - Array of BaseTextures
  114533. */
  114534. getActiveTextures(): BaseTexture[];
  114535. /**
  114536. * Checks to see if a texture is used in the material.
  114537. * @param texture - Base texture to use.
  114538. * @returns - Boolean specifying if a texture is used in the material.
  114539. */
  114540. hasTexture(texture: BaseTexture): boolean;
  114541. /**
  114542. * Disposes the resources of the material.
  114543. * @param forceDisposeEffect - Forces the disposal of effects.
  114544. * @param forceDisposeTextures - Forces the disposal of all textures.
  114545. */
  114546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114547. }
  114548. }
  114549. declare module BABYLON {
  114550. /**
  114551. * The Physically based material of BJS.
  114552. *
  114553. * This offers the main features of a standard PBR material.
  114554. * For more information, please refer to the documentation :
  114555. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114556. */
  114557. export class PBRMaterial extends PBRBaseMaterial {
  114558. /**
  114559. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114560. */
  114561. static readonly PBRMATERIAL_OPAQUE: number;
  114562. /**
  114563. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114564. */
  114565. static readonly PBRMATERIAL_ALPHATEST: number;
  114566. /**
  114567. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114568. */
  114569. static readonly PBRMATERIAL_ALPHABLEND: number;
  114570. /**
  114571. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114572. * They are also discarded below the alpha cutoff threshold to improve performances.
  114573. */
  114574. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114575. /**
  114576. * Defines the default value of how much AO map is occluding the analytical lights
  114577. * (point spot...).
  114578. */
  114579. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114580. /**
  114581. * Intensity of the direct lights e.g. the four lights available in your scene.
  114582. * This impacts both the direct diffuse and specular highlights.
  114583. */
  114584. directIntensity: number;
  114585. /**
  114586. * Intensity of the emissive part of the material.
  114587. * This helps controlling the emissive effect without modifying the emissive color.
  114588. */
  114589. emissiveIntensity: number;
  114590. /**
  114591. * Intensity of the environment e.g. how much the environment will light the object
  114592. * either through harmonics for rough material or through the refelction for shiny ones.
  114593. */
  114594. environmentIntensity: number;
  114595. /**
  114596. * This is a special control allowing the reduction of the specular highlights coming from the
  114597. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114598. */
  114599. specularIntensity: number;
  114600. /**
  114601. * Debug Control allowing disabling the bump map on this material.
  114602. */
  114603. disableBumpMap: boolean;
  114604. /**
  114605. * AKA Diffuse Texture in standard nomenclature.
  114606. */
  114607. albedoTexture: BaseTexture;
  114608. /**
  114609. * AKA Occlusion Texture in other nomenclature.
  114610. */
  114611. ambientTexture: BaseTexture;
  114612. /**
  114613. * AKA Occlusion Texture Intensity in other nomenclature.
  114614. */
  114615. ambientTextureStrength: number;
  114616. /**
  114617. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114618. * 1 means it completely occludes it
  114619. * 0 mean it has no impact
  114620. */
  114621. ambientTextureImpactOnAnalyticalLights: number;
  114622. /**
  114623. * Stores the alpha values in a texture.
  114624. */
  114625. opacityTexture: BaseTexture;
  114626. /**
  114627. * Stores the reflection values in a texture.
  114628. */
  114629. reflectionTexture: Nullable<BaseTexture>;
  114630. /**
  114631. * Stores the emissive values in a texture.
  114632. */
  114633. emissiveTexture: BaseTexture;
  114634. /**
  114635. * AKA Specular texture in other nomenclature.
  114636. */
  114637. reflectivityTexture: BaseTexture;
  114638. /**
  114639. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114640. */
  114641. metallicTexture: BaseTexture;
  114642. /**
  114643. * Specifies the metallic scalar of the metallic/roughness workflow.
  114644. * Can also be used to scale the metalness values of the metallic texture.
  114645. */
  114646. metallic: Nullable<number>;
  114647. /**
  114648. * Specifies the roughness scalar of the metallic/roughness workflow.
  114649. * Can also be used to scale the roughness values of the metallic texture.
  114650. */
  114651. roughness: Nullable<number>;
  114652. /**
  114653. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114654. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114655. */
  114656. microSurfaceTexture: BaseTexture;
  114657. /**
  114658. * Stores surface normal data used to displace a mesh in a texture.
  114659. */
  114660. bumpTexture: BaseTexture;
  114661. /**
  114662. * Stores the pre-calculated light information of a mesh in a texture.
  114663. */
  114664. lightmapTexture: BaseTexture;
  114665. /**
  114666. * Stores the refracted light information in a texture.
  114667. */
  114668. refractionTexture: Nullable<BaseTexture>;
  114669. /**
  114670. * The color of a material in ambient lighting.
  114671. */
  114672. ambientColor: Color3;
  114673. /**
  114674. * AKA Diffuse Color in other nomenclature.
  114675. */
  114676. albedoColor: Color3;
  114677. /**
  114678. * AKA Specular Color in other nomenclature.
  114679. */
  114680. reflectivityColor: Color3;
  114681. /**
  114682. * The color reflected from the material.
  114683. */
  114684. reflectionColor: Color3;
  114685. /**
  114686. * The color emitted from the material.
  114687. */
  114688. emissiveColor: Color3;
  114689. /**
  114690. * AKA Glossiness in other nomenclature.
  114691. */
  114692. microSurface: number;
  114693. /**
  114694. * source material index of refraction (IOR)' / 'destination material IOR.
  114695. */
  114696. indexOfRefraction: number;
  114697. /**
  114698. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114699. */
  114700. invertRefractionY: boolean;
  114701. /**
  114702. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114703. * Materials half opaque for instance using refraction could benefit from this control.
  114704. */
  114705. linkRefractionWithTransparency: boolean;
  114706. /**
  114707. * If true, the light map contains occlusion information instead of lighting info.
  114708. */
  114709. useLightmapAsShadowmap: boolean;
  114710. /**
  114711. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114712. */
  114713. useAlphaFromAlbedoTexture: boolean;
  114714. /**
  114715. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114716. */
  114717. forceAlphaTest: boolean;
  114718. /**
  114719. * Defines the alpha limits in alpha test mode.
  114720. */
  114721. alphaCutOff: number;
  114722. /**
  114723. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114724. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114725. */
  114726. useSpecularOverAlpha: boolean;
  114727. /**
  114728. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114729. */
  114730. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114731. /**
  114732. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114733. */
  114734. useRoughnessFromMetallicTextureAlpha: boolean;
  114735. /**
  114736. * Specifies if the metallic texture contains the roughness information in its green channel.
  114737. */
  114738. useRoughnessFromMetallicTextureGreen: boolean;
  114739. /**
  114740. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114741. */
  114742. useMetallnessFromMetallicTextureBlue: boolean;
  114743. /**
  114744. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114745. */
  114746. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114747. /**
  114748. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114749. */
  114750. useAmbientInGrayScale: boolean;
  114751. /**
  114752. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114753. * The material will try to infer what glossiness each pixel should be.
  114754. */
  114755. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114756. /**
  114757. * BJS is using an harcoded light falloff based on a manually sets up range.
  114758. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114759. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114760. */
  114761. /**
  114762. * BJS is using an harcoded light falloff based on a manually sets up range.
  114763. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114764. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114765. */
  114766. usePhysicalLightFalloff: boolean;
  114767. /**
  114768. * In order to support the falloff compatibility with gltf, a special mode has been added
  114769. * to reproduce the gltf light falloff.
  114770. */
  114771. /**
  114772. * In order to support the falloff compatibility with gltf, a special mode has been added
  114773. * to reproduce the gltf light falloff.
  114774. */
  114775. useGLTFLightFalloff: boolean;
  114776. /**
  114777. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114778. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114779. */
  114780. useRadianceOverAlpha: boolean;
  114781. /**
  114782. * Allows using an object space normal map (instead of tangent space).
  114783. */
  114784. useObjectSpaceNormalMap: boolean;
  114785. /**
  114786. * Allows using the bump map in parallax mode.
  114787. */
  114788. useParallax: boolean;
  114789. /**
  114790. * Allows using the bump map in parallax occlusion mode.
  114791. */
  114792. useParallaxOcclusion: boolean;
  114793. /**
  114794. * Controls the scale bias of the parallax mode.
  114795. */
  114796. parallaxScaleBias: number;
  114797. /**
  114798. * If sets to true, disables all the lights affecting the material.
  114799. */
  114800. disableLighting: boolean;
  114801. /**
  114802. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114803. */
  114804. forceIrradianceInFragment: boolean;
  114805. /**
  114806. * Number of Simultaneous lights allowed on the material.
  114807. */
  114808. maxSimultaneousLights: number;
  114809. /**
  114810. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114811. */
  114812. invertNormalMapX: boolean;
  114813. /**
  114814. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114815. */
  114816. invertNormalMapY: boolean;
  114817. /**
  114818. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114819. */
  114820. twoSidedLighting: boolean;
  114821. /**
  114822. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114823. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114824. */
  114825. useAlphaFresnel: boolean;
  114826. /**
  114827. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114828. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114829. */
  114830. useLinearAlphaFresnel: boolean;
  114831. /**
  114832. * Let user defines the brdf lookup texture used for IBL.
  114833. * A default 8bit version is embedded but you could point at :
  114834. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114835. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114836. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114837. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  114838. */
  114839. environmentBRDFTexture: Nullable<BaseTexture>;
  114840. /**
  114841. * Force normal to face away from face.
  114842. */
  114843. forceNormalForward: boolean;
  114844. /**
  114845. * Enables specular anti aliasing in the PBR shader.
  114846. * It will both interacts on the Geometry for analytical and IBL lighting.
  114847. * It also prefilter the roughness map based on the bump values.
  114848. */
  114849. enableSpecularAntiAliasing: boolean;
  114850. /**
  114851. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114852. * makes the reflect vector face the model (under horizon).
  114853. */
  114854. useHorizonOcclusion: boolean;
  114855. /**
  114856. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114857. * too much the area relying on ambient texture to define their ambient occlusion.
  114858. */
  114859. useRadianceOcclusion: boolean;
  114860. /**
  114861. * If set to true, no lighting calculations will be applied.
  114862. */
  114863. unlit: boolean;
  114864. /**
  114865. * Gets the image processing configuration used either in this material.
  114866. */
  114867. /**
  114868. * Sets the Default image processing configuration used either in the this material.
  114869. *
  114870. * If sets to null, the scene one is in use.
  114871. */
  114872. imageProcessingConfiguration: ImageProcessingConfiguration;
  114873. /**
  114874. * Gets wether the color curves effect is enabled.
  114875. */
  114876. /**
  114877. * Sets wether the color curves effect is enabled.
  114878. */
  114879. cameraColorCurvesEnabled: boolean;
  114880. /**
  114881. * Gets wether the color grading effect is enabled.
  114882. */
  114883. /**
  114884. * Gets wether the color grading effect is enabled.
  114885. */
  114886. cameraColorGradingEnabled: boolean;
  114887. /**
  114888. * Gets wether tonemapping is enabled or not.
  114889. */
  114890. /**
  114891. * Sets wether tonemapping is enabled or not
  114892. */
  114893. cameraToneMappingEnabled: boolean;
  114894. /**
  114895. * The camera exposure used on this material.
  114896. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114897. * This corresponds to a photographic exposure.
  114898. */
  114899. /**
  114900. * The camera exposure used on this material.
  114901. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  114902. * This corresponds to a photographic exposure.
  114903. */
  114904. cameraExposure: number;
  114905. /**
  114906. * Gets The camera contrast used on this material.
  114907. */
  114908. /**
  114909. * Sets The camera contrast used on this material.
  114910. */
  114911. cameraContrast: number;
  114912. /**
  114913. * Gets the Color Grading 2D Lookup Texture.
  114914. */
  114915. /**
  114916. * Sets the Color Grading 2D Lookup Texture.
  114917. */
  114918. cameraColorGradingTexture: Nullable<BaseTexture>;
  114919. /**
  114920. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114921. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114922. * 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;
  114923. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114924. */
  114925. /**
  114926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  114927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  114928. * 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;
  114929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  114930. */
  114931. cameraColorCurves: Nullable<ColorCurves>;
  114932. /**
  114933. * Instantiates a new PBRMaterial instance.
  114934. *
  114935. * @param name The material name
  114936. * @param scene The scene the material will be use in.
  114937. */
  114938. constructor(name: string, scene: Scene);
  114939. /**
  114940. * Returns the name of this material class.
  114941. */
  114942. getClassName(): string;
  114943. /**
  114944. * Makes a duplicate of the current material.
  114945. * @param name - name to use for the new material.
  114946. */
  114947. clone(name: string): PBRMaterial;
  114948. /**
  114949. * Serializes this PBR Material.
  114950. * @returns - An object with the serialized material.
  114951. */
  114952. serialize(): any;
  114953. /**
  114954. * Parses a PBR Material from a serialized object.
  114955. * @param source - Serialized object.
  114956. * @param scene - BJS scene instance.
  114957. * @param rootUrl - url for the scene object
  114958. * @returns - PBRMaterial
  114959. */
  114960. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  114961. }
  114962. }
  114963. declare module BABYLON {
  114964. /**
  114965. * Direct draw surface info
  114966. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  114967. */
  114968. export interface DDSInfo {
  114969. /**
  114970. * Width of the texture
  114971. */
  114972. width: number;
  114973. /**
  114974. * Width of the texture
  114975. */
  114976. height: number;
  114977. /**
  114978. * Number of Mipmaps for the texture
  114979. * @see https://en.wikipedia.org/wiki/Mipmap
  114980. */
  114981. mipmapCount: number;
  114982. /**
  114983. * If the textures format is a known fourCC format
  114984. * @see https://www.fourcc.org/
  114985. */
  114986. isFourCC: boolean;
  114987. /**
  114988. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  114989. */
  114990. isRGB: boolean;
  114991. /**
  114992. * If the texture is a lumincance format
  114993. */
  114994. isLuminance: boolean;
  114995. /**
  114996. * If this is a cube texture
  114997. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  114998. */
  114999. isCube: boolean;
  115000. /**
  115001. * If the texture is a compressed format eg. FOURCC_DXT1
  115002. */
  115003. isCompressed: boolean;
  115004. /**
  115005. * The dxgiFormat of the texture
  115006. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115007. */
  115008. dxgiFormat: number;
  115009. /**
  115010. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115011. */
  115012. textureType: number;
  115013. /**
  115014. * Sphericle polynomial created for the dds texture
  115015. */
  115016. sphericalPolynomial?: SphericalPolynomial;
  115017. }
  115018. /**
  115019. * Class used to provide DDS decompression tools
  115020. */
  115021. export class DDSTools {
  115022. /**
  115023. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115024. */
  115025. static StoreLODInAlphaChannel: boolean;
  115026. /**
  115027. * Gets DDS information from an array buffer
  115028. * @param arrayBuffer defines the array buffer to read data from
  115029. * @returns the DDS information
  115030. */
  115031. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115032. private static _FloatView;
  115033. private static _Int32View;
  115034. private static _ToHalfFloat;
  115035. private static _FromHalfFloat;
  115036. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115037. private static _GetHalfFloatRGBAArrayBuffer;
  115038. private static _GetFloatRGBAArrayBuffer;
  115039. private static _GetFloatAsUIntRGBAArrayBuffer;
  115040. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115041. private static _GetRGBAArrayBuffer;
  115042. private static _ExtractLongWordOrder;
  115043. private static _GetRGBArrayBuffer;
  115044. private static _GetLuminanceArrayBuffer;
  115045. /**
  115046. * Uploads DDS Levels to a Babylon Texture
  115047. * @hidden
  115048. */
  115049. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115050. }
  115051. interface ThinEngine {
  115052. /**
  115053. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115054. * @param rootUrl defines the url where the file to load is located
  115055. * @param scene defines the current scene
  115056. * @param lodScale defines scale to apply to the mip map selection
  115057. * @param lodOffset defines offset to apply to the mip map selection
  115058. * @param onLoad defines an optional callback raised when the texture is loaded
  115059. * @param onError defines an optional callback raised if there is an issue to load the texture
  115060. * @param format defines the format of the data
  115061. * @param forcedExtension defines the extension to use to pick the right loader
  115062. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115063. * @returns the cube texture as an InternalTexture
  115064. */
  115065. 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;
  115066. }
  115067. }
  115068. declare module BABYLON {
  115069. /**
  115070. * Implementation of the DDS Texture Loader.
  115071. * @hidden
  115072. */
  115073. export class _DDSTextureLoader implements IInternalTextureLoader {
  115074. /**
  115075. * Defines wether the loader supports cascade loading the different faces.
  115076. */
  115077. readonly supportCascades: boolean;
  115078. /**
  115079. * This returns if the loader support the current file information.
  115080. * @param extension defines the file extension of the file being loaded
  115081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115082. * @param fallback defines the fallback internal texture if any
  115083. * @param isBase64 defines whether the texture is encoded as a base64
  115084. * @param isBuffer defines whether the texture data are stored as a buffer
  115085. * @returns true if the loader can load the specified file
  115086. */
  115087. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115088. /**
  115089. * Transform the url before loading if required.
  115090. * @param rootUrl the url of the texture
  115091. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115092. * @returns the transformed texture
  115093. */
  115094. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115095. /**
  115096. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115097. * @param rootUrl the url of the texture
  115098. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115099. * @returns the fallback texture
  115100. */
  115101. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115102. /**
  115103. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115104. * @param data contains the texture data
  115105. * @param texture defines the BabylonJS internal texture
  115106. * @param createPolynomials will be true if polynomials have been requested
  115107. * @param onLoad defines the callback to trigger once the texture is ready
  115108. * @param onError defines the callback to trigger in case of error
  115109. */
  115110. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115111. /**
  115112. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115113. * @param data contains the texture data
  115114. * @param texture defines the BabylonJS internal texture
  115115. * @param callback defines the method to call once ready to upload
  115116. */
  115117. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115118. }
  115119. }
  115120. declare module BABYLON {
  115121. /**
  115122. * Implementation of the ENV Texture Loader.
  115123. * @hidden
  115124. */
  115125. export class _ENVTextureLoader implements IInternalTextureLoader {
  115126. /**
  115127. * Defines wether the loader supports cascade loading the different faces.
  115128. */
  115129. readonly supportCascades: boolean;
  115130. /**
  115131. * This returns if the loader support the current file information.
  115132. * @param extension defines the file extension of the file being loaded
  115133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115134. * @param fallback defines the fallback internal texture if any
  115135. * @param isBase64 defines whether the texture is encoded as a base64
  115136. * @param isBuffer defines whether the texture data are stored as a buffer
  115137. * @returns true if the loader can load the specified file
  115138. */
  115139. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115140. /**
  115141. * Transform the url before loading if required.
  115142. * @param rootUrl the url of the texture
  115143. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115144. * @returns the transformed texture
  115145. */
  115146. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115147. /**
  115148. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115149. * @param rootUrl the url of the texture
  115150. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115151. * @returns the fallback texture
  115152. */
  115153. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115154. /**
  115155. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115156. * @param data contains the texture data
  115157. * @param texture defines the BabylonJS internal texture
  115158. * @param createPolynomials will be true if polynomials have been requested
  115159. * @param onLoad defines the callback to trigger once the texture is ready
  115160. * @param onError defines the callback to trigger in case of error
  115161. */
  115162. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115163. /**
  115164. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115165. * @param data contains the texture data
  115166. * @param texture defines the BabylonJS internal texture
  115167. * @param callback defines the method to call once ready to upload
  115168. */
  115169. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115170. }
  115171. }
  115172. declare module BABYLON {
  115173. /**
  115174. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115175. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115176. */
  115177. export class KhronosTextureContainer {
  115178. /** contents of the KTX container file */
  115179. arrayBuffer: any;
  115180. private static HEADER_LEN;
  115181. private static COMPRESSED_2D;
  115182. private static COMPRESSED_3D;
  115183. private static TEX_2D;
  115184. private static TEX_3D;
  115185. /**
  115186. * Gets the openGL type
  115187. */
  115188. glType: number;
  115189. /**
  115190. * Gets the openGL type size
  115191. */
  115192. glTypeSize: number;
  115193. /**
  115194. * Gets the openGL format
  115195. */
  115196. glFormat: number;
  115197. /**
  115198. * Gets the openGL internal format
  115199. */
  115200. glInternalFormat: number;
  115201. /**
  115202. * Gets the base internal format
  115203. */
  115204. glBaseInternalFormat: number;
  115205. /**
  115206. * Gets image width in pixel
  115207. */
  115208. pixelWidth: number;
  115209. /**
  115210. * Gets image height in pixel
  115211. */
  115212. pixelHeight: number;
  115213. /**
  115214. * Gets image depth in pixels
  115215. */
  115216. pixelDepth: number;
  115217. /**
  115218. * Gets the number of array elements
  115219. */
  115220. numberOfArrayElements: number;
  115221. /**
  115222. * Gets the number of faces
  115223. */
  115224. numberOfFaces: number;
  115225. /**
  115226. * Gets the number of mipmap levels
  115227. */
  115228. numberOfMipmapLevels: number;
  115229. /**
  115230. * Gets the bytes of key value data
  115231. */
  115232. bytesOfKeyValueData: number;
  115233. /**
  115234. * Gets the load type
  115235. */
  115236. loadType: number;
  115237. /**
  115238. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115239. */
  115240. isInvalid: boolean;
  115241. /**
  115242. * Creates a new KhronosTextureContainer
  115243. * @param arrayBuffer contents of the KTX container file
  115244. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115245. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115246. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115247. */
  115248. constructor(
  115249. /** contents of the KTX container file */
  115250. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115251. /**
  115252. * Uploads KTX content to a Babylon Texture.
  115253. * It is assumed that the texture has already been created & is currently bound
  115254. * @hidden
  115255. */
  115256. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115257. private _upload2DCompressedLevels;
  115258. }
  115259. }
  115260. declare module BABYLON {
  115261. /**
  115262. * Implementation of the KTX Texture Loader.
  115263. * @hidden
  115264. */
  115265. export class _KTXTextureLoader implements IInternalTextureLoader {
  115266. /**
  115267. * Defines wether the loader supports cascade loading the different faces.
  115268. */
  115269. readonly supportCascades: boolean;
  115270. /**
  115271. * This returns if the loader support the current file information.
  115272. * @param extension defines the file extension of the file being loaded
  115273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115274. * @param fallback defines the fallback internal texture if any
  115275. * @param isBase64 defines whether the texture is encoded as a base64
  115276. * @param isBuffer defines whether the texture data are stored as a buffer
  115277. * @returns true if the loader can load the specified file
  115278. */
  115279. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115280. /**
  115281. * Transform the url before loading if required.
  115282. * @param rootUrl the url of the texture
  115283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115284. * @returns the transformed texture
  115285. */
  115286. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115287. /**
  115288. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115289. * @param rootUrl the url of the texture
  115290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115291. * @returns the fallback texture
  115292. */
  115293. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115294. /**
  115295. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115296. * @param data contains the texture data
  115297. * @param texture defines the BabylonJS internal texture
  115298. * @param createPolynomials will be true if polynomials have been requested
  115299. * @param onLoad defines the callback to trigger once the texture is ready
  115300. * @param onError defines the callback to trigger in case of error
  115301. */
  115302. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115303. /**
  115304. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115305. * @param data contains the texture data
  115306. * @param texture defines the BabylonJS internal texture
  115307. * @param callback defines the method to call once ready to upload
  115308. */
  115309. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115310. }
  115311. }
  115312. declare module BABYLON {
  115313. /**
  115314. * Options for the default xr helper
  115315. */
  115316. export class WebXRDefaultExperienceOptions {
  115317. /**
  115318. * Floor meshes that should be used for teleporting
  115319. */
  115320. floorMeshes: Array<AbstractMesh>;
  115321. }
  115322. /**
  115323. * Default experience which provides a similar setup to the previous webVRExperience
  115324. */
  115325. export class WebXRDefaultExperience {
  115326. /**
  115327. * Base experience
  115328. */
  115329. baseExperience: WebXRExperienceHelper;
  115330. /**
  115331. * Input experience extension
  115332. */
  115333. input: WebXRInput;
  115334. /**
  115335. * Loads the controller models
  115336. */
  115337. controllerModelLoader: WebXRControllerModelLoader;
  115338. /**
  115339. * Enables laser pointer and selection
  115340. */
  115341. pointerSelection: WebXRControllerPointerSelection;
  115342. /**
  115343. * Enables teleportation
  115344. */
  115345. teleportation: WebXRControllerTeleportation;
  115346. /**
  115347. * Enables ui for enetering/exiting xr
  115348. */
  115349. enterExitUI: WebXREnterExitUI;
  115350. /**
  115351. * Default output canvas xr should render to
  115352. */
  115353. outputCanvas: WebXRManagedOutputCanvas;
  115354. /**
  115355. * Creates the default xr experience
  115356. * @param scene scene
  115357. * @param options options for basic configuration
  115358. * @returns resulting WebXRDefaultExperience
  115359. */
  115360. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115361. private constructor();
  115362. /**
  115363. * DIsposes of the experience helper
  115364. */
  115365. dispose(): void;
  115366. }
  115367. }
  115368. declare module BABYLON {
  115369. /** @hidden */
  115370. export var _forceSceneHelpersToBundle: boolean;
  115371. interface Scene {
  115372. /**
  115373. * Creates a default light for the scene.
  115374. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115375. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115376. */
  115377. createDefaultLight(replace?: boolean): void;
  115378. /**
  115379. * Creates a default camera for the scene.
  115380. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115381. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115382. * @param replace has default false, when true replaces the active camera in the scene
  115383. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115384. */
  115385. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115386. /**
  115387. * Creates a default camera and a default light.
  115388. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115389. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115390. * @param replace has the default false, when true replaces the active camera/light in the scene
  115391. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115392. */
  115393. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115394. /**
  115395. * Creates a new sky box
  115396. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115397. * @param environmentTexture defines the texture to use as environment texture
  115398. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115399. * @param scale defines the overall scale of the skybox
  115400. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115401. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115402. * @returns a new mesh holding the sky box
  115403. */
  115404. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115405. /**
  115406. * Creates a new environment
  115407. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115408. * @param options defines the options you can use to configure the environment
  115409. * @returns the new EnvironmentHelper
  115410. */
  115411. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115412. /**
  115413. * Creates a new VREXperienceHelper
  115414. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115415. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115416. * @returns a new VREXperienceHelper
  115417. */
  115418. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115419. /**
  115420. * Creates a new WebXRDefaultExperience
  115421. * @see http://doc.babylonjs.com/how_to/webxr
  115422. * @param options experience options
  115423. * @returns a promise for a new WebXRDefaultExperience
  115424. */
  115425. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115426. }
  115427. }
  115428. declare module BABYLON {
  115429. /**
  115430. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115431. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115432. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115433. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115434. */
  115435. export class VideoDome extends TransformNode {
  115436. /**
  115437. * Define the video source as a Monoscopic panoramic 360 video.
  115438. */
  115439. static readonly MODE_MONOSCOPIC: number;
  115440. /**
  115441. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115442. */
  115443. static readonly MODE_TOPBOTTOM: number;
  115444. /**
  115445. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115446. */
  115447. static readonly MODE_SIDEBYSIDE: number;
  115448. private _halfDome;
  115449. private _useDirectMapping;
  115450. /**
  115451. * The video texture being displayed on the sphere
  115452. */
  115453. protected _videoTexture: VideoTexture;
  115454. /**
  115455. * Gets the video texture being displayed on the sphere
  115456. */
  115457. readonly videoTexture: VideoTexture;
  115458. /**
  115459. * The skybox material
  115460. */
  115461. protected _material: BackgroundMaterial;
  115462. /**
  115463. * The surface used for the skybox
  115464. */
  115465. protected _mesh: Mesh;
  115466. /**
  115467. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115468. */
  115469. private _halfDomeMask;
  115470. /**
  115471. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115472. * Also see the options.resolution property.
  115473. */
  115474. fovMultiplier: number;
  115475. private _videoMode;
  115476. /**
  115477. * Gets or set the current video mode for the video. It can be:
  115478. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115479. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115480. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115481. */
  115482. videoMode: number;
  115483. /**
  115484. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115485. *
  115486. */
  115487. /**
  115488. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115489. */
  115490. halfDome: boolean;
  115491. /**
  115492. * Oberserver used in Stereoscopic VR Mode.
  115493. */
  115494. private _onBeforeCameraRenderObserver;
  115495. /**
  115496. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115497. * @param name Element's name, child elements will append suffixes for their own names.
  115498. * @param urlsOrVideo defines the url(s) or the video element to use
  115499. * @param options An object containing optional or exposed sub element properties
  115500. */
  115501. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115502. resolution?: number;
  115503. clickToPlay?: boolean;
  115504. autoPlay?: boolean;
  115505. loop?: boolean;
  115506. size?: number;
  115507. poster?: string;
  115508. faceForward?: boolean;
  115509. useDirectMapping?: boolean;
  115510. halfDomeMode?: boolean;
  115511. }, scene: Scene);
  115512. private _changeVideoMode;
  115513. /**
  115514. * Releases resources associated with this node.
  115515. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115516. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115517. */
  115518. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115519. }
  115520. }
  115521. declare module BABYLON {
  115522. /**
  115523. * This class can be used to get instrumentation data from a Babylon engine
  115524. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115525. */
  115526. export class EngineInstrumentation implements IDisposable {
  115527. /**
  115528. * Define the instrumented engine.
  115529. */
  115530. engine: Engine;
  115531. private _captureGPUFrameTime;
  115532. private _gpuFrameTimeToken;
  115533. private _gpuFrameTime;
  115534. private _captureShaderCompilationTime;
  115535. private _shaderCompilationTime;
  115536. private _onBeginFrameObserver;
  115537. private _onEndFrameObserver;
  115538. private _onBeforeShaderCompilationObserver;
  115539. private _onAfterShaderCompilationObserver;
  115540. /**
  115541. * Gets the perf counter used for GPU frame time
  115542. */
  115543. readonly gpuFrameTimeCounter: PerfCounter;
  115544. /**
  115545. * Gets the GPU frame time capture status
  115546. */
  115547. /**
  115548. * Enable or disable the GPU frame time capture
  115549. */
  115550. captureGPUFrameTime: boolean;
  115551. /**
  115552. * Gets the perf counter used for shader compilation time
  115553. */
  115554. readonly shaderCompilationTimeCounter: PerfCounter;
  115555. /**
  115556. * Gets the shader compilation time capture status
  115557. */
  115558. /**
  115559. * Enable or disable the shader compilation time capture
  115560. */
  115561. captureShaderCompilationTime: boolean;
  115562. /**
  115563. * Instantiates a new engine instrumentation.
  115564. * This class can be used to get instrumentation data from a Babylon engine
  115565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115566. * @param engine Defines the engine to instrument
  115567. */
  115568. constructor(
  115569. /**
  115570. * Define the instrumented engine.
  115571. */
  115572. engine: Engine);
  115573. /**
  115574. * Dispose and release associated resources.
  115575. */
  115576. dispose(): void;
  115577. }
  115578. }
  115579. declare module BABYLON {
  115580. /**
  115581. * This class can be used to get instrumentation data from a Babylon engine
  115582. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115583. */
  115584. export class SceneInstrumentation implements IDisposable {
  115585. /**
  115586. * Defines the scene to instrument
  115587. */
  115588. scene: Scene;
  115589. private _captureActiveMeshesEvaluationTime;
  115590. private _activeMeshesEvaluationTime;
  115591. private _captureRenderTargetsRenderTime;
  115592. private _renderTargetsRenderTime;
  115593. private _captureFrameTime;
  115594. private _frameTime;
  115595. private _captureRenderTime;
  115596. private _renderTime;
  115597. private _captureInterFrameTime;
  115598. private _interFrameTime;
  115599. private _captureParticlesRenderTime;
  115600. private _particlesRenderTime;
  115601. private _captureSpritesRenderTime;
  115602. private _spritesRenderTime;
  115603. private _capturePhysicsTime;
  115604. private _physicsTime;
  115605. private _captureAnimationsTime;
  115606. private _animationsTime;
  115607. private _captureCameraRenderTime;
  115608. private _cameraRenderTime;
  115609. private _onBeforeActiveMeshesEvaluationObserver;
  115610. private _onAfterActiveMeshesEvaluationObserver;
  115611. private _onBeforeRenderTargetsRenderObserver;
  115612. private _onAfterRenderTargetsRenderObserver;
  115613. private _onAfterRenderObserver;
  115614. private _onBeforeDrawPhaseObserver;
  115615. private _onAfterDrawPhaseObserver;
  115616. private _onBeforeAnimationsObserver;
  115617. private _onBeforeParticlesRenderingObserver;
  115618. private _onAfterParticlesRenderingObserver;
  115619. private _onBeforeSpritesRenderingObserver;
  115620. private _onAfterSpritesRenderingObserver;
  115621. private _onBeforePhysicsObserver;
  115622. private _onAfterPhysicsObserver;
  115623. private _onAfterAnimationsObserver;
  115624. private _onBeforeCameraRenderObserver;
  115625. private _onAfterCameraRenderObserver;
  115626. /**
  115627. * Gets the perf counter used for active meshes evaluation time
  115628. */
  115629. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115630. /**
  115631. * Gets the active meshes evaluation time capture status
  115632. */
  115633. /**
  115634. * Enable or disable the active meshes evaluation time capture
  115635. */
  115636. captureActiveMeshesEvaluationTime: boolean;
  115637. /**
  115638. * Gets the perf counter used for render targets render time
  115639. */
  115640. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115641. /**
  115642. * Gets the render targets render time capture status
  115643. */
  115644. /**
  115645. * Enable or disable the render targets render time capture
  115646. */
  115647. captureRenderTargetsRenderTime: boolean;
  115648. /**
  115649. * Gets the perf counter used for particles render time
  115650. */
  115651. readonly particlesRenderTimeCounter: PerfCounter;
  115652. /**
  115653. * Gets the particles render time capture status
  115654. */
  115655. /**
  115656. * Enable or disable the particles render time capture
  115657. */
  115658. captureParticlesRenderTime: boolean;
  115659. /**
  115660. * Gets the perf counter used for sprites render time
  115661. */
  115662. readonly spritesRenderTimeCounter: PerfCounter;
  115663. /**
  115664. * Gets the sprites render time capture status
  115665. */
  115666. /**
  115667. * Enable or disable the sprites render time capture
  115668. */
  115669. captureSpritesRenderTime: boolean;
  115670. /**
  115671. * Gets the perf counter used for physics time
  115672. */
  115673. readonly physicsTimeCounter: PerfCounter;
  115674. /**
  115675. * Gets the physics time capture status
  115676. */
  115677. /**
  115678. * Enable or disable the physics time capture
  115679. */
  115680. capturePhysicsTime: boolean;
  115681. /**
  115682. * Gets the perf counter used for animations time
  115683. */
  115684. readonly animationsTimeCounter: PerfCounter;
  115685. /**
  115686. * Gets the animations time capture status
  115687. */
  115688. /**
  115689. * Enable or disable the animations time capture
  115690. */
  115691. captureAnimationsTime: boolean;
  115692. /**
  115693. * Gets the perf counter used for frame time capture
  115694. */
  115695. readonly frameTimeCounter: PerfCounter;
  115696. /**
  115697. * Gets the frame time capture status
  115698. */
  115699. /**
  115700. * Enable or disable the frame time capture
  115701. */
  115702. captureFrameTime: boolean;
  115703. /**
  115704. * Gets the perf counter used for inter-frames time capture
  115705. */
  115706. readonly interFrameTimeCounter: PerfCounter;
  115707. /**
  115708. * Gets the inter-frames time capture status
  115709. */
  115710. /**
  115711. * Enable or disable the inter-frames time capture
  115712. */
  115713. captureInterFrameTime: boolean;
  115714. /**
  115715. * Gets the perf counter used for render time capture
  115716. */
  115717. readonly renderTimeCounter: PerfCounter;
  115718. /**
  115719. * Gets the render time capture status
  115720. */
  115721. /**
  115722. * Enable or disable the render time capture
  115723. */
  115724. captureRenderTime: boolean;
  115725. /**
  115726. * Gets the perf counter used for camera render time capture
  115727. */
  115728. readonly cameraRenderTimeCounter: PerfCounter;
  115729. /**
  115730. * Gets the camera render time capture status
  115731. */
  115732. /**
  115733. * Enable or disable the camera render time capture
  115734. */
  115735. captureCameraRenderTime: boolean;
  115736. /**
  115737. * Gets the perf counter used for draw calls
  115738. */
  115739. readonly drawCallsCounter: PerfCounter;
  115740. /**
  115741. * Instantiates a new scene instrumentation.
  115742. * This class can be used to get instrumentation data from a Babylon engine
  115743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115744. * @param scene Defines the scene to instrument
  115745. */
  115746. constructor(
  115747. /**
  115748. * Defines the scene to instrument
  115749. */
  115750. scene: Scene);
  115751. /**
  115752. * Dispose and release associated resources.
  115753. */
  115754. dispose(): void;
  115755. }
  115756. }
  115757. declare module BABYLON {
  115758. /** @hidden */
  115759. export var glowMapGenerationPixelShader: {
  115760. name: string;
  115761. shader: string;
  115762. };
  115763. }
  115764. declare module BABYLON {
  115765. /** @hidden */
  115766. export var glowMapGenerationVertexShader: {
  115767. name: string;
  115768. shader: string;
  115769. };
  115770. }
  115771. declare module BABYLON {
  115772. /**
  115773. * Effect layer options. This helps customizing the behaviour
  115774. * of the effect layer.
  115775. */
  115776. export interface IEffectLayerOptions {
  115777. /**
  115778. * Multiplication factor apply to the canvas size to compute the render target size
  115779. * used to generated the objects (the smaller the faster).
  115780. */
  115781. mainTextureRatio: number;
  115782. /**
  115783. * Enforces a fixed size texture to ensure effect stability across devices.
  115784. */
  115785. mainTextureFixedSize?: number;
  115786. /**
  115787. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  115788. */
  115789. alphaBlendingMode: number;
  115790. /**
  115791. * The camera attached to the layer.
  115792. */
  115793. camera: Nullable<Camera>;
  115794. /**
  115795. * The rendering group to draw the layer in.
  115796. */
  115797. renderingGroupId: number;
  115798. }
  115799. /**
  115800. * The effect layer Helps adding post process effect blended with the main pass.
  115801. *
  115802. * This can be for instance use to generate glow or higlight effects on the scene.
  115803. *
  115804. * The effect layer class can not be used directly and is intented to inherited from to be
  115805. * customized per effects.
  115806. */
  115807. export abstract class EffectLayer {
  115808. private _vertexBuffers;
  115809. private _indexBuffer;
  115810. private _cachedDefines;
  115811. private _effectLayerMapGenerationEffect;
  115812. private _effectLayerOptions;
  115813. private _mergeEffect;
  115814. protected _scene: Scene;
  115815. protected _engine: Engine;
  115816. protected _maxSize: number;
  115817. protected _mainTextureDesiredSize: ISize;
  115818. protected _mainTexture: RenderTargetTexture;
  115819. protected _shouldRender: boolean;
  115820. protected _postProcesses: PostProcess[];
  115821. protected _textures: BaseTexture[];
  115822. protected _emissiveTextureAndColor: {
  115823. texture: Nullable<BaseTexture>;
  115824. color: Color4;
  115825. };
  115826. /**
  115827. * The name of the layer
  115828. */
  115829. name: string;
  115830. /**
  115831. * The clear color of the texture used to generate the glow map.
  115832. */
  115833. neutralColor: Color4;
  115834. /**
  115835. * Specifies wether the highlight layer is enabled or not.
  115836. */
  115837. isEnabled: boolean;
  115838. /**
  115839. * Gets the camera attached to the layer.
  115840. */
  115841. readonly camera: Nullable<Camera>;
  115842. /**
  115843. * Gets the rendering group id the layer should render in.
  115844. */
  115845. renderingGroupId: number;
  115846. /**
  115847. * An event triggered when the effect layer has been disposed.
  115848. */
  115849. onDisposeObservable: Observable<EffectLayer>;
  115850. /**
  115851. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  115852. */
  115853. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  115854. /**
  115855. * An event triggered when the generated texture is being merged in the scene.
  115856. */
  115857. onBeforeComposeObservable: Observable<EffectLayer>;
  115858. /**
  115859. * An event triggered when the generated texture has been merged in the scene.
  115860. */
  115861. onAfterComposeObservable: Observable<EffectLayer>;
  115862. /**
  115863. * An event triggered when the efffect layer changes its size.
  115864. */
  115865. onSizeChangedObservable: Observable<EffectLayer>;
  115866. /** @hidden */
  115867. static _SceneComponentInitialization: (scene: Scene) => void;
  115868. /**
  115869. * Instantiates a new effect Layer and references it in the scene.
  115870. * @param name The name of the layer
  115871. * @param scene The scene to use the layer in
  115872. */
  115873. constructor(
  115874. /** The Friendly of the effect in the scene */
  115875. name: string, scene: Scene);
  115876. /**
  115877. * Get the effect name of the layer.
  115878. * @return The effect name
  115879. */
  115880. abstract getEffectName(): string;
  115881. /**
  115882. * Checks for the readiness of the element composing the layer.
  115883. * @param subMesh the mesh to check for
  115884. * @param useInstances specify wether or not to use instances to render the mesh
  115885. * @return true if ready otherwise, false
  115886. */
  115887. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115888. /**
  115889. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115890. * @returns true if the effect requires stencil during the main canvas render pass.
  115891. */
  115892. abstract needStencil(): boolean;
  115893. /**
  115894. * Create the merge effect. This is the shader use to blit the information back
  115895. * to the main canvas at the end of the scene rendering.
  115896. * @returns The effect containing the shader used to merge the effect on the main canvas
  115897. */
  115898. protected abstract _createMergeEffect(): Effect;
  115899. /**
  115900. * Creates the render target textures and post processes used in the effect layer.
  115901. */
  115902. protected abstract _createTextureAndPostProcesses(): void;
  115903. /**
  115904. * Implementation specific of rendering the generating effect on the main canvas.
  115905. * @param effect The effect used to render through
  115906. */
  115907. protected abstract _internalRender(effect: Effect): void;
  115908. /**
  115909. * Sets the required values for both the emissive texture and and the main color.
  115910. */
  115911. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115912. /**
  115913. * Free any resources and references associated to a mesh.
  115914. * Internal use
  115915. * @param mesh The mesh to free.
  115916. */
  115917. abstract _disposeMesh(mesh: Mesh): void;
  115918. /**
  115919. * Serializes this layer (Glow or Highlight for example)
  115920. * @returns a serialized layer object
  115921. */
  115922. abstract serialize?(): any;
  115923. /**
  115924. * Initializes the effect layer with the required options.
  115925. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  115926. */
  115927. protected _init(options: Partial<IEffectLayerOptions>): void;
  115928. /**
  115929. * Generates the index buffer of the full screen quad blending to the main canvas.
  115930. */
  115931. private _generateIndexBuffer;
  115932. /**
  115933. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  115934. */
  115935. private _generateVertexBuffer;
  115936. /**
  115937. * Sets the main texture desired size which is the closest power of two
  115938. * of the engine canvas size.
  115939. */
  115940. private _setMainTextureSize;
  115941. /**
  115942. * Creates the main texture for the effect layer.
  115943. */
  115944. protected _createMainTexture(): void;
  115945. /**
  115946. * Adds specific effects defines.
  115947. * @param defines The defines to add specifics to.
  115948. */
  115949. protected _addCustomEffectDefines(defines: string[]): void;
  115950. /**
  115951. * Checks for the readiness of the element composing the layer.
  115952. * @param subMesh the mesh to check for
  115953. * @param useInstances specify wether or not to use instances to render the mesh
  115954. * @param emissiveTexture the associated emissive texture used to generate the glow
  115955. * @return true if ready otherwise, false
  115956. */
  115957. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  115958. /**
  115959. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  115960. */
  115961. render(): void;
  115962. /**
  115963. * Determine if a given mesh will be used in the current effect.
  115964. * @param mesh mesh to test
  115965. * @returns true if the mesh will be used
  115966. */
  115967. hasMesh(mesh: AbstractMesh): boolean;
  115968. /**
  115969. * Returns true if the layer contains information to display, otherwise false.
  115970. * @returns true if the glow layer should be rendered
  115971. */
  115972. shouldRender(): boolean;
  115973. /**
  115974. * Returns true if the mesh should render, otherwise false.
  115975. * @param mesh The mesh to render
  115976. * @returns true if it should render otherwise false
  115977. */
  115978. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  115979. /**
  115980. * Returns true if the mesh can be rendered, otherwise false.
  115981. * @param mesh The mesh to render
  115982. * @param material The material used on the mesh
  115983. * @returns true if it can be rendered otherwise false
  115984. */
  115985. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115986. /**
  115987. * Returns true if the mesh should render, otherwise false.
  115988. * @param mesh The mesh to render
  115989. * @returns true if it should render otherwise false
  115990. */
  115991. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  115992. /**
  115993. * Renders the submesh passed in parameter to the generation map.
  115994. */
  115995. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  115996. /**
  115997. * Rebuild the required buffers.
  115998. * @hidden Internal use only.
  115999. */
  116000. _rebuild(): void;
  116001. /**
  116002. * Dispose only the render target textures and post process.
  116003. */
  116004. private _disposeTextureAndPostProcesses;
  116005. /**
  116006. * Dispose the highlight layer and free resources.
  116007. */
  116008. dispose(): void;
  116009. /**
  116010. * Gets the class name of the effect layer
  116011. * @returns the string with the class name of the effect layer
  116012. */
  116013. getClassName(): string;
  116014. /**
  116015. * Creates an effect layer from parsed effect layer data
  116016. * @param parsedEffectLayer defines effect layer data
  116017. * @param scene defines the current scene
  116018. * @param rootUrl defines the root URL containing the effect layer information
  116019. * @returns a parsed effect Layer
  116020. */
  116021. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116022. }
  116023. }
  116024. declare module BABYLON {
  116025. interface AbstractScene {
  116026. /**
  116027. * The list of effect layers (highlights/glow) added to the scene
  116028. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116029. * @see http://doc.babylonjs.com/how_to/glow_layer
  116030. */
  116031. effectLayers: Array<EffectLayer>;
  116032. /**
  116033. * Removes the given effect layer from this scene.
  116034. * @param toRemove defines the effect layer to remove
  116035. * @returns the index of the removed effect layer
  116036. */
  116037. removeEffectLayer(toRemove: EffectLayer): number;
  116038. /**
  116039. * Adds the given effect layer to this scene
  116040. * @param newEffectLayer defines the effect layer to add
  116041. */
  116042. addEffectLayer(newEffectLayer: EffectLayer): void;
  116043. }
  116044. /**
  116045. * Defines the layer scene component responsible to manage any effect layers
  116046. * in a given scene.
  116047. */
  116048. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116049. /**
  116050. * The component name helpfull to identify the component in the list of scene components.
  116051. */
  116052. readonly name: string;
  116053. /**
  116054. * The scene the component belongs to.
  116055. */
  116056. scene: Scene;
  116057. private _engine;
  116058. private _renderEffects;
  116059. private _needStencil;
  116060. private _previousStencilState;
  116061. /**
  116062. * Creates a new instance of the component for the given scene
  116063. * @param scene Defines the scene to register the component in
  116064. */
  116065. constructor(scene: Scene);
  116066. /**
  116067. * Registers the component in a given scene
  116068. */
  116069. register(): void;
  116070. /**
  116071. * Rebuilds the elements related to this component in case of
  116072. * context lost for instance.
  116073. */
  116074. rebuild(): void;
  116075. /**
  116076. * Serializes the component data to the specified json object
  116077. * @param serializationObject The object to serialize to
  116078. */
  116079. serialize(serializationObject: any): void;
  116080. /**
  116081. * Adds all the elements from the container to the scene
  116082. * @param container the container holding the elements
  116083. */
  116084. addFromContainer(container: AbstractScene): void;
  116085. /**
  116086. * Removes all the elements in the container from the scene
  116087. * @param container contains the elements to remove
  116088. * @param dispose if the removed element should be disposed (default: false)
  116089. */
  116090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116091. /**
  116092. * Disposes the component and the associated ressources.
  116093. */
  116094. dispose(): void;
  116095. private _isReadyForMesh;
  116096. private _renderMainTexture;
  116097. private _setStencil;
  116098. private _setStencilBack;
  116099. private _draw;
  116100. private _drawCamera;
  116101. private _drawRenderingGroup;
  116102. }
  116103. }
  116104. declare module BABYLON {
  116105. /** @hidden */
  116106. export var glowMapMergePixelShader: {
  116107. name: string;
  116108. shader: string;
  116109. };
  116110. }
  116111. declare module BABYLON {
  116112. /** @hidden */
  116113. export var glowMapMergeVertexShader: {
  116114. name: string;
  116115. shader: string;
  116116. };
  116117. }
  116118. declare module BABYLON {
  116119. interface AbstractScene {
  116120. /**
  116121. * Return a the first highlight layer of the scene with a given name.
  116122. * @param name The name of the highlight layer to look for.
  116123. * @return The highlight layer if found otherwise null.
  116124. */
  116125. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116126. }
  116127. /**
  116128. * Glow layer options. This helps customizing the behaviour
  116129. * of the glow layer.
  116130. */
  116131. export interface IGlowLayerOptions {
  116132. /**
  116133. * Multiplication factor apply to the canvas size to compute the render target size
  116134. * used to generated the glowing objects (the smaller the faster).
  116135. */
  116136. mainTextureRatio: number;
  116137. /**
  116138. * Enforces a fixed size texture to ensure resize independant blur.
  116139. */
  116140. mainTextureFixedSize?: number;
  116141. /**
  116142. * How big is the kernel of the blur texture.
  116143. */
  116144. blurKernelSize: number;
  116145. /**
  116146. * The camera attached to the layer.
  116147. */
  116148. camera: Nullable<Camera>;
  116149. /**
  116150. * Enable MSAA by chosing the number of samples.
  116151. */
  116152. mainTextureSamples?: number;
  116153. /**
  116154. * The rendering group to draw the layer in.
  116155. */
  116156. renderingGroupId: number;
  116157. }
  116158. /**
  116159. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116160. *
  116161. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116162. * glowy meshes to your scene.
  116163. *
  116164. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116165. */
  116166. export class GlowLayer extends EffectLayer {
  116167. /**
  116168. * Effect Name of the layer.
  116169. */
  116170. static readonly EffectName: string;
  116171. /**
  116172. * The default blur kernel size used for the glow.
  116173. */
  116174. static DefaultBlurKernelSize: number;
  116175. /**
  116176. * The default texture size ratio used for the glow.
  116177. */
  116178. static DefaultTextureRatio: number;
  116179. /**
  116180. * Sets the kernel size of the blur.
  116181. */
  116182. /**
  116183. * Gets the kernel size of the blur.
  116184. */
  116185. blurKernelSize: number;
  116186. /**
  116187. * Sets the glow intensity.
  116188. */
  116189. /**
  116190. * Gets the glow intensity.
  116191. */
  116192. intensity: number;
  116193. private _options;
  116194. private _intensity;
  116195. private _horizontalBlurPostprocess1;
  116196. private _verticalBlurPostprocess1;
  116197. private _horizontalBlurPostprocess2;
  116198. private _verticalBlurPostprocess2;
  116199. private _blurTexture1;
  116200. private _blurTexture2;
  116201. private _postProcesses1;
  116202. private _postProcesses2;
  116203. private _includedOnlyMeshes;
  116204. private _excludedMeshes;
  116205. /**
  116206. * Callback used to let the user override the color selection on a per mesh basis
  116207. */
  116208. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116209. /**
  116210. * Callback used to let the user override the texture selection on a per mesh basis
  116211. */
  116212. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116213. /**
  116214. * Instantiates a new glow Layer and references it to the scene.
  116215. * @param name The name of the layer
  116216. * @param scene The scene to use the layer in
  116217. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116218. */
  116219. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116220. /**
  116221. * Get the effect name of the layer.
  116222. * @return The effect name
  116223. */
  116224. getEffectName(): string;
  116225. /**
  116226. * Create the merge effect. This is the shader use to blit the information back
  116227. * to the main canvas at the end of the scene rendering.
  116228. */
  116229. protected _createMergeEffect(): Effect;
  116230. /**
  116231. * Creates the render target textures and post processes used in the glow layer.
  116232. */
  116233. protected _createTextureAndPostProcesses(): void;
  116234. /**
  116235. * Checks for the readiness of the element composing the layer.
  116236. * @param subMesh the mesh to check for
  116237. * @param useInstances specify wether or not to use instances to render the mesh
  116238. * @param emissiveTexture the associated emissive texture used to generate the glow
  116239. * @return true if ready otherwise, false
  116240. */
  116241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116242. /**
  116243. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116244. */
  116245. needStencil(): boolean;
  116246. /**
  116247. * Returns true if the mesh can be rendered, otherwise false.
  116248. * @param mesh The mesh to render
  116249. * @param material The material used on the mesh
  116250. * @returns true if it can be rendered otherwise false
  116251. */
  116252. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116253. /**
  116254. * Implementation specific of rendering the generating effect on the main canvas.
  116255. * @param effect The effect used to render through
  116256. */
  116257. protected _internalRender(effect: Effect): void;
  116258. /**
  116259. * Sets the required values for both the emissive texture and and the main color.
  116260. */
  116261. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116262. /**
  116263. * Returns true if the mesh should render, otherwise false.
  116264. * @param mesh The mesh to render
  116265. * @returns true if it should render otherwise false
  116266. */
  116267. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116268. /**
  116269. * Adds specific effects defines.
  116270. * @param defines The defines to add specifics to.
  116271. */
  116272. protected _addCustomEffectDefines(defines: string[]): void;
  116273. /**
  116274. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116275. * @param mesh The mesh to exclude from the glow layer
  116276. */
  116277. addExcludedMesh(mesh: Mesh): void;
  116278. /**
  116279. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116280. * @param mesh The mesh to remove
  116281. */
  116282. removeExcludedMesh(mesh: Mesh): void;
  116283. /**
  116284. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116285. * @param mesh The mesh to include in the glow layer
  116286. */
  116287. addIncludedOnlyMesh(mesh: Mesh): void;
  116288. /**
  116289. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116290. * @param mesh The mesh to remove
  116291. */
  116292. removeIncludedOnlyMesh(mesh: Mesh): void;
  116293. /**
  116294. * Determine if a given mesh will be used in the glow layer
  116295. * @param mesh The mesh to test
  116296. * @returns true if the mesh will be highlighted by the current glow layer
  116297. */
  116298. hasMesh(mesh: AbstractMesh): boolean;
  116299. /**
  116300. * Free any resources and references associated to a mesh.
  116301. * Internal use
  116302. * @param mesh The mesh to free.
  116303. * @hidden
  116304. */
  116305. _disposeMesh(mesh: Mesh): void;
  116306. /**
  116307. * Gets the class name of the effect layer
  116308. * @returns the string with the class name of the effect layer
  116309. */
  116310. getClassName(): string;
  116311. /**
  116312. * Serializes this glow layer
  116313. * @returns a serialized glow layer object
  116314. */
  116315. serialize(): any;
  116316. /**
  116317. * Creates a Glow Layer from parsed glow layer data
  116318. * @param parsedGlowLayer defines glow layer data
  116319. * @param scene defines the current scene
  116320. * @param rootUrl defines the root URL containing the glow layer information
  116321. * @returns a parsed Glow Layer
  116322. */
  116323. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116324. }
  116325. }
  116326. declare module BABYLON {
  116327. /** @hidden */
  116328. export var glowBlurPostProcessPixelShader: {
  116329. name: string;
  116330. shader: string;
  116331. };
  116332. }
  116333. declare module BABYLON {
  116334. interface AbstractScene {
  116335. /**
  116336. * Return a the first highlight layer of the scene with a given name.
  116337. * @param name The name of the highlight layer to look for.
  116338. * @return The highlight layer if found otherwise null.
  116339. */
  116340. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116341. }
  116342. /**
  116343. * Highlight layer options. This helps customizing the behaviour
  116344. * of the highlight layer.
  116345. */
  116346. export interface IHighlightLayerOptions {
  116347. /**
  116348. * Multiplication factor apply to the canvas size to compute the render target size
  116349. * used to generated the glowing objects (the smaller the faster).
  116350. */
  116351. mainTextureRatio: number;
  116352. /**
  116353. * Enforces a fixed size texture to ensure resize independant blur.
  116354. */
  116355. mainTextureFixedSize?: number;
  116356. /**
  116357. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116358. * of the picture to blur (the smaller the faster).
  116359. */
  116360. blurTextureSizeRatio: number;
  116361. /**
  116362. * How big in texel of the blur texture is the vertical blur.
  116363. */
  116364. blurVerticalSize: number;
  116365. /**
  116366. * How big in texel of the blur texture is the horizontal blur.
  116367. */
  116368. blurHorizontalSize: number;
  116369. /**
  116370. * Alpha blending mode used to apply the blur. Default is combine.
  116371. */
  116372. alphaBlendingMode: number;
  116373. /**
  116374. * The camera attached to the layer.
  116375. */
  116376. camera: Nullable<Camera>;
  116377. /**
  116378. * Should we display highlight as a solid stroke?
  116379. */
  116380. isStroke?: boolean;
  116381. /**
  116382. * The rendering group to draw the layer in.
  116383. */
  116384. renderingGroupId: number;
  116385. }
  116386. /**
  116387. * The highlight layer Helps adding a glow effect around a mesh.
  116388. *
  116389. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116390. * glowy meshes to your scene.
  116391. *
  116392. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116393. */
  116394. export class HighlightLayer extends EffectLayer {
  116395. name: string;
  116396. /**
  116397. * Effect Name of the highlight layer.
  116398. */
  116399. static readonly EffectName: string;
  116400. /**
  116401. * The neutral color used during the preparation of the glow effect.
  116402. * This is black by default as the blend operation is a blend operation.
  116403. */
  116404. static NeutralColor: Color4;
  116405. /**
  116406. * Stencil value used for glowing meshes.
  116407. */
  116408. static GlowingMeshStencilReference: number;
  116409. /**
  116410. * Stencil value used for the other meshes in the scene.
  116411. */
  116412. static NormalMeshStencilReference: number;
  116413. /**
  116414. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116415. */
  116416. innerGlow: boolean;
  116417. /**
  116418. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116419. */
  116420. outerGlow: boolean;
  116421. /**
  116422. * Specifies the horizontal size of the blur.
  116423. */
  116424. /**
  116425. * Gets the horizontal size of the blur.
  116426. */
  116427. blurHorizontalSize: number;
  116428. /**
  116429. * Specifies the vertical size of the blur.
  116430. */
  116431. /**
  116432. * Gets the vertical size of the blur.
  116433. */
  116434. blurVerticalSize: number;
  116435. /**
  116436. * An event triggered when the highlight layer is being blurred.
  116437. */
  116438. onBeforeBlurObservable: Observable<HighlightLayer>;
  116439. /**
  116440. * An event triggered when the highlight layer has been blurred.
  116441. */
  116442. onAfterBlurObservable: Observable<HighlightLayer>;
  116443. private _instanceGlowingMeshStencilReference;
  116444. private _options;
  116445. private _downSamplePostprocess;
  116446. private _horizontalBlurPostprocess;
  116447. private _verticalBlurPostprocess;
  116448. private _blurTexture;
  116449. private _meshes;
  116450. private _excludedMeshes;
  116451. /**
  116452. * Instantiates a new highlight Layer and references it to the scene..
  116453. * @param name The name of the layer
  116454. * @param scene The scene to use the layer in
  116455. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116456. */
  116457. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116458. /**
  116459. * Get the effect name of the layer.
  116460. * @return The effect name
  116461. */
  116462. getEffectName(): string;
  116463. /**
  116464. * Create the merge effect. This is the shader use to blit the information back
  116465. * to the main canvas at the end of the scene rendering.
  116466. */
  116467. protected _createMergeEffect(): Effect;
  116468. /**
  116469. * Creates the render target textures and post processes used in the highlight layer.
  116470. */
  116471. protected _createTextureAndPostProcesses(): void;
  116472. /**
  116473. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116474. */
  116475. needStencil(): boolean;
  116476. /**
  116477. * Checks for the readiness of the element composing the layer.
  116478. * @param subMesh the mesh to check for
  116479. * @param useInstances specify wether or not to use instances to render the mesh
  116480. * @param emissiveTexture the associated emissive texture used to generate the glow
  116481. * @return true if ready otherwise, false
  116482. */
  116483. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116484. /**
  116485. * Implementation specific of rendering the generating effect on the main canvas.
  116486. * @param effect The effect used to render through
  116487. */
  116488. protected _internalRender(effect: Effect): void;
  116489. /**
  116490. * Returns true if the layer contains information to display, otherwise false.
  116491. */
  116492. shouldRender(): boolean;
  116493. /**
  116494. * Returns true if the mesh should render, otherwise false.
  116495. * @param mesh The mesh to render
  116496. * @returns true if it should render otherwise false
  116497. */
  116498. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116499. /**
  116500. * Sets the required values for both the emissive texture and and the main color.
  116501. */
  116502. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116503. /**
  116504. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116505. * @param mesh The mesh to exclude from the highlight layer
  116506. */
  116507. addExcludedMesh(mesh: Mesh): void;
  116508. /**
  116509. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116510. * @param mesh The mesh to highlight
  116511. */
  116512. removeExcludedMesh(mesh: Mesh): void;
  116513. /**
  116514. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116515. * @param mesh mesh to test
  116516. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116517. */
  116518. hasMesh(mesh: AbstractMesh): boolean;
  116519. /**
  116520. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116521. * @param mesh The mesh to highlight
  116522. * @param color The color of the highlight
  116523. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116524. */
  116525. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116526. /**
  116527. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116528. * @param mesh The mesh to highlight
  116529. */
  116530. removeMesh(mesh: Mesh): void;
  116531. /**
  116532. * Force the stencil to the normal expected value for none glowing parts
  116533. */
  116534. private _defaultStencilReference;
  116535. /**
  116536. * Free any resources and references associated to a mesh.
  116537. * Internal use
  116538. * @param mesh The mesh to free.
  116539. * @hidden
  116540. */
  116541. _disposeMesh(mesh: Mesh): void;
  116542. /**
  116543. * Dispose the highlight layer and free resources.
  116544. */
  116545. dispose(): void;
  116546. /**
  116547. * Gets the class name of the effect layer
  116548. * @returns the string with the class name of the effect layer
  116549. */
  116550. getClassName(): string;
  116551. /**
  116552. * Serializes this Highlight layer
  116553. * @returns a serialized Highlight layer object
  116554. */
  116555. serialize(): any;
  116556. /**
  116557. * Creates a Highlight layer from parsed Highlight layer data
  116558. * @param parsedHightlightLayer defines the Highlight layer data
  116559. * @param scene defines the current scene
  116560. * @param rootUrl defines the root URL containing the Highlight layer information
  116561. * @returns a parsed Highlight layer
  116562. */
  116563. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116564. }
  116565. }
  116566. declare module BABYLON {
  116567. interface AbstractScene {
  116568. /**
  116569. * The list of layers (background and foreground) of the scene
  116570. */
  116571. layers: Array<Layer>;
  116572. }
  116573. /**
  116574. * Defines the layer scene component responsible to manage any layers
  116575. * in a given scene.
  116576. */
  116577. export class LayerSceneComponent implements ISceneComponent {
  116578. /**
  116579. * The component name helpfull to identify the component in the list of scene components.
  116580. */
  116581. readonly name: string;
  116582. /**
  116583. * The scene the component belongs to.
  116584. */
  116585. scene: Scene;
  116586. private _engine;
  116587. /**
  116588. * Creates a new instance of the component for the given scene
  116589. * @param scene Defines the scene to register the component in
  116590. */
  116591. constructor(scene: Scene);
  116592. /**
  116593. * Registers the component in a given scene
  116594. */
  116595. register(): void;
  116596. /**
  116597. * Rebuilds the elements related to this component in case of
  116598. * context lost for instance.
  116599. */
  116600. rebuild(): void;
  116601. /**
  116602. * Disposes the component and the associated ressources.
  116603. */
  116604. dispose(): void;
  116605. private _draw;
  116606. private _drawCameraPredicate;
  116607. private _drawCameraBackground;
  116608. private _drawCameraForeground;
  116609. private _drawRenderTargetPredicate;
  116610. private _drawRenderTargetBackground;
  116611. private _drawRenderTargetForeground;
  116612. /**
  116613. * Adds all the elements from the container to the scene
  116614. * @param container the container holding the elements
  116615. */
  116616. addFromContainer(container: AbstractScene): void;
  116617. /**
  116618. * Removes all the elements in the container from the scene
  116619. * @param container contains the elements to remove
  116620. * @param dispose if the removed element should be disposed (default: false)
  116621. */
  116622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116623. }
  116624. }
  116625. declare module BABYLON {
  116626. /** @hidden */
  116627. export var layerPixelShader: {
  116628. name: string;
  116629. shader: string;
  116630. };
  116631. }
  116632. declare module BABYLON {
  116633. /** @hidden */
  116634. export var layerVertexShader: {
  116635. name: string;
  116636. shader: string;
  116637. };
  116638. }
  116639. declare module BABYLON {
  116640. /**
  116641. * This represents a full screen 2d layer.
  116642. * This can be useful to display a picture in the background of your scene for instance.
  116643. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116644. */
  116645. export class Layer {
  116646. /**
  116647. * Define the name of the layer.
  116648. */
  116649. name: string;
  116650. /**
  116651. * Define the texture the layer should display.
  116652. */
  116653. texture: Nullable<Texture>;
  116654. /**
  116655. * Is the layer in background or foreground.
  116656. */
  116657. isBackground: boolean;
  116658. /**
  116659. * Define the color of the layer (instead of texture).
  116660. */
  116661. color: Color4;
  116662. /**
  116663. * Define the scale of the layer in order to zoom in out of the texture.
  116664. */
  116665. scale: Vector2;
  116666. /**
  116667. * Define an offset for the layer in order to shift the texture.
  116668. */
  116669. offset: Vector2;
  116670. /**
  116671. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116672. */
  116673. alphaBlendingMode: number;
  116674. /**
  116675. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116676. * Alpha test will not mix with the background color in case of transparency.
  116677. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116678. */
  116679. alphaTest: boolean;
  116680. /**
  116681. * Define a mask to restrict the layer to only some of the scene cameras.
  116682. */
  116683. layerMask: number;
  116684. /**
  116685. * Define the list of render target the layer is visible into.
  116686. */
  116687. renderTargetTextures: RenderTargetTexture[];
  116688. /**
  116689. * Define if the layer is only used in renderTarget or if it also
  116690. * renders in the main frame buffer of the canvas.
  116691. */
  116692. renderOnlyInRenderTargetTextures: boolean;
  116693. private _scene;
  116694. private _vertexBuffers;
  116695. private _indexBuffer;
  116696. private _effect;
  116697. private _alphaTestEffect;
  116698. /**
  116699. * An event triggered when the layer is disposed.
  116700. */
  116701. onDisposeObservable: Observable<Layer>;
  116702. private _onDisposeObserver;
  116703. /**
  116704. * Back compatibility with callback before the onDisposeObservable existed.
  116705. * The set callback will be triggered when the layer has been disposed.
  116706. */
  116707. onDispose: () => void;
  116708. /**
  116709. * An event triggered before rendering the scene
  116710. */
  116711. onBeforeRenderObservable: Observable<Layer>;
  116712. private _onBeforeRenderObserver;
  116713. /**
  116714. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116715. * The set callback will be triggered just before rendering the layer.
  116716. */
  116717. onBeforeRender: () => void;
  116718. /**
  116719. * An event triggered after rendering the scene
  116720. */
  116721. onAfterRenderObservable: Observable<Layer>;
  116722. private _onAfterRenderObserver;
  116723. /**
  116724. * Back compatibility with callback before the onAfterRenderObservable existed.
  116725. * The set callback will be triggered just after rendering the layer.
  116726. */
  116727. onAfterRender: () => void;
  116728. /**
  116729. * Instantiates a new layer.
  116730. * This represents a full screen 2d layer.
  116731. * This can be useful to display a picture in the background of your scene for instance.
  116732. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116733. * @param name Define the name of the layer in the scene
  116734. * @param imgUrl Define the url of the texture to display in the layer
  116735. * @param scene Define the scene the layer belongs to
  116736. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116737. * @param color Defines a color for the layer
  116738. */
  116739. constructor(
  116740. /**
  116741. * Define the name of the layer.
  116742. */
  116743. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116744. private _createIndexBuffer;
  116745. /** @hidden */
  116746. _rebuild(): void;
  116747. /**
  116748. * Renders the layer in the scene.
  116749. */
  116750. render(): void;
  116751. /**
  116752. * Disposes and releases the associated ressources.
  116753. */
  116754. dispose(): void;
  116755. }
  116756. }
  116757. declare module BABYLON {
  116758. /** @hidden */
  116759. export var lensFlarePixelShader: {
  116760. name: string;
  116761. shader: string;
  116762. };
  116763. }
  116764. declare module BABYLON {
  116765. /** @hidden */
  116766. export var lensFlareVertexShader: {
  116767. name: string;
  116768. shader: string;
  116769. };
  116770. }
  116771. declare module BABYLON {
  116772. /**
  116773. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116774. * It is usually composed of several `lensFlare`.
  116775. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116776. */
  116777. export class LensFlareSystem {
  116778. /**
  116779. * Define the name of the lens flare system
  116780. */
  116781. name: string;
  116782. /**
  116783. * List of lens flares used in this system.
  116784. */
  116785. lensFlares: LensFlare[];
  116786. /**
  116787. * Define a limit from the border the lens flare can be visible.
  116788. */
  116789. borderLimit: number;
  116790. /**
  116791. * Define a viewport border we do not want to see the lens flare in.
  116792. */
  116793. viewportBorder: number;
  116794. /**
  116795. * Define a predicate which could limit the list of meshes able to occlude the effect.
  116796. */
  116797. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  116798. /**
  116799. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  116800. */
  116801. layerMask: number;
  116802. /**
  116803. * Define the id of the lens flare system in the scene.
  116804. * (equal to name by default)
  116805. */
  116806. id: string;
  116807. private _scene;
  116808. private _emitter;
  116809. private _vertexBuffers;
  116810. private _indexBuffer;
  116811. private _effect;
  116812. private _positionX;
  116813. private _positionY;
  116814. private _isEnabled;
  116815. /** @hidden */
  116816. static _SceneComponentInitialization: (scene: Scene) => void;
  116817. /**
  116818. * Instantiates a lens flare system.
  116819. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116820. * It is usually composed of several `lensFlare`.
  116821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116822. * @param name Define the name of the lens flare system in the scene
  116823. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116824. * @param scene Define the scene the lens flare system belongs to
  116825. */
  116826. constructor(
  116827. /**
  116828. * Define the name of the lens flare system
  116829. */
  116830. name: string, emitter: any, scene: Scene);
  116831. /**
  116832. * Define if the lens flare system is enabled.
  116833. */
  116834. isEnabled: boolean;
  116835. /**
  116836. * Get the scene the effects belongs to.
  116837. * @returns the scene holding the lens flare system
  116838. */
  116839. getScene(): Scene;
  116840. /**
  116841. * Get the emitter of the lens flare system.
  116842. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116843. * @returns the emitter of the lens flare system
  116844. */
  116845. getEmitter(): any;
  116846. /**
  116847. * Set the emitter of the lens flare system.
  116848. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  116849. * @param newEmitter Define the new emitter of the system
  116850. */
  116851. setEmitter(newEmitter: any): void;
  116852. /**
  116853. * Get the lens flare system emitter position.
  116854. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  116855. * @returns the position
  116856. */
  116857. getEmitterPosition(): Vector3;
  116858. /**
  116859. * @hidden
  116860. */
  116861. computeEffectivePosition(globalViewport: Viewport): boolean;
  116862. /** @hidden */
  116863. _isVisible(): boolean;
  116864. /**
  116865. * @hidden
  116866. */
  116867. render(): boolean;
  116868. /**
  116869. * Dispose and release the lens flare with its associated resources.
  116870. */
  116871. dispose(): void;
  116872. /**
  116873. * Parse a lens flare system from a JSON repressentation
  116874. * @param parsedLensFlareSystem Define the JSON to parse
  116875. * @param scene Define the scene the parsed system should be instantiated in
  116876. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  116877. * @returns the parsed system
  116878. */
  116879. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  116880. /**
  116881. * Serialize the current Lens Flare System into a JSON representation.
  116882. * @returns the serialized JSON
  116883. */
  116884. serialize(): any;
  116885. }
  116886. }
  116887. declare module BABYLON {
  116888. /**
  116889. * This represents one of the lens effect in a `lensFlareSystem`.
  116890. * It controls one of the indiviual texture used in the effect.
  116891. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116892. */
  116893. export class LensFlare {
  116894. /**
  116895. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116896. */
  116897. size: number;
  116898. /**
  116899. * 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.
  116900. */
  116901. position: number;
  116902. /**
  116903. * Define the lens color.
  116904. */
  116905. color: Color3;
  116906. /**
  116907. * Define the lens texture.
  116908. */
  116909. texture: Nullable<Texture>;
  116910. /**
  116911. * Define the alpha mode to render this particular lens.
  116912. */
  116913. alphaMode: number;
  116914. private _system;
  116915. /**
  116916. * Creates a new Lens Flare.
  116917. * This represents one of the lens effect in a `lensFlareSystem`.
  116918. * It controls one of the indiviual texture used in the effect.
  116919. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116920. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  116921. * @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.
  116922. * @param color Define the lens color
  116923. * @param imgUrl Define the lens texture url
  116924. * @param system Define the `lensFlareSystem` this flare is part of
  116925. * @returns The newly created Lens Flare
  116926. */
  116927. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  116928. /**
  116929. * Instantiates a new Lens Flare.
  116930. * This represents one of the lens effect in a `lensFlareSystem`.
  116931. * It controls one of the indiviual texture used in the effect.
  116932. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116933. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  116934. * @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.
  116935. * @param color Define the lens color
  116936. * @param imgUrl Define the lens texture url
  116937. * @param system Define the `lensFlareSystem` this flare is part of
  116938. */
  116939. constructor(
  116940. /**
  116941. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  116942. */
  116943. size: number,
  116944. /**
  116945. * 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.
  116946. */
  116947. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  116948. /**
  116949. * Dispose and release the lens flare with its associated resources.
  116950. */
  116951. dispose(): void;
  116952. }
  116953. }
  116954. declare module BABYLON {
  116955. interface AbstractScene {
  116956. /**
  116957. * The list of lens flare system added to the scene
  116958. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116959. */
  116960. lensFlareSystems: Array<LensFlareSystem>;
  116961. /**
  116962. * Removes the given lens flare system from this scene.
  116963. * @param toRemove The lens flare system to remove
  116964. * @returns The index of the removed lens flare system
  116965. */
  116966. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  116967. /**
  116968. * Adds the given lens flare system to this scene
  116969. * @param newLensFlareSystem The lens flare system to add
  116970. */
  116971. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  116972. /**
  116973. * Gets a lens flare system using its name
  116974. * @param name defines the name to look for
  116975. * @returns the lens flare system or null if not found
  116976. */
  116977. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  116978. /**
  116979. * Gets a lens flare system using its id
  116980. * @param id defines the id to look for
  116981. * @returns the lens flare system or null if not found
  116982. */
  116983. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  116984. }
  116985. /**
  116986. * Defines the lens flare scene component responsible to manage any lens flares
  116987. * in a given scene.
  116988. */
  116989. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  116990. /**
  116991. * The component name helpfull to identify the component in the list of scene components.
  116992. */
  116993. readonly name: string;
  116994. /**
  116995. * The scene the component belongs to.
  116996. */
  116997. scene: Scene;
  116998. /**
  116999. * Creates a new instance of the component for the given scene
  117000. * @param scene Defines the scene to register the component in
  117001. */
  117002. constructor(scene: Scene);
  117003. /**
  117004. * Registers the component in a given scene
  117005. */
  117006. register(): void;
  117007. /**
  117008. * Rebuilds the elements related to this component in case of
  117009. * context lost for instance.
  117010. */
  117011. rebuild(): void;
  117012. /**
  117013. * Adds all the elements from the container to the scene
  117014. * @param container the container holding the elements
  117015. */
  117016. addFromContainer(container: AbstractScene): void;
  117017. /**
  117018. * Removes all the elements in the container from the scene
  117019. * @param container contains the elements to remove
  117020. * @param dispose if the removed element should be disposed (default: false)
  117021. */
  117022. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117023. /**
  117024. * Serializes the component data to the specified json object
  117025. * @param serializationObject The object to serialize to
  117026. */
  117027. serialize(serializationObject: any): void;
  117028. /**
  117029. * Disposes the component and the associated ressources.
  117030. */
  117031. dispose(): void;
  117032. private _draw;
  117033. }
  117034. }
  117035. declare module BABYLON {
  117036. /**
  117037. * Defines the shadow generator component responsible to manage any shadow generators
  117038. * in a given scene.
  117039. */
  117040. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117041. /**
  117042. * The component name helpfull to identify the component in the list of scene components.
  117043. */
  117044. readonly name: string;
  117045. /**
  117046. * The scene the component belongs to.
  117047. */
  117048. scene: Scene;
  117049. /**
  117050. * Creates a new instance of the component for the given scene
  117051. * @param scene Defines the scene to register the component in
  117052. */
  117053. constructor(scene: Scene);
  117054. /**
  117055. * Registers the component in a given scene
  117056. */
  117057. register(): void;
  117058. /**
  117059. * Rebuilds the elements related to this component in case of
  117060. * context lost for instance.
  117061. */
  117062. rebuild(): void;
  117063. /**
  117064. * Serializes the component data to the specified json object
  117065. * @param serializationObject The object to serialize to
  117066. */
  117067. serialize(serializationObject: any): void;
  117068. /**
  117069. * Adds all the elements from the container to the scene
  117070. * @param container the container holding the elements
  117071. */
  117072. addFromContainer(container: AbstractScene): void;
  117073. /**
  117074. * Removes all the elements in the container from the scene
  117075. * @param container contains the elements to remove
  117076. * @param dispose if the removed element should be disposed (default: false)
  117077. */
  117078. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117079. /**
  117080. * Rebuilds the elements related to this component in case of
  117081. * context lost for instance.
  117082. */
  117083. dispose(): void;
  117084. private _gatherRenderTargets;
  117085. }
  117086. }
  117087. declare module BABYLON {
  117088. /**
  117089. * A point light is a light defined by an unique point in world space.
  117090. * The light is emitted in every direction from this point.
  117091. * A good example of a point light is a standard light bulb.
  117092. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117093. */
  117094. export class PointLight extends ShadowLight {
  117095. private _shadowAngle;
  117096. /**
  117097. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117098. * This specifies what angle the shadow will use to be created.
  117099. *
  117100. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117101. */
  117102. /**
  117103. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117104. * This specifies what angle the shadow will use to be created.
  117105. *
  117106. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117107. */
  117108. shadowAngle: number;
  117109. /**
  117110. * Gets the direction if it has been set.
  117111. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117112. */
  117113. /**
  117114. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117115. */
  117116. direction: Vector3;
  117117. /**
  117118. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117119. * A PointLight emits the light in every direction.
  117120. * It can cast shadows.
  117121. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117122. * ```javascript
  117123. * var pointLight = new PointLight("pl", camera.position, scene);
  117124. * ```
  117125. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117126. * @param name The light friendly name
  117127. * @param position The position of the point light in the scene
  117128. * @param scene The scene the lights belongs to
  117129. */
  117130. constructor(name: string, position: Vector3, scene: Scene);
  117131. /**
  117132. * Returns the string "PointLight"
  117133. * @returns the class name
  117134. */
  117135. getClassName(): string;
  117136. /**
  117137. * Returns the integer 0.
  117138. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117139. */
  117140. getTypeID(): number;
  117141. /**
  117142. * Specifies wether or not the shadowmap should be a cube texture.
  117143. * @returns true if the shadowmap needs to be a cube texture.
  117144. */
  117145. needCube(): boolean;
  117146. /**
  117147. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117148. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117149. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117150. */
  117151. getShadowDirection(faceIndex?: number): Vector3;
  117152. /**
  117153. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117154. * - fov = PI / 2
  117155. * - aspect ratio : 1.0
  117156. * - z-near and far equal to the active camera minZ and maxZ.
  117157. * Returns the PointLight.
  117158. */
  117159. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117160. protected _buildUniformLayout(): void;
  117161. /**
  117162. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117163. * @param effect The effect to update
  117164. * @param lightIndex The index of the light in the effect to update
  117165. * @returns The point light
  117166. */
  117167. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117168. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117169. /**
  117170. * Prepares the list of defines specific to the light type.
  117171. * @param defines the list of defines
  117172. * @param lightIndex defines the index of the light for the effect
  117173. */
  117174. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117175. }
  117176. }
  117177. declare module BABYLON {
  117178. /**
  117179. * Header information of HDR texture files.
  117180. */
  117181. export interface HDRInfo {
  117182. /**
  117183. * The height of the texture in pixels.
  117184. */
  117185. height: number;
  117186. /**
  117187. * The width of the texture in pixels.
  117188. */
  117189. width: number;
  117190. /**
  117191. * The index of the beginning of the data in the binary file.
  117192. */
  117193. dataPosition: number;
  117194. }
  117195. /**
  117196. * This groups tools to convert HDR texture to native colors array.
  117197. */
  117198. export class HDRTools {
  117199. private static Ldexp;
  117200. private static Rgbe2float;
  117201. private static readStringLine;
  117202. /**
  117203. * Reads header information from an RGBE texture stored in a native array.
  117204. * More information on this format are available here:
  117205. * https://en.wikipedia.org/wiki/RGBE_image_format
  117206. *
  117207. * @param uint8array The binary file stored in native array.
  117208. * @return The header information.
  117209. */
  117210. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117211. /**
  117212. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117213. * This RGBE texture needs to store the information as a panorama.
  117214. *
  117215. * More information on this format are available here:
  117216. * https://en.wikipedia.org/wiki/RGBE_image_format
  117217. *
  117218. * @param buffer The binary file stored in an array buffer.
  117219. * @param size The expected size of the extracted cubemap.
  117220. * @return The Cube Map information.
  117221. */
  117222. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117223. /**
  117224. * Returns the pixels data extracted from an RGBE texture.
  117225. * This pixels will be stored left to right up to down in the R G B order in one array.
  117226. *
  117227. * More information on this format are available here:
  117228. * https://en.wikipedia.org/wiki/RGBE_image_format
  117229. *
  117230. * @param uint8array The binary file stored in an array buffer.
  117231. * @param hdrInfo The header information of the file.
  117232. * @return The pixels data in RGB right to left up to down order.
  117233. */
  117234. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117235. private static RGBE_ReadPixels_RLE;
  117236. }
  117237. }
  117238. declare module BABYLON {
  117239. /**
  117240. * This represents a texture coming from an HDR input.
  117241. *
  117242. * The only supported format is currently panorama picture stored in RGBE format.
  117243. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117244. */
  117245. export class HDRCubeTexture extends BaseTexture {
  117246. private static _facesMapping;
  117247. private _generateHarmonics;
  117248. private _noMipmap;
  117249. private _textureMatrix;
  117250. private _size;
  117251. private _onLoad;
  117252. private _onError;
  117253. /**
  117254. * The texture URL.
  117255. */
  117256. url: string;
  117257. /**
  117258. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117259. */
  117260. coordinatesMode: number;
  117261. protected _isBlocking: boolean;
  117262. /**
  117263. * Sets wether or not the texture is blocking during loading.
  117264. */
  117265. /**
  117266. * Gets wether or not the texture is blocking during loading.
  117267. */
  117268. isBlocking: boolean;
  117269. protected _rotationY: number;
  117270. /**
  117271. * Sets texture matrix rotation angle around Y axis in radians.
  117272. */
  117273. /**
  117274. * Gets texture matrix rotation angle around Y axis radians.
  117275. */
  117276. rotationY: number;
  117277. /**
  117278. * Gets or sets the center of the bounding box associated with the cube texture
  117279. * It must define where the camera used to render the texture was set
  117280. */
  117281. boundingBoxPosition: Vector3;
  117282. private _boundingBoxSize;
  117283. /**
  117284. * Gets or sets the size of the bounding box associated with the cube texture
  117285. * When defined, the cubemap will switch to local mode
  117286. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117287. * @example https://www.babylonjs-playground.com/#RNASML
  117288. */
  117289. boundingBoxSize: Vector3;
  117290. /**
  117291. * Instantiates an HDRTexture from the following parameters.
  117292. *
  117293. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117294. * @param scene The scene the texture will be used in
  117295. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117296. * @param noMipmap Forces to not generate the mipmap if true
  117297. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117298. * @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)
  117299. * @param reserved Reserved flag for internal use.
  117300. */
  117301. 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>);
  117302. /**
  117303. * Get the current class name of the texture useful for serialization or dynamic coding.
  117304. * @returns "HDRCubeTexture"
  117305. */
  117306. getClassName(): string;
  117307. /**
  117308. * Occurs when the file is raw .hdr file.
  117309. */
  117310. private loadTexture;
  117311. clone(): HDRCubeTexture;
  117312. delayLoad(): void;
  117313. /**
  117314. * Get the texture reflection matrix used to rotate/transform the reflection.
  117315. * @returns the reflection matrix
  117316. */
  117317. getReflectionTextureMatrix(): Matrix;
  117318. /**
  117319. * Set the texture reflection matrix used to rotate/transform the reflection.
  117320. * @param value Define the reflection matrix to set
  117321. */
  117322. setReflectionTextureMatrix(value: Matrix): void;
  117323. /**
  117324. * Parses a JSON representation of an HDR Texture in order to create the texture
  117325. * @param parsedTexture Define the JSON representation
  117326. * @param scene Define the scene the texture should be created in
  117327. * @param rootUrl Define the root url in case we need to load relative dependencies
  117328. * @returns the newly created texture after parsing
  117329. */
  117330. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117331. serialize(): any;
  117332. }
  117333. }
  117334. declare module BABYLON {
  117335. /**
  117336. * Class used to control physics engine
  117337. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117338. */
  117339. export class PhysicsEngine implements IPhysicsEngine {
  117340. private _physicsPlugin;
  117341. /**
  117342. * Global value used to control the smallest number supported by the simulation
  117343. */
  117344. static Epsilon: number;
  117345. private _impostors;
  117346. private _joints;
  117347. /**
  117348. * Gets the gravity vector used by the simulation
  117349. */
  117350. gravity: Vector3;
  117351. /**
  117352. * Factory used to create the default physics plugin.
  117353. * @returns The default physics plugin
  117354. */
  117355. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117356. /**
  117357. * Creates a new Physics Engine
  117358. * @param gravity defines the gravity vector used by the simulation
  117359. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117360. */
  117361. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117362. /**
  117363. * Sets the gravity vector used by the simulation
  117364. * @param gravity defines the gravity vector to use
  117365. */
  117366. setGravity(gravity: Vector3): void;
  117367. /**
  117368. * Set the time step of the physics engine.
  117369. * Default is 1/60.
  117370. * To slow it down, enter 1/600 for example.
  117371. * To speed it up, 1/30
  117372. * @param newTimeStep defines the new timestep to apply to this world.
  117373. */
  117374. setTimeStep(newTimeStep?: number): void;
  117375. /**
  117376. * Get the time step of the physics engine.
  117377. * @returns the current time step
  117378. */
  117379. getTimeStep(): number;
  117380. /**
  117381. * Release all resources
  117382. */
  117383. dispose(): void;
  117384. /**
  117385. * Gets the name of the current physics plugin
  117386. * @returns the name of the plugin
  117387. */
  117388. getPhysicsPluginName(): string;
  117389. /**
  117390. * Adding a new impostor for the impostor tracking.
  117391. * This will be done by the impostor itself.
  117392. * @param impostor the impostor to add
  117393. */
  117394. addImpostor(impostor: PhysicsImpostor): void;
  117395. /**
  117396. * Remove an impostor from the engine.
  117397. * This impostor and its mesh will not longer be updated by the physics engine.
  117398. * @param impostor the impostor to remove
  117399. */
  117400. removeImpostor(impostor: PhysicsImpostor): void;
  117401. /**
  117402. * Add a joint to the physics engine
  117403. * @param mainImpostor defines the main impostor to which the joint is added.
  117404. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117405. * @param joint defines the joint that will connect both impostors.
  117406. */
  117407. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117408. /**
  117409. * Removes a joint from the simulation
  117410. * @param mainImpostor defines the impostor used with the joint
  117411. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117412. * @param joint defines the joint to remove
  117413. */
  117414. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117415. /**
  117416. * Called by the scene. No need to call it.
  117417. * @param delta defines the timespam between frames
  117418. */
  117419. _step(delta: number): void;
  117420. /**
  117421. * Gets the current plugin used to run the simulation
  117422. * @returns current plugin
  117423. */
  117424. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117425. /**
  117426. * Gets the list of physic impostors
  117427. * @returns an array of PhysicsImpostor
  117428. */
  117429. getImpostors(): Array<PhysicsImpostor>;
  117430. /**
  117431. * Gets the impostor for a physics enabled object
  117432. * @param object defines the object impersonated by the impostor
  117433. * @returns the PhysicsImpostor or null if not found
  117434. */
  117435. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117436. /**
  117437. * Gets the impostor for a physics body object
  117438. * @param body defines physics body used by the impostor
  117439. * @returns the PhysicsImpostor or null if not found
  117440. */
  117441. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117442. /**
  117443. * Does a raycast in the physics world
  117444. * @param from when should the ray start?
  117445. * @param to when should the ray end?
  117446. * @returns PhysicsRaycastResult
  117447. */
  117448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117449. }
  117450. }
  117451. declare module BABYLON {
  117452. /** @hidden */
  117453. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117454. private _useDeltaForWorldStep;
  117455. world: any;
  117456. name: string;
  117457. private _physicsMaterials;
  117458. private _fixedTimeStep;
  117459. private _cannonRaycastResult;
  117460. private _raycastResult;
  117461. private _physicsBodysToRemoveAfterStep;
  117462. BJSCANNON: any;
  117463. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117464. setGravity(gravity: Vector3): void;
  117465. setTimeStep(timeStep: number): void;
  117466. getTimeStep(): number;
  117467. executeStep(delta: number): void;
  117468. private _removeMarkedPhysicsBodiesFromWorld;
  117469. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117470. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117471. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117472. private _processChildMeshes;
  117473. removePhysicsBody(impostor: PhysicsImpostor): void;
  117474. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117475. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117476. private _addMaterial;
  117477. private _checkWithEpsilon;
  117478. private _createShape;
  117479. private _createHeightmap;
  117480. private _minus90X;
  117481. private _plus90X;
  117482. private _tmpPosition;
  117483. private _tmpDeltaPosition;
  117484. private _tmpUnityRotation;
  117485. private _updatePhysicsBodyTransformation;
  117486. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117487. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117488. isSupported(): boolean;
  117489. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117490. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117491. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117492. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117493. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117494. getBodyMass(impostor: PhysicsImpostor): number;
  117495. getBodyFriction(impostor: PhysicsImpostor): number;
  117496. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117497. getBodyRestitution(impostor: PhysicsImpostor): number;
  117498. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117499. sleepBody(impostor: PhysicsImpostor): void;
  117500. wakeUpBody(impostor: PhysicsImpostor): void;
  117501. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117502. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117503. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117505. getRadius(impostor: PhysicsImpostor): number;
  117506. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117507. dispose(): void;
  117508. private _extendNamespace;
  117509. /**
  117510. * Does a raycast in the physics world
  117511. * @param from when should the ray start?
  117512. * @param to when should the ray end?
  117513. * @returns PhysicsRaycastResult
  117514. */
  117515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117516. }
  117517. }
  117518. declare module BABYLON {
  117519. /** @hidden */
  117520. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117521. world: any;
  117522. name: string;
  117523. BJSOIMO: any;
  117524. private _raycastResult;
  117525. constructor(iterations?: number, oimoInjection?: any);
  117526. setGravity(gravity: Vector3): void;
  117527. setTimeStep(timeStep: number): void;
  117528. getTimeStep(): number;
  117529. private _tmpImpostorsArray;
  117530. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117534. private _tmpPositionVector;
  117535. removePhysicsBody(impostor: PhysicsImpostor): void;
  117536. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117537. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117538. isSupported(): boolean;
  117539. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117540. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117541. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117542. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117544. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117546. getBodyMass(impostor: PhysicsImpostor): number;
  117547. getBodyFriction(impostor: PhysicsImpostor): number;
  117548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117549. getBodyRestitution(impostor: PhysicsImpostor): number;
  117550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117551. sleepBody(impostor: PhysicsImpostor): void;
  117552. wakeUpBody(impostor: PhysicsImpostor): void;
  117553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117554. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117557. getRadius(impostor: PhysicsImpostor): number;
  117558. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117559. dispose(): void;
  117560. /**
  117561. * Does a raycast in the physics world
  117562. * @param from when should the ray start?
  117563. * @param to when should the ray end?
  117564. * @returns PhysicsRaycastResult
  117565. */
  117566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117567. }
  117568. }
  117569. declare module BABYLON {
  117570. /**
  117571. * Class containing static functions to help procedurally build meshes
  117572. */
  117573. export class RibbonBuilder {
  117574. /**
  117575. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117576. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117577. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117578. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117579. * * 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
  117580. * * 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
  117581. * * 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
  117582. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117583. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117584. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117585. * * 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
  117586. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117587. * * 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
  117588. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117590. * @param name defines the name of the mesh
  117591. * @param options defines the options used to create the mesh
  117592. * @param scene defines the hosting scene
  117593. * @returns the ribbon mesh
  117594. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117595. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117596. */
  117597. static CreateRibbon(name: string, options: {
  117598. pathArray: Vector3[][];
  117599. closeArray?: boolean;
  117600. closePath?: boolean;
  117601. offset?: number;
  117602. updatable?: boolean;
  117603. sideOrientation?: number;
  117604. frontUVs?: Vector4;
  117605. backUVs?: Vector4;
  117606. instance?: Mesh;
  117607. invertUV?: boolean;
  117608. uvs?: Vector2[];
  117609. colors?: Color4[];
  117610. }, scene?: Nullable<Scene>): Mesh;
  117611. }
  117612. }
  117613. declare module BABYLON {
  117614. /**
  117615. * Class containing static functions to help procedurally build meshes
  117616. */
  117617. export class ShapeBuilder {
  117618. /**
  117619. * 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.
  117620. * * 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.
  117621. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117622. * * 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.
  117623. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117624. * * 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
  117625. * * 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
  117626. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117627. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117629. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117631. * @param name defines the name of the mesh
  117632. * @param options defines the options used to create the mesh
  117633. * @param scene defines the hosting scene
  117634. * @returns the extruded shape mesh
  117635. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117637. */
  117638. static ExtrudeShape(name: string, options: {
  117639. shape: Vector3[];
  117640. path: Vector3[];
  117641. scale?: number;
  117642. rotation?: number;
  117643. cap?: number;
  117644. updatable?: boolean;
  117645. sideOrientation?: number;
  117646. frontUVs?: Vector4;
  117647. backUVs?: Vector4;
  117648. instance?: Mesh;
  117649. invertUV?: boolean;
  117650. }, scene?: Nullable<Scene>): Mesh;
  117651. /**
  117652. * Creates an custom extruded shape mesh.
  117653. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117654. * * 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.
  117655. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117656. * * 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
  117657. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117658. * * 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
  117659. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117660. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117661. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117662. * * 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
  117663. * * 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
  117664. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117669. * @param name defines the name of the mesh
  117670. * @param options defines the options used to create the mesh
  117671. * @param scene defines the hosting scene
  117672. * @returns the custom extruded shape mesh
  117673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117674. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117675. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117676. */
  117677. static ExtrudeShapeCustom(name: string, options: {
  117678. shape: Vector3[];
  117679. path: Vector3[];
  117680. scaleFunction?: any;
  117681. rotationFunction?: any;
  117682. ribbonCloseArray?: boolean;
  117683. ribbonClosePath?: boolean;
  117684. cap?: number;
  117685. updatable?: boolean;
  117686. sideOrientation?: number;
  117687. frontUVs?: Vector4;
  117688. backUVs?: Vector4;
  117689. instance?: Mesh;
  117690. invertUV?: boolean;
  117691. }, scene?: Nullable<Scene>): Mesh;
  117692. private static _ExtrudeShapeGeneric;
  117693. }
  117694. }
  117695. declare module BABYLON {
  117696. /**
  117697. * AmmoJS Physics plugin
  117698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117699. * @see https://github.com/kripken/ammo.js/
  117700. */
  117701. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117702. private _useDeltaForWorldStep;
  117703. /**
  117704. * Reference to the Ammo library
  117705. */
  117706. bjsAMMO: any;
  117707. /**
  117708. * Created ammoJS world which physics bodies are added to
  117709. */
  117710. world: any;
  117711. /**
  117712. * Name of the plugin
  117713. */
  117714. name: string;
  117715. private _timeStep;
  117716. private _fixedTimeStep;
  117717. private _maxSteps;
  117718. private _tmpQuaternion;
  117719. private _tmpAmmoTransform;
  117720. private _tmpAmmoQuaternion;
  117721. private _tmpAmmoConcreteContactResultCallback;
  117722. private _collisionConfiguration;
  117723. private _dispatcher;
  117724. private _overlappingPairCache;
  117725. private _solver;
  117726. private _softBodySolver;
  117727. private _tmpAmmoVectorA;
  117728. private _tmpAmmoVectorB;
  117729. private _tmpAmmoVectorC;
  117730. private _tmpAmmoVectorD;
  117731. private _tmpContactCallbackResult;
  117732. private _tmpAmmoVectorRCA;
  117733. private _tmpAmmoVectorRCB;
  117734. private _raycastResult;
  117735. private static readonly DISABLE_COLLISION_FLAG;
  117736. private static readonly KINEMATIC_FLAG;
  117737. private static readonly DISABLE_DEACTIVATION_FLAG;
  117738. /**
  117739. * Initializes the ammoJS plugin
  117740. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117741. * @param ammoInjection can be used to inject your own ammo reference
  117742. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117743. */
  117744. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117745. /**
  117746. * Sets the gravity of the physics world (m/(s^2))
  117747. * @param gravity Gravity to set
  117748. */
  117749. setGravity(gravity: Vector3): void;
  117750. /**
  117751. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117752. * @param timeStep timestep to use in seconds
  117753. */
  117754. setTimeStep(timeStep: number): void;
  117755. /**
  117756. * 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)
  117757. * @param fixedTimeStep fixedTimeStep to use in seconds
  117758. */
  117759. setFixedTimeStep(fixedTimeStep: number): void;
  117760. /**
  117761. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117762. * @param maxSteps the maximum number of steps by the physics engine per frame
  117763. */
  117764. setMaxSteps(maxSteps: number): void;
  117765. /**
  117766. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117767. * @returns the current timestep in seconds
  117768. */
  117769. getTimeStep(): number;
  117770. private _isImpostorInContact;
  117771. private _isImpostorPairInContact;
  117772. private _stepSimulation;
  117773. /**
  117774. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117775. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117776. * After the step the babylon meshes are set to the position of the physics imposters
  117777. * @param delta amount of time to step forward
  117778. * @param impostors array of imposters to update before/after the step
  117779. */
  117780. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117781. /**
  117782. * Update babylon mesh to match physics world object
  117783. * @param impostor imposter to match
  117784. */
  117785. private _afterSoftStep;
  117786. /**
  117787. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117788. * @param impostor imposter to match
  117789. */
  117790. private _ropeStep;
  117791. /**
  117792. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117793. * @param impostor imposter to match
  117794. */
  117795. private _softbodyOrClothStep;
  117796. private _tmpVector;
  117797. private _tmpMatrix;
  117798. /**
  117799. * Applies an impulse on the imposter
  117800. * @param impostor imposter to apply impulse to
  117801. * @param force amount of force to be applied to the imposter
  117802. * @param contactPoint the location to apply the impulse on the imposter
  117803. */
  117804. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117805. /**
  117806. * Applies a force on the imposter
  117807. * @param impostor imposter to apply force
  117808. * @param force amount of force to be applied to the imposter
  117809. * @param contactPoint the location to apply the force on the imposter
  117810. */
  117811. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117812. /**
  117813. * Creates a physics body using the plugin
  117814. * @param impostor the imposter to create the physics body on
  117815. */
  117816. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117817. /**
  117818. * Removes the physics body from the imposter and disposes of the body's memory
  117819. * @param impostor imposter to remove the physics body from
  117820. */
  117821. removePhysicsBody(impostor: PhysicsImpostor): void;
  117822. /**
  117823. * Generates a joint
  117824. * @param impostorJoint the imposter joint to create the joint with
  117825. */
  117826. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117827. /**
  117828. * Removes a joint
  117829. * @param impostorJoint the imposter joint to remove the joint from
  117830. */
  117831. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117832. private _addMeshVerts;
  117833. /**
  117834. * Initialise the soft body vertices to match its object's (mesh) vertices
  117835. * Softbody vertices (nodes) are in world space and to match this
  117836. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117837. * @param impostor to create the softbody for
  117838. */
  117839. private _softVertexData;
  117840. /**
  117841. * Create an impostor's soft body
  117842. * @param impostor to create the softbody for
  117843. */
  117844. private _createSoftbody;
  117845. /**
  117846. * Create cloth for an impostor
  117847. * @param impostor to create the softbody for
  117848. */
  117849. private _createCloth;
  117850. /**
  117851. * Create rope for an impostor
  117852. * @param impostor to create the softbody for
  117853. */
  117854. private _createRope;
  117855. private _addHullVerts;
  117856. private _createShape;
  117857. /**
  117858. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  117859. * @param impostor imposter containing the physics body and babylon object
  117860. */
  117861. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117862. /**
  117863. * Sets the babylon object's position/rotation from the physics body's position/rotation
  117864. * @param impostor imposter containing the physics body and babylon object
  117865. * @param newPosition new position
  117866. * @param newRotation new rotation
  117867. */
  117868. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117869. /**
  117870. * If this plugin is supported
  117871. * @returns true if its supported
  117872. */
  117873. isSupported(): boolean;
  117874. /**
  117875. * Sets the linear velocity of the physics body
  117876. * @param impostor imposter to set the velocity on
  117877. * @param velocity velocity to set
  117878. */
  117879. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117880. /**
  117881. * Sets the angular velocity of the physics body
  117882. * @param impostor imposter to set the velocity on
  117883. * @param velocity velocity to set
  117884. */
  117885. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117886. /**
  117887. * gets the linear velocity
  117888. * @param impostor imposter to get linear velocity from
  117889. * @returns linear velocity
  117890. */
  117891. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117892. /**
  117893. * gets the angular velocity
  117894. * @param impostor imposter to get angular velocity from
  117895. * @returns angular velocity
  117896. */
  117897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117898. /**
  117899. * Sets the mass of physics body
  117900. * @param impostor imposter to set the mass on
  117901. * @param mass mass to set
  117902. */
  117903. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117904. /**
  117905. * Gets the mass of the physics body
  117906. * @param impostor imposter to get the mass from
  117907. * @returns mass
  117908. */
  117909. getBodyMass(impostor: PhysicsImpostor): number;
  117910. /**
  117911. * Gets friction of the impostor
  117912. * @param impostor impostor to get friction from
  117913. * @returns friction value
  117914. */
  117915. getBodyFriction(impostor: PhysicsImpostor): number;
  117916. /**
  117917. * Sets friction of the impostor
  117918. * @param impostor impostor to set friction on
  117919. * @param friction friction value
  117920. */
  117921. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117922. /**
  117923. * Gets restitution of the impostor
  117924. * @param impostor impostor to get restitution from
  117925. * @returns restitution value
  117926. */
  117927. getBodyRestitution(impostor: PhysicsImpostor): number;
  117928. /**
  117929. * Sets resitution of the impostor
  117930. * @param impostor impostor to set resitution on
  117931. * @param restitution resitution value
  117932. */
  117933. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117934. /**
  117935. * Gets pressure inside the impostor
  117936. * @param impostor impostor to get pressure from
  117937. * @returns pressure value
  117938. */
  117939. getBodyPressure(impostor: PhysicsImpostor): number;
  117940. /**
  117941. * Sets pressure inside a soft body impostor
  117942. * Cloth and rope must remain 0 pressure
  117943. * @param impostor impostor to set pressure on
  117944. * @param pressure pressure value
  117945. */
  117946. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  117947. /**
  117948. * Gets stiffness of the impostor
  117949. * @param impostor impostor to get stiffness from
  117950. * @returns pressure value
  117951. */
  117952. getBodyStiffness(impostor: PhysicsImpostor): number;
  117953. /**
  117954. * Sets stiffness of the impostor
  117955. * @param impostor impostor to set stiffness on
  117956. * @param stiffness stiffness value from 0 to 1
  117957. */
  117958. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  117959. /**
  117960. * Gets velocityIterations of the impostor
  117961. * @param impostor impostor to get velocity iterations from
  117962. * @returns velocityIterations value
  117963. */
  117964. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  117965. /**
  117966. * Sets velocityIterations of the impostor
  117967. * @param impostor impostor to set velocity iterations on
  117968. * @param velocityIterations velocityIterations value
  117969. */
  117970. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  117971. /**
  117972. * Gets positionIterations of the impostor
  117973. * @param impostor impostor to get position iterations from
  117974. * @returns positionIterations value
  117975. */
  117976. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  117977. /**
  117978. * Sets positionIterations of the impostor
  117979. * @param impostor impostor to set position on
  117980. * @param positionIterations positionIterations value
  117981. */
  117982. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  117983. /**
  117984. * Append an anchor to a cloth object
  117985. * @param impostor is the cloth impostor to add anchor to
  117986. * @param otherImpostor is the rigid impostor to anchor to
  117987. * @param width ratio across width from 0 to 1
  117988. * @param height ratio up height from 0 to 1
  117989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  117990. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  117991. */
  117992. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  117993. /**
  117994. * Append an hook to a rope object
  117995. * @param impostor is the rope impostor to add hook to
  117996. * @param otherImpostor is the rigid impostor to hook to
  117997. * @param length ratio along the rope from 0 to 1
  117998. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  117999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118000. */
  118001. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118002. /**
  118003. * Sleeps the physics body and stops it from being active
  118004. * @param impostor impostor to sleep
  118005. */
  118006. sleepBody(impostor: PhysicsImpostor): void;
  118007. /**
  118008. * Activates the physics body
  118009. * @param impostor impostor to activate
  118010. */
  118011. wakeUpBody(impostor: PhysicsImpostor): void;
  118012. /**
  118013. * Updates the distance parameters of the joint
  118014. * @param joint joint to update
  118015. * @param maxDistance maximum distance of the joint
  118016. * @param minDistance minimum distance of the joint
  118017. */
  118018. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118019. /**
  118020. * Sets a motor on the joint
  118021. * @param joint joint to set motor on
  118022. * @param speed speed of the motor
  118023. * @param maxForce maximum force of the motor
  118024. * @param motorIndex index of the motor
  118025. */
  118026. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118027. /**
  118028. * Sets the motors limit
  118029. * @param joint joint to set limit on
  118030. * @param upperLimit upper limit
  118031. * @param lowerLimit lower limit
  118032. */
  118033. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118034. /**
  118035. * Syncs the position and rotation of a mesh with the impostor
  118036. * @param mesh mesh to sync
  118037. * @param impostor impostor to update the mesh with
  118038. */
  118039. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118040. /**
  118041. * Gets the radius of the impostor
  118042. * @param impostor impostor to get radius from
  118043. * @returns the radius
  118044. */
  118045. getRadius(impostor: PhysicsImpostor): number;
  118046. /**
  118047. * Gets the box size of the impostor
  118048. * @param impostor impostor to get box size from
  118049. * @param result the resulting box size
  118050. */
  118051. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118052. /**
  118053. * Disposes of the impostor
  118054. */
  118055. dispose(): void;
  118056. /**
  118057. * Does a raycast in the physics world
  118058. * @param from when should the ray start?
  118059. * @param to when should the ray end?
  118060. * @returns PhysicsRaycastResult
  118061. */
  118062. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118063. }
  118064. }
  118065. declare module BABYLON {
  118066. interface AbstractScene {
  118067. /**
  118068. * The list of reflection probes added to the scene
  118069. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118070. */
  118071. reflectionProbes: Array<ReflectionProbe>;
  118072. /**
  118073. * Removes the given reflection probe from this scene.
  118074. * @param toRemove The reflection probe to remove
  118075. * @returns The index of the removed reflection probe
  118076. */
  118077. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118078. /**
  118079. * Adds the given reflection probe to this scene.
  118080. * @param newReflectionProbe The reflection probe to add
  118081. */
  118082. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118083. }
  118084. /**
  118085. * Class used to generate realtime reflection / refraction cube textures
  118086. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118087. */
  118088. export class ReflectionProbe {
  118089. /** defines the name of the probe */
  118090. name: string;
  118091. private _scene;
  118092. private _renderTargetTexture;
  118093. private _projectionMatrix;
  118094. private _viewMatrix;
  118095. private _target;
  118096. private _add;
  118097. private _attachedMesh;
  118098. private _invertYAxis;
  118099. /** Gets or sets probe position (center of the cube map) */
  118100. position: Vector3;
  118101. /**
  118102. * Creates a new reflection probe
  118103. * @param name defines the name of the probe
  118104. * @param size defines the texture resolution (for each face)
  118105. * @param scene defines the hosting scene
  118106. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118107. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118108. */
  118109. constructor(
  118110. /** defines the name of the probe */
  118111. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118112. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118113. samples: number;
  118114. /** Gets or sets the refresh rate to use (on every frame by default) */
  118115. refreshRate: number;
  118116. /**
  118117. * Gets the hosting scene
  118118. * @returns a Scene
  118119. */
  118120. getScene(): Scene;
  118121. /** Gets the internal CubeTexture used to render to */
  118122. readonly cubeTexture: RenderTargetTexture;
  118123. /** Gets the list of meshes to render */
  118124. readonly renderList: Nullable<AbstractMesh[]>;
  118125. /**
  118126. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118127. * @param mesh defines the mesh to attach to
  118128. */
  118129. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118130. /**
  118131. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118132. * @param renderingGroupId The rendering group id corresponding to its index
  118133. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118134. */
  118135. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118136. /**
  118137. * Clean all associated resources
  118138. */
  118139. dispose(): void;
  118140. /**
  118141. * Converts the reflection probe information to a readable string for debug purpose.
  118142. * @param fullDetails Supports for multiple levels of logging within scene loading
  118143. * @returns the human readable reflection probe info
  118144. */
  118145. toString(fullDetails?: boolean): string;
  118146. /**
  118147. * Get the class name of the relfection probe.
  118148. * @returns "ReflectionProbe"
  118149. */
  118150. getClassName(): string;
  118151. /**
  118152. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118153. * @returns The JSON representation of the texture
  118154. */
  118155. serialize(): any;
  118156. /**
  118157. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118158. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118159. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118160. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118161. * @returns The parsed reflection probe if successful
  118162. */
  118163. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118164. }
  118165. }
  118166. declare module BABYLON {
  118167. /** @hidden */
  118168. export var _BabylonLoaderRegistered: boolean;
  118169. }
  118170. declare module BABYLON {
  118171. /**
  118172. * The Physically based simple base material of BJS.
  118173. *
  118174. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118175. * It is used as the base class for both the specGloss and metalRough conventions.
  118176. */
  118177. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118178. /**
  118179. * Number of Simultaneous lights allowed on the material.
  118180. */
  118181. maxSimultaneousLights: number;
  118182. /**
  118183. * If sets to true, disables all the lights affecting the material.
  118184. */
  118185. disableLighting: boolean;
  118186. /**
  118187. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118188. */
  118189. environmentTexture: BaseTexture;
  118190. /**
  118191. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118192. */
  118193. invertNormalMapX: boolean;
  118194. /**
  118195. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118196. */
  118197. invertNormalMapY: boolean;
  118198. /**
  118199. * Normal map used in the model.
  118200. */
  118201. normalTexture: BaseTexture;
  118202. /**
  118203. * Emissivie color used to self-illuminate the model.
  118204. */
  118205. emissiveColor: Color3;
  118206. /**
  118207. * Emissivie texture used to self-illuminate the model.
  118208. */
  118209. emissiveTexture: BaseTexture;
  118210. /**
  118211. * Occlusion Channel Strenght.
  118212. */
  118213. occlusionStrength: number;
  118214. /**
  118215. * Occlusion Texture of the material (adding extra occlusion effects).
  118216. */
  118217. occlusionTexture: BaseTexture;
  118218. /**
  118219. * Defines the alpha limits in alpha test mode.
  118220. */
  118221. alphaCutOff: number;
  118222. /**
  118223. * Gets the current double sided mode.
  118224. */
  118225. /**
  118226. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118227. */
  118228. doubleSided: boolean;
  118229. /**
  118230. * Stores the pre-calculated light information of a mesh in a texture.
  118231. */
  118232. lightmapTexture: BaseTexture;
  118233. /**
  118234. * If true, the light map contains occlusion information instead of lighting info.
  118235. */
  118236. useLightmapAsShadowmap: boolean;
  118237. /**
  118238. * Instantiates a new PBRMaterial instance.
  118239. *
  118240. * @param name The material name
  118241. * @param scene The scene the material will be use in.
  118242. */
  118243. constructor(name: string, scene: Scene);
  118244. getClassName(): string;
  118245. }
  118246. }
  118247. declare module BABYLON {
  118248. /**
  118249. * The PBR material of BJS following the metal roughness convention.
  118250. *
  118251. * This fits to the PBR convention in the GLTF definition:
  118252. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118253. */
  118254. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118255. /**
  118256. * The base color has two different interpretations depending on the value of metalness.
  118257. * When the material is a metal, the base color is the specific measured reflectance value
  118258. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118259. * of the material.
  118260. */
  118261. baseColor: Color3;
  118262. /**
  118263. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118264. * well as opacity information in the alpha channel.
  118265. */
  118266. baseTexture: BaseTexture;
  118267. /**
  118268. * Specifies the metallic scalar value of the material.
  118269. * Can also be used to scale the metalness values of the metallic texture.
  118270. */
  118271. metallic: number;
  118272. /**
  118273. * Specifies the roughness scalar value of the material.
  118274. * Can also be used to scale the roughness values of the metallic texture.
  118275. */
  118276. roughness: number;
  118277. /**
  118278. * Texture containing both the metallic value in the B channel and the
  118279. * roughness value in the G channel to keep better precision.
  118280. */
  118281. metallicRoughnessTexture: BaseTexture;
  118282. /**
  118283. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118284. *
  118285. * @param name The material name
  118286. * @param scene The scene the material will be use in.
  118287. */
  118288. constructor(name: string, scene: Scene);
  118289. /**
  118290. * Return the currrent class name of the material.
  118291. */
  118292. getClassName(): string;
  118293. /**
  118294. * Makes a duplicate of the current material.
  118295. * @param name - name to use for the new material.
  118296. */
  118297. clone(name: string): PBRMetallicRoughnessMaterial;
  118298. /**
  118299. * Serialize the material to a parsable JSON object.
  118300. */
  118301. serialize(): any;
  118302. /**
  118303. * Parses a JSON object correponding to the serialize function.
  118304. */
  118305. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118306. }
  118307. }
  118308. declare module BABYLON {
  118309. /**
  118310. * The PBR material of BJS following the specular glossiness convention.
  118311. *
  118312. * This fits to the PBR convention in the GLTF definition:
  118313. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118314. */
  118315. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118316. /**
  118317. * Specifies the diffuse color of the material.
  118318. */
  118319. diffuseColor: Color3;
  118320. /**
  118321. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118322. * channel.
  118323. */
  118324. diffuseTexture: BaseTexture;
  118325. /**
  118326. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118327. */
  118328. specularColor: Color3;
  118329. /**
  118330. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118331. */
  118332. glossiness: number;
  118333. /**
  118334. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118335. */
  118336. specularGlossinessTexture: BaseTexture;
  118337. /**
  118338. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118339. *
  118340. * @param name The material name
  118341. * @param scene The scene the material will be use in.
  118342. */
  118343. constructor(name: string, scene: Scene);
  118344. /**
  118345. * Return the currrent class name of the material.
  118346. */
  118347. getClassName(): string;
  118348. /**
  118349. * Makes a duplicate of the current material.
  118350. * @param name - name to use for the new material.
  118351. */
  118352. clone(name: string): PBRSpecularGlossinessMaterial;
  118353. /**
  118354. * Serialize the material to a parsable JSON object.
  118355. */
  118356. serialize(): any;
  118357. /**
  118358. * Parses a JSON object correponding to the serialize function.
  118359. */
  118360. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118361. }
  118362. }
  118363. declare module BABYLON {
  118364. /**
  118365. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118366. * It can help converting any input color in a desired output one. This can then be used to create effects
  118367. * from sepia, black and white to sixties or futuristic rendering...
  118368. *
  118369. * The only supported format is currently 3dl.
  118370. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118371. */
  118372. export class ColorGradingTexture extends BaseTexture {
  118373. /**
  118374. * The current texture matrix. (will always be identity in color grading texture)
  118375. */
  118376. private _textureMatrix;
  118377. /**
  118378. * The texture URL.
  118379. */
  118380. url: string;
  118381. /**
  118382. * Empty line regex stored for GC.
  118383. */
  118384. private static _noneEmptyLineRegex;
  118385. private _engine;
  118386. /**
  118387. * Instantiates a ColorGradingTexture from the following parameters.
  118388. *
  118389. * @param url The location of the color gradind data (currently only supporting 3dl)
  118390. * @param scene The scene the texture will be used in
  118391. */
  118392. constructor(url: string, scene: Scene);
  118393. /**
  118394. * Returns the texture matrix used in most of the material.
  118395. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118396. */
  118397. getTextureMatrix(): Matrix;
  118398. /**
  118399. * Occurs when the file being loaded is a .3dl LUT file.
  118400. */
  118401. private load3dlTexture;
  118402. /**
  118403. * Starts the loading process of the texture.
  118404. */
  118405. private loadTexture;
  118406. /**
  118407. * Clones the color gradind texture.
  118408. */
  118409. clone(): ColorGradingTexture;
  118410. /**
  118411. * Called during delayed load for textures.
  118412. */
  118413. delayLoad(): void;
  118414. /**
  118415. * Parses a color grading texture serialized by Babylon.
  118416. * @param parsedTexture The texture information being parsedTexture
  118417. * @param scene The scene to load the texture in
  118418. * @param rootUrl The root url of the data assets to load
  118419. * @return A color gradind texture
  118420. */
  118421. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118422. /**
  118423. * Serializes the LUT texture to json format.
  118424. */
  118425. serialize(): any;
  118426. }
  118427. }
  118428. declare module BABYLON {
  118429. /**
  118430. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118431. */
  118432. export class EquiRectangularCubeTexture extends BaseTexture {
  118433. /** The six faces of the cube. */
  118434. private static _FacesMapping;
  118435. private _noMipmap;
  118436. private _onLoad;
  118437. private _onError;
  118438. /** The size of the cubemap. */
  118439. private _size;
  118440. /** The buffer of the image. */
  118441. private _buffer;
  118442. /** The width of the input image. */
  118443. private _width;
  118444. /** The height of the input image. */
  118445. private _height;
  118446. /** The URL to the image. */
  118447. url: string;
  118448. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118449. coordinatesMode: number;
  118450. /**
  118451. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118452. * @param url The location of the image
  118453. * @param scene The scene the texture will be used in
  118454. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118455. * @param noMipmap Forces to not generate the mipmap if true
  118456. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118457. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118458. * @param onLoad — defines a callback called when texture is loaded
  118459. * @param onError — defines a callback called if there is an error
  118460. */
  118461. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118462. /**
  118463. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118464. */
  118465. private loadImage;
  118466. /**
  118467. * Convert the image buffer into a cubemap and create a CubeTexture.
  118468. */
  118469. private loadTexture;
  118470. /**
  118471. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118472. * @param buffer The ArrayBuffer that should be converted.
  118473. * @returns The buffer as Float32Array.
  118474. */
  118475. private getFloat32ArrayFromArrayBuffer;
  118476. /**
  118477. * Get the current class name of the texture useful for serialization or dynamic coding.
  118478. * @returns "EquiRectangularCubeTexture"
  118479. */
  118480. getClassName(): string;
  118481. /**
  118482. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118483. * @returns A clone of the current EquiRectangularCubeTexture.
  118484. */
  118485. clone(): EquiRectangularCubeTexture;
  118486. }
  118487. }
  118488. declare module BABYLON {
  118489. /**
  118490. * Based on jsTGALoader - Javascript loader for TGA file
  118491. * By Vincent Thibault
  118492. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118493. */
  118494. export class TGATools {
  118495. private static _TYPE_INDEXED;
  118496. private static _TYPE_RGB;
  118497. private static _TYPE_GREY;
  118498. private static _TYPE_RLE_INDEXED;
  118499. private static _TYPE_RLE_RGB;
  118500. private static _TYPE_RLE_GREY;
  118501. private static _ORIGIN_MASK;
  118502. private static _ORIGIN_SHIFT;
  118503. private static _ORIGIN_BL;
  118504. private static _ORIGIN_BR;
  118505. private static _ORIGIN_UL;
  118506. private static _ORIGIN_UR;
  118507. /**
  118508. * Gets the header of a TGA file
  118509. * @param data defines the TGA data
  118510. * @returns the header
  118511. */
  118512. static GetTGAHeader(data: Uint8Array): any;
  118513. /**
  118514. * Uploads TGA content to a Babylon Texture
  118515. * @hidden
  118516. */
  118517. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118518. /** @hidden */
  118519. 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;
  118520. /** @hidden */
  118521. 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;
  118522. /** @hidden */
  118523. 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;
  118524. /** @hidden */
  118525. 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;
  118526. /** @hidden */
  118527. 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;
  118528. /** @hidden */
  118529. 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;
  118530. }
  118531. }
  118532. declare module BABYLON {
  118533. /**
  118534. * Implementation of the TGA Texture Loader.
  118535. * @hidden
  118536. */
  118537. export class _TGATextureLoader implements IInternalTextureLoader {
  118538. /**
  118539. * Defines wether the loader supports cascade loading the different faces.
  118540. */
  118541. readonly supportCascades: boolean;
  118542. /**
  118543. * This returns if the loader support the current file information.
  118544. * @param extension defines the file extension of the file being loaded
  118545. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118546. * @param fallback defines the fallback internal texture if any
  118547. * @param isBase64 defines whether the texture is encoded as a base64
  118548. * @param isBuffer defines whether the texture data are stored as a buffer
  118549. * @returns true if the loader can load the specified file
  118550. */
  118551. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118552. /**
  118553. * Transform the url before loading if required.
  118554. * @param rootUrl the url of the texture
  118555. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118556. * @returns the transformed texture
  118557. */
  118558. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118559. /**
  118560. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118561. * @param rootUrl the url of the texture
  118562. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118563. * @returns the fallback texture
  118564. */
  118565. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118566. /**
  118567. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118568. * @param data contains the texture data
  118569. * @param texture defines the BabylonJS internal texture
  118570. * @param createPolynomials will be true if polynomials have been requested
  118571. * @param onLoad defines the callback to trigger once the texture is ready
  118572. * @param onError defines the callback to trigger in case of error
  118573. */
  118574. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118575. /**
  118576. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118577. * @param data contains the texture data
  118578. * @param texture defines the BabylonJS internal texture
  118579. * @param callback defines the method to call once ready to upload
  118580. */
  118581. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118582. }
  118583. }
  118584. declare module BABYLON {
  118585. /**
  118586. * Info about the .basis files
  118587. */
  118588. class BasisFileInfo {
  118589. /**
  118590. * If the file has alpha
  118591. */
  118592. hasAlpha: boolean;
  118593. /**
  118594. * Info about each image of the basis file
  118595. */
  118596. images: Array<{
  118597. levels: Array<{
  118598. width: number;
  118599. height: number;
  118600. transcodedPixels: ArrayBufferView;
  118601. }>;
  118602. }>;
  118603. }
  118604. /**
  118605. * Result of transcoding a basis file
  118606. */
  118607. class TranscodeResult {
  118608. /**
  118609. * Info about the .basis file
  118610. */
  118611. fileInfo: BasisFileInfo;
  118612. /**
  118613. * Format to use when loading the file
  118614. */
  118615. format: number;
  118616. }
  118617. /**
  118618. * Configuration options for the Basis transcoder
  118619. */
  118620. export class BasisTranscodeConfiguration {
  118621. /**
  118622. * Supported compression formats used to determine the supported output format of the transcoder
  118623. */
  118624. supportedCompressionFormats?: {
  118625. /**
  118626. * etc1 compression format
  118627. */
  118628. etc1?: boolean;
  118629. /**
  118630. * s3tc compression format
  118631. */
  118632. s3tc?: boolean;
  118633. /**
  118634. * pvrtc compression format
  118635. */
  118636. pvrtc?: boolean;
  118637. /**
  118638. * etc2 compression format
  118639. */
  118640. etc2?: boolean;
  118641. };
  118642. /**
  118643. * If mipmap levels should be loaded for transcoded images (Default: true)
  118644. */
  118645. loadMipmapLevels?: boolean;
  118646. /**
  118647. * Index of a single image to load (Default: all images)
  118648. */
  118649. loadSingleImage?: number;
  118650. }
  118651. /**
  118652. * Used to load .Basis files
  118653. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118654. */
  118655. export class BasisTools {
  118656. private static _IgnoreSupportedFormats;
  118657. /**
  118658. * URL to use when loading the basis transcoder
  118659. */
  118660. static JSModuleURL: string;
  118661. /**
  118662. * URL to use when loading the wasm module for the transcoder
  118663. */
  118664. static WasmModuleURL: string;
  118665. /**
  118666. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118667. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118668. * @returns internal format corresponding to the Basis format
  118669. */
  118670. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118671. private static _WorkerPromise;
  118672. private static _Worker;
  118673. private static _actionId;
  118674. private static _CreateWorkerAsync;
  118675. /**
  118676. * Transcodes a loaded image file to compressed pixel data
  118677. * @param imageData image data to transcode
  118678. * @param config configuration options for the transcoding
  118679. * @returns a promise resulting in the transcoded image
  118680. */
  118681. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118682. /**
  118683. * Loads a texture from the transcode result
  118684. * @param texture texture load to
  118685. * @param transcodeResult the result of transcoding the basis file to load from
  118686. */
  118687. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118688. }
  118689. }
  118690. declare module BABYLON {
  118691. /**
  118692. * Loader for .basis file format
  118693. */
  118694. export class _BasisTextureLoader implements IInternalTextureLoader {
  118695. /**
  118696. * Defines whether the loader supports cascade loading the different faces.
  118697. */
  118698. readonly supportCascades: boolean;
  118699. /**
  118700. * This returns if the loader support the current file information.
  118701. * @param extension defines the file extension of the file being loaded
  118702. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118703. * @param fallback defines the fallback internal texture if any
  118704. * @param isBase64 defines whether the texture is encoded as a base64
  118705. * @param isBuffer defines whether the texture data are stored as a buffer
  118706. * @returns true if the loader can load the specified file
  118707. */
  118708. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118709. /**
  118710. * Transform the url before loading if required.
  118711. * @param rootUrl the url of the texture
  118712. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118713. * @returns the transformed texture
  118714. */
  118715. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118716. /**
  118717. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118718. * @param rootUrl the url of the texture
  118719. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118720. * @returns the fallback texture
  118721. */
  118722. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118723. /**
  118724. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118725. * @param data contains the texture data
  118726. * @param texture defines the BabylonJS internal texture
  118727. * @param createPolynomials will be true if polynomials have been requested
  118728. * @param onLoad defines the callback to trigger once the texture is ready
  118729. * @param onError defines the callback to trigger in case of error
  118730. */
  118731. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118732. /**
  118733. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118734. * @param data contains the texture data
  118735. * @param texture defines the BabylonJS internal texture
  118736. * @param callback defines the method to call once ready to upload
  118737. */
  118738. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118739. }
  118740. }
  118741. declare module BABYLON {
  118742. /**
  118743. * 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.
  118744. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118745. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118746. */
  118747. export class CustomProceduralTexture extends ProceduralTexture {
  118748. private _animate;
  118749. private _time;
  118750. private _config;
  118751. private _texturePath;
  118752. /**
  118753. * Instantiates a new Custom Procedural Texture.
  118754. * 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.
  118755. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118756. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118757. * @param name Define the name of the texture
  118758. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118759. * @param size Define the size of the texture to create
  118760. * @param scene Define the scene the texture belongs to
  118761. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118762. * @param generateMipMaps Define if the texture should creates mip maps or not
  118763. */
  118764. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118765. private _loadJson;
  118766. /**
  118767. * Is the texture ready to be used ? (rendered at least once)
  118768. * @returns true if ready, otherwise, false.
  118769. */
  118770. isReady(): boolean;
  118771. /**
  118772. * Render the texture to its associated render target.
  118773. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118774. */
  118775. render(useCameraPostProcess?: boolean): void;
  118776. /**
  118777. * Update the list of dependant textures samplers in the shader.
  118778. */
  118779. updateTextures(): void;
  118780. /**
  118781. * Update the uniform values of the procedural texture in the shader.
  118782. */
  118783. updateShaderUniforms(): void;
  118784. /**
  118785. * Define if the texture animates or not.
  118786. */
  118787. animate: boolean;
  118788. }
  118789. }
  118790. declare module BABYLON {
  118791. /** @hidden */
  118792. export var noisePixelShader: {
  118793. name: string;
  118794. shader: string;
  118795. };
  118796. }
  118797. declare module BABYLON {
  118798. /**
  118799. * Class used to generate noise procedural textures
  118800. */
  118801. export class NoiseProceduralTexture extends ProceduralTexture {
  118802. private _time;
  118803. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118804. brightness: number;
  118805. /** Defines the number of octaves to process */
  118806. octaves: number;
  118807. /** Defines the level of persistence (0.8 by default) */
  118808. persistence: number;
  118809. /** Gets or sets animation speed factor (default is 1) */
  118810. animationSpeedFactor: number;
  118811. /**
  118812. * Creates a new NoiseProceduralTexture
  118813. * @param name defines the name fo the texture
  118814. * @param size defines the size of the texture (default is 256)
  118815. * @param scene defines the hosting scene
  118816. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118817. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118818. */
  118819. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118820. private _updateShaderUniforms;
  118821. protected _getDefines(): string;
  118822. /** Generate the current state of the procedural texture */
  118823. render(useCameraPostProcess?: boolean): void;
  118824. /**
  118825. * Serializes this noise procedural texture
  118826. * @returns a serialized noise procedural texture object
  118827. */
  118828. serialize(): any;
  118829. /**
  118830. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118831. * @param parsedTexture defines parsed texture data
  118832. * @param scene defines the current scene
  118833. * @param rootUrl defines the root URL containing noise procedural texture information
  118834. * @returns a parsed NoiseProceduralTexture
  118835. */
  118836. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118837. }
  118838. }
  118839. declare module BABYLON {
  118840. /**
  118841. * Raw cube texture where the raw buffers are passed in
  118842. */
  118843. export class RawCubeTexture extends CubeTexture {
  118844. /**
  118845. * Creates a cube texture where the raw buffers are passed in.
  118846. * @param scene defines the scene the texture is attached to
  118847. * @param data defines the array of data to use to create each face
  118848. * @param size defines the size of the textures
  118849. * @param format defines the format of the data
  118850. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  118851. * @param generateMipMaps defines if the engine should generate the mip levels
  118852. * @param invertY defines if data must be stored with Y axis inverted
  118853. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  118854. * @param compression defines the compression used (null by default)
  118855. */
  118856. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  118857. /**
  118858. * Updates the raw cube texture.
  118859. * @param data defines the data to store
  118860. * @param format defines the data format
  118861. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118862. * @param invertY defines if data must be stored with Y axis inverted
  118863. * @param compression defines the compression used (null by default)
  118864. * @param level defines which level of the texture to update
  118865. */
  118866. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  118867. /**
  118868. * Updates a raw cube texture with RGBD encoded data.
  118869. * @param data defines the array of data [mipmap][face] to use to create each face
  118870. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  118871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118873. * @returns a promsie that resolves when the operation is complete
  118874. */
  118875. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  118876. /**
  118877. * Clones the raw cube texture.
  118878. * @return a new cube texture
  118879. */
  118880. clone(): CubeTexture;
  118881. /** @hidden */
  118882. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118883. }
  118884. }
  118885. declare module BABYLON {
  118886. /**
  118887. * Class used to store 3D textures containing user data
  118888. */
  118889. export class RawTexture3D extends Texture {
  118890. /** Gets or sets the texture format to use */
  118891. format: number;
  118892. private _engine;
  118893. /**
  118894. * Create a new RawTexture3D
  118895. * @param data defines the data of the texture
  118896. * @param width defines the width of the texture
  118897. * @param height defines the height of the texture
  118898. * @param depth defines the depth of the texture
  118899. * @param format defines the texture format to use
  118900. * @param scene defines the hosting scene
  118901. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  118902. * @param invertY defines if texture must be stored with Y axis inverted
  118903. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  118904. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  118905. */
  118906. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  118907. /** Gets or sets the texture format to use */
  118908. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  118909. /**
  118910. * Update the texture with new data
  118911. * @param data defines the data to store in the texture
  118912. */
  118913. update(data: ArrayBufferView): void;
  118914. }
  118915. }
  118916. declare module BABYLON {
  118917. /**
  118918. * Creates a refraction texture used by refraction channel of the standard material.
  118919. * It is like a mirror but to see through a material.
  118920. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118921. */
  118922. export class RefractionTexture extends RenderTargetTexture {
  118923. /**
  118924. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  118925. * 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.
  118926. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118927. */
  118928. refractionPlane: Plane;
  118929. /**
  118930. * Define how deep under the surface we should see.
  118931. */
  118932. depth: number;
  118933. /**
  118934. * Creates a refraction texture used by refraction channel of the standard material.
  118935. * It is like a mirror but to see through a material.
  118936. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  118937. * @param name Define the texture name
  118938. * @param size Define the size of the underlying texture
  118939. * @param scene Define the scene the refraction belongs to
  118940. * @param generateMipMaps Define if we need to generate mips level for the refraction
  118941. */
  118942. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  118943. /**
  118944. * Clone the refraction texture.
  118945. * @returns the cloned texture
  118946. */
  118947. clone(): RefractionTexture;
  118948. /**
  118949. * Serialize the texture to a JSON representation you could use in Parse later on
  118950. * @returns the serialized JSON representation
  118951. */
  118952. serialize(): any;
  118953. }
  118954. }
  118955. declare module BABYLON {
  118956. /**
  118957. * Defines the options related to the creation of an HtmlElementTexture
  118958. */
  118959. export interface IHtmlElementTextureOptions {
  118960. /**
  118961. * Defines wether mip maps should be created or not.
  118962. */
  118963. generateMipMaps?: boolean;
  118964. /**
  118965. * Defines the sampling mode of the texture.
  118966. */
  118967. samplingMode?: number;
  118968. /**
  118969. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  118970. */
  118971. engine: Nullable<Engine>;
  118972. /**
  118973. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  118974. */
  118975. scene: Nullable<Scene>;
  118976. }
  118977. /**
  118978. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  118979. * To be as efficient as possible depending on your constraints nothing aside the first upload
  118980. * is automatically managed.
  118981. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  118982. * in your application.
  118983. *
  118984. * As the update is not automatic, you need to call them manually.
  118985. */
  118986. export class HtmlElementTexture extends BaseTexture {
  118987. /**
  118988. * The texture URL.
  118989. */
  118990. element: HTMLVideoElement | HTMLCanvasElement;
  118991. private static readonly DefaultOptions;
  118992. private _textureMatrix;
  118993. private _engine;
  118994. private _isVideo;
  118995. private _generateMipMaps;
  118996. private _samplingMode;
  118997. /**
  118998. * Instantiates a HtmlElementTexture from the following parameters.
  118999. *
  119000. * @param name Defines the name of the texture
  119001. * @param element Defines the video or canvas the texture is filled with
  119002. * @param options Defines the other none mandatory texture creation options
  119003. */
  119004. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119005. private _createInternalTexture;
  119006. /**
  119007. * Returns the texture matrix used in most of the material.
  119008. */
  119009. getTextureMatrix(): Matrix;
  119010. /**
  119011. * Updates the content of the texture.
  119012. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119013. */
  119014. update(invertY?: Nullable<boolean>): void;
  119015. }
  119016. }
  119017. declare module BABYLON {
  119018. /**
  119019. * Enum used to define the target of a block
  119020. */
  119021. export enum NodeMaterialBlockTargets {
  119022. /** Vertex shader */
  119023. Vertex = 1,
  119024. /** Fragment shader */
  119025. Fragment = 2,
  119026. /** Neutral */
  119027. Neutral = 4,
  119028. /** Vertex and Fragment */
  119029. VertexAndFragment = 3
  119030. }
  119031. }
  119032. declare module BABYLON {
  119033. /**
  119034. * Defines the kind of connection point for node based material
  119035. */
  119036. export enum NodeMaterialBlockConnectionPointTypes {
  119037. /** Float */
  119038. Float = 1,
  119039. /** Int */
  119040. Int = 2,
  119041. /** Vector2 */
  119042. Vector2 = 4,
  119043. /** Vector3 */
  119044. Vector3 = 8,
  119045. /** Vector4 */
  119046. Vector4 = 16,
  119047. /** Color3 */
  119048. Color3 = 32,
  119049. /** Color4 */
  119050. Color4 = 64,
  119051. /** Matrix */
  119052. Matrix = 128,
  119053. /** Detect type based on connection */
  119054. AutoDetect = 1024,
  119055. /** Output type that will be defined by input type */
  119056. BasedOnInput = 2048
  119057. }
  119058. }
  119059. declare module BABYLON {
  119060. /**
  119061. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119062. */
  119063. export enum NodeMaterialBlockConnectionPointMode {
  119064. /** Value is an uniform */
  119065. Uniform = 0,
  119066. /** Value is a mesh attribute */
  119067. Attribute = 1,
  119068. /** Value is a varying between vertex and fragment shaders */
  119069. Varying = 2,
  119070. /** Mode is undefined */
  119071. Undefined = 3
  119072. }
  119073. }
  119074. declare module BABYLON {
  119075. /**
  119076. * Enum used to define system values e.g. values automatically provided by the system
  119077. */
  119078. export enum NodeMaterialSystemValues {
  119079. /** World */
  119080. World = 1,
  119081. /** View */
  119082. View = 2,
  119083. /** Projection */
  119084. Projection = 3,
  119085. /** ViewProjection */
  119086. ViewProjection = 4,
  119087. /** WorldView */
  119088. WorldView = 5,
  119089. /** WorldViewProjection */
  119090. WorldViewProjection = 6,
  119091. /** CameraPosition */
  119092. CameraPosition = 7,
  119093. /** Fog Color */
  119094. FogColor = 8,
  119095. /** Delta time */
  119096. DeltaTime = 9
  119097. }
  119098. }
  119099. declare module BABYLON {
  119100. /**
  119101. * Root class for all node material optimizers
  119102. */
  119103. export class NodeMaterialOptimizer {
  119104. /**
  119105. * Function used to optimize a NodeMaterial graph
  119106. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119107. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119108. */
  119109. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119110. }
  119111. }
  119112. declare module BABYLON {
  119113. /**
  119114. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119115. */
  119116. export class TransformBlock extends NodeMaterialBlock {
  119117. /**
  119118. * Defines the value to use to complement W value to transform it to a Vector4
  119119. */
  119120. complementW: number;
  119121. /**
  119122. * Defines the value to use to complement z value to transform it to a Vector4
  119123. */
  119124. complementZ: number;
  119125. /**
  119126. * Creates a new TransformBlock
  119127. * @param name defines the block name
  119128. */
  119129. constructor(name: string);
  119130. /**
  119131. * Gets the current class name
  119132. * @returns the class name
  119133. */
  119134. getClassName(): string;
  119135. /**
  119136. * Gets the vector input
  119137. */
  119138. readonly vector: NodeMaterialConnectionPoint;
  119139. /**
  119140. * Gets the output component
  119141. */
  119142. readonly output: NodeMaterialConnectionPoint;
  119143. /**
  119144. * Gets the matrix transform input
  119145. */
  119146. readonly transform: NodeMaterialConnectionPoint;
  119147. protected _buildBlock(state: NodeMaterialBuildState): this;
  119148. serialize(): any;
  119149. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119150. protected _dumpPropertiesCode(): string;
  119151. }
  119152. }
  119153. declare module BABYLON {
  119154. /**
  119155. * Block used to output the vertex position
  119156. */
  119157. export class VertexOutputBlock extends NodeMaterialBlock {
  119158. /**
  119159. * Creates a new VertexOutputBlock
  119160. * @param name defines the block name
  119161. */
  119162. constructor(name: string);
  119163. /**
  119164. * Gets the current class name
  119165. * @returns the class name
  119166. */
  119167. getClassName(): string;
  119168. /**
  119169. * Gets the vector input component
  119170. */
  119171. readonly vector: NodeMaterialConnectionPoint;
  119172. protected _buildBlock(state: NodeMaterialBuildState): this;
  119173. }
  119174. }
  119175. declare module BABYLON {
  119176. /**
  119177. * Block used to output the final color
  119178. */
  119179. export class FragmentOutputBlock extends NodeMaterialBlock {
  119180. /**
  119181. * Create a new FragmentOutputBlock
  119182. * @param name defines the block name
  119183. */
  119184. constructor(name: string);
  119185. /**
  119186. * Gets the current class name
  119187. * @returns the class name
  119188. */
  119189. getClassName(): string;
  119190. /**
  119191. * Gets the rgba input component
  119192. */
  119193. readonly rgba: NodeMaterialConnectionPoint;
  119194. /**
  119195. * Gets the rgb input component
  119196. */
  119197. readonly rgb: NodeMaterialConnectionPoint;
  119198. /**
  119199. * Gets the a input component
  119200. */
  119201. readonly a: NodeMaterialConnectionPoint;
  119202. protected _buildBlock(state: NodeMaterialBuildState): this;
  119203. }
  119204. }
  119205. declare module BABYLON {
  119206. /**
  119207. * Block used to read a reflection texture from a sampler
  119208. */
  119209. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119210. private _define3DName;
  119211. private _defineCubicName;
  119212. private _defineExplicitName;
  119213. private _defineProjectionName;
  119214. private _defineLocalCubicName;
  119215. private _defineSphericalName;
  119216. private _definePlanarName;
  119217. private _defineEquirectangularName;
  119218. private _defineMirroredEquirectangularFixedName;
  119219. private _defineEquirectangularFixedName;
  119220. private _defineSkyboxName;
  119221. private _cubeSamplerName;
  119222. private _2DSamplerName;
  119223. private _positionUVWName;
  119224. private _directionWName;
  119225. private _reflectionCoordsName;
  119226. private _reflection2DCoordsName;
  119227. private _reflectionColorName;
  119228. private _reflectionMatrixName;
  119229. /**
  119230. * Gets or sets the texture associated with the node
  119231. */
  119232. texture: Nullable<BaseTexture>;
  119233. /**
  119234. * Create a new TextureBlock
  119235. * @param name defines the block name
  119236. */
  119237. constructor(name: string);
  119238. /**
  119239. * Gets the current class name
  119240. * @returns the class name
  119241. */
  119242. getClassName(): string;
  119243. /**
  119244. * Gets the world position input component
  119245. */
  119246. readonly position: NodeMaterialConnectionPoint;
  119247. /**
  119248. * Gets the world position input component
  119249. */
  119250. readonly worldPosition: NodeMaterialConnectionPoint;
  119251. /**
  119252. * Gets the world normal input component
  119253. */
  119254. readonly worldNormal: NodeMaterialConnectionPoint;
  119255. /**
  119256. * Gets the world input component
  119257. */
  119258. readonly world: NodeMaterialConnectionPoint;
  119259. /**
  119260. * Gets the camera (or eye) position component
  119261. */
  119262. readonly cameraPosition: NodeMaterialConnectionPoint;
  119263. /**
  119264. * Gets the view input component
  119265. */
  119266. readonly view: NodeMaterialConnectionPoint;
  119267. /**
  119268. * Gets the rgb output component
  119269. */
  119270. readonly rgb: NodeMaterialConnectionPoint;
  119271. /**
  119272. * Gets the r output component
  119273. */
  119274. readonly r: NodeMaterialConnectionPoint;
  119275. /**
  119276. * Gets the g output component
  119277. */
  119278. readonly g: NodeMaterialConnectionPoint;
  119279. /**
  119280. * Gets the b output component
  119281. */
  119282. readonly b: NodeMaterialConnectionPoint;
  119283. autoConfigure(material: NodeMaterial): void;
  119284. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119285. isReady(): boolean;
  119286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119287. private _injectVertexCode;
  119288. private _writeOutput;
  119289. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119290. serialize(): any;
  119291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119292. }
  119293. }
  119294. declare module BABYLON {
  119295. /**
  119296. * Interface used to configure the node material editor
  119297. */
  119298. export interface INodeMaterialEditorOptions {
  119299. /** Define the URl to load node editor script */
  119300. editorURL?: string;
  119301. }
  119302. /** @hidden */
  119303. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119304. /** BONES */
  119305. NUM_BONE_INFLUENCERS: number;
  119306. BonesPerMesh: number;
  119307. BONETEXTURE: boolean;
  119308. /** MORPH TARGETS */
  119309. MORPHTARGETS: boolean;
  119310. MORPHTARGETS_NORMAL: boolean;
  119311. MORPHTARGETS_TANGENT: boolean;
  119312. MORPHTARGETS_UV: boolean;
  119313. NUM_MORPH_INFLUENCERS: number;
  119314. /** IMAGE PROCESSING */
  119315. IMAGEPROCESSING: boolean;
  119316. VIGNETTE: boolean;
  119317. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119318. VIGNETTEBLENDMODEOPAQUE: boolean;
  119319. TONEMAPPING: boolean;
  119320. TONEMAPPING_ACES: boolean;
  119321. CONTRAST: boolean;
  119322. EXPOSURE: boolean;
  119323. COLORCURVES: boolean;
  119324. COLORGRADING: boolean;
  119325. COLORGRADING3D: boolean;
  119326. SAMPLER3DGREENDEPTH: boolean;
  119327. SAMPLER3DBGRMAP: boolean;
  119328. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119329. /** MISC. */
  119330. BUMPDIRECTUV: number;
  119331. constructor();
  119332. setValue(name: string, value: boolean): void;
  119333. }
  119334. /**
  119335. * Class used to configure NodeMaterial
  119336. */
  119337. export interface INodeMaterialOptions {
  119338. /**
  119339. * Defines if blocks should emit comments
  119340. */
  119341. emitComments: boolean;
  119342. }
  119343. /**
  119344. * Class used to create a node based material built by assembling shader blocks
  119345. */
  119346. export class NodeMaterial extends PushMaterial {
  119347. private static _BuildIdGenerator;
  119348. private _options;
  119349. private _vertexCompilationState;
  119350. private _fragmentCompilationState;
  119351. private _sharedData;
  119352. private _buildId;
  119353. private _buildWasSuccessful;
  119354. private _cachedWorldViewMatrix;
  119355. private _cachedWorldViewProjectionMatrix;
  119356. private _optimizers;
  119357. private _animationFrame;
  119358. /** Define the URl to load node editor script */
  119359. static EditorURL: string;
  119360. private BJSNODEMATERIALEDITOR;
  119361. /** Get the inspector from bundle or global */
  119362. private _getGlobalNodeMaterialEditor;
  119363. /**
  119364. * 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)
  119365. */
  119366. ignoreAlpha: boolean;
  119367. /**
  119368. * Defines the maximum number of lights that can be used in the material
  119369. */
  119370. maxSimultaneousLights: number;
  119371. /**
  119372. * Observable raised when the material is built
  119373. */
  119374. onBuildObservable: Observable<NodeMaterial>;
  119375. /**
  119376. * Gets or sets the root nodes of the material vertex shader
  119377. */
  119378. _vertexOutputNodes: NodeMaterialBlock[];
  119379. /**
  119380. * Gets or sets the root nodes of the material fragment (pixel) shader
  119381. */
  119382. _fragmentOutputNodes: NodeMaterialBlock[];
  119383. /** Gets or sets options to control the node material overall behavior */
  119384. options: INodeMaterialOptions;
  119385. /**
  119386. * Default configuration related to image processing available in the standard Material.
  119387. */
  119388. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119389. /**
  119390. * Gets the image processing configuration used either in this material.
  119391. */
  119392. /**
  119393. * Sets the Default image processing configuration used either in the this material.
  119394. *
  119395. * If sets to null, the scene one is in use.
  119396. */
  119397. imageProcessingConfiguration: ImageProcessingConfiguration;
  119398. /**
  119399. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119400. */
  119401. attachedBlocks: NodeMaterialBlock[];
  119402. /**
  119403. * Create a new node based material
  119404. * @param name defines the material name
  119405. * @param scene defines the hosting scene
  119406. * @param options defines creation option
  119407. */
  119408. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119409. /**
  119410. * Gets the current class name of the material e.g. "NodeMaterial"
  119411. * @returns the class name
  119412. */
  119413. getClassName(): string;
  119414. /**
  119415. * Keep track of the image processing observer to allow dispose and replace.
  119416. */
  119417. private _imageProcessingObserver;
  119418. /**
  119419. * Attaches a new image processing configuration to the Standard Material.
  119420. * @param configuration
  119421. */
  119422. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119423. /**
  119424. * Get a block by its name
  119425. * @param name defines the name of the block to retrieve
  119426. * @returns the required block or null if not found
  119427. */
  119428. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119429. /**
  119430. * Get a block by its name
  119431. * @param predicate defines the predicate used to find the good candidate
  119432. * @returns the required block or null if not found
  119433. */
  119434. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119435. /**
  119436. * Get an input block by its name
  119437. * @param predicate defines the predicate used to find the good candidate
  119438. * @returns the required input block or null if not found
  119439. */
  119440. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119441. /**
  119442. * Gets the list of input blocks attached to this material
  119443. * @returns an array of InputBlocks
  119444. */
  119445. getInputBlocks(): InputBlock[];
  119446. /**
  119447. * Adds a new optimizer to the list of optimizers
  119448. * @param optimizer defines the optimizers to add
  119449. * @returns the current material
  119450. */
  119451. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119452. /**
  119453. * Remove an optimizer from the list of optimizers
  119454. * @param optimizer defines the optimizers to remove
  119455. * @returns the current material
  119456. */
  119457. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119458. /**
  119459. * Add a new block to the list of output nodes
  119460. * @param node defines the node to add
  119461. * @returns the current material
  119462. */
  119463. addOutputNode(node: NodeMaterialBlock): this;
  119464. /**
  119465. * Remove a block from the list of root nodes
  119466. * @param node defines the node to remove
  119467. * @returns the current material
  119468. */
  119469. removeOutputNode(node: NodeMaterialBlock): this;
  119470. private _addVertexOutputNode;
  119471. private _removeVertexOutputNode;
  119472. private _addFragmentOutputNode;
  119473. private _removeFragmentOutputNode;
  119474. /**
  119475. * Specifies if the material will require alpha blending
  119476. * @returns a boolean specifying if alpha blending is needed
  119477. */
  119478. needAlphaBlending(): boolean;
  119479. /**
  119480. * Specifies if this material should be rendered in alpha test mode
  119481. * @returns a boolean specifying if an alpha test is needed.
  119482. */
  119483. needAlphaTesting(): boolean;
  119484. private _initializeBlock;
  119485. private _resetDualBlocks;
  119486. /**
  119487. * Build the material and generates the inner effect
  119488. * @param verbose defines if the build should log activity
  119489. */
  119490. build(verbose?: boolean): void;
  119491. /**
  119492. * Runs an otpimization phase to try to improve the shader code
  119493. */
  119494. optimize(): void;
  119495. private _prepareDefinesForAttributes;
  119496. /**
  119497. * Get if the submesh is ready to be used and all its information available.
  119498. * Child classes can use it to update shaders
  119499. * @param mesh defines the mesh to check
  119500. * @param subMesh defines which submesh to check
  119501. * @param useInstances specifies that instances should be used
  119502. * @returns a boolean indicating that the submesh is ready or not
  119503. */
  119504. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119505. /**
  119506. * Get a string representing the shaders built by the current node graph
  119507. */
  119508. readonly compiledShaders: string;
  119509. /**
  119510. * Binds the world matrix to the material
  119511. * @param world defines the world transformation matrix
  119512. */
  119513. bindOnlyWorldMatrix(world: Matrix): void;
  119514. /**
  119515. * Binds the submesh to this material by preparing the effect and shader to draw
  119516. * @param world defines the world transformation matrix
  119517. * @param mesh defines the mesh containing the submesh
  119518. * @param subMesh defines the submesh to bind the material to
  119519. */
  119520. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119521. /**
  119522. * Gets the active textures from the material
  119523. * @returns an array of textures
  119524. */
  119525. getActiveTextures(): BaseTexture[];
  119526. /**
  119527. * Gets the list of texture blocks
  119528. * @returns an array of texture blocks
  119529. */
  119530. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119531. /**
  119532. * Specifies if the material uses a texture
  119533. * @param texture defines the texture to check against the material
  119534. * @returns a boolean specifying if the material uses the texture
  119535. */
  119536. hasTexture(texture: BaseTexture): boolean;
  119537. /**
  119538. * Disposes the material
  119539. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119540. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119541. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119542. */
  119543. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119544. /** Creates the node editor window. */
  119545. private _createNodeEditor;
  119546. /**
  119547. * Launch the node material editor
  119548. * @param config Define the configuration of the editor
  119549. * @return a promise fulfilled when the node editor is visible
  119550. */
  119551. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119552. /**
  119553. * Clear the current material
  119554. */
  119555. clear(): void;
  119556. /**
  119557. * Clear the current material and set it to a default state
  119558. */
  119559. setToDefault(): void;
  119560. /**
  119561. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119562. * @param url defines the url to load from
  119563. * @returns a promise that will fullfil when the material is fully loaded
  119564. */
  119565. loadAsync(url: string): Promise<unknown>;
  119566. private _gatherBlocks;
  119567. /**
  119568. * Generate a string containing the code declaration required to create an equivalent of this material
  119569. * @returns a string
  119570. */
  119571. generateCode(): string;
  119572. /**
  119573. * Serializes this material in a JSON representation
  119574. * @returns the serialized material object
  119575. */
  119576. serialize(): any;
  119577. private _restoreConnections;
  119578. /**
  119579. * Clear the current graph and load a new one from a serialization object
  119580. * @param source defines the JSON representation of the material
  119581. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119582. */
  119583. loadFromSerialization(source: any, rootUrl?: string): void;
  119584. /**
  119585. * Creates a node material from parsed material data
  119586. * @param source defines the JSON representation of the material
  119587. * @param scene defines the hosting scene
  119588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119589. * @returns a new node material
  119590. */
  119591. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119592. /**
  119593. * Creates a new node material set to default basic configuration
  119594. * @param name defines the name of the material
  119595. * @param scene defines the hosting scene
  119596. * @returns a new NodeMaterial
  119597. */
  119598. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119599. }
  119600. }
  119601. declare module BABYLON {
  119602. /**
  119603. * Block used to read a texture from a sampler
  119604. */
  119605. export class TextureBlock extends NodeMaterialBlock {
  119606. private _defineName;
  119607. private _linearDefineName;
  119608. private _samplerName;
  119609. private _transformedUVName;
  119610. private _textureTransformName;
  119611. private _textureInfoName;
  119612. private _mainUVName;
  119613. private _mainUVDefineName;
  119614. /**
  119615. * Gets or sets the texture associated with the node
  119616. */
  119617. texture: Nullable<Texture>;
  119618. /**
  119619. * Create a new TextureBlock
  119620. * @param name defines the block name
  119621. */
  119622. constructor(name: string);
  119623. /**
  119624. * Gets the current class name
  119625. * @returns the class name
  119626. */
  119627. getClassName(): string;
  119628. /**
  119629. * Gets the uv input component
  119630. */
  119631. readonly uv: NodeMaterialConnectionPoint;
  119632. /**
  119633. * Gets the rgba output component
  119634. */
  119635. readonly rgba: NodeMaterialConnectionPoint;
  119636. /**
  119637. * Gets the rgb output component
  119638. */
  119639. readonly rgb: NodeMaterialConnectionPoint;
  119640. /**
  119641. * Gets the r output component
  119642. */
  119643. readonly r: NodeMaterialConnectionPoint;
  119644. /**
  119645. * Gets the g output component
  119646. */
  119647. readonly g: NodeMaterialConnectionPoint;
  119648. /**
  119649. * Gets the b output component
  119650. */
  119651. readonly b: NodeMaterialConnectionPoint;
  119652. /**
  119653. * Gets the a output component
  119654. */
  119655. readonly a: NodeMaterialConnectionPoint;
  119656. readonly target: NodeMaterialBlockTargets;
  119657. autoConfigure(material: NodeMaterial): void;
  119658. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119659. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119660. isReady(): boolean;
  119661. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119662. private readonly _isMixed;
  119663. private _injectVertexCode;
  119664. private _writeOutput;
  119665. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119666. protected _dumpPropertiesCode(): string;
  119667. serialize(): any;
  119668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119669. }
  119670. }
  119671. declare module BABYLON {
  119672. /**
  119673. * Class used to store shared data between 2 NodeMaterialBuildState
  119674. */
  119675. export class NodeMaterialBuildStateSharedData {
  119676. /**
  119677. * Gets the list of emitted varyings
  119678. */
  119679. temps: string[];
  119680. /**
  119681. * Gets the list of emitted varyings
  119682. */
  119683. varyings: string[];
  119684. /**
  119685. * Gets the varying declaration string
  119686. */
  119687. varyingDeclaration: string;
  119688. /**
  119689. * Input blocks
  119690. */
  119691. inputBlocks: InputBlock[];
  119692. /**
  119693. * Input blocks
  119694. */
  119695. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119696. /**
  119697. * Bindable blocks (Blocks that need to set data to the effect)
  119698. */
  119699. bindableBlocks: NodeMaterialBlock[];
  119700. /**
  119701. * List of blocks that can provide a compilation fallback
  119702. */
  119703. blocksWithFallbacks: NodeMaterialBlock[];
  119704. /**
  119705. * List of blocks that can provide a define update
  119706. */
  119707. blocksWithDefines: NodeMaterialBlock[];
  119708. /**
  119709. * List of blocks that can provide a repeatable content
  119710. */
  119711. repeatableContentBlocks: NodeMaterialBlock[];
  119712. /**
  119713. * List of blocks that can provide a dynamic list of uniforms
  119714. */
  119715. dynamicUniformBlocks: NodeMaterialBlock[];
  119716. /**
  119717. * List of blocks that can block the isReady function for the material
  119718. */
  119719. blockingBlocks: NodeMaterialBlock[];
  119720. /**
  119721. * Gets the list of animated inputs
  119722. */
  119723. animatedInputs: InputBlock[];
  119724. /**
  119725. * Build Id used to avoid multiple recompilations
  119726. */
  119727. buildId: number;
  119728. /** List of emitted variables */
  119729. variableNames: {
  119730. [key: string]: number;
  119731. };
  119732. /** List of emitted defines */
  119733. defineNames: {
  119734. [key: string]: number;
  119735. };
  119736. /** Should emit comments? */
  119737. emitComments: boolean;
  119738. /** Emit build activity */
  119739. verbose: boolean;
  119740. /** Gets or sets the hosting scene */
  119741. scene: Scene;
  119742. /**
  119743. * Gets the compilation hints emitted at compilation time
  119744. */
  119745. hints: {
  119746. needWorldViewMatrix: boolean;
  119747. needWorldViewProjectionMatrix: boolean;
  119748. needAlphaBlending: boolean;
  119749. needAlphaTesting: boolean;
  119750. };
  119751. /**
  119752. * List of compilation checks
  119753. */
  119754. checks: {
  119755. emitVertex: boolean;
  119756. emitFragment: boolean;
  119757. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119758. };
  119759. /** Creates a new shared data */
  119760. constructor();
  119761. /**
  119762. * Emits console errors and exceptions if there is a failing check
  119763. */
  119764. emitErrors(): void;
  119765. }
  119766. }
  119767. declare module BABYLON {
  119768. /**
  119769. * Class used to store node based material build state
  119770. */
  119771. export class NodeMaterialBuildState {
  119772. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119773. supportUniformBuffers: boolean;
  119774. /**
  119775. * Gets the list of emitted attributes
  119776. */
  119777. attributes: string[];
  119778. /**
  119779. * Gets the list of emitted uniforms
  119780. */
  119781. uniforms: string[];
  119782. /**
  119783. * Gets the list of emitted constants
  119784. */
  119785. constants: string[];
  119786. /**
  119787. * Gets the list of emitted uniform buffers
  119788. */
  119789. uniformBuffers: string[];
  119790. /**
  119791. * Gets the list of emitted samplers
  119792. */
  119793. samplers: string[];
  119794. /**
  119795. * Gets the list of emitted functions
  119796. */
  119797. functions: {
  119798. [key: string]: string;
  119799. };
  119800. /**
  119801. * Gets the list of emitted extensions
  119802. */
  119803. extensions: {
  119804. [key: string]: string;
  119805. };
  119806. /**
  119807. * Gets the target of the compilation state
  119808. */
  119809. target: NodeMaterialBlockTargets;
  119810. /**
  119811. * Gets the list of emitted counters
  119812. */
  119813. counters: {
  119814. [key: string]: number;
  119815. };
  119816. /**
  119817. * Shared data between multiple NodeMaterialBuildState instances
  119818. */
  119819. sharedData: NodeMaterialBuildStateSharedData;
  119820. /** @hidden */
  119821. _vertexState: NodeMaterialBuildState;
  119822. /** @hidden */
  119823. _attributeDeclaration: string;
  119824. /** @hidden */
  119825. _uniformDeclaration: string;
  119826. /** @hidden */
  119827. _constantDeclaration: string;
  119828. /** @hidden */
  119829. _samplerDeclaration: string;
  119830. /** @hidden */
  119831. _varyingTransfer: string;
  119832. private _repeatableContentAnchorIndex;
  119833. /** @hidden */
  119834. _builtCompilationString: string;
  119835. /**
  119836. * Gets the emitted compilation strings
  119837. */
  119838. compilationString: string;
  119839. /**
  119840. * Finalize the compilation strings
  119841. * @param state defines the current compilation state
  119842. */
  119843. finalize(state: NodeMaterialBuildState): void;
  119844. /** @hidden */
  119845. readonly _repeatableContentAnchor: string;
  119846. /** @hidden */
  119847. _getFreeVariableName(prefix: string): string;
  119848. /** @hidden */
  119849. _getFreeDefineName(prefix: string): string;
  119850. /** @hidden */
  119851. _excludeVariableName(name: string): void;
  119852. /** @hidden */
  119853. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  119854. /** @hidden */
  119855. _emitExtension(name: string, extension: string): void;
  119856. /** @hidden */
  119857. _emitFunction(name: string, code: string, comments: string): void;
  119858. /** @hidden */
  119859. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  119860. replaceStrings?: {
  119861. search: RegExp;
  119862. replace: string;
  119863. }[];
  119864. repeatKey?: string;
  119865. }): string;
  119866. /** @hidden */
  119867. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  119868. repeatKey?: string;
  119869. removeAttributes?: boolean;
  119870. removeUniforms?: boolean;
  119871. removeVaryings?: boolean;
  119872. removeIfDef?: boolean;
  119873. replaceStrings?: {
  119874. search: RegExp;
  119875. replace: string;
  119876. }[];
  119877. }, storeKey?: string): void;
  119878. /** @hidden */
  119879. _registerTempVariable(name: string): boolean;
  119880. /** @hidden */
  119881. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  119882. /** @hidden */
  119883. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  119884. }
  119885. }
  119886. declare module BABYLON {
  119887. /**
  119888. * Defines a block that can be used inside a node based material
  119889. */
  119890. export class NodeMaterialBlock {
  119891. private _buildId;
  119892. private _buildTarget;
  119893. private _target;
  119894. private _isFinalMerger;
  119895. private _isInput;
  119896. /** @hidden */
  119897. _codeVariableName: string;
  119898. /** @hidden */
  119899. _inputs: NodeMaterialConnectionPoint[];
  119900. /** @hidden */
  119901. _outputs: NodeMaterialConnectionPoint[];
  119902. /** @hidden */
  119903. _preparationId: number;
  119904. /**
  119905. * Gets or sets the name of the block
  119906. */
  119907. name: string;
  119908. /**
  119909. * Gets or sets the unique id of the node
  119910. */
  119911. uniqueId: number;
  119912. /**
  119913. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  119914. */
  119915. readonly isFinalMerger: boolean;
  119916. /**
  119917. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  119918. */
  119919. readonly isInput: boolean;
  119920. /**
  119921. * Gets or sets the build Id
  119922. */
  119923. buildId: number;
  119924. /**
  119925. * Gets or sets the target of the block
  119926. */
  119927. target: NodeMaterialBlockTargets;
  119928. /**
  119929. * Gets the list of input points
  119930. */
  119931. readonly inputs: NodeMaterialConnectionPoint[];
  119932. /** Gets the list of output points */
  119933. readonly outputs: NodeMaterialConnectionPoint[];
  119934. /**
  119935. * Find an input by its name
  119936. * @param name defines the name of the input to look for
  119937. * @returns the input or null if not found
  119938. */
  119939. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119940. /**
  119941. * Find an output by its name
  119942. * @param name defines the name of the outputto look for
  119943. * @returns the output or null if not found
  119944. */
  119945. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  119946. /**
  119947. * Creates a new NodeMaterialBlock
  119948. * @param name defines the block name
  119949. * @param target defines the target of that block (Vertex by default)
  119950. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  119951. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  119952. */
  119953. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  119954. /**
  119955. * Initialize the block and prepare the context for build
  119956. * @param state defines the state that will be used for the build
  119957. */
  119958. initialize(state: NodeMaterialBuildState): void;
  119959. /**
  119960. * Bind data to effect. Will only be called for blocks with isBindable === true
  119961. * @param effect defines the effect to bind data to
  119962. * @param nodeMaterial defines the hosting NodeMaterial
  119963. * @param mesh defines the mesh that will be rendered
  119964. */
  119965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119966. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  119967. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  119968. protected _writeFloat(value: number): string;
  119969. /**
  119970. * Gets the current class name e.g. "NodeMaterialBlock"
  119971. * @returns the class name
  119972. */
  119973. getClassName(): string;
  119974. /**
  119975. * Register a new input. Must be called inside a block constructor
  119976. * @param name defines the connection point name
  119977. * @param type defines the connection point type
  119978. * @param isOptional defines a boolean indicating that this input can be omitted
  119979. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119980. * @returns the current block
  119981. */
  119982. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  119983. /**
  119984. * Register a new output. Must be called inside a block constructor
  119985. * @param name defines the connection point name
  119986. * @param type defines the connection point type
  119987. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  119988. * @returns the current block
  119989. */
  119990. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  119991. /**
  119992. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  119993. * @param forOutput defines an optional connection point to check compatibility with
  119994. * @returns the first available input or null
  119995. */
  119996. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  119997. /**
  119998. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  119999. * @param forBlock defines an optional block to check compatibility with
  120000. * @returns the first available input or null
  120001. */
  120002. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120003. /**
  120004. * Gets the sibling of the given output
  120005. * @param current defines the current output
  120006. * @returns the next output in the list or null
  120007. */
  120008. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120009. /**
  120010. * Connect current block with another block
  120011. * @param other defines the block to connect with
  120012. * @param options define the various options to help pick the right connections
  120013. * @returns the current block
  120014. */
  120015. connectTo(other: NodeMaterialBlock, options?: {
  120016. input?: string;
  120017. output?: string;
  120018. outputSwizzle?: string;
  120019. }): this | undefined;
  120020. protected _buildBlock(state: NodeMaterialBuildState): void;
  120021. /**
  120022. * Add uniforms, samplers and uniform buffers at compilation time
  120023. * @param state defines the state to update
  120024. * @param nodeMaterial defines the node material requesting the update
  120025. * @param defines defines the material defines to update
  120026. */
  120027. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120028. /**
  120029. * Add potential fallbacks if shader compilation fails
  120030. * @param mesh defines the mesh to be rendered
  120031. * @param fallbacks defines the current prioritized list of fallbacks
  120032. */
  120033. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120034. /**
  120035. * Initialize defines for shader compilation
  120036. * @param mesh defines the mesh to be rendered
  120037. * @param nodeMaterial defines the node material requesting the update
  120038. * @param defines defines the material defines to update
  120039. * @param useInstances specifies that instances should be used
  120040. */
  120041. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120042. /**
  120043. * Update defines for shader compilation
  120044. * @param mesh defines the mesh to be rendered
  120045. * @param nodeMaterial defines the node material requesting the update
  120046. * @param defines defines the material defines to update
  120047. * @param useInstances specifies that instances should be used
  120048. */
  120049. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120050. /**
  120051. * Lets the block try to connect some inputs automatically
  120052. * @param material defines the hosting NodeMaterial
  120053. */
  120054. autoConfigure(material: NodeMaterial): void;
  120055. /**
  120056. * Function called when a block is declared as repeatable content generator
  120057. * @param vertexShaderState defines the current compilation state for the vertex shader
  120058. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120059. * @param mesh defines the mesh to be rendered
  120060. * @param defines defines the material defines to update
  120061. */
  120062. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120063. /**
  120064. * Checks if the block is ready
  120065. * @param mesh defines the mesh to be rendered
  120066. * @param nodeMaterial defines the node material requesting the update
  120067. * @param defines defines the material defines to update
  120068. * @param useInstances specifies that instances should be used
  120069. * @returns true if the block is ready
  120070. */
  120071. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120072. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120073. private _processBuild;
  120074. /**
  120075. * Compile the current node and generate the shader code
  120076. * @param state defines the current compilation state (uniforms, samplers, current string)
  120077. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120078. * @returns true if already built
  120079. */
  120080. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120081. protected _inputRename(name: string): string;
  120082. protected _outputRename(name: string): string;
  120083. protected _dumpPropertiesCode(): string;
  120084. /** @hidden */
  120085. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120086. /**
  120087. * Clone the current block to a new identical block
  120088. * @param scene defines the hosting scene
  120089. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120090. * @returns a copy of the current block
  120091. */
  120092. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120093. /**
  120094. * Serializes this block in a JSON representation
  120095. * @returns the serialized block object
  120096. */
  120097. serialize(): any;
  120098. /** @hidden */
  120099. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120100. }
  120101. }
  120102. declare module BABYLON {
  120103. /**
  120104. * Enum defining the type of animations supported by InputBlock
  120105. */
  120106. export enum AnimatedInputBlockTypes {
  120107. /** No animation */
  120108. None = 0,
  120109. /** Time based animation. Will only work for floats */
  120110. Time = 1
  120111. }
  120112. }
  120113. declare module BABYLON {
  120114. /**
  120115. * Block used to expose an input value
  120116. */
  120117. export class InputBlock extends NodeMaterialBlock {
  120118. private _mode;
  120119. private _associatedVariableName;
  120120. private _storedValue;
  120121. private _valueCallback;
  120122. private _type;
  120123. private _animationType;
  120124. /** Gets or set a value used to limit the range of float values */
  120125. min: number;
  120126. /** Gets or set a value used to limit the range of float values */
  120127. max: number;
  120128. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120129. matrixMode: number;
  120130. /** @hidden */
  120131. _systemValue: Nullable<NodeMaterialSystemValues>;
  120132. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120133. visibleInInspector: boolean;
  120134. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120135. isConstant: boolean;
  120136. /**
  120137. * Gets or sets the connection point type (default is float)
  120138. */
  120139. readonly type: NodeMaterialBlockConnectionPointTypes;
  120140. /**
  120141. * Creates a new InputBlock
  120142. * @param name defines the block name
  120143. * @param target defines the target of that block (Vertex by default)
  120144. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120145. */
  120146. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120147. /**
  120148. * Gets the output component
  120149. */
  120150. readonly output: NodeMaterialConnectionPoint;
  120151. /**
  120152. * Set the source of this connection point to a vertex attribute
  120153. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120154. * @returns the current connection point
  120155. */
  120156. setAsAttribute(attributeName?: string): InputBlock;
  120157. /**
  120158. * Set the source of this connection point to a system value
  120159. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120160. * @returns the current connection point
  120161. */
  120162. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120163. /**
  120164. * Gets or sets the value of that point.
  120165. * Please note that this value will be ignored if valueCallback is defined
  120166. */
  120167. value: any;
  120168. /**
  120169. * Gets or sets a callback used to get the value of that point.
  120170. * Please note that setting this value will force the connection point to ignore the value property
  120171. */
  120172. valueCallback: () => any;
  120173. /**
  120174. * Gets or sets the associated variable name in the shader
  120175. */
  120176. associatedVariableName: string;
  120177. /** Gets or sets the type of animation applied to the input */
  120178. animationType: AnimatedInputBlockTypes;
  120179. /**
  120180. * Gets a boolean indicating that this connection point not defined yet
  120181. */
  120182. readonly isUndefined: boolean;
  120183. /**
  120184. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120185. * In this case the connection point name must be the name of the uniform to use.
  120186. * Can only be set on inputs
  120187. */
  120188. isUniform: boolean;
  120189. /**
  120190. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120191. * In this case the connection point name must be the name of the attribute to use
  120192. * Can only be set on inputs
  120193. */
  120194. isAttribute: boolean;
  120195. /**
  120196. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120197. * Can only be set on exit points
  120198. */
  120199. isVarying: boolean;
  120200. /**
  120201. * Gets a boolean indicating that the current connection point is a system value
  120202. */
  120203. readonly isSystemValue: boolean;
  120204. /**
  120205. * Gets or sets the current well known value or null if not defined as a system value
  120206. */
  120207. systemValue: Nullable<NodeMaterialSystemValues>;
  120208. /**
  120209. * Gets the current class name
  120210. * @returns the class name
  120211. */
  120212. getClassName(): string;
  120213. /**
  120214. * Animate the input if animationType !== None
  120215. * @param scene defines the rendering scene
  120216. */
  120217. animate(scene: Scene): void;
  120218. private _emitDefine;
  120219. initialize(state: NodeMaterialBuildState): void;
  120220. /**
  120221. * Set the input block to its default value (based on its type)
  120222. */
  120223. setDefaultValue(): void;
  120224. private _emitConstant;
  120225. private _emit;
  120226. /** @hidden */
  120227. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120228. /** @hidden */
  120229. _transmit(effect: Effect, scene: Scene): void;
  120230. protected _buildBlock(state: NodeMaterialBuildState): void;
  120231. protected _dumpPropertiesCode(): string;
  120232. serialize(): any;
  120233. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. /**
  120238. * Defines a connection point for a block
  120239. */
  120240. export class NodeMaterialConnectionPoint {
  120241. /** @hidden */
  120242. _ownerBlock: NodeMaterialBlock;
  120243. /** @hidden */
  120244. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120245. private _endpoints;
  120246. private _associatedVariableName;
  120247. /** @hidden */
  120248. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120249. /** @hidden */
  120250. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120251. private _type;
  120252. /** @hidden */
  120253. _enforceAssociatedVariableName: boolean;
  120254. /**
  120255. * Gets or sets the additional types supported by this connection point
  120256. */
  120257. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120258. /**
  120259. * Gets or sets the additional types excluded by this connection point
  120260. */
  120261. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120262. /**
  120263. * Gets or sets the associated variable name in the shader
  120264. */
  120265. associatedVariableName: string;
  120266. /**
  120267. * Gets or sets the connection point type (default is float)
  120268. */
  120269. type: NodeMaterialBlockConnectionPointTypes;
  120270. /**
  120271. * Gets or sets the connection point name
  120272. */
  120273. name: string;
  120274. /**
  120275. * Gets or sets a boolean indicating that this connection point can be omitted
  120276. */
  120277. isOptional: boolean;
  120278. /**
  120279. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120280. */
  120281. define: string;
  120282. /** Gets or sets the target of that connection point */
  120283. target: NodeMaterialBlockTargets;
  120284. /**
  120285. * Gets a boolean indicating that the current point is connected
  120286. */
  120287. readonly isConnected: boolean;
  120288. /**
  120289. * Gets a boolean indicating that the current point is connected to an input block
  120290. */
  120291. readonly isConnectedToInputBlock: boolean;
  120292. /**
  120293. * Gets a the connected input block (if any)
  120294. */
  120295. readonly connectInputBlock: Nullable<InputBlock>;
  120296. /** Get the other side of the connection (if any) */
  120297. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120298. /** Get the block that owns this connection point */
  120299. readonly ownerBlock: NodeMaterialBlock;
  120300. /** Get the block connected on the other side of this connection (if any) */
  120301. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120302. /** Get the block connected on the endpoints of this connection (if any) */
  120303. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120304. /** Gets the list of connected endpoints */
  120305. readonly endpoints: NodeMaterialConnectionPoint[];
  120306. /** Gets a boolean indicating if that output point is connected to at least one input */
  120307. readonly hasEndpoints: boolean;
  120308. /**
  120309. * Creates a new connection point
  120310. * @param name defines the connection point name
  120311. * @param ownerBlock defines the block hosting this connection point
  120312. */
  120313. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120314. /**
  120315. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120316. * @returns the class name
  120317. */
  120318. getClassName(): string;
  120319. /**
  120320. * Gets an boolean indicating if the current point can be connected to another point
  120321. * @param connectionPoint defines the other connection point
  120322. * @returns true if the connection is possible
  120323. */
  120324. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120325. /**
  120326. * Connect this point to another connection point
  120327. * @param connectionPoint defines the other connection point
  120328. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120329. * @returns the current connection point
  120330. */
  120331. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120332. /**
  120333. * Disconnect this point from one of his endpoint
  120334. * @param endpoint defines the other connection point
  120335. * @returns the current connection point
  120336. */
  120337. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120338. /**
  120339. * Serializes this point in a JSON representation
  120340. * @returns the serialized point object
  120341. */
  120342. serialize(): any;
  120343. }
  120344. }
  120345. declare module BABYLON {
  120346. /**
  120347. * Block used to add support for vertex skinning (bones)
  120348. */
  120349. export class BonesBlock extends NodeMaterialBlock {
  120350. /**
  120351. * Creates a new BonesBlock
  120352. * @param name defines the block name
  120353. */
  120354. constructor(name: string);
  120355. /**
  120356. * Initialize the block and prepare the context for build
  120357. * @param state defines the state that will be used for the build
  120358. */
  120359. initialize(state: NodeMaterialBuildState): void;
  120360. /**
  120361. * Gets the current class name
  120362. * @returns the class name
  120363. */
  120364. getClassName(): string;
  120365. /**
  120366. * Gets the matrix indices input component
  120367. */
  120368. readonly matricesIndices: NodeMaterialConnectionPoint;
  120369. /**
  120370. * Gets the matrix weights input component
  120371. */
  120372. readonly matricesWeights: NodeMaterialConnectionPoint;
  120373. /**
  120374. * Gets the extra matrix indices input component
  120375. */
  120376. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120377. /**
  120378. * Gets the extra matrix weights input component
  120379. */
  120380. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120381. /**
  120382. * Gets the world input component
  120383. */
  120384. readonly world: NodeMaterialConnectionPoint;
  120385. /**
  120386. * Gets the output component
  120387. */
  120388. readonly output: NodeMaterialConnectionPoint;
  120389. autoConfigure(material: NodeMaterial): void;
  120390. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120391. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120392. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120393. protected _buildBlock(state: NodeMaterialBuildState): this;
  120394. }
  120395. }
  120396. declare module BABYLON {
  120397. /**
  120398. * Block used to add support for instances
  120399. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120400. */
  120401. export class InstancesBlock extends NodeMaterialBlock {
  120402. /**
  120403. * Creates a new InstancesBlock
  120404. * @param name defines the block name
  120405. */
  120406. constructor(name: string);
  120407. /**
  120408. * Gets the current class name
  120409. * @returns the class name
  120410. */
  120411. getClassName(): string;
  120412. /**
  120413. * Gets the first world row input component
  120414. */
  120415. readonly world0: NodeMaterialConnectionPoint;
  120416. /**
  120417. * Gets the second world row input component
  120418. */
  120419. readonly world1: NodeMaterialConnectionPoint;
  120420. /**
  120421. * Gets the third world row input component
  120422. */
  120423. readonly world2: NodeMaterialConnectionPoint;
  120424. /**
  120425. * Gets the forth world row input component
  120426. */
  120427. readonly world3: NodeMaterialConnectionPoint;
  120428. /**
  120429. * Gets the world input component
  120430. */
  120431. readonly world: NodeMaterialConnectionPoint;
  120432. /**
  120433. * Gets the output component
  120434. */
  120435. readonly output: NodeMaterialConnectionPoint;
  120436. autoConfigure(material: NodeMaterial): void;
  120437. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120438. protected _buildBlock(state: NodeMaterialBuildState): this;
  120439. }
  120440. }
  120441. declare module BABYLON {
  120442. /**
  120443. * Block used to add morph targets support to vertex shader
  120444. */
  120445. export class MorphTargetsBlock extends NodeMaterialBlock {
  120446. private _repeatableContentAnchor;
  120447. private _repeatebleContentGenerated;
  120448. /**
  120449. * Create a new MorphTargetsBlock
  120450. * @param name defines the block name
  120451. */
  120452. constructor(name: string);
  120453. /**
  120454. * Gets the current class name
  120455. * @returns the class name
  120456. */
  120457. getClassName(): string;
  120458. /**
  120459. * Gets the position input component
  120460. */
  120461. readonly position: NodeMaterialConnectionPoint;
  120462. /**
  120463. * Gets the normal input component
  120464. */
  120465. readonly normal: NodeMaterialConnectionPoint;
  120466. /**
  120467. * Gets the tangent input component
  120468. */
  120469. readonly tangent: NodeMaterialConnectionPoint;
  120470. /**
  120471. * Gets the tangent input component
  120472. */
  120473. readonly uv: NodeMaterialConnectionPoint;
  120474. /**
  120475. * Gets the position output component
  120476. */
  120477. readonly positionOutput: NodeMaterialConnectionPoint;
  120478. /**
  120479. * Gets the normal output component
  120480. */
  120481. readonly normalOutput: NodeMaterialConnectionPoint;
  120482. /**
  120483. * Gets the tangent output component
  120484. */
  120485. readonly tangentOutput: NodeMaterialConnectionPoint;
  120486. /**
  120487. * Gets the tangent output component
  120488. */
  120489. readonly uvOutput: NodeMaterialConnectionPoint;
  120490. initialize(state: NodeMaterialBuildState): void;
  120491. autoConfigure(material: NodeMaterial): void;
  120492. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120493. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120494. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120495. protected _buildBlock(state: NodeMaterialBuildState): this;
  120496. }
  120497. }
  120498. declare module BABYLON {
  120499. /**
  120500. * Block used to get data information from a light
  120501. */
  120502. export class LightInformationBlock extends NodeMaterialBlock {
  120503. private _lightDataUniformName;
  120504. private _lightColorUniformName;
  120505. private _lightTypeDefineName;
  120506. /**
  120507. * Gets or sets the light associated with this block
  120508. */
  120509. light: Nullable<Light>;
  120510. /**
  120511. * Creates a new LightInformationBlock
  120512. * @param name defines the block name
  120513. */
  120514. constructor(name: string);
  120515. /**
  120516. * Gets the current class name
  120517. * @returns the class name
  120518. */
  120519. getClassName(): string;
  120520. /**
  120521. * Gets the world position input component
  120522. */
  120523. readonly worldPosition: NodeMaterialConnectionPoint;
  120524. /**
  120525. * Gets the direction output component
  120526. */
  120527. readonly direction: NodeMaterialConnectionPoint;
  120528. /**
  120529. * Gets the direction output component
  120530. */
  120531. readonly color: NodeMaterialConnectionPoint;
  120532. /**
  120533. * Gets the direction output component
  120534. */
  120535. readonly intensity: NodeMaterialConnectionPoint;
  120536. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120537. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120538. protected _buildBlock(state: NodeMaterialBuildState): this;
  120539. serialize(): any;
  120540. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120541. }
  120542. }
  120543. declare module BABYLON {
  120544. /**
  120545. * Block used to add image processing support to fragment shader
  120546. */
  120547. export class ImageProcessingBlock extends NodeMaterialBlock {
  120548. /**
  120549. * Create a new ImageProcessingBlock
  120550. * @param name defines the block name
  120551. */
  120552. constructor(name: string);
  120553. /**
  120554. * Gets the current class name
  120555. * @returns the class name
  120556. */
  120557. getClassName(): string;
  120558. /**
  120559. * Gets the color input component
  120560. */
  120561. readonly color: NodeMaterialConnectionPoint;
  120562. /**
  120563. * Gets the output component
  120564. */
  120565. readonly output: NodeMaterialConnectionPoint;
  120566. /**
  120567. * Initialize the block and prepare the context for build
  120568. * @param state defines the state that will be used for the build
  120569. */
  120570. initialize(state: NodeMaterialBuildState): void;
  120571. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120572. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120573. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120574. protected _buildBlock(state: NodeMaterialBuildState): this;
  120575. }
  120576. }
  120577. declare module BABYLON {
  120578. /**
  120579. * Block used to pertub normals based on a normal map
  120580. */
  120581. export class PerturbNormalBlock extends NodeMaterialBlock {
  120582. private _tangentSpaceParameterName;
  120583. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120584. invertX: boolean;
  120585. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120586. invertY: boolean;
  120587. /**
  120588. * Create a new PerturbNormalBlock
  120589. * @param name defines the block name
  120590. */
  120591. constructor(name: string);
  120592. /**
  120593. * Gets the current class name
  120594. * @returns the class name
  120595. */
  120596. getClassName(): string;
  120597. /**
  120598. * Gets the world position input component
  120599. */
  120600. readonly worldPosition: NodeMaterialConnectionPoint;
  120601. /**
  120602. * Gets the world normal input component
  120603. */
  120604. readonly worldNormal: NodeMaterialConnectionPoint;
  120605. /**
  120606. * Gets the uv input component
  120607. */
  120608. readonly uv: NodeMaterialConnectionPoint;
  120609. /**
  120610. * Gets the normal map color input component
  120611. */
  120612. readonly normalMapColor: NodeMaterialConnectionPoint;
  120613. /**
  120614. * Gets the strength input component
  120615. */
  120616. readonly strength: NodeMaterialConnectionPoint;
  120617. /**
  120618. * Gets the output component
  120619. */
  120620. readonly output: NodeMaterialConnectionPoint;
  120621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120622. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120623. autoConfigure(material: NodeMaterial): void;
  120624. protected _buildBlock(state: NodeMaterialBuildState): this;
  120625. protected _dumpPropertiesCode(): string;
  120626. serialize(): any;
  120627. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120628. }
  120629. }
  120630. declare module BABYLON {
  120631. /**
  120632. * Block used to discard a pixel if a value is smaller than a cutoff
  120633. */
  120634. export class DiscardBlock extends NodeMaterialBlock {
  120635. /**
  120636. * Create a new DiscardBlock
  120637. * @param name defines the block name
  120638. */
  120639. constructor(name: string);
  120640. /**
  120641. * Gets the current class name
  120642. * @returns the class name
  120643. */
  120644. getClassName(): string;
  120645. /**
  120646. * Gets the color input component
  120647. */
  120648. readonly value: NodeMaterialConnectionPoint;
  120649. /**
  120650. * Gets the cutoff input component
  120651. */
  120652. readonly cutoff: NodeMaterialConnectionPoint;
  120653. protected _buildBlock(state: NodeMaterialBuildState): this;
  120654. }
  120655. }
  120656. declare module BABYLON {
  120657. /**
  120658. * Block used to add support for scene fog
  120659. */
  120660. export class FogBlock extends NodeMaterialBlock {
  120661. private _fogDistanceName;
  120662. private _fogParameters;
  120663. /**
  120664. * Create a new FogBlock
  120665. * @param name defines the block name
  120666. */
  120667. constructor(name: string);
  120668. /**
  120669. * Gets the current class name
  120670. * @returns the class name
  120671. */
  120672. getClassName(): string;
  120673. /**
  120674. * Gets the world position input component
  120675. */
  120676. readonly worldPosition: NodeMaterialConnectionPoint;
  120677. /**
  120678. * Gets the view input component
  120679. */
  120680. readonly view: NodeMaterialConnectionPoint;
  120681. /**
  120682. * Gets the color input component
  120683. */
  120684. readonly input: NodeMaterialConnectionPoint;
  120685. /**
  120686. * Gets the fog color input component
  120687. */
  120688. readonly fogColor: NodeMaterialConnectionPoint;
  120689. /**
  120690. * Gets the output component
  120691. */
  120692. readonly output: NodeMaterialConnectionPoint;
  120693. autoConfigure(material: NodeMaterial): void;
  120694. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120695. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120696. protected _buildBlock(state: NodeMaterialBuildState): this;
  120697. }
  120698. }
  120699. declare module BABYLON {
  120700. /**
  120701. * Block used to add light in the fragment shader
  120702. */
  120703. export class LightBlock extends NodeMaterialBlock {
  120704. private _lightId;
  120705. /**
  120706. * Gets or sets the light associated with this block
  120707. */
  120708. light: Nullable<Light>;
  120709. /**
  120710. * Create a new LightBlock
  120711. * @param name defines the block name
  120712. */
  120713. constructor(name: string);
  120714. /**
  120715. * Gets the current class name
  120716. * @returns the class name
  120717. */
  120718. getClassName(): string;
  120719. /**
  120720. * Gets the world position input component
  120721. */
  120722. readonly worldPosition: NodeMaterialConnectionPoint;
  120723. /**
  120724. * Gets the world normal input component
  120725. */
  120726. readonly worldNormal: NodeMaterialConnectionPoint;
  120727. /**
  120728. * Gets the camera (or eye) position component
  120729. */
  120730. readonly cameraPosition: NodeMaterialConnectionPoint;
  120731. /**
  120732. * Gets the glossiness component
  120733. */
  120734. readonly glossiness: NodeMaterialConnectionPoint;
  120735. /**
  120736. * Gets the glossinness power component
  120737. */
  120738. readonly glossPower: NodeMaterialConnectionPoint;
  120739. /**
  120740. * Gets the diffuse color component
  120741. */
  120742. readonly diffuseColor: NodeMaterialConnectionPoint;
  120743. /**
  120744. * Gets the specular color component
  120745. */
  120746. readonly specularColor: NodeMaterialConnectionPoint;
  120747. /**
  120748. * Gets the diffuse output component
  120749. */
  120750. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120751. /**
  120752. * Gets the specular output component
  120753. */
  120754. readonly specularOutput: NodeMaterialConnectionPoint;
  120755. autoConfigure(material: NodeMaterial): void;
  120756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120757. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120758. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120759. private _injectVertexCode;
  120760. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120761. serialize(): any;
  120762. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120763. }
  120764. }
  120765. declare module BABYLON {
  120766. /**
  120767. * Block used to multiply 2 values
  120768. */
  120769. export class MultiplyBlock extends NodeMaterialBlock {
  120770. /**
  120771. * Creates a new MultiplyBlock
  120772. * @param name defines the block name
  120773. */
  120774. constructor(name: string);
  120775. /**
  120776. * Gets the current class name
  120777. * @returns the class name
  120778. */
  120779. getClassName(): string;
  120780. /**
  120781. * Gets the left operand input component
  120782. */
  120783. readonly left: NodeMaterialConnectionPoint;
  120784. /**
  120785. * Gets the right operand input component
  120786. */
  120787. readonly right: NodeMaterialConnectionPoint;
  120788. /**
  120789. * Gets the output component
  120790. */
  120791. readonly output: NodeMaterialConnectionPoint;
  120792. protected _buildBlock(state: NodeMaterialBuildState): this;
  120793. }
  120794. }
  120795. declare module BABYLON {
  120796. /**
  120797. * Block used to add 2 vectors
  120798. */
  120799. export class AddBlock extends NodeMaterialBlock {
  120800. /**
  120801. * Creates a new AddBlock
  120802. * @param name defines the block name
  120803. */
  120804. constructor(name: string);
  120805. /**
  120806. * Gets the current class name
  120807. * @returns the class name
  120808. */
  120809. getClassName(): string;
  120810. /**
  120811. * Gets the left operand input component
  120812. */
  120813. readonly left: NodeMaterialConnectionPoint;
  120814. /**
  120815. * Gets the right operand input component
  120816. */
  120817. readonly right: NodeMaterialConnectionPoint;
  120818. /**
  120819. * Gets the output component
  120820. */
  120821. readonly output: NodeMaterialConnectionPoint;
  120822. protected _buildBlock(state: NodeMaterialBuildState): this;
  120823. }
  120824. }
  120825. declare module BABYLON {
  120826. /**
  120827. * Block used to scale a vector by a float
  120828. */
  120829. export class ScaleBlock extends NodeMaterialBlock {
  120830. /**
  120831. * Creates a new ScaleBlock
  120832. * @param name defines the block name
  120833. */
  120834. constructor(name: string);
  120835. /**
  120836. * Gets the current class name
  120837. * @returns the class name
  120838. */
  120839. getClassName(): string;
  120840. /**
  120841. * Gets the input component
  120842. */
  120843. readonly input: NodeMaterialConnectionPoint;
  120844. /**
  120845. * Gets the factor input component
  120846. */
  120847. readonly factor: NodeMaterialConnectionPoint;
  120848. /**
  120849. * Gets the output component
  120850. */
  120851. readonly output: NodeMaterialConnectionPoint;
  120852. protected _buildBlock(state: NodeMaterialBuildState): this;
  120853. }
  120854. }
  120855. declare module BABYLON {
  120856. /**
  120857. * Block used to clamp a float
  120858. */
  120859. export class ClampBlock extends NodeMaterialBlock {
  120860. /** Gets or sets the minimum range */
  120861. minimum: number;
  120862. /** Gets or sets the maximum range */
  120863. maximum: number;
  120864. /**
  120865. * Creates a new ClampBlock
  120866. * @param name defines the block name
  120867. */
  120868. constructor(name: string);
  120869. /**
  120870. * Gets the current class name
  120871. * @returns the class name
  120872. */
  120873. getClassName(): string;
  120874. /**
  120875. * Gets the value input component
  120876. */
  120877. readonly value: NodeMaterialConnectionPoint;
  120878. /**
  120879. * Gets the output component
  120880. */
  120881. readonly output: NodeMaterialConnectionPoint;
  120882. protected _buildBlock(state: NodeMaterialBuildState): this;
  120883. protected _dumpPropertiesCode(): string;
  120884. serialize(): any;
  120885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120886. }
  120887. }
  120888. declare module BABYLON {
  120889. /**
  120890. * Block used to apply a cross product between 2 vectors
  120891. */
  120892. export class CrossBlock extends NodeMaterialBlock {
  120893. /**
  120894. * Creates a new CrossBlock
  120895. * @param name defines the block name
  120896. */
  120897. constructor(name: string);
  120898. /**
  120899. * Gets the current class name
  120900. * @returns the class name
  120901. */
  120902. getClassName(): string;
  120903. /**
  120904. * Gets the left operand input component
  120905. */
  120906. readonly left: NodeMaterialConnectionPoint;
  120907. /**
  120908. * Gets the right operand input component
  120909. */
  120910. readonly right: NodeMaterialConnectionPoint;
  120911. /**
  120912. * Gets the output component
  120913. */
  120914. readonly output: NodeMaterialConnectionPoint;
  120915. protected _buildBlock(state: NodeMaterialBuildState): this;
  120916. }
  120917. }
  120918. declare module BABYLON {
  120919. /**
  120920. * Block used to apply a dot product between 2 vectors
  120921. */
  120922. export class DotBlock extends NodeMaterialBlock {
  120923. /**
  120924. * Creates a new DotBlock
  120925. * @param name defines the block name
  120926. */
  120927. constructor(name: string);
  120928. /**
  120929. * Gets the current class name
  120930. * @returns the class name
  120931. */
  120932. getClassName(): string;
  120933. /**
  120934. * Gets the left operand input component
  120935. */
  120936. readonly left: NodeMaterialConnectionPoint;
  120937. /**
  120938. * Gets the right operand input component
  120939. */
  120940. readonly right: NodeMaterialConnectionPoint;
  120941. /**
  120942. * Gets the output component
  120943. */
  120944. readonly output: NodeMaterialConnectionPoint;
  120945. protected _buildBlock(state: NodeMaterialBuildState): this;
  120946. }
  120947. }
  120948. declare module BABYLON {
  120949. /**
  120950. * Block used to remap a float from a range to a new one
  120951. */
  120952. export class RemapBlock extends NodeMaterialBlock {
  120953. /**
  120954. * Gets or sets the source range
  120955. */
  120956. sourceRange: Vector2;
  120957. /**
  120958. * Gets or sets the target range
  120959. */
  120960. targetRange: Vector2;
  120961. /**
  120962. * Creates a new RemapBlock
  120963. * @param name defines the block name
  120964. */
  120965. constructor(name: string);
  120966. /**
  120967. * Gets the current class name
  120968. * @returns the class name
  120969. */
  120970. getClassName(): string;
  120971. /**
  120972. * Gets the input component
  120973. */
  120974. readonly input: NodeMaterialConnectionPoint;
  120975. /**
  120976. * Gets the source min input component
  120977. */
  120978. readonly sourceMin: NodeMaterialConnectionPoint;
  120979. /**
  120980. * Gets the source max input component
  120981. */
  120982. readonly sourceMax: NodeMaterialConnectionPoint;
  120983. /**
  120984. * Gets the target min input component
  120985. */
  120986. readonly targetMin: NodeMaterialConnectionPoint;
  120987. /**
  120988. * Gets the target max input component
  120989. */
  120990. readonly targetMax: NodeMaterialConnectionPoint;
  120991. /**
  120992. * Gets the output component
  120993. */
  120994. readonly output: NodeMaterialConnectionPoint;
  120995. protected _buildBlock(state: NodeMaterialBuildState): this;
  120996. protected _dumpPropertiesCode(): string;
  120997. serialize(): any;
  120998. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120999. }
  121000. }
  121001. declare module BABYLON {
  121002. /**
  121003. * Block used to normalize a vector
  121004. */
  121005. export class NormalizeBlock extends NodeMaterialBlock {
  121006. /**
  121007. * Creates a new NormalizeBlock
  121008. * @param name defines the block name
  121009. */
  121010. constructor(name: string);
  121011. /**
  121012. * Gets the current class name
  121013. * @returns the class name
  121014. */
  121015. getClassName(): string;
  121016. /**
  121017. * Gets the input component
  121018. */
  121019. readonly input: NodeMaterialConnectionPoint;
  121020. /**
  121021. * Gets the output component
  121022. */
  121023. readonly output: NodeMaterialConnectionPoint;
  121024. protected _buildBlock(state: NodeMaterialBuildState): this;
  121025. }
  121026. }
  121027. declare module BABYLON {
  121028. /**
  121029. * Operations supported by the Trigonometry block
  121030. */
  121031. export enum TrigonometryBlockOperations {
  121032. /** Cos */
  121033. Cos = 0,
  121034. /** Sin */
  121035. Sin = 1,
  121036. /** Abs */
  121037. Abs = 2,
  121038. /** Exp */
  121039. Exp = 3,
  121040. /** Exp2 */
  121041. Exp2 = 4,
  121042. /** Round */
  121043. Round = 5,
  121044. /** Floor */
  121045. Floor = 6,
  121046. /** Ceiling */
  121047. Ceiling = 7,
  121048. /** Square root */
  121049. Sqrt = 8,
  121050. /** Log */
  121051. Log = 9,
  121052. /** Tangent */
  121053. Tan = 10,
  121054. /** Arc tangent */
  121055. ArcTan = 11,
  121056. /** Arc cosinus */
  121057. ArcCos = 12,
  121058. /** Arc sinus */
  121059. ArcSin = 13,
  121060. /** Fraction */
  121061. Fract = 14,
  121062. /** Sign */
  121063. Sign = 15,
  121064. /** To radians (from degrees) */
  121065. Radians = 16,
  121066. /** To degrees (from radians) */
  121067. Degrees = 17
  121068. }
  121069. /**
  121070. * Block used to apply trigonometry operation to floats
  121071. */
  121072. export class TrigonometryBlock extends NodeMaterialBlock {
  121073. /**
  121074. * Gets or sets the operation applied by the block
  121075. */
  121076. operation: TrigonometryBlockOperations;
  121077. /**
  121078. * Creates a new TrigonometryBlock
  121079. * @param name defines the block name
  121080. */
  121081. constructor(name: string);
  121082. /**
  121083. * Gets the current class name
  121084. * @returns the class name
  121085. */
  121086. getClassName(): string;
  121087. /**
  121088. * Gets the input component
  121089. */
  121090. readonly input: NodeMaterialConnectionPoint;
  121091. /**
  121092. * Gets the output component
  121093. */
  121094. readonly output: NodeMaterialConnectionPoint;
  121095. protected _buildBlock(state: NodeMaterialBuildState): this;
  121096. serialize(): any;
  121097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121098. }
  121099. }
  121100. declare module BABYLON {
  121101. /**
  121102. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121103. */
  121104. export class ColorMergerBlock extends NodeMaterialBlock {
  121105. /**
  121106. * Create a new ColorMergerBlock
  121107. * @param name defines the block name
  121108. */
  121109. constructor(name: string);
  121110. /**
  121111. * Gets the current class name
  121112. * @returns the class name
  121113. */
  121114. getClassName(): string;
  121115. /**
  121116. * Gets the r component (input)
  121117. */
  121118. readonly r: NodeMaterialConnectionPoint;
  121119. /**
  121120. * Gets the g component (input)
  121121. */
  121122. readonly g: NodeMaterialConnectionPoint;
  121123. /**
  121124. * Gets the b component (input)
  121125. */
  121126. readonly b: NodeMaterialConnectionPoint;
  121127. /**
  121128. * Gets the a component (input)
  121129. */
  121130. readonly a: NodeMaterialConnectionPoint;
  121131. /**
  121132. * Gets the rgba component (output)
  121133. */
  121134. readonly rgba: NodeMaterialConnectionPoint;
  121135. /**
  121136. * Gets the rgb component (output)
  121137. */
  121138. readonly rgb: NodeMaterialConnectionPoint;
  121139. protected _buildBlock(state: NodeMaterialBuildState): this;
  121140. }
  121141. }
  121142. declare module BABYLON {
  121143. /**
  121144. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121145. */
  121146. export class VectorMergerBlock extends NodeMaterialBlock {
  121147. /**
  121148. * Create a new VectorMergerBlock
  121149. * @param name defines the block name
  121150. */
  121151. constructor(name: string);
  121152. /**
  121153. * Gets the current class name
  121154. * @returns the class name
  121155. */
  121156. getClassName(): string;
  121157. /**
  121158. * Gets the x component (input)
  121159. */
  121160. readonly x: NodeMaterialConnectionPoint;
  121161. /**
  121162. * Gets the y component (input)
  121163. */
  121164. readonly y: NodeMaterialConnectionPoint;
  121165. /**
  121166. * Gets the z component (input)
  121167. */
  121168. readonly z: NodeMaterialConnectionPoint;
  121169. /**
  121170. * Gets the w component (input)
  121171. */
  121172. readonly w: NodeMaterialConnectionPoint;
  121173. /**
  121174. * Gets the xyzw component (output)
  121175. */
  121176. readonly xyzw: NodeMaterialConnectionPoint;
  121177. /**
  121178. * Gets the xyz component (output)
  121179. */
  121180. readonly xyz: NodeMaterialConnectionPoint;
  121181. /**
  121182. * Gets the xy component (output)
  121183. */
  121184. readonly xy: NodeMaterialConnectionPoint;
  121185. protected _buildBlock(state: NodeMaterialBuildState): this;
  121186. }
  121187. }
  121188. declare module BABYLON {
  121189. /**
  121190. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121191. */
  121192. export class ColorSplitterBlock extends NodeMaterialBlock {
  121193. /**
  121194. * Create a new ColorSplitterBlock
  121195. * @param name defines the block name
  121196. */
  121197. constructor(name: string);
  121198. /**
  121199. * Gets the current class name
  121200. * @returns the class name
  121201. */
  121202. getClassName(): string;
  121203. /**
  121204. * Gets the rgba component (input)
  121205. */
  121206. readonly rgba: NodeMaterialConnectionPoint;
  121207. /**
  121208. * Gets the rgb component (input)
  121209. */
  121210. readonly rgbIn: NodeMaterialConnectionPoint;
  121211. /**
  121212. * Gets the rgb component (output)
  121213. */
  121214. readonly rgbOut: NodeMaterialConnectionPoint;
  121215. /**
  121216. * Gets the r component (output)
  121217. */
  121218. readonly r: NodeMaterialConnectionPoint;
  121219. /**
  121220. * Gets the g component (output)
  121221. */
  121222. readonly g: NodeMaterialConnectionPoint;
  121223. /**
  121224. * Gets the b component (output)
  121225. */
  121226. readonly b: NodeMaterialConnectionPoint;
  121227. /**
  121228. * Gets the a component (output)
  121229. */
  121230. readonly a: NodeMaterialConnectionPoint;
  121231. protected _inputRename(name: string): string;
  121232. protected _outputRename(name: string): string;
  121233. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121234. }
  121235. }
  121236. declare module BABYLON {
  121237. /**
  121238. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121239. */
  121240. export class VectorSplitterBlock extends NodeMaterialBlock {
  121241. /**
  121242. * Create a new VectorSplitterBlock
  121243. * @param name defines the block name
  121244. */
  121245. constructor(name: string);
  121246. /**
  121247. * Gets the current class name
  121248. * @returns the class name
  121249. */
  121250. getClassName(): string;
  121251. /**
  121252. * Gets the xyzw component (input)
  121253. */
  121254. readonly xyzw: NodeMaterialConnectionPoint;
  121255. /**
  121256. * Gets the xyz component (input)
  121257. */
  121258. readonly xyzIn: NodeMaterialConnectionPoint;
  121259. /**
  121260. * Gets the xy component (input)
  121261. */
  121262. readonly xyIn: NodeMaterialConnectionPoint;
  121263. /**
  121264. * Gets the xyz component (output)
  121265. */
  121266. readonly xyzOut: NodeMaterialConnectionPoint;
  121267. /**
  121268. * Gets the xy component (output)
  121269. */
  121270. readonly xyOut: NodeMaterialConnectionPoint;
  121271. /**
  121272. * Gets the x component (output)
  121273. */
  121274. readonly x: NodeMaterialConnectionPoint;
  121275. /**
  121276. * Gets the y component (output)
  121277. */
  121278. readonly y: NodeMaterialConnectionPoint;
  121279. /**
  121280. * Gets the z component (output)
  121281. */
  121282. readonly z: NodeMaterialConnectionPoint;
  121283. /**
  121284. * Gets the w component (output)
  121285. */
  121286. readonly w: NodeMaterialConnectionPoint;
  121287. protected _inputRename(name: string): string;
  121288. protected _outputRename(name: string): string;
  121289. protected _buildBlock(state: NodeMaterialBuildState): this;
  121290. }
  121291. }
  121292. declare module BABYLON {
  121293. /**
  121294. * Block used to lerp 2 values
  121295. */
  121296. export class LerpBlock extends NodeMaterialBlock {
  121297. /**
  121298. * Creates a new LerpBlock
  121299. * @param name defines the block name
  121300. */
  121301. constructor(name: string);
  121302. /**
  121303. * Gets the current class name
  121304. * @returns the class name
  121305. */
  121306. getClassName(): string;
  121307. /**
  121308. * Gets the left operand input component
  121309. */
  121310. readonly left: NodeMaterialConnectionPoint;
  121311. /**
  121312. * Gets the right operand input component
  121313. */
  121314. readonly right: NodeMaterialConnectionPoint;
  121315. /**
  121316. * Gets the gradient operand input component
  121317. */
  121318. readonly gradient: NodeMaterialConnectionPoint;
  121319. /**
  121320. * Gets the output component
  121321. */
  121322. readonly output: NodeMaterialConnectionPoint;
  121323. protected _buildBlock(state: NodeMaterialBuildState): this;
  121324. }
  121325. }
  121326. declare module BABYLON {
  121327. /**
  121328. * Block used to divide 2 vectors
  121329. */
  121330. export class DivideBlock extends NodeMaterialBlock {
  121331. /**
  121332. * Creates a new DivideBlock
  121333. * @param name defines the block name
  121334. */
  121335. constructor(name: string);
  121336. /**
  121337. * Gets the current class name
  121338. * @returns the class name
  121339. */
  121340. getClassName(): string;
  121341. /**
  121342. * Gets the left operand input component
  121343. */
  121344. readonly left: NodeMaterialConnectionPoint;
  121345. /**
  121346. * Gets the right operand input component
  121347. */
  121348. readonly right: NodeMaterialConnectionPoint;
  121349. /**
  121350. * Gets the output component
  121351. */
  121352. readonly output: NodeMaterialConnectionPoint;
  121353. protected _buildBlock(state: NodeMaterialBuildState): this;
  121354. }
  121355. }
  121356. declare module BABYLON {
  121357. /**
  121358. * Block used to subtract 2 vectors
  121359. */
  121360. export class SubtractBlock extends NodeMaterialBlock {
  121361. /**
  121362. * Creates a new SubtractBlock
  121363. * @param name defines the block name
  121364. */
  121365. constructor(name: string);
  121366. /**
  121367. * Gets the current class name
  121368. * @returns the class name
  121369. */
  121370. getClassName(): string;
  121371. /**
  121372. * Gets the left operand input component
  121373. */
  121374. readonly left: NodeMaterialConnectionPoint;
  121375. /**
  121376. * Gets the right operand input component
  121377. */
  121378. readonly right: NodeMaterialConnectionPoint;
  121379. /**
  121380. * Gets the output component
  121381. */
  121382. readonly output: NodeMaterialConnectionPoint;
  121383. protected _buildBlock(state: NodeMaterialBuildState): this;
  121384. }
  121385. }
  121386. declare module BABYLON {
  121387. /**
  121388. * Block used to step a value
  121389. */
  121390. export class StepBlock extends NodeMaterialBlock {
  121391. /**
  121392. * Creates a new StepBlock
  121393. * @param name defines the block name
  121394. */
  121395. constructor(name: string);
  121396. /**
  121397. * Gets the current class name
  121398. * @returns the class name
  121399. */
  121400. getClassName(): string;
  121401. /**
  121402. * Gets the value operand input component
  121403. */
  121404. readonly value: NodeMaterialConnectionPoint;
  121405. /**
  121406. * Gets the edge operand input component
  121407. */
  121408. readonly edge: NodeMaterialConnectionPoint;
  121409. /**
  121410. * Gets the output component
  121411. */
  121412. readonly output: NodeMaterialConnectionPoint;
  121413. protected _buildBlock(state: NodeMaterialBuildState): this;
  121414. }
  121415. }
  121416. declare module BABYLON {
  121417. /**
  121418. * Block used to get the opposite (1 - x) of a value
  121419. */
  121420. export class OneMinusBlock extends NodeMaterialBlock {
  121421. /**
  121422. * Creates a new OneMinusBlock
  121423. * @param name defines the block name
  121424. */
  121425. constructor(name: string);
  121426. /**
  121427. * Gets the current class name
  121428. * @returns the class name
  121429. */
  121430. getClassName(): string;
  121431. /**
  121432. * Gets the input component
  121433. */
  121434. readonly input: NodeMaterialConnectionPoint;
  121435. /**
  121436. * Gets the output component
  121437. */
  121438. readonly output: NodeMaterialConnectionPoint;
  121439. protected _buildBlock(state: NodeMaterialBuildState): this;
  121440. }
  121441. }
  121442. declare module BABYLON {
  121443. /**
  121444. * Block used to get the view direction
  121445. */
  121446. export class ViewDirectionBlock extends NodeMaterialBlock {
  121447. /**
  121448. * Creates a new ViewDirectionBlock
  121449. * @param name defines the block name
  121450. */
  121451. constructor(name: string);
  121452. /**
  121453. * Gets the current class name
  121454. * @returns the class name
  121455. */
  121456. getClassName(): string;
  121457. /**
  121458. * Gets the world position component
  121459. */
  121460. readonly worldPosition: NodeMaterialConnectionPoint;
  121461. /**
  121462. * Gets the camera position component
  121463. */
  121464. readonly cameraPosition: NodeMaterialConnectionPoint;
  121465. /**
  121466. * Gets the output component
  121467. */
  121468. readonly output: NodeMaterialConnectionPoint;
  121469. autoConfigure(material: NodeMaterial): void;
  121470. protected _buildBlock(state: NodeMaterialBuildState): this;
  121471. }
  121472. }
  121473. declare module BABYLON {
  121474. /**
  121475. * Block used to compute fresnel value
  121476. */
  121477. export class FresnelBlock extends NodeMaterialBlock {
  121478. /**
  121479. * Create a new FresnelBlock
  121480. * @param name defines the block name
  121481. */
  121482. constructor(name: string);
  121483. /**
  121484. * Gets the current class name
  121485. * @returns the class name
  121486. */
  121487. getClassName(): string;
  121488. /**
  121489. * Gets the world normal input component
  121490. */
  121491. readonly worldNormal: NodeMaterialConnectionPoint;
  121492. /**
  121493. * Gets the view direction input component
  121494. */
  121495. readonly viewDirection: NodeMaterialConnectionPoint;
  121496. /**
  121497. * Gets the bias input component
  121498. */
  121499. readonly bias: NodeMaterialConnectionPoint;
  121500. /**
  121501. * Gets the camera (or eye) position component
  121502. */
  121503. readonly power: NodeMaterialConnectionPoint;
  121504. /**
  121505. * Gets the fresnel output component
  121506. */
  121507. readonly fresnel: NodeMaterialConnectionPoint;
  121508. autoConfigure(material: NodeMaterial): void;
  121509. protected _buildBlock(state: NodeMaterialBuildState): this;
  121510. }
  121511. }
  121512. declare module BABYLON {
  121513. /**
  121514. * Block used to get the max of 2 values
  121515. */
  121516. export class MaxBlock extends NodeMaterialBlock {
  121517. /**
  121518. * Creates a new MaxBlock
  121519. * @param name defines the block name
  121520. */
  121521. constructor(name: string);
  121522. /**
  121523. * Gets the current class name
  121524. * @returns the class name
  121525. */
  121526. getClassName(): string;
  121527. /**
  121528. * Gets the left operand input component
  121529. */
  121530. readonly left: NodeMaterialConnectionPoint;
  121531. /**
  121532. * Gets the right operand input component
  121533. */
  121534. readonly right: NodeMaterialConnectionPoint;
  121535. /**
  121536. * Gets the output component
  121537. */
  121538. readonly output: NodeMaterialConnectionPoint;
  121539. protected _buildBlock(state: NodeMaterialBuildState): this;
  121540. }
  121541. }
  121542. declare module BABYLON {
  121543. /**
  121544. * Block used to get the min of 2 values
  121545. */
  121546. export class MinBlock extends NodeMaterialBlock {
  121547. /**
  121548. * Creates a new MinBlock
  121549. * @param name defines the block name
  121550. */
  121551. constructor(name: string);
  121552. /**
  121553. * Gets the current class name
  121554. * @returns the class name
  121555. */
  121556. getClassName(): string;
  121557. /**
  121558. * Gets the left operand input component
  121559. */
  121560. readonly left: NodeMaterialConnectionPoint;
  121561. /**
  121562. * Gets the right operand input component
  121563. */
  121564. readonly right: NodeMaterialConnectionPoint;
  121565. /**
  121566. * Gets the output component
  121567. */
  121568. readonly output: NodeMaterialConnectionPoint;
  121569. protected _buildBlock(state: NodeMaterialBuildState): this;
  121570. }
  121571. }
  121572. declare module BABYLON {
  121573. /**
  121574. * Block used to get the distance between 2 values
  121575. */
  121576. export class DistanceBlock extends NodeMaterialBlock {
  121577. /**
  121578. * Creates a new DistanceBlock
  121579. * @param name defines the block name
  121580. */
  121581. constructor(name: string);
  121582. /**
  121583. * Gets the current class name
  121584. * @returns the class name
  121585. */
  121586. getClassName(): string;
  121587. /**
  121588. * Gets the left operand input component
  121589. */
  121590. readonly left: NodeMaterialConnectionPoint;
  121591. /**
  121592. * Gets the right operand input component
  121593. */
  121594. readonly right: NodeMaterialConnectionPoint;
  121595. /**
  121596. * Gets the output component
  121597. */
  121598. readonly output: NodeMaterialConnectionPoint;
  121599. protected _buildBlock(state: NodeMaterialBuildState): this;
  121600. }
  121601. }
  121602. declare module BABYLON {
  121603. /**
  121604. * Block used to get the length of a vector
  121605. */
  121606. export class LengthBlock extends NodeMaterialBlock {
  121607. /**
  121608. * Creates a new LengthBlock
  121609. * @param name defines the block name
  121610. */
  121611. constructor(name: string);
  121612. /**
  121613. * Gets the current class name
  121614. * @returns the class name
  121615. */
  121616. getClassName(): string;
  121617. /**
  121618. * Gets the value input component
  121619. */
  121620. readonly value: NodeMaterialConnectionPoint;
  121621. /**
  121622. * Gets the output component
  121623. */
  121624. readonly output: NodeMaterialConnectionPoint;
  121625. protected _buildBlock(state: NodeMaterialBuildState): this;
  121626. }
  121627. }
  121628. declare module BABYLON {
  121629. /**
  121630. * Block used to get negative version of a value (i.e. x * -1)
  121631. */
  121632. export class NegateBlock extends NodeMaterialBlock {
  121633. /**
  121634. * Creates a new NegateBlock
  121635. * @param name defines the block name
  121636. */
  121637. constructor(name: string);
  121638. /**
  121639. * Gets the current class name
  121640. * @returns the class name
  121641. */
  121642. getClassName(): string;
  121643. /**
  121644. * Gets the value input component
  121645. */
  121646. readonly value: NodeMaterialConnectionPoint;
  121647. /**
  121648. * Gets the output component
  121649. */
  121650. readonly output: NodeMaterialConnectionPoint;
  121651. protected _buildBlock(state: NodeMaterialBuildState): this;
  121652. }
  121653. }
  121654. declare module BABYLON {
  121655. /**
  121656. * Block used to get the value of the first parameter raised to the power of the second
  121657. */
  121658. export class PowBlock extends NodeMaterialBlock {
  121659. /**
  121660. * Creates a new PowBlock
  121661. * @param name defines the block name
  121662. */
  121663. constructor(name: string);
  121664. /**
  121665. * Gets the current class name
  121666. * @returns the class name
  121667. */
  121668. getClassName(): string;
  121669. /**
  121670. * Gets the value operand input component
  121671. */
  121672. readonly value: NodeMaterialConnectionPoint;
  121673. /**
  121674. * Gets the power operand input component
  121675. */
  121676. readonly power: NodeMaterialConnectionPoint;
  121677. /**
  121678. * Gets the output component
  121679. */
  121680. readonly output: NodeMaterialConnectionPoint;
  121681. protected _buildBlock(state: NodeMaterialBuildState): this;
  121682. }
  121683. }
  121684. declare module BABYLON {
  121685. /**
  121686. * Block used to get a random number
  121687. */
  121688. export class RandomNumberBlock extends NodeMaterialBlock {
  121689. /**
  121690. * Creates a new RandomNumberBlock
  121691. * @param name defines the block name
  121692. */
  121693. constructor(name: string);
  121694. /**
  121695. * Gets the current class name
  121696. * @returns the class name
  121697. */
  121698. getClassName(): string;
  121699. /**
  121700. * Gets the seed input component
  121701. */
  121702. readonly seed: NodeMaterialConnectionPoint;
  121703. /**
  121704. * Gets the output component
  121705. */
  121706. readonly output: NodeMaterialConnectionPoint;
  121707. protected _buildBlock(state: NodeMaterialBuildState): this;
  121708. }
  121709. }
  121710. declare module BABYLON {
  121711. /**
  121712. * Block used to compute arc tangent of 2 values
  121713. */
  121714. export class ArcTan2Block extends NodeMaterialBlock {
  121715. /**
  121716. * Creates a new ArcTan2Block
  121717. * @param name defines the block name
  121718. */
  121719. constructor(name: string);
  121720. /**
  121721. * Gets the current class name
  121722. * @returns the class name
  121723. */
  121724. getClassName(): string;
  121725. /**
  121726. * Gets the x operand input component
  121727. */
  121728. readonly x: NodeMaterialConnectionPoint;
  121729. /**
  121730. * Gets the y operand input component
  121731. */
  121732. readonly y: NodeMaterialConnectionPoint;
  121733. /**
  121734. * Gets the output component
  121735. */
  121736. readonly output: NodeMaterialConnectionPoint;
  121737. protected _buildBlock(state: NodeMaterialBuildState): this;
  121738. }
  121739. }
  121740. declare module BABYLON {
  121741. /**
  121742. * Block used to smooth step a value
  121743. */
  121744. export class SmoothStepBlock extends NodeMaterialBlock {
  121745. /**
  121746. * Creates a new SmoothStepBlock
  121747. * @param name defines the block name
  121748. */
  121749. constructor(name: string);
  121750. /**
  121751. * Gets the current class name
  121752. * @returns the class name
  121753. */
  121754. getClassName(): string;
  121755. /**
  121756. * Gets the value operand input component
  121757. */
  121758. readonly value: NodeMaterialConnectionPoint;
  121759. /**
  121760. * Gets the first edge operand input component
  121761. */
  121762. readonly edge0: NodeMaterialConnectionPoint;
  121763. /**
  121764. * Gets the second edge operand input component
  121765. */
  121766. readonly edge1: NodeMaterialConnectionPoint;
  121767. /**
  121768. * Gets the output component
  121769. */
  121770. readonly output: NodeMaterialConnectionPoint;
  121771. protected _buildBlock(state: NodeMaterialBuildState): this;
  121772. }
  121773. }
  121774. declare module BABYLON {
  121775. /**
  121776. * Block used to get the reciprocal (1 / x) of a value
  121777. */
  121778. export class ReciprocalBlock extends NodeMaterialBlock {
  121779. /**
  121780. * Creates a new ReciprocalBlock
  121781. * @param name defines the block name
  121782. */
  121783. constructor(name: string);
  121784. /**
  121785. * Gets the current class name
  121786. * @returns the class name
  121787. */
  121788. getClassName(): string;
  121789. /**
  121790. * Gets the input component
  121791. */
  121792. readonly input: NodeMaterialConnectionPoint;
  121793. /**
  121794. * Gets the output component
  121795. */
  121796. readonly output: NodeMaterialConnectionPoint;
  121797. protected _buildBlock(state: NodeMaterialBuildState): this;
  121798. }
  121799. }
  121800. declare module BABYLON {
  121801. /**
  121802. * Block used to replace a color by another one
  121803. */
  121804. export class ReplaceColorBlock extends NodeMaterialBlock {
  121805. /**
  121806. * Creates a new ReplaceColorBlock
  121807. * @param name defines the block name
  121808. */
  121809. constructor(name: string);
  121810. /**
  121811. * Gets the current class name
  121812. * @returns the class name
  121813. */
  121814. getClassName(): string;
  121815. /**
  121816. * Gets the value input component
  121817. */
  121818. readonly value: NodeMaterialConnectionPoint;
  121819. /**
  121820. * Gets the reference input component
  121821. */
  121822. readonly reference: NodeMaterialConnectionPoint;
  121823. /**
  121824. * Gets the distance input component
  121825. */
  121826. readonly distance: NodeMaterialConnectionPoint;
  121827. /**
  121828. * Gets the replacement input component
  121829. */
  121830. readonly replacement: NodeMaterialConnectionPoint;
  121831. /**
  121832. * Gets the output component
  121833. */
  121834. readonly output: NodeMaterialConnectionPoint;
  121835. protected _buildBlock(state: NodeMaterialBuildState): this;
  121836. }
  121837. }
  121838. declare module BABYLON {
  121839. /**
  121840. * Effect Render Options
  121841. */
  121842. export interface IEffectRendererOptions {
  121843. /**
  121844. * Defines the vertices positions.
  121845. */
  121846. positions?: number[];
  121847. /**
  121848. * Defines the indices.
  121849. */
  121850. indices?: number[];
  121851. }
  121852. /**
  121853. * Helper class to render one or more effects
  121854. */
  121855. export class EffectRenderer {
  121856. private engine;
  121857. private static _DefaultOptions;
  121858. private _vertexBuffers;
  121859. private _indexBuffer;
  121860. private _ringBufferIndex;
  121861. private _ringScreenBuffer;
  121862. private _fullscreenViewport;
  121863. private _getNextFrameBuffer;
  121864. /**
  121865. * Creates an effect renderer
  121866. * @param engine the engine to use for rendering
  121867. * @param options defines the options of the effect renderer
  121868. */
  121869. constructor(engine: Engine, options?: IEffectRendererOptions);
  121870. /**
  121871. * Sets the current viewport in normalized coordinates 0-1
  121872. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  121873. */
  121874. setViewport(viewport?: Viewport): void;
  121875. /**
  121876. * Binds the embedded attributes buffer to the effect.
  121877. * @param effect Defines the effect to bind the attributes for
  121878. */
  121879. bindBuffers(effect: Effect): void;
  121880. /**
  121881. * Sets the current effect wrapper to use during draw.
  121882. * The effect needs to be ready before calling this api.
  121883. * This also sets the default full screen position attribute.
  121884. * @param effectWrapper Defines the effect to draw with
  121885. */
  121886. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  121887. /**
  121888. * Draws a full screen quad.
  121889. */
  121890. draw(): void;
  121891. /**
  121892. * renders one or more effects to a specified texture
  121893. * @param effectWrappers list of effects to renderer
  121894. * @param outputTexture texture to draw to, if null it will render to the screen
  121895. */
  121896. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  121897. /**
  121898. * Disposes of the effect renderer
  121899. */
  121900. dispose(): void;
  121901. }
  121902. /**
  121903. * Options to create an EffectWrapper
  121904. */
  121905. interface EffectWrapperCreationOptions {
  121906. /**
  121907. * Engine to use to create the effect
  121908. */
  121909. engine: Engine;
  121910. /**
  121911. * Fragment shader for the effect
  121912. */
  121913. fragmentShader: string;
  121914. /**
  121915. * Vertex shader for the effect
  121916. */
  121917. vertexShader?: string;
  121918. /**
  121919. * Attributes to use in the shader
  121920. */
  121921. attributeNames?: Array<string>;
  121922. /**
  121923. * Uniforms to use in the shader
  121924. */
  121925. uniformNames?: Array<string>;
  121926. /**
  121927. * Texture sampler names to use in the shader
  121928. */
  121929. samplerNames?: Array<string>;
  121930. /**
  121931. * The friendly name of the effect displayed in Spector.
  121932. */
  121933. name?: string;
  121934. }
  121935. /**
  121936. * Wraps an effect to be used for rendering
  121937. */
  121938. export class EffectWrapper {
  121939. /**
  121940. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  121941. */
  121942. onApplyObservable: Observable<{}>;
  121943. /**
  121944. * The underlying effect
  121945. */
  121946. effect: Effect;
  121947. /**
  121948. * Creates an effect to be renderer
  121949. * @param creationOptions options to create the effect
  121950. */
  121951. constructor(creationOptions: EffectWrapperCreationOptions);
  121952. /**
  121953. * Disposes of the effect wrapper
  121954. */
  121955. dispose(): void;
  121956. }
  121957. }
  121958. declare module BABYLON {
  121959. /**
  121960. * Helper class to push actions to a pool of workers.
  121961. */
  121962. export class WorkerPool implements IDisposable {
  121963. private _workerInfos;
  121964. private _pendingActions;
  121965. /**
  121966. * Constructor
  121967. * @param workers Array of workers to use for actions
  121968. */
  121969. constructor(workers: Array<Worker>);
  121970. /**
  121971. * Terminates all workers and clears any pending actions.
  121972. */
  121973. dispose(): void;
  121974. /**
  121975. * Pushes an action to the worker pool. If all the workers are active, the action will be
  121976. * pended until a worker has completed its action.
  121977. * @param action The action to perform. Call onComplete when the action is complete.
  121978. */
  121979. push(action: (worker: Worker, onComplete: () => void) => void): void;
  121980. private _execute;
  121981. }
  121982. }
  121983. declare module BABYLON {
  121984. /**
  121985. * Configuration for Draco compression
  121986. */
  121987. export interface IDracoCompressionConfiguration {
  121988. /**
  121989. * Configuration for the decoder.
  121990. */
  121991. decoder: {
  121992. /**
  121993. * The url to the WebAssembly module.
  121994. */
  121995. wasmUrl?: string;
  121996. /**
  121997. * The url to the WebAssembly binary.
  121998. */
  121999. wasmBinaryUrl?: string;
  122000. /**
  122001. * The url to the fallback JavaScript module.
  122002. */
  122003. fallbackUrl?: string;
  122004. };
  122005. }
  122006. /**
  122007. * Draco compression (https://google.github.io/draco/)
  122008. *
  122009. * This class wraps the Draco module.
  122010. *
  122011. * **Encoder**
  122012. *
  122013. * The encoder is not currently implemented.
  122014. *
  122015. * **Decoder**
  122016. *
  122017. * 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.
  122018. *
  122019. * To update the configuration, use the following code:
  122020. * ```javascript
  122021. * DracoCompression.Configuration = {
  122022. * decoder: {
  122023. * wasmUrl: "<url to the WebAssembly library>",
  122024. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122025. * fallbackUrl: "<url to the fallback JavaScript library>",
  122026. * }
  122027. * };
  122028. * ```
  122029. *
  122030. * 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.
  122031. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122032. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122033. *
  122034. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122035. * ```javascript
  122036. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122037. * ```
  122038. *
  122039. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122040. */
  122041. export class DracoCompression implements IDisposable {
  122042. private _workerPoolPromise?;
  122043. private _decoderModulePromise?;
  122044. /**
  122045. * The configuration. Defaults to the following urls:
  122046. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122047. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122048. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122049. */
  122050. static Configuration: IDracoCompressionConfiguration;
  122051. /**
  122052. * Returns true if the decoder configuration is available.
  122053. */
  122054. static readonly DecoderAvailable: boolean;
  122055. /**
  122056. * Default number of workers to create when creating the draco compression object.
  122057. */
  122058. static DefaultNumWorkers: number;
  122059. private static GetDefaultNumWorkers;
  122060. private static _Default;
  122061. /**
  122062. * Default instance for the draco compression object.
  122063. */
  122064. static readonly Default: DracoCompression;
  122065. /**
  122066. * Constructor
  122067. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122068. */
  122069. constructor(numWorkers?: number);
  122070. /**
  122071. * Stop all async operations and release resources.
  122072. */
  122073. dispose(): void;
  122074. /**
  122075. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122076. * @returns a promise that resolves when ready
  122077. */
  122078. whenReadyAsync(): Promise<void>;
  122079. /**
  122080. * Decode Draco compressed mesh data to vertex data.
  122081. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122082. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122083. * @returns A promise that resolves with the decoded vertex data
  122084. */
  122085. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122086. [kind: string]: number;
  122087. }): Promise<VertexData>;
  122088. }
  122089. }
  122090. declare module BABYLON {
  122091. /**
  122092. * Class for building Constructive Solid Geometry
  122093. */
  122094. export class CSG {
  122095. private polygons;
  122096. /**
  122097. * The world matrix
  122098. */
  122099. matrix: Matrix;
  122100. /**
  122101. * Stores the position
  122102. */
  122103. position: Vector3;
  122104. /**
  122105. * Stores the rotation
  122106. */
  122107. rotation: Vector3;
  122108. /**
  122109. * Stores the rotation quaternion
  122110. */
  122111. rotationQuaternion: Nullable<Quaternion>;
  122112. /**
  122113. * Stores the scaling vector
  122114. */
  122115. scaling: Vector3;
  122116. /**
  122117. * Convert the Mesh to CSG
  122118. * @param mesh The Mesh to convert to CSG
  122119. * @returns A new CSG from the Mesh
  122120. */
  122121. static FromMesh(mesh: Mesh): CSG;
  122122. /**
  122123. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122124. * @param polygons Polygons used to construct a CSG solid
  122125. */
  122126. private static FromPolygons;
  122127. /**
  122128. * Clones, or makes a deep copy, of the CSG
  122129. * @returns A new CSG
  122130. */
  122131. clone(): CSG;
  122132. /**
  122133. * Unions this CSG with another CSG
  122134. * @param csg The CSG to union against this CSG
  122135. * @returns The unioned CSG
  122136. */
  122137. union(csg: CSG): CSG;
  122138. /**
  122139. * Unions this CSG with another CSG in place
  122140. * @param csg The CSG to union against this CSG
  122141. */
  122142. unionInPlace(csg: CSG): void;
  122143. /**
  122144. * Subtracts this CSG with another CSG
  122145. * @param csg The CSG to subtract against this CSG
  122146. * @returns A new CSG
  122147. */
  122148. subtract(csg: CSG): CSG;
  122149. /**
  122150. * Subtracts this CSG with another CSG in place
  122151. * @param csg The CSG to subtact against this CSG
  122152. */
  122153. subtractInPlace(csg: CSG): void;
  122154. /**
  122155. * Intersect this CSG with another CSG
  122156. * @param csg The CSG to intersect against this CSG
  122157. * @returns A new CSG
  122158. */
  122159. intersect(csg: CSG): CSG;
  122160. /**
  122161. * Intersects this CSG with another CSG in place
  122162. * @param csg The CSG to intersect against this CSG
  122163. */
  122164. intersectInPlace(csg: CSG): void;
  122165. /**
  122166. * Return a new CSG solid with solid and empty space switched. This solid is
  122167. * not modified.
  122168. * @returns A new CSG solid with solid and empty space switched
  122169. */
  122170. inverse(): CSG;
  122171. /**
  122172. * Inverses the CSG in place
  122173. */
  122174. inverseInPlace(): void;
  122175. /**
  122176. * This is used to keep meshes transformations so they can be restored
  122177. * when we build back a Babylon Mesh
  122178. * NB : All CSG operations are performed in world coordinates
  122179. * @param csg The CSG to copy the transform attributes from
  122180. * @returns This CSG
  122181. */
  122182. copyTransformAttributes(csg: CSG): CSG;
  122183. /**
  122184. * Build Raw mesh from CSG
  122185. * Coordinates here are in world space
  122186. * @param name The name of the mesh geometry
  122187. * @param scene The Scene
  122188. * @param keepSubMeshes Specifies if the submeshes should be kept
  122189. * @returns A new Mesh
  122190. */
  122191. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122192. /**
  122193. * Build Mesh from CSG taking material and transforms into account
  122194. * @param name The name of the Mesh
  122195. * @param material The material of the Mesh
  122196. * @param scene The Scene
  122197. * @param keepSubMeshes Specifies if submeshes should be kept
  122198. * @returns The new Mesh
  122199. */
  122200. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122201. }
  122202. }
  122203. declare module BABYLON {
  122204. /**
  122205. * Class used to create a trail following a mesh
  122206. */
  122207. export class TrailMesh extends Mesh {
  122208. private _generator;
  122209. private _autoStart;
  122210. private _running;
  122211. private _diameter;
  122212. private _length;
  122213. private _sectionPolygonPointsCount;
  122214. private _sectionVectors;
  122215. private _sectionNormalVectors;
  122216. private _beforeRenderObserver;
  122217. /**
  122218. * @constructor
  122219. * @param name The value used by scene.getMeshByName() to do a lookup.
  122220. * @param generator The mesh to generate a trail.
  122221. * @param scene The scene to add this mesh to.
  122222. * @param diameter Diameter of trailing mesh. Default is 1.
  122223. * @param length Length of trailing mesh. Default is 60.
  122224. * @param autoStart Automatically start trailing mesh. Default true.
  122225. */
  122226. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122227. /**
  122228. * "TrailMesh"
  122229. * @returns "TrailMesh"
  122230. */
  122231. getClassName(): string;
  122232. private _createMesh;
  122233. /**
  122234. * Start trailing mesh.
  122235. */
  122236. start(): void;
  122237. /**
  122238. * Stop trailing mesh.
  122239. */
  122240. stop(): void;
  122241. /**
  122242. * Update trailing mesh geometry.
  122243. */
  122244. update(): void;
  122245. /**
  122246. * Returns a new TrailMesh object.
  122247. * @param name is a string, the name given to the new mesh
  122248. * @param newGenerator use new generator object for cloned trail mesh
  122249. * @returns a new mesh
  122250. */
  122251. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122252. /**
  122253. * Serializes this trail mesh
  122254. * @param serializationObject object to write serialization to
  122255. */
  122256. serialize(serializationObject: any): void;
  122257. /**
  122258. * Parses a serialized trail mesh
  122259. * @param parsedMesh the serialized mesh
  122260. * @param scene the scene to create the trail mesh in
  122261. * @returns the created trail mesh
  122262. */
  122263. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122264. }
  122265. }
  122266. declare module BABYLON {
  122267. /**
  122268. * Class containing static functions to help procedurally build meshes
  122269. */
  122270. export class TiledBoxBuilder {
  122271. /**
  122272. * Creates a box mesh
  122273. * 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)
  122274. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122276. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122278. * @param name defines the name of the mesh
  122279. * @param options defines the options used to create the mesh
  122280. * @param scene defines the hosting scene
  122281. * @returns the box mesh
  122282. */
  122283. static CreateTiledBox(name: string, options: {
  122284. pattern?: number;
  122285. width?: number;
  122286. height?: number;
  122287. depth?: number;
  122288. tileSize?: number;
  122289. tileWidth?: number;
  122290. tileHeight?: number;
  122291. alignHorizontal?: number;
  122292. alignVertical?: number;
  122293. faceUV?: Vector4[];
  122294. faceColors?: Color4[];
  122295. sideOrientation?: number;
  122296. updatable?: boolean;
  122297. }, scene?: Nullable<Scene>): Mesh;
  122298. }
  122299. }
  122300. declare module BABYLON {
  122301. /**
  122302. * Class containing static functions to help procedurally build meshes
  122303. */
  122304. export class TorusKnotBuilder {
  122305. /**
  122306. * Creates a torus knot mesh
  122307. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122308. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122309. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122310. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122314. * @param name defines the name of the mesh
  122315. * @param options defines the options used to create the mesh
  122316. * @param scene defines the hosting scene
  122317. * @returns the torus knot mesh
  122318. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122319. */
  122320. static CreateTorusKnot(name: string, options: {
  122321. radius?: number;
  122322. tube?: number;
  122323. radialSegments?: number;
  122324. tubularSegments?: number;
  122325. p?: number;
  122326. q?: number;
  122327. updatable?: boolean;
  122328. sideOrientation?: number;
  122329. frontUVs?: Vector4;
  122330. backUVs?: Vector4;
  122331. }, scene: any): Mesh;
  122332. }
  122333. }
  122334. declare module BABYLON {
  122335. /**
  122336. * Polygon
  122337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122338. */
  122339. export class Polygon {
  122340. /**
  122341. * Creates a rectangle
  122342. * @param xmin bottom X coord
  122343. * @param ymin bottom Y coord
  122344. * @param xmax top X coord
  122345. * @param ymax top Y coord
  122346. * @returns points that make the resulting rectation
  122347. */
  122348. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122349. /**
  122350. * Creates a circle
  122351. * @param radius radius of circle
  122352. * @param cx scale in x
  122353. * @param cy scale in y
  122354. * @param numberOfSides number of sides that make up the circle
  122355. * @returns points that make the resulting circle
  122356. */
  122357. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122358. /**
  122359. * Creates a polygon from input string
  122360. * @param input Input polygon data
  122361. * @returns the parsed points
  122362. */
  122363. static Parse(input: string): Vector2[];
  122364. /**
  122365. * Starts building a polygon from x and y coordinates
  122366. * @param x x coordinate
  122367. * @param y y coordinate
  122368. * @returns the started path2
  122369. */
  122370. static StartingAt(x: number, y: number): Path2;
  122371. }
  122372. /**
  122373. * Builds a polygon
  122374. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122375. */
  122376. export class PolygonMeshBuilder {
  122377. private _points;
  122378. private _outlinepoints;
  122379. private _holes;
  122380. private _name;
  122381. private _scene;
  122382. private _epoints;
  122383. private _eholes;
  122384. private _addToepoint;
  122385. /**
  122386. * Babylon reference to the earcut plugin.
  122387. */
  122388. bjsEarcut: any;
  122389. /**
  122390. * Creates a PolygonMeshBuilder
  122391. * @param name name of the builder
  122392. * @param contours Path of the polygon
  122393. * @param scene scene to add to when creating the mesh
  122394. * @param earcutInjection can be used to inject your own earcut reference
  122395. */
  122396. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122397. /**
  122398. * Adds a whole within the polygon
  122399. * @param hole Array of points defining the hole
  122400. * @returns this
  122401. */
  122402. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122403. /**
  122404. * Creates the polygon
  122405. * @param updatable If the mesh should be updatable
  122406. * @param depth The depth of the mesh created
  122407. * @returns the created mesh
  122408. */
  122409. build(updatable?: boolean, depth?: number): Mesh;
  122410. /**
  122411. * Creates the polygon
  122412. * @param depth The depth of the mesh created
  122413. * @returns the created VertexData
  122414. */
  122415. buildVertexData(depth?: number): VertexData;
  122416. /**
  122417. * Adds a side to the polygon
  122418. * @param positions points that make the polygon
  122419. * @param normals normals of the polygon
  122420. * @param uvs uvs of the polygon
  122421. * @param indices indices of the polygon
  122422. * @param bounds bounds of the polygon
  122423. * @param points points of the polygon
  122424. * @param depth depth of the polygon
  122425. * @param flip flip of the polygon
  122426. */
  122427. private addSide;
  122428. }
  122429. }
  122430. declare module BABYLON {
  122431. /**
  122432. * Class containing static functions to help procedurally build meshes
  122433. */
  122434. export class PolygonBuilder {
  122435. /**
  122436. * Creates a polygon mesh
  122437. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122438. * * 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
  122439. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122442. * * Remember you can only change the shape positions, not their number when updating a polygon
  122443. * @param name defines the name of the mesh
  122444. * @param options defines the options used to create the mesh
  122445. * @param scene defines the hosting scene
  122446. * @param earcutInjection can be used to inject your own earcut reference
  122447. * @returns the polygon mesh
  122448. */
  122449. static CreatePolygon(name: string, options: {
  122450. shape: Vector3[];
  122451. holes?: Vector3[][];
  122452. depth?: number;
  122453. faceUV?: Vector4[];
  122454. faceColors?: Color4[];
  122455. updatable?: boolean;
  122456. sideOrientation?: number;
  122457. frontUVs?: Vector4;
  122458. backUVs?: Vector4;
  122459. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122460. /**
  122461. * Creates an extruded polygon mesh, with depth in the Y direction.
  122462. * * 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)
  122463. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122464. * @param name defines the name of the mesh
  122465. * @param options defines the options used to create the mesh
  122466. * @param scene defines the hosting scene
  122467. * @param earcutInjection can be used to inject your own earcut reference
  122468. * @returns the polygon mesh
  122469. */
  122470. static ExtrudePolygon(name: string, options: {
  122471. shape: Vector3[];
  122472. holes?: Vector3[][];
  122473. depth?: number;
  122474. faceUV?: Vector4[];
  122475. faceColors?: Color4[];
  122476. updatable?: boolean;
  122477. sideOrientation?: number;
  122478. frontUVs?: Vector4;
  122479. backUVs?: Vector4;
  122480. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122481. }
  122482. }
  122483. declare module BABYLON {
  122484. /**
  122485. * Class containing static functions to help procedurally build meshes
  122486. */
  122487. export class LatheBuilder {
  122488. /**
  122489. * Creates lathe mesh.
  122490. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122491. * * 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
  122492. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122493. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122494. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122495. * * 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
  122496. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122497. * * 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
  122498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122499. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122500. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122502. * @param name defines the name of the mesh
  122503. * @param options defines the options used to create the mesh
  122504. * @param scene defines the hosting scene
  122505. * @returns the lathe mesh
  122506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122507. */
  122508. static CreateLathe(name: string, options: {
  122509. shape: Vector3[];
  122510. radius?: number;
  122511. tessellation?: number;
  122512. clip?: number;
  122513. arc?: number;
  122514. closed?: boolean;
  122515. updatable?: boolean;
  122516. sideOrientation?: number;
  122517. frontUVs?: Vector4;
  122518. backUVs?: Vector4;
  122519. cap?: number;
  122520. invertUV?: boolean;
  122521. }, scene?: Nullable<Scene>): Mesh;
  122522. }
  122523. }
  122524. declare module BABYLON {
  122525. /**
  122526. * Class containing static functions to help procedurally build meshes
  122527. */
  122528. export class TiledPlaneBuilder {
  122529. /**
  122530. * Creates a tiled plane mesh
  122531. * * The parameter `pattern` will, depending on value, do nothing or
  122532. * * * flip (reflect about central vertical) alternate tiles across and up
  122533. * * * flip every tile on alternate rows
  122534. * * * rotate (180 degs) alternate tiles across and up
  122535. * * * rotate every tile on alternate rows
  122536. * * * flip and rotate alternate tiles across and up
  122537. * * * flip and rotate every tile on alternate rows
  122538. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122539. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122542. * * 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)
  122543. * * 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)
  122544. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122545. * @param name defines the name of the mesh
  122546. * @param options defines the options used to create the mesh
  122547. * @param scene defines the hosting scene
  122548. * @returns the box mesh
  122549. */
  122550. static CreateTiledPlane(name: string, options: {
  122551. pattern?: number;
  122552. tileSize?: number;
  122553. tileWidth?: number;
  122554. tileHeight?: number;
  122555. size?: number;
  122556. width?: number;
  122557. height?: number;
  122558. alignHorizontal?: number;
  122559. alignVertical?: number;
  122560. sideOrientation?: number;
  122561. frontUVs?: Vector4;
  122562. backUVs?: Vector4;
  122563. updatable?: boolean;
  122564. }, scene?: Nullable<Scene>): Mesh;
  122565. }
  122566. }
  122567. declare module BABYLON {
  122568. /**
  122569. * Class containing static functions to help procedurally build meshes
  122570. */
  122571. export class TubeBuilder {
  122572. /**
  122573. * Creates a tube mesh.
  122574. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122575. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122576. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122577. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122578. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122579. * * 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)
  122580. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122581. * * 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
  122582. * * 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
  122583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122585. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122587. * @param name defines the name of the mesh
  122588. * @param options defines the options used to create the mesh
  122589. * @param scene defines the hosting scene
  122590. * @returns the tube mesh
  122591. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122592. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122593. */
  122594. static CreateTube(name: string, options: {
  122595. path: Vector3[];
  122596. radius?: number;
  122597. tessellation?: number;
  122598. radiusFunction?: {
  122599. (i: number, distance: number): number;
  122600. };
  122601. cap?: number;
  122602. arc?: number;
  122603. updatable?: boolean;
  122604. sideOrientation?: number;
  122605. frontUVs?: Vector4;
  122606. backUVs?: Vector4;
  122607. instance?: Mesh;
  122608. invertUV?: boolean;
  122609. }, scene?: Nullable<Scene>): Mesh;
  122610. }
  122611. }
  122612. declare module BABYLON {
  122613. /**
  122614. * Class containing static functions to help procedurally build meshes
  122615. */
  122616. export class IcoSphereBuilder {
  122617. /**
  122618. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122619. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122620. * * 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`)
  122621. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122622. * * 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
  122623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122626. * @param name defines the name of the mesh
  122627. * @param options defines the options used to create the mesh
  122628. * @param scene defines the hosting scene
  122629. * @returns the icosahedron mesh
  122630. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122631. */
  122632. static CreateIcoSphere(name: string, options: {
  122633. radius?: number;
  122634. radiusX?: number;
  122635. radiusY?: number;
  122636. radiusZ?: number;
  122637. flat?: boolean;
  122638. subdivisions?: number;
  122639. sideOrientation?: number;
  122640. frontUVs?: Vector4;
  122641. backUVs?: Vector4;
  122642. updatable?: boolean;
  122643. }, scene?: Nullable<Scene>): Mesh;
  122644. }
  122645. }
  122646. declare module BABYLON {
  122647. /**
  122648. * Class containing static functions to help procedurally build meshes
  122649. */
  122650. export class DecalBuilder {
  122651. /**
  122652. * Creates a decal mesh.
  122653. * 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
  122654. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122655. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122656. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122657. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122658. * @param name defines the name of the mesh
  122659. * @param sourceMesh defines the mesh where the decal must be applied
  122660. * @param options defines the options used to create the mesh
  122661. * @param scene defines the hosting scene
  122662. * @returns the decal mesh
  122663. * @see https://doc.babylonjs.com/how_to/decals
  122664. */
  122665. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122666. position?: Vector3;
  122667. normal?: Vector3;
  122668. size?: Vector3;
  122669. angle?: number;
  122670. }): Mesh;
  122671. }
  122672. }
  122673. declare module BABYLON {
  122674. /**
  122675. * Class containing static functions to help procedurally build meshes
  122676. */
  122677. export class MeshBuilder {
  122678. /**
  122679. * Creates a box mesh
  122680. * * The parameter `size` sets the size (float) of each box side (default 1)
  122681. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122682. * * 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)
  122683. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122687. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122688. * @param name defines the name of the mesh
  122689. * @param options defines the options used to create the mesh
  122690. * @param scene defines the hosting scene
  122691. * @returns the box mesh
  122692. */
  122693. static CreateBox(name: string, options: {
  122694. size?: number;
  122695. width?: number;
  122696. height?: number;
  122697. depth?: number;
  122698. faceUV?: Vector4[];
  122699. faceColors?: Color4[];
  122700. sideOrientation?: number;
  122701. frontUVs?: Vector4;
  122702. backUVs?: Vector4;
  122703. updatable?: boolean;
  122704. }, scene?: Nullable<Scene>): Mesh;
  122705. /**
  122706. * Creates a tiled box mesh
  122707. * * faceTiles sets the pattern, tile size and number of tiles for a face
  122708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122709. * @param name defines the name of the mesh
  122710. * @param options defines the options used to create the mesh
  122711. * @param scene defines the hosting scene
  122712. * @returns the tiled box mesh
  122713. */
  122714. static CreateTiledBox(name: string, options: {
  122715. pattern?: number;
  122716. size?: number;
  122717. width?: number;
  122718. height?: number;
  122719. depth: number;
  122720. tileSize?: number;
  122721. tileWidth?: number;
  122722. tileHeight?: number;
  122723. faceUV?: Vector4[];
  122724. faceColors?: Color4[];
  122725. alignHorizontal?: number;
  122726. alignVertical?: number;
  122727. sideOrientation?: number;
  122728. updatable?: boolean;
  122729. }, scene?: Nullable<Scene>): Mesh;
  122730. /**
  122731. * Creates a sphere mesh
  122732. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  122733. * * 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`)
  122734. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  122735. * * 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
  122736. * * 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)
  122737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122740. * @param name defines the name of the mesh
  122741. * @param options defines the options used to create the mesh
  122742. * @param scene defines the hosting scene
  122743. * @returns the sphere mesh
  122744. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  122745. */
  122746. static CreateSphere(name: string, options: {
  122747. segments?: number;
  122748. diameter?: number;
  122749. diameterX?: number;
  122750. diameterY?: number;
  122751. diameterZ?: number;
  122752. arc?: number;
  122753. slice?: number;
  122754. sideOrientation?: number;
  122755. frontUVs?: Vector4;
  122756. backUVs?: Vector4;
  122757. updatable?: boolean;
  122758. }, scene?: Nullable<Scene>): Mesh;
  122759. /**
  122760. * Creates a plane polygonal mesh. By default, this is a disc
  122761. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  122762. * * 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
  122763. * * 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
  122764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122767. * @param name defines the name of the mesh
  122768. * @param options defines the options used to create the mesh
  122769. * @param scene defines the hosting scene
  122770. * @returns the plane polygonal mesh
  122771. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  122772. */
  122773. static CreateDisc(name: string, options: {
  122774. radius?: number;
  122775. tessellation?: number;
  122776. arc?: number;
  122777. updatable?: boolean;
  122778. sideOrientation?: number;
  122779. frontUVs?: Vector4;
  122780. backUVs?: Vector4;
  122781. }, scene?: Nullable<Scene>): Mesh;
  122782. /**
  122783. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122784. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122785. * * 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`)
  122786. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122787. * * 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
  122788. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122789. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122791. * @param name defines the name of the mesh
  122792. * @param options defines the options used to create the mesh
  122793. * @param scene defines the hosting scene
  122794. * @returns the icosahedron mesh
  122795. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122796. */
  122797. static CreateIcoSphere(name: string, options: {
  122798. radius?: number;
  122799. radiusX?: number;
  122800. radiusY?: number;
  122801. radiusZ?: number;
  122802. flat?: boolean;
  122803. subdivisions?: number;
  122804. sideOrientation?: number;
  122805. frontUVs?: Vector4;
  122806. backUVs?: Vector4;
  122807. updatable?: boolean;
  122808. }, scene?: Nullable<Scene>): Mesh;
  122809. /**
  122810. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122811. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  122812. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  122813. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  122814. * * 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
  122815. * * 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
  122816. * * 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
  122817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122820. * * 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
  122821. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  122822. * * 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
  122823. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  122824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122825. * @param name defines the name of the mesh
  122826. * @param options defines the options used to create the mesh
  122827. * @param scene defines the hosting scene
  122828. * @returns the ribbon mesh
  122829. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  122830. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122831. */
  122832. static CreateRibbon(name: string, options: {
  122833. pathArray: Vector3[][];
  122834. closeArray?: boolean;
  122835. closePath?: boolean;
  122836. offset?: number;
  122837. updatable?: boolean;
  122838. sideOrientation?: number;
  122839. frontUVs?: Vector4;
  122840. backUVs?: Vector4;
  122841. instance?: Mesh;
  122842. invertUV?: boolean;
  122843. uvs?: Vector2[];
  122844. colors?: Color4[];
  122845. }, scene?: Nullable<Scene>): Mesh;
  122846. /**
  122847. * Creates a cylinder or a cone mesh
  122848. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  122849. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  122850. * * 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.
  122851. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  122852. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  122853. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  122854. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  122855. * * 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).
  122856. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  122857. * * 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).
  122858. * * 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
  122859. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  122860. * * 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
  122861. * * 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.
  122862. * * If `enclose` is false, a ring surface is one element.
  122863. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  122864. * * 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
  122865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122868. * @param name defines the name of the mesh
  122869. * @param options defines the options used to create the mesh
  122870. * @param scene defines the hosting scene
  122871. * @returns the cylinder mesh
  122872. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  122873. */
  122874. static CreateCylinder(name: string, options: {
  122875. height?: number;
  122876. diameterTop?: number;
  122877. diameterBottom?: number;
  122878. diameter?: number;
  122879. tessellation?: number;
  122880. subdivisions?: number;
  122881. arc?: number;
  122882. faceColors?: Color4[];
  122883. faceUV?: Vector4[];
  122884. updatable?: boolean;
  122885. hasRings?: boolean;
  122886. enclose?: boolean;
  122887. cap?: number;
  122888. sideOrientation?: number;
  122889. frontUVs?: Vector4;
  122890. backUVs?: Vector4;
  122891. }, scene?: Nullable<Scene>): Mesh;
  122892. /**
  122893. * Creates a torus mesh
  122894. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  122895. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  122896. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  122897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122900. * @param name defines the name of the mesh
  122901. * @param options defines the options used to create the mesh
  122902. * @param scene defines the hosting scene
  122903. * @returns the torus mesh
  122904. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  122905. */
  122906. static CreateTorus(name: string, options: {
  122907. diameter?: number;
  122908. thickness?: number;
  122909. tessellation?: number;
  122910. updatable?: boolean;
  122911. sideOrientation?: number;
  122912. frontUVs?: Vector4;
  122913. backUVs?: Vector4;
  122914. }, scene?: Nullable<Scene>): Mesh;
  122915. /**
  122916. * Creates a torus knot mesh
  122917. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122918. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122919. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122920. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122921. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122924. * @param name defines the name of the mesh
  122925. * @param options defines the options used to create the mesh
  122926. * @param scene defines the hosting scene
  122927. * @returns the torus knot mesh
  122928. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122929. */
  122930. static CreateTorusKnot(name: string, options: {
  122931. radius?: number;
  122932. tube?: number;
  122933. radialSegments?: number;
  122934. tubularSegments?: number;
  122935. p?: number;
  122936. q?: number;
  122937. updatable?: boolean;
  122938. sideOrientation?: number;
  122939. frontUVs?: Vector4;
  122940. backUVs?: Vector4;
  122941. }, scene?: Nullable<Scene>): Mesh;
  122942. /**
  122943. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  122944. * * 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
  122945. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  122946. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  122947. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  122948. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  122949. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  122950. * * 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
  122951. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  122952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  122954. * @param name defines the name of the new line system
  122955. * @param options defines the options used to create the line system
  122956. * @param scene defines the hosting scene
  122957. * @returns a new line system mesh
  122958. */
  122959. static CreateLineSystem(name: string, options: {
  122960. lines: Vector3[][];
  122961. updatable?: boolean;
  122962. instance?: Nullable<LinesMesh>;
  122963. colors?: Nullable<Color4[][]>;
  122964. useVertexAlpha?: boolean;
  122965. }, scene: Nullable<Scene>): LinesMesh;
  122966. /**
  122967. * Creates a line mesh
  122968. * 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
  122969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122970. * * The parameter `points` is an array successive Vector3
  122971. * * 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
  122972. * * The optional parameter `colors` is an array of successive Color4, one per line point
  122973. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  122974. * * When updating an instance, remember that only point positions can change, not the number of points
  122975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  122977. * @param name defines the name of the new line system
  122978. * @param options defines the options used to create the line system
  122979. * @param scene defines the hosting scene
  122980. * @returns a new line mesh
  122981. */
  122982. static CreateLines(name: string, options: {
  122983. points: Vector3[];
  122984. updatable?: boolean;
  122985. instance?: Nullable<LinesMesh>;
  122986. colors?: Color4[];
  122987. useVertexAlpha?: boolean;
  122988. }, scene?: Nullable<Scene>): LinesMesh;
  122989. /**
  122990. * Creates a dashed line mesh
  122991. * * 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
  122992. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  122993. * * The parameter `points` is an array successive Vector3
  122994. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  122995. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  122996. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  122997. * * 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
  122998. * * When updating an instance, remember that only point positions can change, not the number of points
  122999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123000. * @param name defines the name of the mesh
  123001. * @param options defines the options used to create the mesh
  123002. * @param scene defines the hosting scene
  123003. * @returns the dashed line mesh
  123004. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123005. */
  123006. static CreateDashedLines(name: string, options: {
  123007. points: Vector3[];
  123008. dashSize?: number;
  123009. gapSize?: number;
  123010. dashNb?: number;
  123011. updatable?: boolean;
  123012. instance?: LinesMesh;
  123013. }, scene?: Nullable<Scene>): LinesMesh;
  123014. /**
  123015. * 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.
  123016. * * 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.
  123017. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123018. * * 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.
  123019. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123020. * * 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
  123021. * * 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
  123022. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123024. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123025. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123027. * @param name defines the name of the mesh
  123028. * @param options defines the options used to create the mesh
  123029. * @param scene defines the hosting scene
  123030. * @returns the extruded shape mesh
  123031. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123032. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123033. */
  123034. static ExtrudeShape(name: string, options: {
  123035. shape: Vector3[];
  123036. path: Vector3[];
  123037. scale?: number;
  123038. rotation?: number;
  123039. cap?: number;
  123040. updatable?: boolean;
  123041. sideOrientation?: number;
  123042. frontUVs?: Vector4;
  123043. backUVs?: Vector4;
  123044. instance?: Mesh;
  123045. invertUV?: boolean;
  123046. }, scene?: Nullable<Scene>): Mesh;
  123047. /**
  123048. * Creates an custom extruded shape mesh.
  123049. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123050. * * 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.
  123051. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123052. * * 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
  123053. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123054. * * 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
  123055. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123056. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123057. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123058. * * 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
  123059. * * 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
  123060. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123065. * @param name defines the name of the mesh
  123066. * @param options defines the options used to create the mesh
  123067. * @param scene defines the hosting scene
  123068. * @returns the custom extruded shape mesh
  123069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123070. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123072. */
  123073. static ExtrudeShapeCustom(name: string, options: {
  123074. shape: Vector3[];
  123075. path: Vector3[];
  123076. scaleFunction?: any;
  123077. rotationFunction?: any;
  123078. ribbonCloseArray?: boolean;
  123079. ribbonClosePath?: boolean;
  123080. cap?: number;
  123081. updatable?: boolean;
  123082. sideOrientation?: number;
  123083. frontUVs?: Vector4;
  123084. backUVs?: Vector4;
  123085. instance?: Mesh;
  123086. invertUV?: boolean;
  123087. }, scene?: Nullable<Scene>): Mesh;
  123088. /**
  123089. * Creates lathe mesh.
  123090. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123091. * * 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
  123092. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123093. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123094. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123095. * * 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
  123096. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123097. * * 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
  123098. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123099. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123100. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123102. * @param name defines the name of the mesh
  123103. * @param options defines the options used to create the mesh
  123104. * @param scene defines the hosting scene
  123105. * @returns the lathe mesh
  123106. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123107. */
  123108. static CreateLathe(name: string, options: {
  123109. shape: Vector3[];
  123110. radius?: number;
  123111. tessellation?: number;
  123112. clip?: number;
  123113. arc?: number;
  123114. closed?: boolean;
  123115. updatable?: boolean;
  123116. sideOrientation?: number;
  123117. frontUVs?: Vector4;
  123118. backUVs?: Vector4;
  123119. cap?: number;
  123120. invertUV?: boolean;
  123121. }, scene?: Nullable<Scene>): Mesh;
  123122. /**
  123123. * Creates a tiled plane mesh
  123124. * * You can set a limited pattern arrangement with the tiles
  123125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123128. * @param name defines the name of the mesh
  123129. * @param options defines the options used to create the mesh
  123130. * @param scene defines the hosting scene
  123131. * @returns the plane mesh
  123132. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123133. */
  123134. static CreateTiledPlane(name: string, options: {
  123135. pattern?: number;
  123136. tileSize?: number;
  123137. tileWidth?: number;
  123138. tileHeight?: number;
  123139. size?: number;
  123140. width?: number;
  123141. height?: number;
  123142. alignHorizontal?: number;
  123143. alignVertical?: number;
  123144. sideOrientation?: number;
  123145. frontUVs?: Vector4;
  123146. backUVs?: Vector4;
  123147. updatable?: boolean;
  123148. }, scene?: Nullable<Scene>): Mesh;
  123149. /**
  123150. * Creates a plane mesh
  123151. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123152. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123153. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123157. * @param name defines the name of the mesh
  123158. * @param options defines the options used to create the mesh
  123159. * @param scene defines the hosting scene
  123160. * @returns the plane mesh
  123161. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123162. */
  123163. static CreatePlane(name: string, options: {
  123164. size?: number;
  123165. width?: number;
  123166. height?: number;
  123167. sideOrientation?: number;
  123168. frontUVs?: Vector4;
  123169. backUVs?: Vector4;
  123170. updatable?: boolean;
  123171. sourcePlane?: Plane;
  123172. }, scene?: Nullable<Scene>): Mesh;
  123173. /**
  123174. * Creates a ground mesh
  123175. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123176. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123178. * @param name defines the name of the mesh
  123179. * @param options defines the options used to create the mesh
  123180. * @param scene defines the hosting scene
  123181. * @returns the ground mesh
  123182. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123183. */
  123184. static CreateGround(name: string, options: {
  123185. width?: number;
  123186. height?: number;
  123187. subdivisions?: number;
  123188. subdivisionsX?: number;
  123189. subdivisionsY?: number;
  123190. updatable?: boolean;
  123191. }, scene?: Nullable<Scene>): Mesh;
  123192. /**
  123193. * Creates a tiled ground mesh
  123194. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123195. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123196. * * 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
  123197. * * 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
  123198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123199. * @param name defines the name of the mesh
  123200. * @param options defines the options used to create the mesh
  123201. * @param scene defines the hosting scene
  123202. * @returns the tiled ground mesh
  123203. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123204. */
  123205. static CreateTiledGround(name: string, options: {
  123206. xmin: number;
  123207. zmin: number;
  123208. xmax: number;
  123209. zmax: number;
  123210. subdivisions?: {
  123211. w: number;
  123212. h: number;
  123213. };
  123214. precision?: {
  123215. w: number;
  123216. h: number;
  123217. };
  123218. updatable?: boolean;
  123219. }, scene?: Nullable<Scene>): Mesh;
  123220. /**
  123221. * Creates a ground mesh from a height map
  123222. * * The parameter `url` sets the URL of the height map image resource.
  123223. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123224. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123225. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123226. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123227. * * 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.
  123228. * * 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).
  123229. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123231. * @param name defines the name of the mesh
  123232. * @param url defines the url to the height map
  123233. * @param options defines the options used to create the mesh
  123234. * @param scene defines the hosting scene
  123235. * @returns the ground mesh
  123236. * @see https://doc.babylonjs.com/babylon101/height_map
  123237. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123238. */
  123239. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123240. width?: number;
  123241. height?: number;
  123242. subdivisions?: number;
  123243. minHeight?: number;
  123244. maxHeight?: number;
  123245. colorFilter?: Color3;
  123246. alphaFilter?: number;
  123247. updatable?: boolean;
  123248. onReady?: (mesh: GroundMesh) => void;
  123249. }, scene?: Nullable<Scene>): GroundMesh;
  123250. /**
  123251. * Creates a polygon mesh
  123252. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123253. * * 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
  123254. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123257. * * Remember you can only change the shape positions, not their number when updating a polygon
  123258. * @param name defines the name of the mesh
  123259. * @param options defines the options used to create the mesh
  123260. * @param scene defines the hosting scene
  123261. * @param earcutInjection can be used to inject your own earcut reference
  123262. * @returns the polygon mesh
  123263. */
  123264. static CreatePolygon(name: string, options: {
  123265. shape: Vector3[];
  123266. holes?: Vector3[][];
  123267. depth?: number;
  123268. faceUV?: Vector4[];
  123269. faceColors?: Color4[];
  123270. updatable?: boolean;
  123271. sideOrientation?: number;
  123272. frontUVs?: Vector4;
  123273. backUVs?: Vector4;
  123274. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123275. /**
  123276. * Creates an extruded polygon mesh, with depth in the Y direction.
  123277. * * 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)
  123278. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123279. * @param name defines the name of the mesh
  123280. * @param options defines the options used to create the mesh
  123281. * @param scene defines the hosting scene
  123282. * @param earcutInjection can be used to inject your own earcut reference
  123283. * @returns the polygon mesh
  123284. */
  123285. static ExtrudePolygon(name: string, options: {
  123286. shape: Vector3[];
  123287. holes?: Vector3[][];
  123288. depth?: number;
  123289. faceUV?: Vector4[];
  123290. faceColors?: Color4[];
  123291. updatable?: boolean;
  123292. sideOrientation?: number;
  123293. frontUVs?: Vector4;
  123294. backUVs?: Vector4;
  123295. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123296. /**
  123297. * Creates a tube mesh.
  123298. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123299. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123300. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123301. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123302. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123303. * * 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)
  123304. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123305. * * 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
  123306. * * 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
  123307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123309. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123311. * @param name defines the name of the mesh
  123312. * @param options defines the options used to create the mesh
  123313. * @param scene defines the hosting scene
  123314. * @returns the tube mesh
  123315. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123316. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123317. */
  123318. static CreateTube(name: string, options: {
  123319. path: Vector3[];
  123320. radius?: number;
  123321. tessellation?: number;
  123322. radiusFunction?: {
  123323. (i: number, distance: number): number;
  123324. };
  123325. cap?: number;
  123326. arc?: number;
  123327. updatable?: boolean;
  123328. sideOrientation?: number;
  123329. frontUVs?: Vector4;
  123330. backUVs?: Vector4;
  123331. instance?: Mesh;
  123332. invertUV?: boolean;
  123333. }, scene?: Nullable<Scene>): Mesh;
  123334. /**
  123335. * Creates a polyhedron mesh
  123336. * * 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
  123337. * * The parameter `size` (positive float, default 1) sets the polygon size
  123338. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123339. * * 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`
  123340. * * 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
  123341. * * 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)`)
  123342. * * 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
  123343. * * 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
  123344. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123345. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123347. * @param name defines the name of the mesh
  123348. * @param options defines the options used to create the mesh
  123349. * @param scene defines the hosting scene
  123350. * @returns the polyhedron mesh
  123351. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123352. */
  123353. static CreatePolyhedron(name: string, options: {
  123354. type?: number;
  123355. size?: number;
  123356. sizeX?: number;
  123357. sizeY?: number;
  123358. sizeZ?: number;
  123359. custom?: any;
  123360. faceUV?: Vector4[];
  123361. faceColors?: Color4[];
  123362. flat?: boolean;
  123363. updatable?: boolean;
  123364. sideOrientation?: number;
  123365. frontUVs?: Vector4;
  123366. backUVs?: Vector4;
  123367. }, scene?: Nullable<Scene>): Mesh;
  123368. /**
  123369. * Creates a decal mesh.
  123370. * 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
  123371. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123372. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123373. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123374. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123375. * @param name defines the name of the mesh
  123376. * @param sourceMesh defines the mesh where the decal must be applied
  123377. * @param options defines the options used to create the mesh
  123378. * @param scene defines the hosting scene
  123379. * @returns the decal mesh
  123380. * @see https://doc.babylonjs.com/how_to/decals
  123381. */
  123382. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123383. position?: Vector3;
  123384. normal?: Vector3;
  123385. size?: Vector3;
  123386. angle?: number;
  123387. }): Mesh;
  123388. }
  123389. }
  123390. declare module BABYLON {
  123391. /**
  123392. * A simplifier interface for future simplification implementations
  123393. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123394. */
  123395. export interface ISimplifier {
  123396. /**
  123397. * Simplification of a given mesh according to the given settings.
  123398. * Since this requires computation, it is assumed that the function runs async.
  123399. * @param settings The settings of the simplification, including quality and distance
  123400. * @param successCallback A callback that will be called after the mesh was simplified.
  123401. * @param errorCallback in case of an error, this callback will be called. optional.
  123402. */
  123403. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123404. }
  123405. /**
  123406. * Expected simplification settings.
  123407. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123408. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123409. */
  123410. export interface ISimplificationSettings {
  123411. /**
  123412. * Gets or sets the expected quality
  123413. */
  123414. quality: number;
  123415. /**
  123416. * Gets or sets the distance when this optimized version should be used
  123417. */
  123418. distance: number;
  123419. /**
  123420. * Gets an already optimized mesh
  123421. */
  123422. optimizeMesh?: boolean;
  123423. }
  123424. /**
  123425. * Class used to specify simplification options
  123426. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123427. */
  123428. export class SimplificationSettings implements ISimplificationSettings {
  123429. /** expected quality */
  123430. quality: number;
  123431. /** distance when this optimized version should be used */
  123432. distance: number;
  123433. /** already optimized mesh */
  123434. optimizeMesh?: boolean | undefined;
  123435. /**
  123436. * Creates a SimplificationSettings
  123437. * @param quality expected quality
  123438. * @param distance distance when this optimized version should be used
  123439. * @param optimizeMesh already optimized mesh
  123440. */
  123441. constructor(
  123442. /** expected quality */
  123443. quality: number,
  123444. /** distance when this optimized version should be used */
  123445. distance: number,
  123446. /** already optimized mesh */
  123447. optimizeMesh?: boolean | undefined);
  123448. }
  123449. /**
  123450. * Interface used to define a simplification task
  123451. */
  123452. export interface ISimplificationTask {
  123453. /**
  123454. * Array of settings
  123455. */
  123456. settings: Array<ISimplificationSettings>;
  123457. /**
  123458. * Simplification type
  123459. */
  123460. simplificationType: SimplificationType;
  123461. /**
  123462. * Mesh to simplify
  123463. */
  123464. mesh: Mesh;
  123465. /**
  123466. * Callback called on success
  123467. */
  123468. successCallback?: () => void;
  123469. /**
  123470. * Defines if parallel processing can be used
  123471. */
  123472. parallelProcessing: boolean;
  123473. }
  123474. /**
  123475. * Queue used to order the simplification tasks
  123476. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123477. */
  123478. export class SimplificationQueue {
  123479. private _simplificationArray;
  123480. /**
  123481. * Gets a boolean indicating that the process is still running
  123482. */
  123483. running: boolean;
  123484. /**
  123485. * Creates a new queue
  123486. */
  123487. constructor();
  123488. /**
  123489. * Adds a new simplification task
  123490. * @param task defines a task to add
  123491. */
  123492. addTask(task: ISimplificationTask): void;
  123493. /**
  123494. * Execute next task
  123495. */
  123496. executeNext(): void;
  123497. /**
  123498. * Execute a simplification task
  123499. * @param task defines the task to run
  123500. */
  123501. runSimplification(task: ISimplificationTask): void;
  123502. private getSimplifier;
  123503. }
  123504. /**
  123505. * The implemented types of simplification
  123506. * At the moment only Quadratic Error Decimation is implemented
  123507. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123508. */
  123509. export enum SimplificationType {
  123510. /** Quadratic error decimation */
  123511. QUADRATIC = 0
  123512. }
  123513. }
  123514. declare module BABYLON {
  123515. interface Scene {
  123516. /** @hidden (Backing field) */
  123517. _simplificationQueue: SimplificationQueue;
  123518. /**
  123519. * Gets or sets the simplification queue attached to the scene
  123520. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123521. */
  123522. simplificationQueue: SimplificationQueue;
  123523. }
  123524. interface Mesh {
  123525. /**
  123526. * Simplify the mesh according to the given array of settings.
  123527. * Function will return immediately and will simplify async
  123528. * @param settings a collection of simplification settings
  123529. * @param parallelProcessing should all levels calculate parallel or one after the other
  123530. * @param simplificationType the type of simplification to run
  123531. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123532. * @returns the current mesh
  123533. */
  123534. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123535. }
  123536. /**
  123537. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123538. * created in a scene
  123539. */
  123540. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123541. /**
  123542. * The component name helpfull to identify the component in the list of scene components.
  123543. */
  123544. readonly name: string;
  123545. /**
  123546. * The scene the component belongs to.
  123547. */
  123548. scene: Scene;
  123549. /**
  123550. * Creates a new instance of the component for the given scene
  123551. * @param scene Defines the scene to register the component in
  123552. */
  123553. constructor(scene: Scene);
  123554. /**
  123555. * Registers the component in a given scene
  123556. */
  123557. register(): void;
  123558. /**
  123559. * Rebuilds the elements related to this component in case of
  123560. * context lost for instance.
  123561. */
  123562. rebuild(): void;
  123563. /**
  123564. * Disposes the component and the associated ressources
  123565. */
  123566. dispose(): void;
  123567. private _beforeCameraUpdate;
  123568. }
  123569. }
  123570. declare module BABYLON {
  123571. /**
  123572. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123573. */
  123574. export interface INavigationEnginePlugin {
  123575. /**
  123576. * plugin name
  123577. */
  123578. name: string;
  123579. /**
  123580. * Creates a navigation mesh
  123581. * @param meshes array of all the geometry used to compute the navigatio mesh
  123582. * @param parameters bunch of parameters used to filter geometry
  123583. */
  123584. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123585. /**
  123586. * Create a navigation mesh debug mesh
  123587. * @param scene is where the mesh will be added
  123588. * @returns debug display mesh
  123589. */
  123590. createDebugNavMesh(scene: Scene): Mesh;
  123591. /**
  123592. * Get a navigation mesh constrained position, closest to the parameter position
  123593. * @param position world position
  123594. * @returns the closest point to position constrained by the navigation mesh
  123595. */
  123596. getClosestPoint(position: Vector3): Vector3;
  123597. /**
  123598. * Get a navigation mesh constrained position, within a particular radius
  123599. * @param position world position
  123600. * @param maxRadius the maximum distance to the constrained world position
  123601. * @returns the closest point to position constrained by the navigation mesh
  123602. */
  123603. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123604. /**
  123605. * Compute the final position from a segment made of destination-position
  123606. * @param position world position
  123607. * @param destination world position
  123608. * @returns the resulting point along the navmesh
  123609. */
  123610. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123611. /**
  123612. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123613. * @param start world position
  123614. * @param end world position
  123615. * @returns array containing world position composing the path
  123616. */
  123617. computePath(start: Vector3, end: Vector3): Vector3[];
  123618. /**
  123619. * If this plugin is supported
  123620. * @returns true if plugin is supported
  123621. */
  123622. isSupported(): boolean;
  123623. /**
  123624. * Create a new Crowd so you can add agents
  123625. * @param maxAgents the maximum agent count in the crowd
  123626. * @param maxAgentRadius the maximum radius an agent can have
  123627. * @param scene to attach the crowd to
  123628. * @returns the crowd you can add agents to
  123629. */
  123630. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123631. /**
  123632. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123633. * The queries will try to find a solution within those bounds
  123634. * default is (1,1,1)
  123635. * @param extent x,y,z value that define the extent around the queries point of reference
  123636. */
  123637. setDefaultQueryExtent(extent: Vector3): void;
  123638. /**
  123639. * Get the Bounding box extent specified by setDefaultQueryExtent
  123640. * @returns the box extent values
  123641. */
  123642. getDefaultQueryExtent(): Vector3;
  123643. /**
  123644. * Release all resources
  123645. */
  123646. dispose(): void;
  123647. }
  123648. /**
  123649. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  123650. */
  123651. export interface ICrowd {
  123652. /**
  123653. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123654. * You can attach anything to that node. The node position is updated in the scene update tick.
  123655. * @param pos world position that will be constrained by the navigation mesh
  123656. * @param parameters agent parameters
  123657. * @param transform hooked to the agent that will be update by the scene
  123658. * @returns agent index
  123659. */
  123660. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123661. /**
  123662. * Returns the agent position in world space
  123663. * @param index agent index returned by addAgent
  123664. * @returns world space position
  123665. */
  123666. getAgentPosition(index: number): Vector3;
  123667. /**
  123668. * Gets the agent velocity in world space
  123669. * @param index agent index returned by addAgent
  123670. * @returns world space velocity
  123671. */
  123672. getAgentVelocity(index: number): Vector3;
  123673. /**
  123674. * remove a particular agent previously created
  123675. * @param index agent index returned by addAgent
  123676. */
  123677. removeAgent(index: number): void;
  123678. /**
  123679. * get the list of all agents attached to this crowd
  123680. * @returns list of agent indices
  123681. */
  123682. getAgents(): number[];
  123683. /**
  123684. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123685. * @param deltaTime in seconds
  123686. */
  123687. update(deltaTime: number): void;
  123688. /**
  123689. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123690. * @param index agent index returned by addAgent
  123691. * @param destination targeted world position
  123692. */
  123693. agentGoto(index: number, destination: Vector3): void;
  123694. /**
  123695. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123696. * The queries will try to find a solution within those bounds
  123697. * default is (1,1,1)
  123698. * @param extent x,y,z value that define the extent around the queries point of reference
  123699. */
  123700. setDefaultQueryExtent(extent: Vector3): void;
  123701. /**
  123702. * Get the Bounding box extent specified by setDefaultQueryExtent
  123703. * @returns the box extent values
  123704. */
  123705. getDefaultQueryExtent(): Vector3;
  123706. /**
  123707. * Release all resources
  123708. */
  123709. dispose(): void;
  123710. }
  123711. /**
  123712. * Configures an agent
  123713. */
  123714. export interface IAgentParameters {
  123715. /**
  123716. * Agent radius. [Limit: >= 0]
  123717. */
  123718. radius: number;
  123719. /**
  123720. * Agent height. [Limit: > 0]
  123721. */
  123722. height: number;
  123723. /**
  123724. * Maximum allowed acceleration. [Limit: >= 0]
  123725. */
  123726. maxAcceleration: number;
  123727. /**
  123728. * Maximum allowed speed. [Limit: >= 0]
  123729. */
  123730. maxSpeed: number;
  123731. /**
  123732. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  123733. */
  123734. collisionQueryRange: number;
  123735. /**
  123736. * The path visibility optimization range. [Limit: > 0]
  123737. */
  123738. pathOptimizationRange: number;
  123739. /**
  123740. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  123741. */
  123742. separationWeight: number;
  123743. }
  123744. /**
  123745. * Configures the navigation mesh creation
  123746. */
  123747. export interface INavMeshParameters {
  123748. /**
  123749. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  123750. */
  123751. cs: number;
  123752. /**
  123753. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  123754. */
  123755. ch: number;
  123756. /**
  123757. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  123758. */
  123759. walkableSlopeAngle: number;
  123760. /**
  123761. * Minimum floor to 'ceiling' height that will still allow the floor area to
  123762. * be considered walkable. [Limit: >= 3] [Units: vx]
  123763. */
  123764. walkableHeight: number;
  123765. /**
  123766. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  123767. */
  123768. walkableClimb: number;
  123769. /**
  123770. * The distance to erode/shrink the walkable area of the heightfield away from
  123771. * obstructions. [Limit: >=0] [Units: vx]
  123772. */
  123773. walkableRadius: number;
  123774. /**
  123775. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  123776. */
  123777. maxEdgeLen: number;
  123778. /**
  123779. * The maximum distance a simplfied contour's border edges should deviate
  123780. * the original raw contour. [Limit: >=0] [Units: vx]
  123781. */
  123782. maxSimplificationError: number;
  123783. /**
  123784. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  123785. */
  123786. minRegionArea: number;
  123787. /**
  123788. * Any regions with a span count smaller than this value will, if possible,
  123789. * be merged with larger regions. [Limit: >=0] [Units: vx]
  123790. */
  123791. mergeRegionArea: number;
  123792. /**
  123793. * The maximum number of vertices allowed for polygons generated during the
  123794. * contour to polygon conversion process. [Limit: >= 3]
  123795. */
  123796. maxVertsPerPoly: number;
  123797. /**
  123798. * Sets the sampling distance to use when generating the detail mesh.
  123799. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  123800. */
  123801. detailSampleDist: number;
  123802. /**
  123803. * The maximum distance the detail mesh surface should deviate from heightfield
  123804. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  123805. */
  123806. detailSampleMaxError: number;
  123807. }
  123808. }
  123809. declare module BABYLON {
  123810. /**
  123811. * RecastJS navigation plugin
  123812. */
  123813. export class RecastJSPlugin implements INavigationEnginePlugin {
  123814. /**
  123815. * Reference to the Recast library
  123816. */
  123817. bjsRECAST: any;
  123818. /**
  123819. * plugin name
  123820. */
  123821. name: string;
  123822. /**
  123823. * the first navmesh created. We might extend this to support multiple navmeshes
  123824. */
  123825. navMesh: any;
  123826. /**
  123827. * Initializes the recastJS plugin
  123828. * @param recastInjection can be used to inject your own recast reference
  123829. */
  123830. constructor(recastInjection?: any);
  123831. /**
  123832. * Creates a navigation mesh
  123833. * @param meshes array of all the geometry used to compute the navigatio mesh
  123834. * @param parameters bunch of parameters used to filter geometry
  123835. */
  123836. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123837. /**
  123838. * Create a navigation mesh debug mesh
  123839. * @param scene is where the mesh will be added
  123840. * @returns debug display mesh
  123841. */
  123842. createDebugNavMesh(scene: Scene): Mesh;
  123843. /**
  123844. * Get a navigation mesh constrained position, closest to the parameter position
  123845. * @param position world position
  123846. * @returns the closest point to position constrained by the navigation mesh
  123847. */
  123848. getClosestPoint(position: Vector3): Vector3;
  123849. /**
  123850. * Get a navigation mesh constrained position, within a particular radius
  123851. * @param position world position
  123852. * @param maxRadius the maximum distance to the constrained world position
  123853. * @returns the closest point to position constrained by the navigation mesh
  123854. */
  123855. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123856. /**
  123857. * Compute the final position from a segment made of destination-position
  123858. * @param position world position
  123859. * @param destination world position
  123860. * @returns the resulting point along the navmesh
  123861. */
  123862. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123863. /**
  123864. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123865. * @param start world position
  123866. * @param end world position
  123867. * @returns array containing world position composing the path
  123868. */
  123869. computePath(start: Vector3, end: Vector3): Vector3[];
  123870. /**
  123871. * Create a new Crowd so you can add agents
  123872. * @param maxAgents the maximum agent count in the crowd
  123873. * @param maxAgentRadius the maximum radius an agent can have
  123874. * @param scene to attach the crowd to
  123875. * @returns the crowd you can add agents to
  123876. */
  123877. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123878. /**
  123879. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123880. * The queries will try to find a solution within those bounds
  123881. * default is (1,1,1)
  123882. * @param extent x,y,z value that define the extent around the queries point of reference
  123883. */
  123884. setDefaultQueryExtent(extent: Vector3): void;
  123885. /**
  123886. * Get the Bounding box extent specified by setDefaultQueryExtent
  123887. * @returns the box extent values
  123888. */
  123889. getDefaultQueryExtent(): Vector3;
  123890. /**
  123891. * Disposes
  123892. */
  123893. dispose(): void;
  123894. /**
  123895. * If this plugin is supported
  123896. * @returns true if plugin is supported
  123897. */
  123898. isSupported(): boolean;
  123899. }
  123900. /**
  123901. * Recast detour crowd implementation
  123902. */
  123903. export class RecastJSCrowd implements ICrowd {
  123904. /**
  123905. * Recast/detour plugin
  123906. */
  123907. bjsRECASTPlugin: RecastJSPlugin;
  123908. /**
  123909. * Link to the detour crowd
  123910. */
  123911. recastCrowd: any;
  123912. /**
  123913. * One transform per agent
  123914. */
  123915. transforms: TransformNode[];
  123916. /**
  123917. * All agents created
  123918. */
  123919. agents: number[];
  123920. /**
  123921. * Link to the scene is kept to unregister the crowd from the scene
  123922. */
  123923. private _scene;
  123924. /**
  123925. * Observer for crowd updates
  123926. */
  123927. private _onBeforeAnimationsObserver;
  123928. /**
  123929. * Constructor
  123930. * @param plugin recastJS plugin
  123931. * @param maxAgents the maximum agent count in the crowd
  123932. * @param maxAgentRadius the maximum radius an agent can have
  123933. * @param scene to attach the crowd to
  123934. * @returns the crowd you can add agents to
  123935. */
  123936. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  123937. /**
  123938. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123939. * You can attach anything to that node. The node position is updated in the scene update tick.
  123940. * @param pos world position that will be constrained by the navigation mesh
  123941. * @param parameters agent parameters
  123942. * @param transform hooked to the agent that will be update by the scene
  123943. * @returns agent index
  123944. */
  123945. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123946. /**
  123947. * Returns the agent position in world space
  123948. * @param index agent index returned by addAgent
  123949. * @returns world space position
  123950. */
  123951. getAgentPosition(index: number): Vector3;
  123952. /**
  123953. * Returns the agent velocity in world space
  123954. * @param index agent index returned by addAgent
  123955. * @returns world space velocity
  123956. */
  123957. getAgentVelocity(index: number): Vector3;
  123958. /**
  123959. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123960. * @param index agent index returned by addAgent
  123961. * @param destination targeted world position
  123962. */
  123963. agentGoto(index: number, destination: Vector3): void;
  123964. /**
  123965. * remove a particular agent previously created
  123966. * @param index agent index returned by addAgent
  123967. */
  123968. removeAgent(index: number): void;
  123969. /**
  123970. * get the list of all agents attached to this crowd
  123971. * @returns list of agent indices
  123972. */
  123973. getAgents(): number[];
  123974. /**
  123975. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123976. * @param deltaTime in seconds
  123977. */
  123978. update(deltaTime: number): void;
  123979. /**
  123980. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123981. * The queries will try to find a solution within those bounds
  123982. * default is (1,1,1)
  123983. * @param extent x,y,z value that define the extent around the queries point of reference
  123984. */
  123985. setDefaultQueryExtent(extent: Vector3): void;
  123986. /**
  123987. * Get the Bounding box extent specified by setDefaultQueryExtent
  123988. * @returns the box extent values
  123989. */
  123990. getDefaultQueryExtent(): Vector3;
  123991. /**
  123992. * Release all resources
  123993. */
  123994. dispose(): void;
  123995. }
  123996. }
  123997. declare module BABYLON {
  123998. /**
  123999. * Class used to enable access to IndexedDB
  124000. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124001. */
  124002. export class Database implements IOfflineProvider {
  124003. private _callbackManifestChecked;
  124004. private _currentSceneUrl;
  124005. private _db;
  124006. private _enableSceneOffline;
  124007. private _enableTexturesOffline;
  124008. private _manifestVersionFound;
  124009. private _mustUpdateRessources;
  124010. private _hasReachedQuota;
  124011. private _isSupported;
  124012. private _idbFactory;
  124013. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124014. private static IsUASupportingBlobStorage;
  124015. /**
  124016. * Gets a boolean indicating if Database storate is enabled (off by default)
  124017. */
  124018. static IDBStorageEnabled: boolean;
  124019. /**
  124020. * Gets a boolean indicating if scene must be saved in the database
  124021. */
  124022. readonly enableSceneOffline: boolean;
  124023. /**
  124024. * Gets a boolean indicating if textures must be saved in the database
  124025. */
  124026. readonly enableTexturesOffline: boolean;
  124027. /**
  124028. * Creates a new Database
  124029. * @param urlToScene defines the url to load the scene
  124030. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124031. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124032. */
  124033. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124034. private static _ParseURL;
  124035. private static _ReturnFullUrlLocation;
  124036. private _checkManifestFile;
  124037. /**
  124038. * Open the database and make it available
  124039. * @param successCallback defines the callback to call on success
  124040. * @param errorCallback defines the callback to call on error
  124041. */
  124042. open(successCallback: () => void, errorCallback: () => void): void;
  124043. /**
  124044. * Loads an image from the database
  124045. * @param url defines the url to load from
  124046. * @param image defines the target DOM image
  124047. */
  124048. loadImage(url: string, image: HTMLImageElement): void;
  124049. private _loadImageFromDBAsync;
  124050. private _saveImageIntoDBAsync;
  124051. private _checkVersionFromDB;
  124052. private _loadVersionFromDBAsync;
  124053. private _saveVersionIntoDBAsync;
  124054. /**
  124055. * Loads a file from database
  124056. * @param url defines the URL to load from
  124057. * @param sceneLoaded defines a callback to call on success
  124058. * @param progressCallBack defines a callback to call when progress changed
  124059. * @param errorCallback defines a callback to call on error
  124060. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124061. */
  124062. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124063. private _loadFileAsync;
  124064. private _saveFileAsync;
  124065. /**
  124066. * Validates if xhr data is correct
  124067. * @param xhr defines the request to validate
  124068. * @param dataType defines the expected data type
  124069. * @returns true if data is correct
  124070. */
  124071. private static _ValidateXHRData;
  124072. }
  124073. }
  124074. declare module BABYLON {
  124075. /** @hidden */
  124076. export var gpuUpdateParticlesPixelShader: {
  124077. name: string;
  124078. shader: string;
  124079. };
  124080. }
  124081. declare module BABYLON {
  124082. /** @hidden */
  124083. export var gpuUpdateParticlesVertexShader: {
  124084. name: string;
  124085. shader: string;
  124086. };
  124087. }
  124088. declare module BABYLON {
  124089. /** @hidden */
  124090. export var clipPlaneFragmentDeclaration2: {
  124091. name: string;
  124092. shader: string;
  124093. };
  124094. }
  124095. declare module BABYLON {
  124096. /** @hidden */
  124097. export var gpuRenderParticlesPixelShader: {
  124098. name: string;
  124099. shader: string;
  124100. };
  124101. }
  124102. declare module BABYLON {
  124103. /** @hidden */
  124104. export var clipPlaneVertexDeclaration2: {
  124105. name: string;
  124106. shader: string;
  124107. };
  124108. }
  124109. declare module BABYLON {
  124110. /** @hidden */
  124111. export var gpuRenderParticlesVertexShader: {
  124112. name: string;
  124113. shader: string;
  124114. };
  124115. }
  124116. declare module BABYLON {
  124117. /**
  124118. * This represents a GPU particle system in Babylon
  124119. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124120. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124121. */
  124122. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124123. /**
  124124. * The layer mask we are rendering the particles through.
  124125. */
  124126. layerMask: number;
  124127. private _capacity;
  124128. private _activeCount;
  124129. private _currentActiveCount;
  124130. private _accumulatedCount;
  124131. private _renderEffect;
  124132. private _updateEffect;
  124133. private _buffer0;
  124134. private _buffer1;
  124135. private _spriteBuffer;
  124136. private _updateVAO;
  124137. private _renderVAO;
  124138. private _targetIndex;
  124139. private _sourceBuffer;
  124140. private _targetBuffer;
  124141. private _engine;
  124142. private _currentRenderId;
  124143. private _started;
  124144. private _stopped;
  124145. private _timeDelta;
  124146. private _randomTexture;
  124147. private _randomTexture2;
  124148. private _attributesStrideSize;
  124149. private _updateEffectOptions;
  124150. private _randomTextureSize;
  124151. private _actualFrame;
  124152. private readonly _rawTextureWidth;
  124153. /**
  124154. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124155. */
  124156. static readonly IsSupported: boolean;
  124157. /**
  124158. * An event triggered when the system is disposed.
  124159. */
  124160. onDisposeObservable: Observable<GPUParticleSystem>;
  124161. /**
  124162. * Gets the maximum number of particles active at the same time.
  124163. * @returns The max number of active particles.
  124164. */
  124165. getCapacity(): number;
  124166. /**
  124167. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124168. * to override the particles.
  124169. */
  124170. forceDepthWrite: boolean;
  124171. /**
  124172. * Gets or set the number of active particles
  124173. */
  124174. activeParticleCount: number;
  124175. private _preWarmDone;
  124176. /**
  124177. * Is this system ready to be used/rendered
  124178. * @return true if the system is ready
  124179. */
  124180. isReady(): boolean;
  124181. /**
  124182. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124183. * @returns True if it has been started, otherwise false.
  124184. */
  124185. isStarted(): boolean;
  124186. /**
  124187. * Starts the particle system and begins to emit
  124188. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124189. */
  124190. start(delay?: number): void;
  124191. /**
  124192. * Stops the particle system.
  124193. */
  124194. stop(): void;
  124195. /**
  124196. * Remove all active particles
  124197. */
  124198. reset(): void;
  124199. /**
  124200. * Returns the string "GPUParticleSystem"
  124201. * @returns a string containing the class name
  124202. */
  124203. getClassName(): string;
  124204. private _colorGradientsTexture;
  124205. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124206. /**
  124207. * Adds a new color gradient
  124208. * @param gradient defines the gradient to use (between 0 and 1)
  124209. * @param color1 defines the color to affect to the specified gradient
  124210. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124211. * @returns the current particle system
  124212. */
  124213. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124214. /**
  124215. * Remove a specific color gradient
  124216. * @param gradient defines the gradient to remove
  124217. * @returns the current particle system
  124218. */
  124219. removeColorGradient(gradient: number): GPUParticleSystem;
  124220. private _angularSpeedGradientsTexture;
  124221. private _sizeGradientsTexture;
  124222. private _velocityGradientsTexture;
  124223. private _limitVelocityGradientsTexture;
  124224. private _dragGradientsTexture;
  124225. private _addFactorGradient;
  124226. /**
  124227. * Adds a new size gradient
  124228. * @param gradient defines the gradient to use (between 0 and 1)
  124229. * @param factor defines the size factor to affect to the specified gradient
  124230. * @returns the current particle system
  124231. */
  124232. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124233. /**
  124234. * Remove a specific size gradient
  124235. * @param gradient defines the gradient to remove
  124236. * @returns the current particle system
  124237. */
  124238. removeSizeGradient(gradient: number): GPUParticleSystem;
  124239. /**
  124240. * Adds a new angular speed gradient
  124241. * @param gradient defines the gradient to use (between 0 and 1)
  124242. * @param factor defines the angular speed to affect to the specified gradient
  124243. * @returns the current particle system
  124244. */
  124245. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124246. /**
  124247. * Remove a specific angular speed gradient
  124248. * @param gradient defines the gradient to remove
  124249. * @returns the current particle system
  124250. */
  124251. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124252. /**
  124253. * Adds a new velocity gradient
  124254. * @param gradient defines the gradient to use (between 0 and 1)
  124255. * @param factor defines the velocity to affect to the specified gradient
  124256. * @returns the current particle system
  124257. */
  124258. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124259. /**
  124260. * Remove a specific velocity gradient
  124261. * @param gradient defines the gradient to remove
  124262. * @returns the current particle system
  124263. */
  124264. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124265. /**
  124266. * Adds a new limit velocity gradient
  124267. * @param gradient defines the gradient to use (between 0 and 1)
  124268. * @param factor defines the limit velocity value to affect to the specified gradient
  124269. * @returns the current particle system
  124270. */
  124271. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124272. /**
  124273. * Remove a specific limit velocity gradient
  124274. * @param gradient defines the gradient to remove
  124275. * @returns the current particle system
  124276. */
  124277. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124278. /**
  124279. * Adds a new drag gradient
  124280. * @param gradient defines the gradient to use (between 0 and 1)
  124281. * @param factor defines the drag value to affect to the specified gradient
  124282. * @returns the current particle system
  124283. */
  124284. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124285. /**
  124286. * Remove a specific drag gradient
  124287. * @param gradient defines the gradient to remove
  124288. * @returns the current particle system
  124289. */
  124290. removeDragGradient(gradient: number): GPUParticleSystem;
  124291. /**
  124292. * Not supported by GPUParticleSystem
  124293. * @param gradient defines the gradient to use (between 0 and 1)
  124294. * @param factor defines the emit rate value to affect to the specified gradient
  124295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124296. * @returns the current particle system
  124297. */
  124298. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124299. /**
  124300. * Not supported by GPUParticleSystem
  124301. * @param gradient defines the gradient to remove
  124302. * @returns the current particle system
  124303. */
  124304. removeEmitRateGradient(gradient: number): IParticleSystem;
  124305. /**
  124306. * Not supported by GPUParticleSystem
  124307. * @param gradient defines the gradient to use (between 0 and 1)
  124308. * @param factor defines the start size value to affect to the specified gradient
  124309. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124310. * @returns the current particle system
  124311. */
  124312. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124313. /**
  124314. * Not supported by GPUParticleSystem
  124315. * @param gradient defines the gradient to remove
  124316. * @returns the current particle system
  124317. */
  124318. removeStartSizeGradient(gradient: number): IParticleSystem;
  124319. /**
  124320. * Not supported by GPUParticleSystem
  124321. * @param gradient defines the gradient to use (between 0 and 1)
  124322. * @param min defines the color remap minimal range
  124323. * @param max defines the color remap maximal range
  124324. * @returns the current particle system
  124325. */
  124326. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124327. /**
  124328. * Not supported by GPUParticleSystem
  124329. * @param gradient defines the gradient to remove
  124330. * @returns the current particle system
  124331. */
  124332. removeColorRemapGradient(): IParticleSystem;
  124333. /**
  124334. * Not supported by GPUParticleSystem
  124335. * @param gradient defines the gradient to use (between 0 and 1)
  124336. * @param min defines the alpha remap minimal range
  124337. * @param max defines the alpha remap maximal range
  124338. * @returns the current particle system
  124339. */
  124340. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124341. /**
  124342. * Not supported by GPUParticleSystem
  124343. * @param gradient defines the gradient to remove
  124344. * @returns the current particle system
  124345. */
  124346. removeAlphaRemapGradient(): IParticleSystem;
  124347. /**
  124348. * Not supported by GPUParticleSystem
  124349. * @param gradient defines the gradient to use (between 0 and 1)
  124350. * @param color defines the color to affect to the specified gradient
  124351. * @returns the current particle system
  124352. */
  124353. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124354. /**
  124355. * Not supported by GPUParticleSystem
  124356. * @param gradient defines the gradient to remove
  124357. * @returns the current particle system
  124358. */
  124359. removeRampGradient(): IParticleSystem;
  124360. /**
  124361. * Not supported by GPUParticleSystem
  124362. * @returns the list of ramp gradients
  124363. */
  124364. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124365. /**
  124366. * Not supported by GPUParticleSystem
  124367. * Gets or sets a boolean indicating that ramp gradients must be used
  124368. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124369. */
  124370. useRampGradients: boolean;
  124371. /**
  124372. * Not supported by GPUParticleSystem
  124373. * @param gradient defines the gradient to use (between 0 and 1)
  124374. * @param factor defines the life time factor to affect to the specified gradient
  124375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124376. * @returns the current particle system
  124377. */
  124378. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124379. /**
  124380. * Not supported by GPUParticleSystem
  124381. * @param gradient defines the gradient to remove
  124382. * @returns the current particle system
  124383. */
  124384. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124385. /**
  124386. * Instantiates a GPU particle system.
  124387. * 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.
  124388. * @param name The name of the particle system
  124389. * @param options The options used to create the system
  124390. * @param scene The scene the particle system belongs to
  124391. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124392. */
  124393. constructor(name: string, options: Partial<{
  124394. capacity: number;
  124395. randomTextureSize: number;
  124396. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124397. protected _reset(): void;
  124398. private _createUpdateVAO;
  124399. private _createRenderVAO;
  124400. private _initialize;
  124401. /** @hidden */
  124402. _recreateUpdateEffect(): void;
  124403. /** @hidden */
  124404. _recreateRenderEffect(): void;
  124405. /**
  124406. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124407. * @param preWarm defines if we are in the pre-warmimg phase
  124408. */
  124409. animate(preWarm?: boolean): void;
  124410. private _createFactorGradientTexture;
  124411. private _createSizeGradientTexture;
  124412. private _createAngularSpeedGradientTexture;
  124413. private _createVelocityGradientTexture;
  124414. private _createLimitVelocityGradientTexture;
  124415. private _createDragGradientTexture;
  124416. private _createColorGradientTexture;
  124417. /**
  124418. * Renders the particle system in its current state
  124419. * @param preWarm defines if the system should only update the particles but not render them
  124420. * @returns the current number of particles
  124421. */
  124422. render(preWarm?: boolean): number;
  124423. /**
  124424. * Rebuilds the particle system
  124425. */
  124426. rebuild(): void;
  124427. private _releaseBuffers;
  124428. private _releaseVAOs;
  124429. /**
  124430. * Disposes the particle system and free the associated resources
  124431. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124432. */
  124433. dispose(disposeTexture?: boolean): void;
  124434. /**
  124435. * Clones the particle system.
  124436. * @param name The name of the cloned object
  124437. * @param newEmitter The new emitter to use
  124438. * @returns the cloned particle system
  124439. */
  124440. clone(name: string, newEmitter: any): GPUParticleSystem;
  124441. /**
  124442. * Serializes the particle system to a JSON object.
  124443. * @returns the JSON object
  124444. */
  124445. serialize(): any;
  124446. /**
  124447. * Parses a JSON object to create a GPU particle system.
  124448. * @param parsedParticleSystem The JSON object to parse
  124449. * @param scene The scene to create the particle system in
  124450. * @param rootUrl The root url to use to load external dependencies like texture
  124451. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124452. * @returns the parsed GPU particle system
  124453. */
  124454. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124455. }
  124456. }
  124457. declare module BABYLON {
  124458. /**
  124459. * Represents a set of particle systems working together to create a specific effect
  124460. */
  124461. export class ParticleSystemSet implements IDisposable {
  124462. private _emitterCreationOptions;
  124463. private _emitterNode;
  124464. /**
  124465. * Gets the particle system list
  124466. */
  124467. systems: IParticleSystem[];
  124468. /**
  124469. * Gets the emitter node used with this set
  124470. */
  124471. readonly emitterNode: Nullable<TransformNode>;
  124472. /**
  124473. * Creates a new emitter mesh as a sphere
  124474. * @param options defines the options used to create the sphere
  124475. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124476. * @param scene defines the hosting scene
  124477. */
  124478. setEmitterAsSphere(options: {
  124479. diameter: number;
  124480. segments: number;
  124481. color: Color3;
  124482. }, renderingGroupId: number, scene: Scene): void;
  124483. /**
  124484. * Starts all particle systems of the set
  124485. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124486. */
  124487. start(emitter?: AbstractMesh): void;
  124488. /**
  124489. * Release all associated resources
  124490. */
  124491. dispose(): void;
  124492. /**
  124493. * Serialize the set into a JSON compatible object
  124494. * @returns a JSON compatible representation of the set
  124495. */
  124496. serialize(): any;
  124497. /**
  124498. * Parse a new ParticleSystemSet from a serialized source
  124499. * @param data defines a JSON compatible representation of the set
  124500. * @param scene defines the hosting scene
  124501. * @param gpu defines if we want GPU particles or CPU particles
  124502. * @returns a new ParticleSystemSet
  124503. */
  124504. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124505. }
  124506. }
  124507. declare module BABYLON {
  124508. /**
  124509. * This class is made for on one-liner static method to help creating particle system set.
  124510. */
  124511. export class ParticleHelper {
  124512. /**
  124513. * Gets or sets base Assets URL
  124514. */
  124515. static BaseAssetsUrl: string;
  124516. /**
  124517. * Create a default particle system that you can tweak
  124518. * @param emitter defines the emitter to use
  124519. * @param capacity defines the system capacity (default is 500 particles)
  124520. * @param scene defines the hosting scene
  124521. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124522. * @returns the new Particle system
  124523. */
  124524. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124525. /**
  124526. * This is the main static method (one-liner) of this helper to create different particle systems
  124527. * @param type This string represents the type to the particle system to create
  124528. * @param scene The scene where the particle system should live
  124529. * @param gpu If the system will use gpu
  124530. * @returns the ParticleSystemSet created
  124531. */
  124532. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124533. /**
  124534. * Static function used to export a particle system to a ParticleSystemSet variable.
  124535. * Please note that the emitter shape is not exported
  124536. * @param systems defines the particle systems to export
  124537. * @returns the created particle system set
  124538. */
  124539. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124540. }
  124541. }
  124542. declare module BABYLON {
  124543. interface Engine {
  124544. /**
  124545. * Create an effect to use with particle systems.
  124546. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124547. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124548. * @param uniformsNames defines a list of attribute names
  124549. * @param samplers defines an array of string used to represent textures
  124550. * @param defines defines the string containing the defines to use to compile the shaders
  124551. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124552. * @param onCompiled defines a function to call when the effect creation is successful
  124553. * @param onError defines a function to call when the effect creation has failed
  124554. * @returns the new Effect
  124555. */
  124556. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124557. }
  124558. interface Mesh {
  124559. /**
  124560. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124561. * @returns an array of IParticleSystem
  124562. */
  124563. getEmittedParticleSystems(): IParticleSystem[];
  124564. /**
  124565. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124566. * @returns an array of IParticleSystem
  124567. */
  124568. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124569. }
  124570. /**
  124571. * @hidden
  124572. */
  124573. export var _IDoNeedToBeInTheBuild: number;
  124574. }
  124575. declare module BABYLON {
  124576. interface Scene {
  124577. /** @hidden (Backing field) */
  124578. _physicsEngine: Nullable<IPhysicsEngine>;
  124579. /**
  124580. * Gets the current physics engine
  124581. * @returns a IPhysicsEngine or null if none attached
  124582. */
  124583. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124584. /**
  124585. * Enables physics to the current scene
  124586. * @param gravity defines the scene's gravity for the physics engine
  124587. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124588. * @return a boolean indicating if the physics engine was initialized
  124589. */
  124590. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124591. /**
  124592. * Disables and disposes the physics engine associated with the scene
  124593. */
  124594. disablePhysicsEngine(): void;
  124595. /**
  124596. * Gets a boolean indicating if there is an active physics engine
  124597. * @returns a boolean indicating if there is an active physics engine
  124598. */
  124599. isPhysicsEnabled(): boolean;
  124600. /**
  124601. * Deletes a physics compound impostor
  124602. * @param compound defines the compound to delete
  124603. */
  124604. deleteCompoundImpostor(compound: any): void;
  124605. /**
  124606. * An event triggered when physic simulation is about to be run
  124607. */
  124608. onBeforePhysicsObservable: Observable<Scene>;
  124609. /**
  124610. * An event triggered when physic simulation has been done
  124611. */
  124612. onAfterPhysicsObservable: Observable<Scene>;
  124613. }
  124614. interface AbstractMesh {
  124615. /** @hidden */
  124616. _physicsImpostor: Nullable<PhysicsImpostor>;
  124617. /**
  124618. * Gets or sets impostor used for physic simulation
  124619. * @see http://doc.babylonjs.com/features/physics_engine
  124620. */
  124621. physicsImpostor: Nullable<PhysicsImpostor>;
  124622. /**
  124623. * Gets the current physics impostor
  124624. * @see http://doc.babylonjs.com/features/physics_engine
  124625. * @returns a physics impostor or null
  124626. */
  124627. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  124628. /** Apply a physic impulse to the mesh
  124629. * @param force defines the force to apply
  124630. * @param contactPoint defines where to apply the force
  124631. * @returns the current mesh
  124632. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  124633. */
  124634. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  124635. /**
  124636. * Creates a physic joint between two meshes
  124637. * @param otherMesh defines the other mesh to use
  124638. * @param pivot1 defines the pivot to use on this mesh
  124639. * @param pivot2 defines the pivot to use on the other mesh
  124640. * @param options defines additional options (can be plugin dependent)
  124641. * @returns the current mesh
  124642. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  124643. */
  124644. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  124645. /** @hidden */
  124646. _disposePhysicsObserver: Nullable<Observer<Node>>;
  124647. }
  124648. /**
  124649. * Defines the physics engine scene component responsible to manage a physics engine
  124650. */
  124651. export class PhysicsEngineSceneComponent implements ISceneComponent {
  124652. /**
  124653. * The component name helpful to identify the component in the list of scene components.
  124654. */
  124655. readonly name: string;
  124656. /**
  124657. * The scene the component belongs to.
  124658. */
  124659. scene: Scene;
  124660. /**
  124661. * Creates a new instance of the component for the given scene
  124662. * @param scene Defines the scene to register the component in
  124663. */
  124664. constructor(scene: Scene);
  124665. /**
  124666. * Registers the component in a given scene
  124667. */
  124668. register(): void;
  124669. /**
  124670. * Rebuilds the elements related to this component in case of
  124671. * context lost for instance.
  124672. */
  124673. rebuild(): void;
  124674. /**
  124675. * Disposes the component and the associated ressources
  124676. */
  124677. dispose(): void;
  124678. }
  124679. }
  124680. declare module BABYLON {
  124681. /**
  124682. * A helper for physics simulations
  124683. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124684. */
  124685. export class PhysicsHelper {
  124686. private _scene;
  124687. private _physicsEngine;
  124688. /**
  124689. * Initializes the Physics helper
  124690. * @param scene Babylon.js scene
  124691. */
  124692. constructor(scene: Scene);
  124693. /**
  124694. * Applies a radial explosion impulse
  124695. * @param origin the origin of the explosion
  124696. * @param radiusOrEventOptions the radius or the options of radial explosion
  124697. * @param strength the explosion strength
  124698. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124699. * @returns A physics radial explosion event, or null
  124700. */
  124701. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124702. /**
  124703. * Applies a radial explosion force
  124704. * @param origin the origin of the explosion
  124705. * @param radiusOrEventOptions the radius or the options of radial explosion
  124706. * @param strength the explosion strength
  124707. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124708. * @returns A physics radial explosion event, or null
  124709. */
  124710. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  124711. /**
  124712. * Creates a gravitational field
  124713. * @param origin the origin of the explosion
  124714. * @param radiusOrEventOptions the radius or the options of radial explosion
  124715. * @param strength the explosion strength
  124716. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124717. * @returns A physics gravitational field event, or null
  124718. */
  124719. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  124720. /**
  124721. * Creates a physics updraft event
  124722. * @param origin the origin of the updraft
  124723. * @param radiusOrEventOptions the radius or the options of the updraft
  124724. * @param strength the strength of the updraft
  124725. * @param height the height of the updraft
  124726. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  124727. * @returns A physics updraft event, or null
  124728. */
  124729. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  124730. /**
  124731. * Creates a physics vortex event
  124732. * @param origin the of the vortex
  124733. * @param radiusOrEventOptions the radius or the options of the vortex
  124734. * @param strength the strength of the vortex
  124735. * @param height the height of the vortex
  124736. * @returns a Physics vortex event, or null
  124737. * A physics vortex event or null
  124738. */
  124739. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  124740. }
  124741. /**
  124742. * Represents a physics radial explosion event
  124743. */
  124744. class PhysicsRadialExplosionEvent {
  124745. private _scene;
  124746. private _options;
  124747. private _sphere;
  124748. private _dataFetched;
  124749. /**
  124750. * Initializes a radial explosioin event
  124751. * @param _scene BabylonJS scene
  124752. * @param _options The options for the vortex event
  124753. */
  124754. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  124755. /**
  124756. * Returns the data related to the radial explosion event (sphere).
  124757. * @returns The radial explosion event data
  124758. */
  124759. getData(): PhysicsRadialExplosionEventData;
  124760. /**
  124761. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  124762. * @param impostor A physics imposter
  124763. * @param origin the origin of the explosion
  124764. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  124765. */
  124766. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  124767. /**
  124768. * Triggers affecterd impostors callbacks
  124769. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  124770. */
  124771. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  124772. /**
  124773. * Disposes the sphere.
  124774. * @param force Specifies if the sphere should be disposed by force
  124775. */
  124776. dispose(force?: boolean): void;
  124777. /*** Helpers ***/
  124778. private _prepareSphere;
  124779. private _intersectsWithSphere;
  124780. }
  124781. /**
  124782. * Represents a gravitational field event
  124783. */
  124784. class PhysicsGravitationalFieldEvent {
  124785. private _physicsHelper;
  124786. private _scene;
  124787. private _origin;
  124788. private _options;
  124789. private _tickCallback;
  124790. private _sphere;
  124791. private _dataFetched;
  124792. /**
  124793. * Initializes the physics gravitational field event
  124794. * @param _physicsHelper A physics helper
  124795. * @param _scene BabylonJS scene
  124796. * @param _origin The origin position of the gravitational field event
  124797. * @param _options The options for the vortex event
  124798. */
  124799. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  124800. /**
  124801. * Returns the data related to the gravitational field event (sphere).
  124802. * @returns A gravitational field event
  124803. */
  124804. getData(): PhysicsGravitationalFieldEventData;
  124805. /**
  124806. * Enables the gravitational field.
  124807. */
  124808. enable(): void;
  124809. /**
  124810. * Disables the gravitational field.
  124811. */
  124812. disable(): void;
  124813. /**
  124814. * Disposes the sphere.
  124815. * @param force The force to dispose from the gravitational field event
  124816. */
  124817. dispose(force?: boolean): void;
  124818. private _tick;
  124819. }
  124820. /**
  124821. * Represents a physics updraft event
  124822. */
  124823. class PhysicsUpdraftEvent {
  124824. private _scene;
  124825. private _origin;
  124826. private _options;
  124827. private _physicsEngine;
  124828. private _originTop;
  124829. private _originDirection;
  124830. private _tickCallback;
  124831. private _cylinder;
  124832. private _cylinderPosition;
  124833. private _dataFetched;
  124834. /**
  124835. * Initializes the physics updraft event
  124836. * @param _scene BabylonJS scene
  124837. * @param _origin The origin position of the updraft
  124838. * @param _options The options for the updraft event
  124839. */
  124840. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  124841. /**
  124842. * Returns the data related to the updraft event (cylinder).
  124843. * @returns A physics updraft event
  124844. */
  124845. getData(): PhysicsUpdraftEventData;
  124846. /**
  124847. * Enables the updraft.
  124848. */
  124849. enable(): void;
  124850. /**
  124851. * Disables the updraft.
  124852. */
  124853. disable(): void;
  124854. /**
  124855. * Disposes the cylinder.
  124856. * @param force Specifies if the updraft should be disposed by force
  124857. */
  124858. dispose(force?: boolean): void;
  124859. private getImpostorHitData;
  124860. private _tick;
  124861. /*** Helpers ***/
  124862. private _prepareCylinder;
  124863. private _intersectsWithCylinder;
  124864. }
  124865. /**
  124866. * Represents a physics vortex event
  124867. */
  124868. class PhysicsVortexEvent {
  124869. private _scene;
  124870. private _origin;
  124871. private _options;
  124872. private _physicsEngine;
  124873. private _originTop;
  124874. private _tickCallback;
  124875. private _cylinder;
  124876. private _cylinderPosition;
  124877. private _dataFetched;
  124878. /**
  124879. * Initializes the physics vortex event
  124880. * @param _scene The BabylonJS scene
  124881. * @param _origin The origin position of the vortex
  124882. * @param _options The options for the vortex event
  124883. */
  124884. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  124885. /**
  124886. * Returns the data related to the vortex event (cylinder).
  124887. * @returns The physics vortex event data
  124888. */
  124889. getData(): PhysicsVortexEventData;
  124890. /**
  124891. * Enables the vortex.
  124892. */
  124893. enable(): void;
  124894. /**
  124895. * Disables the cortex.
  124896. */
  124897. disable(): void;
  124898. /**
  124899. * Disposes the sphere.
  124900. * @param force
  124901. */
  124902. dispose(force?: boolean): void;
  124903. private getImpostorHitData;
  124904. private _tick;
  124905. /*** Helpers ***/
  124906. private _prepareCylinder;
  124907. private _intersectsWithCylinder;
  124908. }
  124909. /**
  124910. * Options fot the radial explosion event
  124911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124912. */
  124913. export class PhysicsRadialExplosionEventOptions {
  124914. /**
  124915. * The radius of the sphere for the radial explosion.
  124916. */
  124917. radius: number;
  124918. /**
  124919. * The strenth of the explosion.
  124920. */
  124921. strength: number;
  124922. /**
  124923. * The strenght of the force in correspondence to the distance of the affected object
  124924. */
  124925. falloff: PhysicsRadialImpulseFalloff;
  124926. /**
  124927. * Sphere options for the radial explosion.
  124928. */
  124929. sphere: {
  124930. segments: number;
  124931. diameter: number;
  124932. };
  124933. /**
  124934. * Sphere options for the radial explosion.
  124935. */
  124936. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  124937. }
  124938. /**
  124939. * Options fot the updraft event
  124940. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124941. */
  124942. export class PhysicsUpdraftEventOptions {
  124943. /**
  124944. * The radius of the cylinder for the vortex
  124945. */
  124946. radius: number;
  124947. /**
  124948. * The strenth of the updraft.
  124949. */
  124950. strength: number;
  124951. /**
  124952. * The height of the cylinder for the updraft.
  124953. */
  124954. height: number;
  124955. /**
  124956. * The mode for the the updraft.
  124957. */
  124958. updraftMode: PhysicsUpdraftMode;
  124959. }
  124960. /**
  124961. * Options fot the vortex event
  124962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124963. */
  124964. export class PhysicsVortexEventOptions {
  124965. /**
  124966. * The radius of the cylinder for the vortex
  124967. */
  124968. radius: number;
  124969. /**
  124970. * The strenth of the vortex.
  124971. */
  124972. strength: number;
  124973. /**
  124974. * The height of the cylinder for the vortex.
  124975. */
  124976. height: number;
  124977. /**
  124978. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  124979. */
  124980. centripetalForceThreshold: number;
  124981. /**
  124982. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  124983. */
  124984. centripetalForceMultiplier: number;
  124985. /**
  124986. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  124987. */
  124988. centrifugalForceMultiplier: number;
  124989. /**
  124990. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  124991. */
  124992. updraftForceMultiplier: number;
  124993. }
  124994. /**
  124995. * The strenght of the force in correspondence to the distance of the affected object
  124996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124997. */
  124998. export enum PhysicsRadialImpulseFalloff {
  124999. /** Defines that impulse is constant in strength across it's whole radius */
  125000. Constant = 0,
  125001. /** Defines that impulse gets weaker if it's further from the origin */
  125002. Linear = 1
  125003. }
  125004. /**
  125005. * The strength of the force in correspondence to the distance of the affected object
  125006. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125007. */
  125008. export enum PhysicsUpdraftMode {
  125009. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125010. Center = 0,
  125011. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125012. Perpendicular = 1
  125013. }
  125014. /**
  125015. * Interface for a physics hit data
  125016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125017. */
  125018. export interface PhysicsHitData {
  125019. /**
  125020. * The force applied at the contact point
  125021. */
  125022. force: Vector3;
  125023. /**
  125024. * The contact point
  125025. */
  125026. contactPoint: Vector3;
  125027. /**
  125028. * The distance from the origin to the contact point
  125029. */
  125030. distanceFromOrigin: number;
  125031. }
  125032. /**
  125033. * Interface for radial explosion event data
  125034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125035. */
  125036. export interface PhysicsRadialExplosionEventData {
  125037. /**
  125038. * A sphere used for the radial explosion event
  125039. */
  125040. sphere: Mesh;
  125041. }
  125042. /**
  125043. * Interface for gravitational field event data
  125044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125045. */
  125046. export interface PhysicsGravitationalFieldEventData {
  125047. /**
  125048. * A sphere mesh used for the gravitational field event
  125049. */
  125050. sphere: Mesh;
  125051. }
  125052. /**
  125053. * Interface for updraft event data
  125054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125055. */
  125056. export interface PhysicsUpdraftEventData {
  125057. /**
  125058. * A cylinder used for the updraft event
  125059. */
  125060. cylinder: Mesh;
  125061. }
  125062. /**
  125063. * Interface for vortex event data
  125064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125065. */
  125066. export interface PhysicsVortexEventData {
  125067. /**
  125068. * A cylinder used for the vortex event
  125069. */
  125070. cylinder: Mesh;
  125071. }
  125072. /**
  125073. * Interface for an affected physics impostor
  125074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125075. */
  125076. export interface PhysicsAffectedImpostorWithData {
  125077. /**
  125078. * The impostor affected by the effect
  125079. */
  125080. impostor: PhysicsImpostor;
  125081. /**
  125082. * The data about the hit/horce from the explosion
  125083. */
  125084. hitData: PhysicsHitData;
  125085. }
  125086. }
  125087. declare module BABYLON {
  125088. /** @hidden */
  125089. export var blackAndWhitePixelShader: {
  125090. name: string;
  125091. shader: string;
  125092. };
  125093. }
  125094. declare module BABYLON {
  125095. /**
  125096. * Post process used to render in black and white
  125097. */
  125098. export class BlackAndWhitePostProcess extends PostProcess {
  125099. /**
  125100. * Linear about to convert he result to black and white (default: 1)
  125101. */
  125102. degree: number;
  125103. /**
  125104. * Creates a black and white post process
  125105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125106. * @param name The name of the effect.
  125107. * @param options The required width/height ratio to downsize to before computing the render pass.
  125108. * @param camera The camera to apply the render pass to.
  125109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125110. * @param engine The engine which the post process will be applied. (default: current engine)
  125111. * @param reusable If the post process can be reused on the same frame. (default: false)
  125112. */
  125113. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125114. }
  125115. }
  125116. declare module BABYLON {
  125117. /**
  125118. * This represents a set of one or more post processes in Babylon.
  125119. * A post process can be used to apply a shader to a texture after it is rendered.
  125120. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125121. */
  125122. export class PostProcessRenderEffect {
  125123. private _postProcesses;
  125124. private _getPostProcesses;
  125125. private _singleInstance;
  125126. private _cameras;
  125127. private _indicesForCamera;
  125128. /**
  125129. * Name of the effect
  125130. * @hidden
  125131. */
  125132. _name: string;
  125133. /**
  125134. * Instantiates a post process render effect.
  125135. * A post process can be used to apply a shader to a texture after it is rendered.
  125136. * @param engine The engine the effect is tied to
  125137. * @param name The name of the effect
  125138. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125139. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125140. */
  125141. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125142. /**
  125143. * Checks if all the post processes in the effect are supported.
  125144. */
  125145. readonly isSupported: boolean;
  125146. /**
  125147. * Updates the current state of the effect
  125148. * @hidden
  125149. */
  125150. _update(): void;
  125151. /**
  125152. * Attaches the effect on cameras
  125153. * @param cameras The camera to attach to.
  125154. * @hidden
  125155. */
  125156. _attachCameras(cameras: Camera): void;
  125157. /**
  125158. * Attaches the effect on cameras
  125159. * @param cameras The camera to attach to.
  125160. * @hidden
  125161. */
  125162. _attachCameras(cameras: Camera[]): void;
  125163. /**
  125164. * Detaches the effect on cameras
  125165. * @param cameras The camera to detatch from.
  125166. * @hidden
  125167. */
  125168. _detachCameras(cameras: Camera): void;
  125169. /**
  125170. * Detatches the effect on cameras
  125171. * @param cameras The camera to detatch from.
  125172. * @hidden
  125173. */
  125174. _detachCameras(cameras: Camera[]): void;
  125175. /**
  125176. * Enables the effect on given cameras
  125177. * @param cameras The camera to enable.
  125178. * @hidden
  125179. */
  125180. _enable(cameras: Camera): void;
  125181. /**
  125182. * Enables the effect on given cameras
  125183. * @param cameras The camera to enable.
  125184. * @hidden
  125185. */
  125186. _enable(cameras: Nullable<Camera[]>): void;
  125187. /**
  125188. * Disables the effect on the given cameras
  125189. * @param cameras The camera to disable.
  125190. * @hidden
  125191. */
  125192. _disable(cameras: Camera): void;
  125193. /**
  125194. * Disables the effect on the given cameras
  125195. * @param cameras The camera to disable.
  125196. * @hidden
  125197. */
  125198. _disable(cameras: Nullable<Camera[]>): void;
  125199. /**
  125200. * Gets a list of the post processes contained in the effect.
  125201. * @param camera The camera to get the post processes on.
  125202. * @returns The list of the post processes in the effect.
  125203. */
  125204. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125205. }
  125206. }
  125207. declare module BABYLON {
  125208. /** @hidden */
  125209. export var extractHighlightsPixelShader: {
  125210. name: string;
  125211. shader: string;
  125212. };
  125213. }
  125214. declare module BABYLON {
  125215. /**
  125216. * 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.
  125217. */
  125218. export class ExtractHighlightsPostProcess extends PostProcess {
  125219. /**
  125220. * The luminance threshold, pixels below this value will be set to black.
  125221. */
  125222. threshold: number;
  125223. /** @hidden */
  125224. _exposure: number;
  125225. /**
  125226. * Post process which has the input texture to be used when performing highlight extraction
  125227. * @hidden
  125228. */
  125229. _inputPostProcess: Nullable<PostProcess>;
  125230. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125231. }
  125232. }
  125233. declare module BABYLON {
  125234. /** @hidden */
  125235. export var bloomMergePixelShader: {
  125236. name: string;
  125237. shader: string;
  125238. };
  125239. }
  125240. declare module BABYLON {
  125241. /**
  125242. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125243. */
  125244. export class BloomMergePostProcess extends PostProcess {
  125245. /** Weight of the bloom to be added to the original input. */
  125246. weight: number;
  125247. /**
  125248. * Creates a new instance of @see BloomMergePostProcess
  125249. * @param name The name of the effect.
  125250. * @param originalFromInput Post process which's input will be used for the merge.
  125251. * @param blurred Blurred highlights post process which's output will be used.
  125252. * @param weight Weight of the bloom to be added to the original input.
  125253. * @param options The required width/height ratio to downsize to before computing the render pass.
  125254. * @param camera The camera to apply the render pass to.
  125255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125256. * @param engine The engine which the post process will be applied. (default: current engine)
  125257. * @param reusable If the post process can be reused on the same frame. (default: false)
  125258. * @param textureType Type of textures used when performing the post process. (default: 0)
  125259. * @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)
  125260. */
  125261. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125262. /** Weight of the bloom to be added to the original input. */
  125263. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125264. }
  125265. }
  125266. declare module BABYLON {
  125267. /**
  125268. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125269. */
  125270. export class BloomEffect extends PostProcessRenderEffect {
  125271. private bloomScale;
  125272. /**
  125273. * @hidden Internal
  125274. */
  125275. _effects: Array<PostProcess>;
  125276. /**
  125277. * @hidden Internal
  125278. */
  125279. _downscale: ExtractHighlightsPostProcess;
  125280. private _blurX;
  125281. private _blurY;
  125282. private _merge;
  125283. /**
  125284. * The luminance threshold to find bright areas of the image to bloom.
  125285. */
  125286. threshold: number;
  125287. /**
  125288. * The strength of the bloom.
  125289. */
  125290. weight: number;
  125291. /**
  125292. * Specifies the size of the bloom blur kernel, relative to the final output size
  125293. */
  125294. kernel: number;
  125295. /**
  125296. * Creates a new instance of @see BloomEffect
  125297. * @param scene The scene the effect belongs to.
  125298. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125299. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125300. * @param bloomWeight The the strength of bloom.
  125301. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125302. * @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)
  125303. */
  125304. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125305. /**
  125306. * Disposes each of the internal effects for a given camera.
  125307. * @param camera The camera to dispose the effect on.
  125308. */
  125309. disposeEffects(camera: Camera): void;
  125310. /**
  125311. * @hidden Internal
  125312. */
  125313. _updateEffects(): void;
  125314. /**
  125315. * Internal
  125316. * @returns if all the contained post processes are ready.
  125317. * @hidden
  125318. */
  125319. _isReady(): boolean;
  125320. }
  125321. }
  125322. declare module BABYLON {
  125323. /** @hidden */
  125324. export var chromaticAberrationPixelShader: {
  125325. name: string;
  125326. shader: string;
  125327. };
  125328. }
  125329. declare module BABYLON {
  125330. /**
  125331. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125332. */
  125333. export class ChromaticAberrationPostProcess extends PostProcess {
  125334. /**
  125335. * The amount of seperation of rgb channels (default: 30)
  125336. */
  125337. aberrationAmount: number;
  125338. /**
  125339. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125340. */
  125341. radialIntensity: number;
  125342. /**
  125343. * 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))
  125344. */
  125345. direction: Vector2;
  125346. /**
  125347. * 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))
  125348. */
  125349. centerPosition: Vector2;
  125350. /**
  125351. * Creates a new instance ChromaticAberrationPostProcess
  125352. * @param name The name of the effect.
  125353. * @param screenWidth The width of the screen to apply the effect on.
  125354. * @param screenHeight The height of the screen to apply the effect on.
  125355. * @param options The required width/height ratio to downsize to before computing the render pass.
  125356. * @param camera The camera to apply the render pass to.
  125357. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125358. * @param engine The engine which the post process will be applied. (default: current engine)
  125359. * @param reusable If the post process can be reused on the same frame. (default: false)
  125360. * @param textureType Type of textures used when performing the post process. (default: 0)
  125361. * @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)
  125362. */
  125363. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125364. }
  125365. }
  125366. declare module BABYLON {
  125367. /** @hidden */
  125368. export var circleOfConfusionPixelShader: {
  125369. name: string;
  125370. shader: string;
  125371. };
  125372. }
  125373. declare module BABYLON {
  125374. /**
  125375. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125376. */
  125377. export class CircleOfConfusionPostProcess extends PostProcess {
  125378. /**
  125379. * 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.
  125380. */
  125381. lensSize: number;
  125382. /**
  125383. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125384. */
  125385. fStop: number;
  125386. /**
  125387. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125388. */
  125389. focusDistance: number;
  125390. /**
  125391. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125392. */
  125393. focalLength: number;
  125394. private _depthTexture;
  125395. /**
  125396. * Creates a new instance CircleOfConfusionPostProcess
  125397. * @param name The name of the effect.
  125398. * @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.
  125399. * @param options The required width/height ratio to downsize to before computing the render pass.
  125400. * @param camera The camera to apply the render pass to.
  125401. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125402. * @param engine The engine which the post process will be applied. (default: current engine)
  125403. * @param reusable If the post process can be reused on the same frame. (default: false)
  125404. * @param textureType Type of textures used when performing the post process. (default: 0)
  125405. * @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)
  125406. */
  125407. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125408. /**
  125409. * 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.
  125410. */
  125411. depthTexture: RenderTargetTexture;
  125412. }
  125413. }
  125414. declare module BABYLON {
  125415. /** @hidden */
  125416. export var colorCorrectionPixelShader: {
  125417. name: string;
  125418. shader: string;
  125419. };
  125420. }
  125421. declare module BABYLON {
  125422. /**
  125423. *
  125424. * This post-process allows the modification of rendered colors by using
  125425. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125426. *
  125427. * The object needs to be provided an url to a texture containing the color
  125428. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125429. * Use an image editing software to tweak the LUT to match your needs.
  125430. *
  125431. * For an example of a color LUT, see here:
  125432. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125433. * For explanations on color grading, see here:
  125434. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125435. *
  125436. */
  125437. export class ColorCorrectionPostProcess extends PostProcess {
  125438. private _colorTableTexture;
  125439. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125440. }
  125441. }
  125442. declare module BABYLON {
  125443. /** @hidden */
  125444. export var convolutionPixelShader: {
  125445. name: string;
  125446. shader: string;
  125447. };
  125448. }
  125449. declare module BABYLON {
  125450. /**
  125451. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125452. * input texture to perform effects such as edge detection or sharpening
  125453. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125454. */
  125455. export class ConvolutionPostProcess extends PostProcess {
  125456. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125457. kernel: number[];
  125458. /**
  125459. * Creates a new instance ConvolutionPostProcess
  125460. * @param name The name of the effect.
  125461. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125462. * @param options The required width/height ratio to downsize to before computing the render pass.
  125463. * @param camera The camera to apply the render pass to.
  125464. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125465. * @param engine The engine which the post process will be applied. (default: current engine)
  125466. * @param reusable If the post process can be reused on the same frame. (default: false)
  125467. * @param textureType Type of textures used when performing the post process. (default: 0)
  125468. */
  125469. constructor(name: string,
  125470. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125471. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125472. /**
  125473. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125474. */
  125475. static EdgeDetect0Kernel: number[];
  125476. /**
  125477. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125478. */
  125479. static EdgeDetect1Kernel: number[];
  125480. /**
  125481. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125482. */
  125483. static EdgeDetect2Kernel: number[];
  125484. /**
  125485. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125486. */
  125487. static SharpenKernel: number[];
  125488. /**
  125489. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125490. */
  125491. static EmbossKernel: number[];
  125492. /**
  125493. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125494. */
  125495. static GaussianKernel: number[];
  125496. }
  125497. }
  125498. declare module BABYLON {
  125499. /**
  125500. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125501. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125502. * based on samples that have a large difference in distance than the center pixel.
  125503. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125504. */
  125505. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125506. direction: Vector2;
  125507. /**
  125508. * Creates a new instance CircleOfConfusionPostProcess
  125509. * @param name The name of the effect.
  125510. * @param scene The scene the effect belongs to.
  125511. * @param direction The direction the blur should be applied.
  125512. * @param kernel The size of the kernel used to blur.
  125513. * @param options The required width/height ratio to downsize to before computing the render pass.
  125514. * @param camera The camera to apply the render pass to.
  125515. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125516. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125518. * @param engine The engine which the post process will be applied. (default: current engine)
  125519. * @param reusable If the post process can be reused on the same frame. (default: false)
  125520. * @param textureType Type of textures used when performing the post process. (default: 0)
  125521. * @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)
  125522. */
  125523. 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);
  125524. }
  125525. }
  125526. declare module BABYLON {
  125527. /** @hidden */
  125528. export var depthOfFieldMergePixelShader: {
  125529. name: string;
  125530. shader: string;
  125531. };
  125532. }
  125533. declare module BABYLON {
  125534. /**
  125535. * Options to be set when merging outputs from the default pipeline.
  125536. */
  125537. export class DepthOfFieldMergePostProcessOptions {
  125538. /**
  125539. * The original image to merge on top of
  125540. */
  125541. originalFromInput: PostProcess;
  125542. /**
  125543. * Parameters to perform the merge of the depth of field effect
  125544. */
  125545. depthOfField?: {
  125546. circleOfConfusion: PostProcess;
  125547. blurSteps: Array<PostProcess>;
  125548. };
  125549. /**
  125550. * Parameters to perform the merge of bloom effect
  125551. */
  125552. bloom?: {
  125553. blurred: PostProcess;
  125554. weight: number;
  125555. };
  125556. }
  125557. /**
  125558. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125559. */
  125560. export class DepthOfFieldMergePostProcess extends PostProcess {
  125561. private blurSteps;
  125562. /**
  125563. * Creates a new instance of DepthOfFieldMergePostProcess
  125564. * @param name The name of the effect.
  125565. * @param originalFromInput Post process which's input will be used for the merge.
  125566. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125567. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125568. * @param options The required width/height ratio to downsize to before computing the render pass.
  125569. * @param camera The camera to apply the render pass to.
  125570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125571. * @param engine The engine which the post process will be applied. (default: current engine)
  125572. * @param reusable If the post process can be reused on the same frame. (default: false)
  125573. * @param textureType Type of textures used when performing the post process. (default: 0)
  125574. * @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)
  125575. */
  125576. 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);
  125577. /**
  125578. * Updates the effect with the current post process compile time values and recompiles the shader.
  125579. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125580. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125581. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125582. * @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
  125583. * @param onCompiled Called when the shader has been compiled.
  125584. * @param onError Called if there is an error when compiling a shader.
  125585. */
  125586. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125587. }
  125588. }
  125589. declare module BABYLON {
  125590. /**
  125591. * Specifies the level of max blur that should be applied when using the depth of field effect
  125592. */
  125593. export enum DepthOfFieldEffectBlurLevel {
  125594. /**
  125595. * Subtle blur
  125596. */
  125597. Low = 0,
  125598. /**
  125599. * Medium blur
  125600. */
  125601. Medium = 1,
  125602. /**
  125603. * Large blur
  125604. */
  125605. High = 2
  125606. }
  125607. /**
  125608. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125609. */
  125610. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125611. private _circleOfConfusion;
  125612. /**
  125613. * @hidden Internal, blurs from high to low
  125614. */
  125615. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  125616. private _depthOfFieldBlurY;
  125617. private _dofMerge;
  125618. /**
  125619. * @hidden Internal post processes in depth of field effect
  125620. */
  125621. _effects: Array<PostProcess>;
  125622. /**
  125623. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125624. */
  125625. focalLength: number;
  125626. /**
  125627. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125628. */
  125629. fStop: number;
  125630. /**
  125631. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125632. */
  125633. focusDistance: number;
  125634. /**
  125635. * 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.
  125636. */
  125637. lensSize: number;
  125638. /**
  125639. * Creates a new instance DepthOfFieldEffect
  125640. * @param scene The scene the effect belongs to.
  125641. * @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.
  125642. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125643. * @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)
  125644. */
  125645. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  125646. /**
  125647. * Get the current class name of the current effet
  125648. * @returns "DepthOfFieldEffect"
  125649. */
  125650. getClassName(): string;
  125651. /**
  125652. * 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.
  125653. */
  125654. depthTexture: RenderTargetTexture;
  125655. /**
  125656. * Disposes each of the internal effects for a given camera.
  125657. * @param camera The camera to dispose the effect on.
  125658. */
  125659. disposeEffects(camera: Camera): void;
  125660. /**
  125661. * @hidden Internal
  125662. */
  125663. _updateEffects(): void;
  125664. /**
  125665. * Internal
  125666. * @returns if all the contained post processes are ready.
  125667. * @hidden
  125668. */
  125669. _isReady(): boolean;
  125670. }
  125671. }
  125672. declare module BABYLON {
  125673. /** @hidden */
  125674. export var displayPassPixelShader: {
  125675. name: string;
  125676. shader: string;
  125677. };
  125678. }
  125679. declare module BABYLON {
  125680. /**
  125681. * DisplayPassPostProcess which produces an output the same as it's input
  125682. */
  125683. export class DisplayPassPostProcess extends PostProcess {
  125684. /**
  125685. * Creates the DisplayPassPostProcess
  125686. * @param name The name of the effect.
  125687. * @param options The required width/height ratio to downsize to before computing the render pass.
  125688. * @param camera The camera to apply the render pass to.
  125689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125690. * @param engine The engine which the post process will be applied. (default: current engine)
  125691. * @param reusable If the post process can be reused on the same frame. (default: false)
  125692. */
  125693. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125694. }
  125695. }
  125696. declare module BABYLON {
  125697. /** @hidden */
  125698. export var filterPixelShader: {
  125699. name: string;
  125700. shader: string;
  125701. };
  125702. }
  125703. declare module BABYLON {
  125704. /**
  125705. * Applies a kernel filter to the image
  125706. */
  125707. export class FilterPostProcess extends PostProcess {
  125708. /** The matrix to be applied to the image */
  125709. kernelMatrix: Matrix;
  125710. /**
  125711. *
  125712. * @param name The name of the effect.
  125713. * @param kernelMatrix The matrix to be applied to the image
  125714. * @param options The required width/height ratio to downsize to before computing the render pass.
  125715. * @param camera The camera to apply the render pass to.
  125716. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125717. * @param engine The engine which the post process will be applied. (default: current engine)
  125718. * @param reusable If the post process can be reused on the same frame. (default: false)
  125719. */
  125720. constructor(name: string,
  125721. /** The matrix to be applied to the image */
  125722. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125723. }
  125724. }
  125725. declare module BABYLON {
  125726. /** @hidden */
  125727. export var fxaaPixelShader: {
  125728. name: string;
  125729. shader: string;
  125730. };
  125731. }
  125732. declare module BABYLON {
  125733. /** @hidden */
  125734. export var fxaaVertexShader: {
  125735. name: string;
  125736. shader: string;
  125737. };
  125738. }
  125739. declare module BABYLON {
  125740. /**
  125741. * Fxaa post process
  125742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  125743. */
  125744. export class FxaaPostProcess extends PostProcess {
  125745. /** @hidden */
  125746. texelWidth: number;
  125747. /** @hidden */
  125748. texelHeight: number;
  125749. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125750. private _getDefines;
  125751. }
  125752. }
  125753. declare module BABYLON {
  125754. /** @hidden */
  125755. export var grainPixelShader: {
  125756. name: string;
  125757. shader: string;
  125758. };
  125759. }
  125760. declare module BABYLON {
  125761. /**
  125762. * The GrainPostProcess adds noise to the image at mid luminance levels
  125763. */
  125764. export class GrainPostProcess extends PostProcess {
  125765. /**
  125766. * The intensity of the grain added (default: 30)
  125767. */
  125768. intensity: number;
  125769. /**
  125770. * If the grain should be randomized on every frame
  125771. */
  125772. animated: boolean;
  125773. /**
  125774. * Creates a new instance of @see GrainPostProcess
  125775. * @param name The name of the effect.
  125776. * @param options The required width/height ratio to downsize to before computing the render pass.
  125777. * @param camera The camera to apply the render pass to.
  125778. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125779. * @param engine The engine which the post process will be applied. (default: current engine)
  125780. * @param reusable If the post process can be reused on the same frame. (default: false)
  125781. * @param textureType Type of textures used when performing the post process. (default: 0)
  125782. * @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)
  125783. */
  125784. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125785. }
  125786. }
  125787. declare module BABYLON {
  125788. /** @hidden */
  125789. export var highlightsPixelShader: {
  125790. name: string;
  125791. shader: string;
  125792. };
  125793. }
  125794. declare module BABYLON {
  125795. /**
  125796. * Extracts highlights from the image
  125797. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125798. */
  125799. export class HighlightsPostProcess extends PostProcess {
  125800. /**
  125801. * Extracts highlights from the image
  125802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  125803. * @param name The name of the effect.
  125804. * @param options The required width/height ratio to downsize to before computing the render pass.
  125805. * @param camera The camera to apply the render pass to.
  125806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125807. * @param engine The engine which the post process will be applied. (default: current engine)
  125808. * @param reusable If the post process can be reused on the same frame. (default: false)
  125809. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  125810. */
  125811. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125812. }
  125813. }
  125814. declare module BABYLON {
  125815. /** @hidden */
  125816. export var mrtFragmentDeclaration: {
  125817. name: string;
  125818. shader: string;
  125819. };
  125820. }
  125821. declare module BABYLON {
  125822. /** @hidden */
  125823. export var geometryPixelShader: {
  125824. name: string;
  125825. shader: string;
  125826. };
  125827. }
  125828. declare module BABYLON {
  125829. /** @hidden */
  125830. export var geometryVertexShader: {
  125831. name: string;
  125832. shader: string;
  125833. };
  125834. }
  125835. declare module BABYLON {
  125836. /** @hidden */
  125837. interface ISavedTransformationMatrix {
  125838. world: Matrix;
  125839. viewProjection: Matrix;
  125840. }
  125841. /**
  125842. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  125843. */
  125844. export class GeometryBufferRenderer {
  125845. /**
  125846. * Constant used to retrieve the position texture index in the G-Buffer textures array
  125847. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  125848. */
  125849. static readonly POSITION_TEXTURE_TYPE: number;
  125850. /**
  125851. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  125852. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  125853. */
  125854. static readonly VELOCITY_TEXTURE_TYPE: number;
  125855. /**
  125856. * Dictionary used to store the previous transformation matrices of each rendered mesh
  125857. * in order to compute objects velocities when enableVelocity is set to "true"
  125858. * @hidden
  125859. */
  125860. _previousTransformationMatrices: {
  125861. [index: number]: ISavedTransformationMatrix;
  125862. };
  125863. /**
  125864. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  125865. * in order to compute objects velocities when enableVelocity is set to "true"
  125866. * @hidden
  125867. */
  125868. _previousBonesTransformationMatrices: {
  125869. [index: number]: Float32Array;
  125870. };
  125871. /**
  125872. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  125873. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  125874. */
  125875. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  125876. private _scene;
  125877. private _multiRenderTarget;
  125878. private _ratio;
  125879. private _enablePosition;
  125880. private _enableVelocity;
  125881. private _positionIndex;
  125882. private _velocityIndex;
  125883. protected _effect: Effect;
  125884. protected _cachedDefines: string;
  125885. /**
  125886. * Set the render list (meshes to be rendered) used in the G buffer.
  125887. */
  125888. renderList: Mesh[];
  125889. /**
  125890. * Gets wether or not G buffer are supported by the running hardware.
  125891. * This requires draw buffer supports
  125892. */
  125893. readonly isSupported: boolean;
  125894. /**
  125895. * Returns the index of the given texture type in the G-Buffer textures array
  125896. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  125897. * @returns the index of the given texture type in the G-Buffer textures array
  125898. */
  125899. getTextureIndex(textureType: number): number;
  125900. /**
  125901. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  125902. */
  125903. /**
  125904. * Sets whether or not objects positions are enabled for the G buffer.
  125905. */
  125906. enablePosition: boolean;
  125907. /**
  125908. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  125909. */
  125910. /**
  125911. * Sets wether or not objects velocities are enabled for the G buffer.
  125912. */
  125913. enableVelocity: boolean;
  125914. /**
  125915. * Gets the scene associated with the buffer.
  125916. */
  125917. readonly scene: Scene;
  125918. /**
  125919. * Gets the ratio used by the buffer during its creation.
  125920. * How big is the buffer related to the main canvas.
  125921. */
  125922. readonly ratio: number;
  125923. /** @hidden */
  125924. static _SceneComponentInitialization: (scene: Scene) => void;
  125925. /**
  125926. * Creates a new G Buffer for the scene
  125927. * @param scene The scene the buffer belongs to
  125928. * @param ratio How big is the buffer related to the main canvas.
  125929. */
  125930. constructor(scene: Scene, ratio?: number);
  125931. /**
  125932. * Checks wether everything is ready to render a submesh to the G buffer.
  125933. * @param subMesh the submesh to check readiness for
  125934. * @param useInstances is the mesh drawn using instance or not
  125935. * @returns true if ready otherwise false
  125936. */
  125937. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125938. /**
  125939. * Gets the current underlying G Buffer.
  125940. * @returns the buffer
  125941. */
  125942. getGBuffer(): MultiRenderTarget;
  125943. /**
  125944. * Gets the number of samples used to render the buffer (anti aliasing).
  125945. */
  125946. /**
  125947. * Sets the number of samples used to render the buffer (anti aliasing).
  125948. */
  125949. samples: number;
  125950. /**
  125951. * Disposes the renderer and frees up associated resources.
  125952. */
  125953. dispose(): void;
  125954. protected _createRenderTargets(): void;
  125955. private _copyBonesTransformationMatrices;
  125956. }
  125957. }
  125958. declare module BABYLON {
  125959. interface Scene {
  125960. /** @hidden (Backing field) */
  125961. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  125962. /**
  125963. * Gets or Sets the current geometry buffer associated to the scene.
  125964. */
  125965. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  125966. /**
  125967. * Enables a GeometryBufferRender and associates it with the scene
  125968. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  125969. * @returns the GeometryBufferRenderer
  125970. */
  125971. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  125972. /**
  125973. * Disables the GeometryBufferRender associated with the scene
  125974. */
  125975. disableGeometryBufferRenderer(): void;
  125976. }
  125977. /**
  125978. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  125979. * in several rendering techniques.
  125980. */
  125981. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  125982. /**
  125983. * The component name helpful to identify the component in the list of scene components.
  125984. */
  125985. readonly name: string;
  125986. /**
  125987. * The scene the component belongs to.
  125988. */
  125989. scene: Scene;
  125990. /**
  125991. * Creates a new instance of the component for the given scene
  125992. * @param scene Defines the scene to register the component in
  125993. */
  125994. constructor(scene: Scene);
  125995. /**
  125996. * Registers the component in a given scene
  125997. */
  125998. register(): void;
  125999. /**
  126000. * Rebuilds the elements related to this component in case of
  126001. * context lost for instance.
  126002. */
  126003. rebuild(): void;
  126004. /**
  126005. * Disposes the component and the associated ressources
  126006. */
  126007. dispose(): void;
  126008. private _gatherRenderTargets;
  126009. }
  126010. }
  126011. declare module BABYLON {
  126012. /** @hidden */
  126013. export var motionBlurPixelShader: {
  126014. name: string;
  126015. shader: string;
  126016. };
  126017. }
  126018. declare module BABYLON {
  126019. /**
  126020. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126021. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126022. * As an example, all you have to do is to create the post-process:
  126023. * var mb = new BABYLON.MotionBlurPostProcess(
  126024. * 'mb', // The name of the effect.
  126025. * scene, // The scene containing the objects to blur according to their velocity.
  126026. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126027. * camera // The camera to apply the render pass to.
  126028. * );
  126029. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126030. */
  126031. export class MotionBlurPostProcess extends PostProcess {
  126032. /**
  126033. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126034. */
  126035. motionStrength: number;
  126036. /**
  126037. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126038. */
  126039. /**
  126040. * Sets the number of iterations to be used for motion blur quality
  126041. */
  126042. motionBlurSamples: number;
  126043. private _motionBlurSamples;
  126044. private _geometryBufferRenderer;
  126045. /**
  126046. * Creates a new instance MotionBlurPostProcess
  126047. * @param name The name of the effect.
  126048. * @param scene The scene containing the objects to blur according to their velocity.
  126049. * @param options The required width/height ratio to downsize to before computing the render pass.
  126050. * @param camera The camera to apply the render pass to.
  126051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126052. * @param engine The engine which the post process will be applied. (default: current engine)
  126053. * @param reusable If the post process can be reused on the same frame. (default: false)
  126054. * @param textureType Type of textures used when performing the post process. (default: 0)
  126055. * @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)
  126056. */
  126057. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126058. /**
  126059. * Excludes the given skinned mesh from computing bones velocities.
  126060. * 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.
  126061. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126062. */
  126063. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126064. /**
  126065. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126066. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126067. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126068. */
  126069. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126070. /**
  126071. * Disposes the post process.
  126072. * @param camera The camera to dispose the post process on.
  126073. */
  126074. dispose(camera?: Camera): void;
  126075. }
  126076. }
  126077. declare module BABYLON {
  126078. /** @hidden */
  126079. export var refractionPixelShader: {
  126080. name: string;
  126081. shader: string;
  126082. };
  126083. }
  126084. declare module BABYLON {
  126085. /**
  126086. * Post process which applies a refractin texture
  126087. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126088. */
  126089. export class RefractionPostProcess extends PostProcess {
  126090. /** the base color of the refraction (used to taint the rendering) */
  126091. color: Color3;
  126092. /** simulated refraction depth */
  126093. depth: number;
  126094. /** the coefficient of the base color (0 to remove base color tainting) */
  126095. colorLevel: number;
  126096. private _refTexture;
  126097. private _ownRefractionTexture;
  126098. /**
  126099. * Gets or sets the refraction texture
  126100. * Please note that you are responsible for disposing the texture if you set it manually
  126101. */
  126102. refractionTexture: Texture;
  126103. /**
  126104. * Initializes the RefractionPostProcess
  126105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126106. * @param name The name of the effect.
  126107. * @param refractionTextureUrl Url of the refraction texture to use
  126108. * @param color the base color of the refraction (used to taint the rendering)
  126109. * @param depth simulated refraction depth
  126110. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126111. * @param camera The camera to apply the render pass to.
  126112. * @param options The required width/height ratio to downsize to before computing the render pass.
  126113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126114. * @param engine The engine which the post process will be applied. (default: current engine)
  126115. * @param reusable If the post process can be reused on the same frame. (default: false)
  126116. */
  126117. constructor(name: string, refractionTextureUrl: string,
  126118. /** the base color of the refraction (used to taint the rendering) */
  126119. color: Color3,
  126120. /** simulated refraction depth */
  126121. depth: number,
  126122. /** the coefficient of the base color (0 to remove base color tainting) */
  126123. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126124. /**
  126125. * Disposes of the post process
  126126. * @param camera Camera to dispose post process on
  126127. */
  126128. dispose(camera: Camera): void;
  126129. }
  126130. }
  126131. declare module BABYLON {
  126132. /** @hidden */
  126133. export var sharpenPixelShader: {
  126134. name: string;
  126135. shader: string;
  126136. };
  126137. }
  126138. declare module BABYLON {
  126139. /**
  126140. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126141. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126142. */
  126143. export class SharpenPostProcess extends PostProcess {
  126144. /**
  126145. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126146. */
  126147. colorAmount: number;
  126148. /**
  126149. * How much sharpness should be applied (default: 0.3)
  126150. */
  126151. edgeAmount: number;
  126152. /**
  126153. * Creates a new instance ConvolutionPostProcess
  126154. * @param name The name of the effect.
  126155. * @param options The required width/height ratio to downsize to before computing the render pass.
  126156. * @param camera The camera to apply the render pass to.
  126157. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126158. * @param engine The engine which the post process will be applied. (default: current engine)
  126159. * @param reusable If the post process can be reused on the same frame. (default: false)
  126160. * @param textureType Type of textures used when performing the post process. (default: 0)
  126161. * @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)
  126162. */
  126163. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126164. }
  126165. }
  126166. declare module BABYLON {
  126167. /**
  126168. * PostProcessRenderPipeline
  126169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126170. */
  126171. export class PostProcessRenderPipeline {
  126172. private engine;
  126173. private _renderEffects;
  126174. private _renderEffectsForIsolatedPass;
  126175. /**
  126176. * List of inspectable custom properties (used by the Inspector)
  126177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126178. */
  126179. inspectableCustomProperties: IInspectable[];
  126180. /**
  126181. * @hidden
  126182. */
  126183. protected _cameras: Camera[];
  126184. /** @hidden */
  126185. _name: string;
  126186. /**
  126187. * Gets pipeline name
  126188. */
  126189. readonly name: string;
  126190. /**
  126191. * Initializes a PostProcessRenderPipeline
  126192. * @param engine engine to add the pipeline to
  126193. * @param name name of the pipeline
  126194. */
  126195. constructor(engine: Engine, name: string);
  126196. /**
  126197. * Gets the class name
  126198. * @returns "PostProcessRenderPipeline"
  126199. */
  126200. getClassName(): string;
  126201. /**
  126202. * If all the render effects in the pipeline are supported
  126203. */
  126204. readonly isSupported: boolean;
  126205. /**
  126206. * Adds an effect to the pipeline
  126207. * @param renderEffect the effect to add
  126208. */
  126209. addEffect(renderEffect: PostProcessRenderEffect): void;
  126210. /** @hidden */
  126211. _rebuild(): void;
  126212. /** @hidden */
  126213. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126214. /** @hidden */
  126215. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126216. /** @hidden */
  126217. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126218. /** @hidden */
  126219. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126220. /** @hidden */
  126221. _attachCameras(cameras: Camera, unique: boolean): void;
  126222. /** @hidden */
  126223. _attachCameras(cameras: Camera[], unique: boolean): void;
  126224. /** @hidden */
  126225. _detachCameras(cameras: Camera): void;
  126226. /** @hidden */
  126227. _detachCameras(cameras: Nullable<Camera[]>): void;
  126228. /** @hidden */
  126229. _update(): void;
  126230. /** @hidden */
  126231. _reset(): void;
  126232. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126233. /**
  126234. * Disposes of the pipeline
  126235. */
  126236. dispose(): void;
  126237. }
  126238. }
  126239. declare module BABYLON {
  126240. /**
  126241. * PostProcessRenderPipelineManager class
  126242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126243. */
  126244. export class PostProcessRenderPipelineManager {
  126245. private _renderPipelines;
  126246. /**
  126247. * Initializes a PostProcessRenderPipelineManager
  126248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126249. */
  126250. constructor();
  126251. /**
  126252. * Gets the list of supported render pipelines
  126253. */
  126254. readonly supportedPipelines: PostProcessRenderPipeline[];
  126255. /**
  126256. * Adds a pipeline to the manager
  126257. * @param renderPipeline The pipeline to add
  126258. */
  126259. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126260. /**
  126261. * Attaches a camera to the pipeline
  126262. * @param renderPipelineName The name of the pipeline to attach to
  126263. * @param cameras the camera to attach
  126264. * @param unique if the camera can be attached multiple times to the pipeline
  126265. */
  126266. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126267. /**
  126268. * Detaches a camera from the pipeline
  126269. * @param renderPipelineName The name of the pipeline to detach from
  126270. * @param cameras the camera to detach
  126271. */
  126272. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126273. /**
  126274. * Enables an effect by name on a pipeline
  126275. * @param renderPipelineName the name of the pipeline to enable the effect in
  126276. * @param renderEffectName the name of the effect to enable
  126277. * @param cameras the cameras that the effect should be enabled on
  126278. */
  126279. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126280. /**
  126281. * Disables an effect by name on a pipeline
  126282. * @param renderPipelineName the name of the pipeline to disable the effect in
  126283. * @param renderEffectName the name of the effect to disable
  126284. * @param cameras the cameras that the effect should be disabled on
  126285. */
  126286. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126287. /**
  126288. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126289. */
  126290. update(): void;
  126291. /** @hidden */
  126292. _rebuild(): void;
  126293. /**
  126294. * Disposes of the manager and pipelines
  126295. */
  126296. dispose(): void;
  126297. }
  126298. }
  126299. declare module BABYLON {
  126300. interface Scene {
  126301. /** @hidden (Backing field) */
  126302. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126303. /**
  126304. * Gets the postprocess render pipeline manager
  126305. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126306. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126307. */
  126308. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126309. }
  126310. /**
  126311. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126312. */
  126313. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126314. /**
  126315. * The component name helpfull to identify the component in the list of scene components.
  126316. */
  126317. readonly name: string;
  126318. /**
  126319. * The scene the component belongs to.
  126320. */
  126321. scene: Scene;
  126322. /**
  126323. * Creates a new instance of the component for the given scene
  126324. * @param scene Defines the scene to register the component in
  126325. */
  126326. constructor(scene: Scene);
  126327. /**
  126328. * Registers the component in a given scene
  126329. */
  126330. register(): void;
  126331. /**
  126332. * Rebuilds the elements related to this component in case of
  126333. * context lost for instance.
  126334. */
  126335. rebuild(): void;
  126336. /**
  126337. * Disposes the component and the associated ressources
  126338. */
  126339. dispose(): void;
  126340. private _gatherRenderTargets;
  126341. }
  126342. }
  126343. declare module BABYLON {
  126344. /**
  126345. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126346. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126347. */
  126348. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126349. private _scene;
  126350. private _camerasToBeAttached;
  126351. /**
  126352. * ID of the sharpen post process,
  126353. */
  126354. private readonly SharpenPostProcessId;
  126355. /**
  126356. * @ignore
  126357. * ID of the image processing post process;
  126358. */
  126359. readonly ImageProcessingPostProcessId: string;
  126360. /**
  126361. * @ignore
  126362. * ID of the Fast Approximate Anti-Aliasing post process;
  126363. */
  126364. readonly FxaaPostProcessId: string;
  126365. /**
  126366. * ID of the chromatic aberration post process,
  126367. */
  126368. private readonly ChromaticAberrationPostProcessId;
  126369. /**
  126370. * ID of the grain post process
  126371. */
  126372. private readonly GrainPostProcessId;
  126373. /**
  126374. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126375. */
  126376. sharpen: SharpenPostProcess;
  126377. private _sharpenEffect;
  126378. private bloom;
  126379. /**
  126380. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126381. */
  126382. depthOfField: DepthOfFieldEffect;
  126383. /**
  126384. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126385. */
  126386. fxaa: FxaaPostProcess;
  126387. /**
  126388. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126389. */
  126390. imageProcessing: ImageProcessingPostProcess;
  126391. /**
  126392. * Chromatic aberration post process which will shift rgb colors in the image
  126393. */
  126394. chromaticAberration: ChromaticAberrationPostProcess;
  126395. private _chromaticAberrationEffect;
  126396. /**
  126397. * Grain post process which add noise to the image
  126398. */
  126399. grain: GrainPostProcess;
  126400. private _grainEffect;
  126401. /**
  126402. * Glow post process which adds a glow to emissive areas of the image
  126403. */
  126404. private _glowLayer;
  126405. /**
  126406. * Animations which can be used to tweak settings over a period of time
  126407. */
  126408. animations: Animation[];
  126409. private _imageProcessingConfigurationObserver;
  126410. private _sharpenEnabled;
  126411. private _bloomEnabled;
  126412. private _depthOfFieldEnabled;
  126413. private _depthOfFieldBlurLevel;
  126414. private _fxaaEnabled;
  126415. private _imageProcessingEnabled;
  126416. private _defaultPipelineTextureType;
  126417. private _bloomScale;
  126418. private _chromaticAberrationEnabled;
  126419. private _grainEnabled;
  126420. private _buildAllowed;
  126421. /**
  126422. * Gets active scene
  126423. */
  126424. readonly scene: Scene;
  126425. /**
  126426. * Enable or disable the sharpen process from the pipeline
  126427. */
  126428. sharpenEnabled: boolean;
  126429. private _resizeObserver;
  126430. private _hardwareScaleLevel;
  126431. private _bloomKernel;
  126432. /**
  126433. * Specifies the size of the bloom blur kernel, relative to the final output size
  126434. */
  126435. bloomKernel: number;
  126436. /**
  126437. * Specifies the weight of the bloom in the final rendering
  126438. */
  126439. private _bloomWeight;
  126440. /**
  126441. * Specifies the luma threshold for the area that will be blurred by the bloom
  126442. */
  126443. private _bloomThreshold;
  126444. private _hdr;
  126445. /**
  126446. * The strength of the bloom.
  126447. */
  126448. bloomWeight: number;
  126449. /**
  126450. * The strength of the bloom.
  126451. */
  126452. bloomThreshold: number;
  126453. /**
  126454. * The scale of the bloom, lower value will provide better performance.
  126455. */
  126456. bloomScale: number;
  126457. /**
  126458. * Enable or disable the bloom from the pipeline
  126459. */
  126460. bloomEnabled: boolean;
  126461. private _rebuildBloom;
  126462. /**
  126463. * If the depth of field is enabled.
  126464. */
  126465. depthOfFieldEnabled: boolean;
  126466. /**
  126467. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126468. */
  126469. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126470. /**
  126471. * If the anti aliasing is enabled.
  126472. */
  126473. fxaaEnabled: boolean;
  126474. private _samples;
  126475. /**
  126476. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126477. */
  126478. samples: number;
  126479. /**
  126480. * If image processing is enabled.
  126481. */
  126482. imageProcessingEnabled: boolean;
  126483. /**
  126484. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126485. */
  126486. glowLayerEnabled: boolean;
  126487. /**
  126488. * Gets the glow layer (or null if not defined)
  126489. */
  126490. readonly glowLayer: Nullable<GlowLayer>;
  126491. /**
  126492. * Enable or disable the chromaticAberration process from the pipeline
  126493. */
  126494. chromaticAberrationEnabled: boolean;
  126495. /**
  126496. * Enable or disable the grain process from the pipeline
  126497. */
  126498. grainEnabled: boolean;
  126499. /**
  126500. * @constructor
  126501. * @param name - The rendering pipeline name (default: "")
  126502. * @param hdr - If high dynamic range textures should be used (default: true)
  126503. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126504. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126505. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126506. */
  126507. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126508. /**
  126509. * Get the class name
  126510. * @returns "DefaultRenderingPipeline"
  126511. */
  126512. getClassName(): string;
  126513. /**
  126514. * Force the compilation of the entire pipeline.
  126515. */
  126516. prepare(): void;
  126517. private _hasCleared;
  126518. private _prevPostProcess;
  126519. private _prevPrevPostProcess;
  126520. private _setAutoClearAndTextureSharing;
  126521. private _depthOfFieldSceneObserver;
  126522. private _buildPipeline;
  126523. private _disposePostProcesses;
  126524. /**
  126525. * Adds a camera to the pipeline
  126526. * @param camera the camera to be added
  126527. */
  126528. addCamera(camera: Camera): void;
  126529. /**
  126530. * Removes a camera from the pipeline
  126531. * @param camera the camera to remove
  126532. */
  126533. removeCamera(camera: Camera): void;
  126534. /**
  126535. * Dispose of the pipeline and stop all post processes
  126536. */
  126537. dispose(): void;
  126538. /**
  126539. * Serialize the rendering pipeline (Used when exporting)
  126540. * @returns the serialized object
  126541. */
  126542. serialize(): any;
  126543. /**
  126544. * Parse the serialized pipeline
  126545. * @param source Source pipeline.
  126546. * @param scene The scene to load the pipeline to.
  126547. * @param rootUrl The URL of the serialized pipeline.
  126548. * @returns An instantiated pipeline from the serialized object.
  126549. */
  126550. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126551. }
  126552. }
  126553. declare module BABYLON {
  126554. /** @hidden */
  126555. export var lensHighlightsPixelShader: {
  126556. name: string;
  126557. shader: string;
  126558. };
  126559. }
  126560. declare module BABYLON {
  126561. /** @hidden */
  126562. export var depthOfFieldPixelShader: {
  126563. name: string;
  126564. shader: string;
  126565. };
  126566. }
  126567. declare module BABYLON {
  126568. /**
  126569. * BABYLON.JS Chromatic Aberration GLSL Shader
  126570. * Author: Olivier Guyot
  126571. * Separates very slightly R, G and B colors on the edges of the screen
  126572. * Inspired by Francois Tarlier & Martins Upitis
  126573. */
  126574. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126575. /**
  126576. * @ignore
  126577. * The chromatic aberration PostProcess id in the pipeline
  126578. */
  126579. LensChromaticAberrationEffect: string;
  126580. /**
  126581. * @ignore
  126582. * The highlights enhancing PostProcess id in the pipeline
  126583. */
  126584. HighlightsEnhancingEffect: string;
  126585. /**
  126586. * @ignore
  126587. * The depth-of-field PostProcess id in the pipeline
  126588. */
  126589. LensDepthOfFieldEffect: string;
  126590. private _scene;
  126591. private _depthTexture;
  126592. private _grainTexture;
  126593. private _chromaticAberrationPostProcess;
  126594. private _highlightsPostProcess;
  126595. private _depthOfFieldPostProcess;
  126596. private _edgeBlur;
  126597. private _grainAmount;
  126598. private _chromaticAberration;
  126599. private _distortion;
  126600. private _highlightsGain;
  126601. private _highlightsThreshold;
  126602. private _dofDistance;
  126603. private _dofAperture;
  126604. private _dofDarken;
  126605. private _dofPentagon;
  126606. private _blurNoise;
  126607. /**
  126608. * @constructor
  126609. *
  126610. * Effect parameters are as follow:
  126611. * {
  126612. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126613. * edge_blur: number; // from 0 to x (1 for realism)
  126614. * distortion: number; // from 0 to x (1 for realism)
  126615. * grain_amount: number; // from 0 to 1
  126616. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  126617. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  126618. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  126619. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  126620. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  126621. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  126622. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  126623. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  126624. * }
  126625. * Note: if an effect parameter is unset, effect is disabled
  126626. *
  126627. * @param name The rendering pipeline name
  126628. * @param parameters - An object containing all parameters (see above)
  126629. * @param scene The scene linked to this pipeline
  126630. * @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)
  126631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126632. */
  126633. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  126634. /**
  126635. * Get the class name
  126636. * @returns "LensRenderingPipeline"
  126637. */
  126638. getClassName(): string;
  126639. /**
  126640. * Gets associated scene
  126641. */
  126642. readonly scene: Scene;
  126643. /**
  126644. * Gets or sets the edge blur
  126645. */
  126646. edgeBlur: number;
  126647. /**
  126648. * Gets or sets the grain amount
  126649. */
  126650. grainAmount: number;
  126651. /**
  126652. * Gets or sets the chromatic aberration amount
  126653. */
  126654. chromaticAberration: number;
  126655. /**
  126656. * Gets or sets the depth of field aperture
  126657. */
  126658. dofAperture: number;
  126659. /**
  126660. * Gets or sets the edge distortion
  126661. */
  126662. edgeDistortion: number;
  126663. /**
  126664. * Gets or sets the depth of field distortion
  126665. */
  126666. dofDistortion: number;
  126667. /**
  126668. * Gets or sets the darken out of focus amount
  126669. */
  126670. darkenOutOfFocus: number;
  126671. /**
  126672. * Gets or sets a boolean indicating if blur noise is enabled
  126673. */
  126674. blurNoise: boolean;
  126675. /**
  126676. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  126677. */
  126678. pentagonBokeh: boolean;
  126679. /**
  126680. * Gets or sets the highlight grain amount
  126681. */
  126682. highlightsGain: number;
  126683. /**
  126684. * Gets or sets the highlight threshold
  126685. */
  126686. highlightsThreshold: number;
  126687. /**
  126688. * Sets the amount of blur at the edges
  126689. * @param amount blur amount
  126690. */
  126691. setEdgeBlur(amount: number): void;
  126692. /**
  126693. * Sets edge blur to 0
  126694. */
  126695. disableEdgeBlur(): void;
  126696. /**
  126697. * Sets the amout of grain
  126698. * @param amount Amount of grain
  126699. */
  126700. setGrainAmount(amount: number): void;
  126701. /**
  126702. * Set grain amount to 0
  126703. */
  126704. disableGrain(): void;
  126705. /**
  126706. * Sets the chromatic aberration amount
  126707. * @param amount amount of chromatic aberration
  126708. */
  126709. setChromaticAberration(amount: number): void;
  126710. /**
  126711. * Sets chromatic aberration amount to 0
  126712. */
  126713. disableChromaticAberration(): void;
  126714. /**
  126715. * Sets the EdgeDistortion amount
  126716. * @param amount amount of EdgeDistortion
  126717. */
  126718. setEdgeDistortion(amount: number): void;
  126719. /**
  126720. * Sets edge distortion to 0
  126721. */
  126722. disableEdgeDistortion(): void;
  126723. /**
  126724. * Sets the FocusDistance amount
  126725. * @param amount amount of FocusDistance
  126726. */
  126727. setFocusDistance(amount: number): void;
  126728. /**
  126729. * Disables depth of field
  126730. */
  126731. disableDepthOfField(): void;
  126732. /**
  126733. * Sets the Aperture amount
  126734. * @param amount amount of Aperture
  126735. */
  126736. setAperture(amount: number): void;
  126737. /**
  126738. * Sets the DarkenOutOfFocus amount
  126739. * @param amount amount of DarkenOutOfFocus
  126740. */
  126741. setDarkenOutOfFocus(amount: number): void;
  126742. private _pentagonBokehIsEnabled;
  126743. /**
  126744. * Creates a pentagon bokeh effect
  126745. */
  126746. enablePentagonBokeh(): void;
  126747. /**
  126748. * Disables the pentagon bokeh effect
  126749. */
  126750. disablePentagonBokeh(): void;
  126751. /**
  126752. * Enables noise blur
  126753. */
  126754. enableNoiseBlur(): void;
  126755. /**
  126756. * Disables noise blur
  126757. */
  126758. disableNoiseBlur(): void;
  126759. /**
  126760. * Sets the HighlightsGain amount
  126761. * @param amount amount of HighlightsGain
  126762. */
  126763. setHighlightsGain(amount: number): void;
  126764. /**
  126765. * Sets the HighlightsThreshold amount
  126766. * @param amount amount of HighlightsThreshold
  126767. */
  126768. setHighlightsThreshold(amount: number): void;
  126769. /**
  126770. * Disables highlights
  126771. */
  126772. disableHighlights(): void;
  126773. /**
  126774. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  126775. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  126776. */
  126777. dispose(disableDepthRender?: boolean): void;
  126778. private _createChromaticAberrationPostProcess;
  126779. private _createHighlightsPostProcess;
  126780. private _createDepthOfFieldPostProcess;
  126781. private _createGrainTexture;
  126782. }
  126783. }
  126784. declare module BABYLON {
  126785. /** @hidden */
  126786. export var ssao2PixelShader: {
  126787. name: string;
  126788. shader: string;
  126789. };
  126790. }
  126791. declare module BABYLON {
  126792. /** @hidden */
  126793. export var ssaoCombinePixelShader: {
  126794. name: string;
  126795. shader: string;
  126796. };
  126797. }
  126798. declare module BABYLON {
  126799. /**
  126800. * Render pipeline to produce ssao effect
  126801. */
  126802. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  126803. /**
  126804. * @ignore
  126805. * The PassPostProcess id in the pipeline that contains the original scene color
  126806. */
  126807. SSAOOriginalSceneColorEffect: string;
  126808. /**
  126809. * @ignore
  126810. * The SSAO PostProcess id in the pipeline
  126811. */
  126812. SSAORenderEffect: string;
  126813. /**
  126814. * @ignore
  126815. * The horizontal blur PostProcess id in the pipeline
  126816. */
  126817. SSAOBlurHRenderEffect: string;
  126818. /**
  126819. * @ignore
  126820. * The vertical blur PostProcess id in the pipeline
  126821. */
  126822. SSAOBlurVRenderEffect: string;
  126823. /**
  126824. * @ignore
  126825. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126826. */
  126827. SSAOCombineRenderEffect: string;
  126828. /**
  126829. * The output strength of the SSAO post-process. Default value is 1.0.
  126830. */
  126831. totalStrength: number;
  126832. /**
  126833. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  126834. */
  126835. maxZ: number;
  126836. /**
  126837. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  126838. */
  126839. minZAspect: number;
  126840. private _samples;
  126841. /**
  126842. * Number of samples used for the SSAO calculations. Default value is 8
  126843. */
  126844. samples: number;
  126845. private _textureSamples;
  126846. /**
  126847. * Number of samples to use for antialiasing
  126848. */
  126849. textureSamples: number;
  126850. /**
  126851. * Ratio object used for SSAO ratio and blur ratio
  126852. */
  126853. private _ratio;
  126854. /**
  126855. * Dynamically generated sphere sampler.
  126856. */
  126857. private _sampleSphere;
  126858. /**
  126859. * Blur filter offsets
  126860. */
  126861. private _samplerOffsets;
  126862. private _expensiveBlur;
  126863. /**
  126864. * If bilateral blur should be used
  126865. */
  126866. expensiveBlur: boolean;
  126867. /**
  126868. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  126869. */
  126870. radius: number;
  126871. /**
  126872. * The base color of the SSAO post-process
  126873. * The final result is "base + ssao" between [0, 1]
  126874. */
  126875. base: number;
  126876. /**
  126877. * Support test.
  126878. */
  126879. static readonly IsSupported: boolean;
  126880. private _scene;
  126881. private _depthTexture;
  126882. private _normalTexture;
  126883. private _randomTexture;
  126884. private _originalColorPostProcess;
  126885. private _ssaoPostProcess;
  126886. private _blurHPostProcess;
  126887. private _blurVPostProcess;
  126888. private _ssaoCombinePostProcess;
  126889. private _firstUpdate;
  126890. /**
  126891. * Gets active scene
  126892. */
  126893. readonly scene: Scene;
  126894. /**
  126895. * @constructor
  126896. * @param name The rendering pipeline name
  126897. * @param scene The scene linked to this pipeline
  126898. * @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 }
  126899. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126900. */
  126901. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  126902. /**
  126903. * Get the class name
  126904. * @returns "SSAO2RenderingPipeline"
  126905. */
  126906. getClassName(): string;
  126907. /**
  126908. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  126909. */
  126910. dispose(disableGeometryBufferRenderer?: boolean): void;
  126911. private _createBlurPostProcess;
  126912. /** @hidden */
  126913. _rebuild(): void;
  126914. private _bits;
  126915. private _radicalInverse_VdC;
  126916. private _hammersley;
  126917. private _hemisphereSample_uniform;
  126918. private _generateHemisphere;
  126919. private _createSSAOPostProcess;
  126920. private _createSSAOCombinePostProcess;
  126921. private _createRandomTexture;
  126922. /**
  126923. * Serialize the rendering pipeline (Used when exporting)
  126924. * @returns the serialized object
  126925. */
  126926. serialize(): any;
  126927. /**
  126928. * Parse the serialized pipeline
  126929. * @param source Source pipeline.
  126930. * @param scene The scene to load the pipeline to.
  126931. * @param rootUrl The URL of the serialized pipeline.
  126932. * @returns An instantiated pipeline from the serialized object.
  126933. */
  126934. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  126935. }
  126936. }
  126937. declare module BABYLON {
  126938. /** @hidden */
  126939. export var ssaoPixelShader: {
  126940. name: string;
  126941. shader: string;
  126942. };
  126943. }
  126944. declare module BABYLON {
  126945. /**
  126946. * Render pipeline to produce ssao effect
  126947. */
  126948. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  126949. /**
  126950. * @ignore
  126951. * The PassPostProcess id in the pipeline that contains the original scene color
  126952. */
  126953. SSAOOriginalSceneColorEffect: string;
  126954. /**
  126955. * @ignore
  126956. * The SSAO PostProcess id in the pipeline
  126957. */
  126958. SSAORenderEffect: string;
  126959. /**
  126960. * @ignore
  126961. * The horizontal blur PostProcess id in the pipeline
  126962. */
  126963. SSAOBlurHRenderEffect: string;
  126964. /**
  126965. * @ignore
  126966. * The vertical blur PostProcess id in the pipeline
  126967. */
  126968. SSAOBlurVRenderEffect: string;
  126969. /**
  126970. * @ignore
  126971. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  126972. */
  126973. SSAOCombineRenderEffect: string;
  126974. /**
  126975. * The output strength of the SSAO post-process. Default value is 1.0.
  126976. */
  126977. totalStrength: number;
  126978. /**
  126979. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  126980. */
  126981. radius: number;
  126982. /**
  126983. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  126984. * Must not be equal to fallOff and superior to fallOff.
  126985. * Default value is 0.0075
  126986. */
  126987. area: number;
  126988. /**
  126989. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  126990. * Must not be equal to area and inferior to area.
  126991. * Default value is 0.000001
  126992. */
  126993. fallOff: number;
  126994. /**
  126995. * The base color of the SSAO post-process
  126996. * The final result is "base + ssao" between [0, 1]
  126997. */
  126998. base: number;
  126999. private _scene;
  127000. private _depthTexture;
  127001. private _randomTexture;
  127002. private _originalColorPostProcess;
  127003. private _ssaoPostProcess;
  127004. private _blurHPostProcess;
  127005. private _blurVPostProcess;
  127006. private _ssaoCombinePostProcess;
  127007. private _firstUpdate;
  127008. /**
  127009. * Gets active scene
  127010. */
  127011. readonly scene: Scene;
  127012. /**
  127013. * @constructor
  127014. * @param name - The rendering pipeline name
  127015. * @param scene - The scene linked to this pipeline
  127016. * @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 }
  127017. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127018. */
  127019. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127020. /**
  127021. * Get the class name
  127022. * @returns "SSAORenderingPipeline"
  127023. */
  127024. getClassName(): string;
  127025. /**
  127026. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127027. */
  127028. dispose(disableDepthRender?: boolean): void;
  127029. private _createBlurPostProcess;
  127030. /** @hidden */
  127031. _rebuild(): void;
  127032. private _createSSAOPostProcess;
  127033. private _createSSAOCombinePostProcess;
  127034. private _createRandomTexture;
  127035. }
  127036. }
  127037. declare module BABYLON {
  127038. /** @hidden */
  127039. export var standardPixelShader: {
  127040. name: string;
  127041. shader: string;
  127042. };
  127043. }
  127044. declare module BABYLON {
  127045. /**
  127046. * Standard rendering pipeline
  127047. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127048. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127049. */
  127050. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127051. /**
  127052. * Public members
  127053. */
  127054. /**
  127055. * Post-process which contains the original scene color before the pipeline applies all the effects
  127056. */
  127057. originalPostProcess: Nullable<PostProcess>;
  127058. /**
  127059. * Post-process used to down scale an image x4
  127060. */
  127061. downSampleX4PostProcess: Nullable<PostProcess>;
  127062. /**
  127063. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127064. */
  127065. brightPassPostProcess: Nullable<PostProcess>;
  127066. /**
  127067. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127068. */
  127069. blurHPostProcesses: PostProcess[];
  127070. /**
  127071. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127072. */
  127073. blurVPostProcesses: PostProcess[];
  127074. /**
  127075. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127076. */
  127077. textureAdderPostProcess: Nullable<PostProcess>;
  127078. /**
  127079. * Post-process used to create volumetric lighting effect
  127080. */
  127081. volumetricLightPostProcess: Nullable<PostProcess>;
  127082. /**
  127083. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127084. */
  127085. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127086. /**
  127087. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127088. */
  127089. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127090. /**
  127091. * Post-process used to merge the volumetric light effect and the real scene color
  127092. */
  127093. volumetricLightMergePostProces: Nullable<PostProcess>;
  127094. /**
  127095. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127096. */
  127097. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127098. /**
  127099. * Base post-process used to calculate the average luminance of the final image for HDR
  127100. */
  127101. luminancePostProcess: Nullable<PostProcess>;
  127102. /**
  127103. * Post-processes used to create down sample post-processes in order to get
  127104. * the average luminance of the final image for HDR
  127105. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127106. */
  127107. luminanceDownSamplePostProcesses: PostProcess[];
  127108. /**
  127109. * Post-process used to create a HDR effect (light adaptation)
  127110. */
  127111. hdrPostProcess: Nullable<PostProcess>;
  127112. /**
  127113. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127114. */
  127115. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127116. /**
  127117. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127118. */
  127119. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127120. /**
  127121. * Post-process used to merge the final HDR post-process and the real scene color
  127122. */
  127123. hdrFinalPostProcess: Nullable<PostProcess>;
  127124. /**
  127125. * Post-process used to create a lens flare effect
  127126. */
  127127. lensFlarePostProcess: Nullable<PostProcess>;
  127128. /**
  127129. * Post-process that merges the result of the lens flare post-process and the real scene color
  127130. */
  127131. lensFlareComposePostProcess: Nullable<PostProcess>;
  127132. /**
  127133. * Post-process used to create a motion blur effect
  127134. */
  127135. motionBlurPostProcess: Nullable<PostProcess>;
  127136. /**
  127137. * Post-process used to create a depth of field effect
  127138. */
  127139. depthOfFieldPostProcess: Nullable<PostProcess>;
  127140. /**
  127141. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127142. */
  127143. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127144. /**
  127145. * Represents the brightness threshold in order to configure the illuminated surfaces
  127146. */
  127147. brightThreshold: number;
  127148. /**
  127149. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127150. */
  127151. blurWidth: number;
  127152. /**
  127153. * Sets if the blur for highlighted surfaces must be only horizontal
  127154. */
  127155. horizontalBlur: boolean;
  127156. /**
  127157. * Gets the overall exposure used by the pipeline
  127158. */
  127159. /**
  127160. * Sets the overall exposure used by the pipeline
  127161. */
  127162. exposure: number;
  127163. /**
  127164. * Texture used typically to simulate "dirty" on camera lens
  127165. */
  127166. lensTexture: Nullable<Texture>;
  127167. /**
  127168. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127169. */
  127170. volumetricLightCoefficient: number;
  127171. /**
  127172. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127173. */
  127174. volumetricLightPower: number;
  127175. /**
  127176. * Used the set the blur intensity to smooth the volumetric lights
  127177. */
  127178. volumetricLightBlurScale: number;
  127179. /**
  127180. * Light (spot or directional) used to generate the volumetric lights rays
  127181. * The source light must have a shadow generate so the pipeline can get its
  127182. * depth map
  127183. */
  127184. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127185. /**
  127186. * For eye adaptation, represents the minimum luminance the eye can see
  127187. */
  127188. hdrMinimumLuminance: number;
  127189. /**
  127190. * For eye adaptation, represents the decrease luminance speed
  127191. */
  127192. hdrDecreaseRate: number;
  127193. /**
  127194. * For eye adaptation, represents the increase luminance speed
  127195. */
  127196. hdrIncreaseRate: number;
  127197. /**
  127198. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127199. */
  127200. /**
  127201. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127202. */
  127203. hdrAutoExposure: boolean;
  127204. /**
  127205. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127206. */
  127207. lensColorTexture: Nullable<Texture>;
  127208. /**
  127209. * The overall strengh for the lens flare effect
  127210. */
  127211. lensFlareStrength: number;
  127212. /**
  127213. * Dispersion coefficient for lens flare ghosts
  127214. */
  127215. lensFlareGhostDispersal: number;
  127216. /**
  127217. * Main lens flare halo width
  127218. */
  127219. lensFlareHaloWidth: number;
  127220. /**
  127221. * Based on the lens distortion effect, defines how much the lens flare result
  127222. * is distorted
  127223. */
  127224. lensFlareDistortionStrength: number;
  127225. /**
  127226. * Configures the blur intensity used for for lens flare (halo)
  127227. */
  127228. lensFlareBlurWidth: number;
  127229. /**
  127230. * Lens star texture must be used to simulate rays on the flares and is available
  127231. * in the documentation
  127232. */
  127233. lensStarTexture: Nullable<Texture>;
  127234. /**
  127235. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127236. * flare effect by taking account of the dirt texture
  127237. */
  127238. lensFlareDirtTexture: Nullable<Texture>;
  127239. /**
  127240. * Represents the focal length for the depth of field effect
  127241. */
  127242. depthOfFieldDistance: number;
  127243. /**
  127244. * Represents the blur intensity for the blurred part of the depth of field effect
  127245. */
  127246. depthOfFieldBlurWidth: number;
  127247. /**
  127248. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127249. */
  127250. /**
  127251. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127252. */
  127253. motionStrength: number;
  127254. /**
  127255. * Gets wether or not the motion blur post-process is object based or screen based.
  127256. */
  127257. /**
  127258. * Sets wether or not the motion blur post-process should be object based or screen based
  127259. */
  127260. objectBasedMotionBlur: boolean;
  127261. /**
  127262. * List of animations for the pipeline (IAnimatable implementation)
  127263. */
  127264. animations: Animation[];
  127265. /**
  127266. * Private members
  127267. */
  127268. private _scene;
  127269. private _currentDepthOfFieldSource;
  127270. private _basePostProcess;
  127271. private _fixedExposure;
  127272. private _currentExposure;
  127273. private _hdrAutoExposure;
  127274. private _hdrCurrentLuminance;
  127275. private _motionStrength;
  127276. private _isObjectBasedMotionBlur;
  127277. private _floatTextureType;
  127278. private _camerasToBeAttached;
  127279. private _ratio;
  127280. private _bloomEnabled;
  127281. private _depthOfFieldEnabled;
  127282. private _vlsEnabled;
  127283. private _lensFlareEnabled;
  127284. private _hdrEnabled;
  127285. private _motionBlurEnabled;
  127286. private _fxaaEnabled;
  127287. private _motionBlurSamples;
  127288. private _volumetricLightStepsCount;
  127289. private _samples;
  127290. /**
  127291. * @ignore
  127292. * Specifies if the bloom pipeline is enabled
  127293. */
  127294. BloomEnabled: boolean;
  127295. /**
  127296. * @ignore
  127297. * Specifies if the depth of field pipeline is enabed
  127298. */
  127299. DepthOfFieldEnabled: boolean;
  127300. /**
  127301. * @ignore
  127302. * Specifies if the lens flare pipeline is enabed
  127303. */
  127304. LensFlareEnabled: boolean;
  127305. /**
  127306. * @ignore
  127307. * Specifies if the HDR pipeline is enabled
  127308. */
  127309. HDREnabled: boolean;
  127310. /**
  127311. * @ignore
  127312. * Specifies if the volumetric lights scattering effect is enabled
  127313. */
  127314. VLSEnabled: boolean;
  127315. /**
  127316. * @ignore
  127317. * Specifies if the motion blur effect is enabled
  127318. */
  127319. MotionBlurEnabled: boolean;
  127320. /**
  127321. * Specifies if anti-aliasing is enabled
  127322. */
  127323. fxaaEnabled: boolean;
  127324. /**
  127325. * Specifies the number of steps used to calculate the volumetric lights
  127326. * Typically in interval [50, 200]
  127327. */
  127328. volumetricLightStepsCount: number;
  127329. /**
  127330. * Specifies the number of samples used for the motion blur effect
  127331. * Typically in interval [16, 64]
  127332. */
  127333. motionBlurSamples: number;
  127334. /**
  127335. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127336. */
  127337. samples: number;
  127338. /**
  127339. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127340. * @constructor
  127341. * @param name The rendering pipeline name
  127342. * @param scene The scene linked to this pipeline
  127343. * @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)
  127344. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127345. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127346. */
  127347. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127348. private _buildPipeline;
  127349. private _createDownSampleX4PostProcess;
  127350. private _createBrightPassPostProcess;
  127351. private _createBlurPostProcesses;
  127352. private _createTextureAdderPostProcess;
  127353. private _createVolumetricLightPostProcess;
  127354. private _createLuminancePostProcesses;
  127355. private _createHdrPostProcess;
  127356. private _createLensFlarePostProcess;
  127357. private _createDepthOfFieldPostProcess;
  127358. private _createMotionBlurPostProcess;
  127359. private _getDepthTexture;
  127360. private _disposePostProcesses;
  127361. /**
  127362. * Dispose of the pipeline and stop all post processes
  127363. */
  127364. dispose(): void;
  127365. /**
  127366. * Serialize the rendering pipeline (Used when exporting)
  127367. * @returns the serialized object
  127368. */
  127369. serialize(): any;
  127370. /**
  127371. * Parse the serialized pipeline
  127372. * @param source Source pipeline.
  127373. * @param scene The scene to load the pipeline to.
  127374. * @param rootUrl The URL of the serialized pipeline.
  127375. * @returns An instantiated pipeline from the serialized object.
  127376. */
  127377. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127378. /**
  127379. * Luminance steps
  127380. */
  127381. static LuminanceSteps: number;
  127382. }
  127383. }
  127384. declare module BABYLON {
  127385. /** @hidden */
  127386. export var tonemapPixelShader: {
  127387. name: string;
  127388. shader: string;
  127389. };
  127390. }
  127391. declare module BABYLON {
  127392. /** Defines operator used for tonemapping */
  127393. export enum TonemappingOperator {
  127394. /** Hable */
  127395. Hable = 0,
  127396. /** Reinhard */
  127397. Reinhard = 1,
  127398. /** HejiDawson */
  127399. HejiDawson = 2,
  127400. /** Photographic */
  127401. Photographic = 3
  127402. }
  127403. /**
  127404. * Defines a post process to apply tone mapping
  127405. */
  127406. export class TonemapPostProcess extends PostProcess {
  127407. private _operator;
  127408. /** Defines the required exposure adjustement */
  127409. exposureAdjustment: number;
  127410. /**
  127411. * Creates a new TonemapPostProcess
  127412. * @param name defines the name of the postprocess
  127413. * @param _operator defines the operator to use
  127414. * @param exposureAdjustment defines the required exposure adjustement
  127415. * @param camera defines the camera to use (can be null)
  127416. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127417. * @param engine defines the hosting engine (can be ignore if camera is set)
  127418. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127419. */
  127420. constructor(name: string, _operator: TonemappingOperator,
  127421. /** Defines the required exposure adjustement */
  127422. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127423. }
  127424. }
  127425. declare module BABYLON {
  127426. /** @hidden */
  127427. export var depthVertexShader: {
  127428. name: string;
  127429. shader: string;
  127430. };
  127431. }
  127432. declare module BABYLON {
  127433. /** @hidden */
  127434. export var volumetricLightScatteringPixelShader: {
  127435. name: string;
  127436. shader: string;
  127437. };
  127438. }
  127439. declare module BABYLON {
  127440. /** @hidden */
  127441. export var volumetricLightScatteringPassVertexShader: {
  127442. name: string;
  127443. shader: string;
  127444. };
  127445. }
  127446. declare module BABYLON {
  127447. /** @hidden */
  127448. export var volumetricLightScatteringPassPixelShader: {
  127449. name: string;
  127450. shader: string;
  127451. };
  127452. }
  127453. declare module BABYLON {
  127454. /**
  127455. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127456. */
  127457. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127458. private _volumetricLightScatteringPass;
  127459. private _volumetricLightScatteringRTT;
  127460. private _viewPort;
  127461. private _screenCoordinates;
  127462. private _cachedDefines;
  127463. /**
  127464. * If not undefined, the mesh position is computed from the attached node position
  127465. */
  127466. attachedNode: {
  127467. position: Vector3;
  127468. };
  127469. /**
  127470. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127471. */
  127472. customMeshPosition: Vector3;
  127473. /**
  127474. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127475. */
  127476. useCustomMeshPosition: boolean;
  127477. /**
  127478. * If the post-process should inverse the light scattering direction
  127479. */
  127480. invert: boolean;
  127481. /**
  127482. * The internal mesh used by the post-process
  127483. */
  127484. mesh: Mesh;
  127485. /**
  127486. * @hidden
  127487. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127488. */
  127489. useDiffuseColor: boolean;
  127490. /**
  127491. * Array containing the excluded meshes not rendered in the internal pass
  127492. */
  127493. excludedMeshes: AbstractMesh[];
  127494. /**
  127495. * Controls the overall intensity of the post-process
  127496. */
  127497. exposure: number;
  127498. /**
  127499. * Dissipates each sample's contribution in range [0, 1]
  127500. */
  127501. decay: number;
  127502. /**
  127503. * Controls the overall intensity of each sample
  127504. */
  127505. weight: number;
  127506. /**
  127507. * Controls the density of each sample
  127508. */
  127509. density: number;
  127510. /**
  127511. * @constructor
  127512. * @param name The post-process name
  127513. * @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)
  127514. * @param camera The camera that the post-process will be attached to
  127515. * @param mesh The mesh used to create the light scattering
  127516. * @param samples The post-process quality, default 100
  127517. * @param samplingModeThe post-process filtering mode
  127518. * @param engine The babylon engine
  127519. * @param reusable If the post-process is reusable
  127520. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127521. */
  127522. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127523. /**
  127524. * Returns the string "VolumetricLightScatteringPostProcess"
  127525. * @returns "VolumetricLightScatteringPostProcess"
  127526. */
  127527. getClassName(): string;
  127528. private _isReady;
  127529. /**
  127530. * Sets the new light position for light scattering effect
  127531. * @param position The new custom light position
  127532. */
  127533. setCustomMeshPosition(position: Vector3): void;
  127534. /**
  127535. * Returns the light position for light scattering effect
  127536. * @return Vector3 The custom light position
  127537. */
  127538. getCustomMeshPosition(): Vector3;
  127539. /**
  127540. * Disposes the internal assets and detaches the post-process from the camera
  127541. */
  127542. dispose(camera: Camera): void;
  127543. /**
  127544. * Returns the render target texture used by the post-process
  127545. * @return the render target texture used by the post-process
  127546. */
  127547. getPass(): RenderTargetTexture;
  127548. private _meshExcluded;
  127549. private _createPass;
  127550. private _updateMeshScreenCoordinates;
  127551. /**
  127552. * Creates a default mesh for the Volumeric Light Scattering post-process
  127553. * @param name The mesh name
  127554. * @param scene The scene where to create the mesh
  127555. * @return the default mesh
  127556. */
  127557. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127558. }
  127559. }
  127560. declare module BABYLON {
  127561. interface Scene {
  127562. /** @hidden (Backing field) */
  127563. _boundingBoxRenderer: BoundingBoxRenderer;
  127564. /** @hidden (Backing field) */
  127565. _forceShowBoundingBoxes: boolean;
  127566. /**
  127567. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127568. */
  127569. forceShowBoundingBoxes: boolean;
  127570. /**
  127571. * Gets the bounding box renderer associated with the scene
  127572. * @returns a BoundingBoxRenderer
  127573. */
  127574. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127575. }
  127576. interface AbstractMesh {
  127577. /** @hidden (Backing field) */
  127578. _showBoundingBox: boolean;
  127579. /**
  127580. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127581. */
  127582. showBoundingBox: boolean;
  127583. }
  127584. /**
  127585. * Component responsible of rendering the bounding box of the meshes in a scene.
  127586. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127587. */
  127588. export class BoundingBoxRenderer implements ISceneComponent {
  127589. /**
  127590. * The component name helpfull to identify the component in the list of scene components.
  127591. */
  127592. readonly name: string;
  127593. /**
  127594. * The scene the component belongs to.
  127595. */
  127596. scene: Scene;
  127597. /**
  127598. * Color of the bounding box lines placed in front of an object
  127599. */
  127600. frontColor: Color3;
  127601. /**
  127602. * Color of the bounding box lines placed behind an object
  127603. */
  127604. backColor: Color3;
  127605. /**
  127606. * Defines if the renderer should show the back lines or not
  127607. */
  127608. showBackLines: boolean;
  127609. /**
  127610. * @hidden
  127611. */
  127612. renderList: SmartArray<BoundingBox>;
  127613. private _colorShader;
  127614. private _vertexBuffers;
  127615. private _indexBuffer;
  127616. private _fillIndexBuffer;
  127617. private _fillIndexData;
  127618. /**
  127619. * Instantiates a new bounding box renderer in a scene.
  127620. * @param scene the scene the renderer renders in
  127621. */
  127622. constructor(scene: Scene);
  127623. /**
  127624. * Registers the component in a given scene
  127625. */
  127626. register(): void;
  127627. private _evaluateSubMesh;
  127628. private _activeMesh;
  127629. private _prepareRessources;
  127630. private _createIndexBuffer;
  127631. /**
  127632. * Rebuilds the elements related to this component in case of
  127633. * context lost for instance.
  127634. */
  127635. rebuild(): void;
  127636. /**
  127637. * @hidden
  127638. */
  127639. reset(): void;
  127640. /**
  127641. * Render the bounding boxes of a specific rendering group
  127642. * @param renderingGroupId defines the rendering group to render
  127643. */
  127644. render(renderingGroupId: number): void;
  127645. /**
  127646. * In case of occlusion queries, we can render the occlusion bounding box through this method
  127647. * @param mesh Define the mesh to render the occlusion bounding box for
  127648. */
  127649. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  127650. /**
  127651. * Dispose and release the resources attached to this renderer.
  127652. */
  127653. dispose(): void;
  127654. }
  127655. }
  127656. declare module BABYLON {
  127657. /** @hidden */
  127658. export var depthPixelShader: {
  127659. name: string;
  127660. shader: string;
  127661. };
  127662. }
  127663. declare module BABYLON {
  127664. /**
  127665. * This represents a depth renderer in Babylon.
  127666. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127667. */
  127668. export class DepthRenderer {
  127669. private _scene;
  127670. private _depthMap;
  127671. private _effect;
  127672. private readonly _storeNonLinearDepth;
  127673. private readonly _clearColor;
  127674. /** Get if the depth renderer is using packed depth or not */
  127675. readonly isPacked: boolean;
  127676. private _cachedDefines;
  127677. private _camera;
  127678. /**
  127679. * Specifiess that the depth renderer will only be used within
  127680. * the camera it is created for.
  127681. * This can help forcing its rendering during the camera processing.
  127682. */
  127683. useOnlyInActiveCamera: boolean;
  127684. /** @hidden */
  127685. static _SceneComponentInitialization: (scene: Scene) => void;
  127686. /**
  127687. * Instantiates a depth renderer
  127688. * @param scene The scene the renderer belongs to
  127689. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127690. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127691. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127692. */
  127693. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127694. /**
  127695. * Creates the depth rendering effect and checks if the effect is ready.
  127696. * @param subMesh The submesh to be used to render the depth map of
  127697. * @param useInstances If multiple world instances should be used
  127698. * @returns if the depth renderer is ready to render the depth map
  127699. */
  127700. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127701. /**
  127702. * Gets the texture which the depth map will be written to.
  127703. * @returns The depth map texture
  127704. */
  127705. getDepthMap(): RenderTargetTexture;
  127706. /**
  127707. * Disposes of the depth renderer.
  127708. */
  127709. dispose(): void;
  127710. }
  127711. }
  127712. declare module BABYLON {
  127713. interface Scene {
  127714. /** @hidden (Backing field) */
  127715. _depthRenderer: {
  127716. [id: string]: DepthRenderer;
  127717. };
  127718. /**
  127719. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  127720. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  127721. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127722. * @returns the created depth renderer
  127723. */
  127724. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  127725. /**
  127726. * Disables a depth renderer for a given camera
  127727. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  127728. */
  127729. disableDepthRenderer(camera?: Nullable<Camera>): void;
  127730. }
  127731. /**
  127732. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  127733. * in several rendering techniques.
  127734. */
  127735. export class DepthRendererSceneComponent implements ISceneComponent {
  127736. /**
  127737. * The component name helpfull to identify the component in the list of scene components.
  127738. */
  127739. readonly name: string;
  127740. /**
  127741. * The scene the component belongs to.
  127742. */
  127743. scene: Scene;
  127744. /**
  127745. * Creates a new instance of the component for the given scene
  127746. * @param scene Defines the scene to register the component in
  127747. */
  127748. constructor(scene: Scene);
  127749. /**
  127750. * Registers the component in a given scene
  127751. */
  127752. register(): void;
  127753. /**
  127754. * Rebuilds the elements related to this component in case of
  127755. * context lost for instance.
  127756. */
  127757. rebuild(): void;
  127758. /**
  127759. * Disposes the component and the associated ressources
  127760. */
  127761. dispose(): void;
  127762. private _gatherRenderTargets;
  127763. private _gatherActiveCameraRenderTargets;
  127764. }
  127765. }
  127766. declare module BABYLON {
  127767. /** @hidden */
  127768. export var outlinePixelShader: {
  127769. name: string;
  127770. shader: string;
  127771. };
  127772. }
  127773. declare module BABYLON {
  127774. /** @hidden */
  127775. export var outlineVertexShader: {
  127776. name: string;
  127777. shader: string;
  127778. };
  127779. }
  127780. declare module BABYLON {
  127781. interface Scene {
  127782. /** @hidden */
  127783. _outlineRenderer: OutlineRenderer;
  127784. /**
  127785. * Gets the outline renderer associated with the scene
  127786. * @returns a OutlineRenderer
  127787. */
  127788. getOutlineRenderer(): OutlineRenderer;
  127789. }
  127790. interface AbstractMesh {
  127791. /** @hidden (Backing field) */
  127792. _renderOutline: boolean;
  127793. /**
  127794. * Gets or sets a boolean indicating if the outline must be rendered as well
  127795. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  127796. */
  127797. renderOutline: boolean;
  127798. /** @hidden (Backing field) */
  127799. _renderOverlay: boolean;
  127800. /**
  127801. * Gets or sets a boolean indicating if the overlay must be rendered as well
  127802. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  127803. */
  127804. renderOverlay: boolean;
  127805. }
  127806. /**
  127807. * This class is responsible to draw bothe outline/overlay of meshes.
  127808. * It should not be used directly but through the available method on mesh.
  127809. */
  127810. export class OutlineRenderer implements ISceneComponent {
  127811. /**
  127812. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  127813. */
  127814. private static _StencilReference;
  127815. /**
  127816. * The name of the component. Each component must have a unique name.
  127817. */
  127818. name: string;
  127819. /**
  127820. * The scene the component belongs to.
  127821. */
  127822. scene: Scene;
  127823. /**
  127824. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  127825. */
  127826. zOffset: number;
  127827. private _engine;
  127828. private _effect;
  127829. private _cachedDefines;
  127830. private _savedDepthWrite;
  127831. /**
  127832. * Instantiates a new outline renderer. (There could be only one per scene).
  127833. * @param scene Defines the scene it belongs to
  127834. */
  127835. constructor(scene: Scene);
  127836. /**
  127837. * Register the component to one instance of a scene.
  127838. */
  127839. register(): void;
  127840. /**
  127841. * Rebuilds the elements related to this component in case of
  127842. * context lost for instance.
  127843. */
  127844. rebuild(): void;
  127845. /**
  127846. * Disposes the component and the associated ressources.
  127847. */
  127848. dispose(): void;
  127849. /**
  127850. * Renders the outline in the canvas.
  127851. * @param subMesh Defines the sumesh to render
  127852. * @param batch Defines the batch of meshes in case of instances
  127853. * @param useOverlay Defines if the rendering is for the overlay or the outline
  127854. */
  127855. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  127856. /**
  127857. * Returns whether or not the outline renderer is ready for a given submesh.
  127858. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  127859. * @param subMesh Defines the submesh to check readyness for
  127860. * @param useInstances Defines wheter wee are trying to render instances or not
  127861. * @returns true if ready otherwise false
  127862. */
  127863. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127864. private _beforeRenderingMesh;
  127865. private _afterRenderingMesh;
  127866. }
  127867. }
  127868. declare module BABYLON {
  127869. /**
  127870. * Class used to manage multiple sprites of different sizes on the same spritesheet
  127871. * @see http://doc.babylonjs.com/babylon101/sprites
  127872. */
  127873. export class SpritePackedManager extends SpriteManager {
  127874. /** defines the packed manager's name */
  127875. name: string;
  127876. /**
  127877. * Creates a new sprite manager from a packed sprite sheet
  127878. * @param name defines the manager's name
  127879. * @param imgUrl defines the sprite sheet url
  127880. * @param capacity defines the maximum allowed number of sprites
  127881. * @param scene defines the hosting scene
  127882. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  127883. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  127884. * @param samplingMode defines the smapling mode to use with spritesheet
  127885. * @param fromPacked set to true; do not alter
  127886. */
  127887. constructor(
  127888. /** defines the packed manager's name */
  127889. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  127890. }
  127891. }
  127892. declare module BABYLON {
  127893. /**
  127894. * Defines the list of states available for a task inside a AssetsManager
  127895. */
  127896. export enum AssetTaskState {
  127897. /**
  127898. * Initialization
  127899. */
  127900. INIT = 0,
  127901. /**
  127902. * Running
  127903. */
  127904. RUNNING = 1,
  127905. /**
  127906. * Done
  127907. */
  127908. DONE = 2,
  127909. /**
  127910. * Error
  127911. */
  127912. ERROR = 3
  127913. }
  127914. /**
  127915. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  127916. */
  127917. export abstract class AbstractAssetTask {
  127918. /**
  127919. * Task name
  127920. */ name: string;
  127921. /**
  127922. * Callback called when the task is successful
  127923. */
  127924. onSuccess: (task: any) => void;
  127925. /**
  127926. * Callback called when the task is not successful
  127927. */
  127928. onError: (task: any, message?: string, exception?: any) => void;
  127929. /**
  127930. * Creates a new AssetsManager
  127931. * @param name defines the name of the task
  127932. */
  127933. constructor(
  127934. /**
  127935. * Task name
  127936. */ name: string);
  127937. private _isCompleted;
  127938. private _taskState;
  127939. private _errorObject;
  127940. /**
  127941. * Get if the task is completed
  127942. */
  127943. readonly isCompleted: boolean;
  127944. /**
  127945. * Gets the current state of the task
  127946. */
  127947. readonly taskState: AssetTaskState;
  127948. /**
  127949. * Gets the current error object (if task is in error)
  127950. */
  127951. readonly errorObject: {
  127952. message?: string;
  127953. exception?: any;
  127954. };
  127955. /**
  127956. * Internal only
  127957. * @hidden
  127958. */
  127959. _setErrorObject(message?: string, exception?: any): void;
  127960. /**
  127961. * Execute the current task
  127962. * @param scene defines the scene where you want your assets to be loaded
  127963. * @param onSuccess is a callback called when the task is successfully executed
  127964. * @param onError is a callback called if an error occurs
  127965. */
  127966. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127967. /**
  127968. * Execute the current task
  127969. * @param scene defines the scene where you want your assets to be loaded
  127970. * @param onSuccess is a callback called when the task is successfully executed
  127971. * @param onError is a callback called if an error occurs
  127972. */
  127973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127974. /**
  127975. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  127976. * This can be used with failed tasks that have the reason for failure fixed.
  127977. */
  127978. reset(): void;
  127979. private onErrorCallback;
  127980. private onDoneCallback;
  127981. }
  127982. /**
  127983. * Define the interface used by progress events raised during assets loading
  127984. */
  127985. export interface IAssetsProgressEvent {
  127986. /**
  127987. * Defines the number of remaining tasks to process
  127988. */
  127989. remainingCount: number;
  127990. /**
  127991. * Defines the total number of tasks
  127992. */
  127993. totalCount: number;
  127994. /**
  127995. * Defines the task that was just processed
  127996. */
  127997. task: AbstractAssetTask;
  127998. }
  127999. /**
  128000. * Class used to share progress information about assets loading
  128001. */
  128002. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128003. /**
  128004. * Defines the number of remaining tasks to process
  128005. */
  128006. remainingCount: number;
  128007. /**
  128008. * Defines the total number of tasks
  128009. */
  128010. totalCount: number;
  128011. /**
  128012. * Defines the task that was just processed
  128013. */
  128014. task: AbstractAssetTask;
  128015. /**
  128016. * Creates a AssetsProgressEvent
  128017. * @param remainingCount defines the number of remaining tasks to process
  128018. * @param totalCount defines the total number of tasks
  128019. * @param task defines the task that was just processed
  128020. */
  128021. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128022. }
  128023. /**
  128024. * Define a task used by AssetsManager to load meshes
  128025. */
  128026. export class MeshAssetTask extends AbstractAssetTask {
  128027. /**
  128028. * Defines the name of the task
  128029. */
  128030. name: string;
  128031. /**
  128032. * Defines the list of mesh's names you want to load
  128033. */
  128034. meshesNames: any;
  128035. /**
  128036. * Defines the root url to use as a base to load your meshes and associated resources
  128037. */
  128038. rootUrl: string;
  128039. /**
  128040. * Defines the filename of the scene to load from
  128041. */
  128042. sceneFilename: string;
  128043. /**
  128044. * Gets the list of loaded meshes
  128045. */
  128046. loadedMeshes: Array<AbstractMesh>;
  128047. /**
  128048. * Gets the list of loaded particle systems
  128049. */
  128050. loadedParticleSystems: Array<IParticleSystem>;
  128051. /**
  128052. * Gets the list of loaded skeletons
  128053. */
  128054. loadedSkeletons: Array<Skeleton>;
  128055. /**
  128056. * Gets the list of loaded animation groups
  128057. */
  128058. loadedAnimationGroups: Array<AnimationGroup>;
  128059. /**
  128060. * Callback called when the task is successful
  128061. */
  128062. onSuccess: (task: MeshAssetTask) => void;
  128063. /**
  128064. * Callback called when the task is successful
  128065. */
  128066. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128067. /**
  128068. * Creates a new MeshAssetTask
  128069. * @param name defines the name of the task
  128070. * @param meshesNames defines the list of mesh's names you want to load
  128071. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128072. * @param sceneFilename defines the filename of the scene to load from
  128073. */
  128074. constructor(
  128075. /**
  128076. * Defines the name of the task
  128077. */
  128078. name: string,
  128079. /**
  128080. * Defines the list of mesh's names you want to load
  128081. */
  128082. meshesNames: any,
  128083. /**
  128084. * Defines the root url to use as a base to load your meshes and associated resources
  128085. */
  128086. rootUrl: string,
  128087. /**
  128088. * Defines the filename of the scene to load from
  128089. */
  128090. sceneFilename: string);
  128091. /**
  128092. * Execute the current task
  128093. * @param scene defines the scene where you want your assets to be loaded
  128094. * @param onSuccess is a callback called when the task is successfully executed
  128095. * @param onError is a callback called if an error occurs
  128096. */
  128097. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128098. }
  128099. /**
  128100. * Define a task used by AssetsManager to load text content
  128101. */
  128102. export class TextFileAssetTask extends AbstractAssetTask {
  128103. /**
  128104. * Defines the name of the task
  128105. */
  128106. name: string;
  128107. /**
  128108. * Defines the location of the file to load
  128109. */
  128110. url: string;
  128111. /**
  128112. * Gets the loaded text string
  128113. */
  128114. text: string;
  128115. /**
  128116. * Callback called when the task is successful
  128117. */
  128118. onSuccess: (task: TextFileAssetTask) => void;
  128119. /**
  128120. * Callback called when the task is successful
  128121. */
  128122. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128123. /**
  128124. * Creates a new TextFileAssetTask object
  128125. * @param name defines the name of the task
  128126. * @param url defines the location of the file to load
  128127. */
  128128. constructor(
  128129. /**
  128130. * Defines the name of the task
  128131. */
  128132. name: string,
  128133. /**
  128134. * Defines the location of the file to load
  128135. */
  128136. url: string);
  128137. /**
  128138. * Execute the current task
  128139. * @param scene defines the scene where you want your assets to be loaded
  128140. * @param onSuccess is a callback called when the task is successfully executed
  128141. * @param onError is a callback called if an error occurs
  128142. */
  128143. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128144. }
  128145. /**
  128146. * Define a task used by AssetsManager to load binary data
  128147. */
  128148. export class BinaryFileAssetTask extends AbstractAssetTask {
  128149. /**
  128150. * Defines the name of the task
  128151. */
  128152. name: string;
  128153. /**
  128154. * Defines the location of the file to load
  128155. */
  128156. url: string;
  128157. /**
  128158. * Gets the lodaded data (as an array buffer)
  128159. */
  128160. data: ArrayBuffer;
  128161. /**
  128162. * Callback called when the task is successful
  128163. */
  128164. onSuccess: (task: BinaryFileAssetTask) => void;
  128165. /**
  128166. * Callback called when the task is successful
  128167. */
  128168. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128169. /**
  128170. * Creates a new BinaryFileAssetTask object
  128171. * @param name defines the name of the new task
  128172. * @param url defines the location of the file to load
  128173. */
  128174. constructor(
  128175. /**
  128176. * Defines the name of the task
  128177. */
  128178. name: string,
  128179. /**
  128180. * Defines the location of the file to load
  128181. */
  128182. url: string);
  128183. /**
  128184. * Execute the current task
  128185. * @param scene defines the scene where you want your assets to be loaded
  128186. * @param onSuccess is a callback called when the task is successfully executed
  128187. * @param onError is a callback called if an error occurs
  128188. */
  128189. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128190. }
  128191. /**
  128192. * Define a task used by AssetsManager to load images
  128193. */
  128194. export class ImageAssetTask extends AbstractAssetTask {
  128195. /**
  128196. * Defines the name of the task
  128197. */
  128198. name: string;
  128199. /**
  128200. * Defines the location of the image to load
  128201. */
  128202. url: string;
  128203. /**
  128204. * Gets the loaded images
  128205. */
  128206. image: HTMLImageElement;
  128207. /**
  128208. * Callback called when the task is successful
  128209. */
  128210. onSuccess: (task: ImageAssetTask) => void;
  128211. /**
  128212. * Callback called when the task is successful
  128213. */
  128214. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128215. /**
  128216. * Creates a new ImageAssetTask
  128217. * @param name defines the name of the task
  128218. * @param url defines the location of the image to load
  128219. */
  128220. constructor(
  128221. /**
  128222. * Defines the name of the task
  128223. */
  128224. name: string,
  128225. /**
  128226. * Defines the location of the image to load
  128227. */
  128228. url: string);
  128229. /**
  128230. * Execute the current task
  128231. * @param scene defines the scene where you want your assets to be loaded
  128232. * @param onSuccess is a callback called when the task is successfully executed
  128233. * @param onError is a callback called if an error occurs
  128234. */
  128235. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128236. }
  128237. /**
  128238. * Defines the interface used by texture loading tasks
  128239. */
  128240. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128241. /**
  128242. * Gets the loaded texture
  128243. */
  128244. texture: TEX;
  128245. }
  128246. /**
  128247. * Define a task used by AssetsManager to load 2D textures
  128248. */
  128249. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128250. /**
  128251. * Defines the name of the task
  128252. */
  128253. name: string;
  128254. /**
  128255. * Defines the location of the file to load
  128256. */
  128257. url: string;
  128258. /**
  128259. * Defines if mipmap should not be generated (default is false)
  128260. */
  128261. noMipmap?: boolean | undefined;
  128262. /**
  128263. * Defines if texture must be inverted on Y axis (default is false)
  128264. */
  128265. invertY?: boolean | undefined;
  128266. /**
  128267. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128268. */
  128269. samplingMode: number;
  128270. /**
  128271. * Gets the loaded texture
  128272. */
  128273. texture: Texture;
  128274. /**
  128275. * Callback called when the task is successful
  128276. */
  128277. onSuccess: (task: TextureAssetTask) => void;
  128278. /**
  128279. * Callback called when the task is successful
  128280. */
  128281. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128282. /**
  128283. * Creates a new TextureAssetTask object
  128284. * @param name defines the name of the task
  128285. * @param url defines the location of the file to load
  128286. * @param noMipmap defines if mipmap should not be generated (default is false)
  128287. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128288. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128289. */
  128290. constructor(
  128291. /**
  128292. * Defines the name of the task
  128293. */
  128294. name: string,
  128295. /**
  128296. * Defines the location of the file to load
  128297. */
  128298. url: string,
  128299. /**
  128300. * Defines if mipmap should not be generated (default is false)
  128301. */
  128302. noMipmap?: boolean | undefined,
  128303. /**
  128304. * Defines if texture must be inverted on Y axis (default is false)
  128305. */
  128306. invertY?: boolean | undefined,
  128307. /**
  128308. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128309. */
  128310. samplingMode?: number);
  128311. /**
  128312. * Execute the current task
  128313. * @param scene defines the scene where you want your assets to be loaded
  128314. * @param onSuccess is a callback called when the task is successfully executed
  128315. * @param onError is a callback called if an error occurs
  128316. */
  128317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128318. }
  128319. /**
  128320. * Define a task used by AssetsManager to load cube textures
  128321. */
  128322. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128323. /**
  128324. * Defines the name of the task
  128325. */
  128326. name: string;
  128327. /**
  128328. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128329. */
  128330. url: string;
  128331. /**
  128332. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128333. */
  128334. extensions?: string[] | undefined;
  128335. /**
  128336. * Defines if mipmaps should not be generated (default is false)
  128337. */
  128338. noMipmap?: boolean | undefined;
  128339. /**
  128340. * Defines the explicit list of files (undefined by default)
  128341. */
  128342. files?: string[] | undefined;
  128343. /**
  128344. * Gets the loaded texture
  128345. */
  128346. texture: CubeTexture;
  128347. /**
  128348. * Callback called when the task is successful
  128349. */
  128350. onSuccess: (task: CubeTextureAssetTask) => void;
  128351. /**
  128352. * Callback called when the task is successful
  128353. */
  128354. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128355. /**
  128356. * Creates a new CubeTextureAssetTask
  128357. * @param name defines the name of the task
  128358. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128359. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128360. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128361. * @param files defines the explicit list of files (undefined by default)
  128362. */
  128363. constructor(
  128364. /**
  128365. * Defines the name of the task
  128366. */
  128367. name: string,
  128368. /**
  128369. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128370. */
  128371. url: string,
  128372. /**
  128373. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128374. */
  128375. extensions?: string[] | undefined,
  128376. /**
  128377. * Defines if mipmaps should not be generated (default is false)
  128378. */
  128379. noMipmap?: boolean | undefined,
  128380. /**
  128381. * Defines the explicit list of files (undefined by default)
  128382. */
  128383. files?: string[] | undefined);
  128384. /**
  128385. * Execute the current task
  128386. * @param scene defines the scene where you want your assets to be loaded
  128387. * @param onSuccess is a callback called when the task is successfully executed
  128388. * @param onError is a callback called if an error occurs
  128389. */
  128390. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128391. }
  128392. /**
  128393. * Define a task used by AssetsManager to load HDR cube textures
  128394. */
  128395. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128396. /**
  128397. * Defines the name of the task
  128398. */
  128399. name: string;
  128400. /**
  128401. * Defines the location of the file to load
  128402. */
  128403. url: string;
  128404. /**
  128405. * Defines the desired size (the more it increases the longer the generation will be)
  128406. */
  128407. size: number;
  128408. /**
  128409. * Defines if mipmaps should not be generated (default is false)
  128410. */
  128411. noMipmap: boolean;
  128412. /**
  128413. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128414. */
  128415. generateHarmonics: boolean;
  128416. /**
  128417. * 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)
  128418. */
  128419. gammaSpace: boolean;
  128420. /**
  128421. * Internal Use Only
  128422. */
  128423. reserved: boolean;
  128424. /**
  128425. * Gets the loaded texture
  128426. */
  128427. texture: HDRCubeTexture;
  128428. /**
  128429. * Callback called when the task is successful
  128430. */
  128431. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128432. /**
  128433. * Callback called when the task is successful
  128434. */
  128435. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128436. /**
  128437. * Creates a new HDRCubeTextureAssetTask object
  128438. * @param name defines the name of the task
  128439. * @param url defines the location of the file to load
  128440. * @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.
  128441. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128442. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128443. * @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)
  128444. * @param reserved Internal use only
  128445. */
  128446. constructor(
  128447. /**
  128448. * Defines the name of the task
  128449. */
  128450. name: string,
  128451. /**
  128452. * Defines the location of the file to load
  128453. */
  128454. url: string,
  128455. /**
  128456. * Defines the desired size (the more it increases the longer the generation will be)
  128457. */
  128458. size: number,
  128459. /**
  128460. * Defines if mipmaps should not be generated (default is false)
  128461. */
  128462. noMipmap?: boolean,
  128463. /**
  128464. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128465. */
  128466. generateHarmonics?: boolean,
  128467. /**
  128468. * 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)
  128469. */
  128470. gammaSpace?: boolean,
  128471. /**
  128472. * Internal Use Only
  128473. */
  128474. reserved?: boolean);
  128475. /**
  128476. * Execute the current task
  128477. * @param scene defines the scene where you want your assets to be loaded
  128478. * @param onSuccess is a callback called when the task is successfully executed
  128479. * @param onError is a callback called if an error occurs
  128480. */
  128481. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128482. }
  128483. /**
  128484. * Define a task used by AssetsManager to load Equirectangular cube textures
  128485. */
  128486. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128487. /**
  128488. * Defines the name of the task
  128489. */
  128490. name: string;
  128491. /**
  128492. * Defines the location of the file to load
  128493. */
  128494. url: string;
  128495. /**
  128496. * Defines the desired size (the more it increases the longer the generation will be)
  128497. */
  128498. size: number;
  128499. /**
  128500. * Defines if mipmaps should not be generated (default is false)
  128501. */
  128502. noMipmap: boolean;
  128503. /**
  128504. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128505. * but the standard material would require them in Gamma space) (default is true)
  128506. */
  128507. gammaSpace: boolean;
  128508. /**
  128509. * Gets the loaded texture
  128510. */
  128511. texture: EquiRectangularCubeTexture;
  128512. /**
  128513. * Callback called when the task is successful
  128514. */
  128515. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128516. /**
  128517. * Callback called when the task is successful
  128518. */
  128519. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128520. /**
  128521. * Creates a new EquiRectangularCubeTextureAssetTask object
  128522. * @param name defines the name of the task
  128523. * @param url defines the location of the file to load
  128524. * @param size defines the desired size (the more it increases the longer the generation will be)
  128525. * If the size is omitted this implies you are using a preprocessed cubemap.
  128526. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128527. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128528. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128529. * (default is true)
  128530. */
  128531. constructor(
  128532. /**
  128533. * Defines the name of the task
  128534. */
  128535. name: string,
  128536. /**
  128537. * Defines the location of the file to load
  128538. */
  128539. url: string,
  128540. /**
  128541. * Defines the desired size (the more it increases the longer the generation will be)
  128542. */
  128543. size: number,
  128544. /**
  128545. * Defines if mipmaps should not be generated (default is false)
  128546. */
  128547. noMipmap?: boolean,
  128548. /**
  128549. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128550. * but the standard material would require them in Gamma space) (default is true)
  128551. */
  128552. gammaSpace?: boolean);
  128553. /**
  128554. * Execute the current task
  128555. * @param scene defines the scene where you want your assets to be loaded
  128556. * @param onSuccess is a callback called when the task is successfully executed
  128557. * @param onError is a callback called if an error occurs
  128558. */
  128559. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128560. }
  128561. /**
  128562. * This class can be used to easily import assets into a scene
  128563. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128564. */
  128565. export class AssetsManager {
  128566. private _scene;
  128567. private _isLoading;
  128568. protected _tasks: AbstractAssetTask[];
  128569. protected _waitingTasksCount: number;
  128570. protected _totalTasksCount: number;
  128571. /**
  128572. * Callback called when all tasks are processed
  128573. */
  128574. onFinish: (tasks: AbstractAssetTask[]) => void;
  128575. /**
  128576. * Callback called when a task is successful
  128577. */
  128578. onTaskSuccess: (task: AbstractAssetTask) => void;
  128579. /**
  128580. * Callback called when a task had an error
  128581. */
  128582. onTaskError: (task: AbstractAssetTask) => void;
  128583. /**
  128584. * Callback called when a task is done (whatever the result is)
  128585. */
  128586. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128587. /**
  128588. * Observable called when all tasks are processed
  128589. */
  128590. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128591. /**
  128592. * Observable called when a task had an error
  128593. */
  128594. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128595. /**
  128596. * Observable called when all tasks were executed
  128597. */
  128598. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128599. /**
  128600. * Observable called when a task is done (whatever the result is)
  128601. */
  128602. onProgressObservable: Observable<IAssetsProgressEvent>;
  128603. /**
  128604. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128605. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128606. */
  128607. useDefaultLoadingScreen: boolean;
  128608. /**
  128609. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128610. * when all assets have been downloaded.
  128611. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128612. */
  128613. autoHideLoadingUI: boolean;
  128614. /**
  128615. * Creates a new AssetsManager
  128616. * @param scene defines the scene to work on
  128617. */
  128618. constructor(scene: Scene);
  128619. /**
  128620. * Add a MeshAssetTask to the list of active tasks
  128621. * @param taskName defines the name of the new task
  128622. * @param meshesNames defines the name of meshes to load
  128623. * @param rootUrl defines the root url to use to locate files
  128624. * @param sceneFilename defines the filename of the scene file
  128625. * @returns a new MeshAssetTask object
  128626. */
  128627. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  128628. /**
  128629. * Add a TextFileAssetTask to the list of active tasks
  128630. * @param taskName defines the name of the new task
  128631. * @param url defines the url of the file to load
  128632. * @returns a new TextFileAssetTask object
  128633. */
  128634. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  128635. /**
  128636. * Add a BinaryFileAssetTask to the list of active tasks
  128637. * @param taskName defines the name of the new task
  128638. * @param url defines the url of the file to load
  128639. * @returns a new BinaryFileAssetTask object
  128640. */
  128641. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  128642. /**
  128643. * Add a ImageAssetTask to the list of active tasks
  128644. * @param taskName defines the name of the new task
  128645. * @param url defines the url of the file to load
  128646. * @returns a new ImageAssetTask object
  128647. */
  128648. addImageTask(taskName: string, url: string): ImageAssetTask;
  128649. /**
  128650. * Add a TextureAssetTask to the list of active tasks
  128651. * @param taskName defines the name of the new task
  128652. * @param url defines the url of the file to load
  128653. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128654. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  128655. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128656. * @returns a new TextureAssetTask object
  128657. */
  128658. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  128659. /**
  128660. * Add a CubeTextureAssetTask to the list of active tasks
  128661. * @param taskName defines the name of the new task
  128662. * @param url defines the url of the file to load
  128663. * @param extensions defines the extension to use to load the cube map (can be null)
  128664. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128665. * @param files defines the list of files to load (can be null)
  128666. * @returns a new CubeTextureAssetTask object
  128667. */
  128668. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  128669. /**
  128670. *
  128671. * Add a HDRCubeTextureAssetTask to the list of active tasks
  128672. * @param taskName defines the name of the new task
  128673. * @param url defines the url of the file to load
  128674. * @param size defines the size you want for the cubemap (can be null)
  128675. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128676. * @param generateHarmonics defines if you want to automatically generate (true by default)
  128677. * @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)
  128678. * @param reserved Internal use only
  128679. * @returns a new HDRCubeTextureAssetTask object
  128680. */
  128681. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  128682. /**
  128683. *
  128684. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  128685. * @param taskName defines the name of the new task
  128686. * @param url defines the url of the file to load
  128687. * @param size defines the size you want for the cubemap (can be null)
  128688. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128689. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128690. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128691. * @returns a new EquiRectangularCubeTextureAssetTask object
  128692. */
  128693. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  128694. /**
  128695. * Remove a task from the assets manager.
  128696. * @param task the task to remove
  128697. */
  128698. removeTask(task: AbstractAssetTask): void;
  128699. private _decreaseWaitingTasksCount;
  128700. private _runTask;
  128701. /**
  128702. * Reset the AssetsManager and remove all tasks
  128703. * @return the current instance of the AssetsManager
  128704. */
  128705. reset(): AssetsManager;
  128706. /**
  128707. * Start the loading process
  128708. * @return the current instance of the AssetsManager
  128709. */
  128710. load(): AssetsManager;
  128711. /**
  128712. * Start the loading process as an async operation
  128713. * @return a promise returning the list of failed tasks
  128714. */
  128715. loadAsync(): Promise<void>;
  128716. }
  128717. }
  128718. declare module BABYLON {
  128719. /**
  128720. * Wrapper class for promise with external resolve and reject.
  128721. */
  128722. export class Deferred<T> {
  128723. /**
  128724. * The promise associated with this deferred object.
  128725. */
  128726. readonly promise: Promise<T>;
  128727. private _resolve;
  128728. private _reject;
  128729. /**
  128730. * The resolve method of the promise associated with this deferred object.
  128731. */
  128732. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  128733. /**
  128734. * The reject method of the promise associated with this deferred object.
  128735. */
  128736. readonly reject: (reason?: any) => void;
  128737. /**
  128738. * Constructor for this deferred object.
  128739. */
  128740. constructor();
  128741. }
  128742. }
  128743. declare module BABYLON {
  128744. /**
  128745. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  128746. */
  128747. export class MeshExploder {
  128748. private _centerMesh;
  128749. private _meshes;
  128750. private _meshesOrigins;
  128751. private _toCenterVectors;
  128752. private _scaledDirection;
  128753. private _newPosition;
  128754. private _centerPosition;
  128755. /**
  128756. * Explodes meshes from a center mesh.
  128757. * @param meshes The meshes to explode.
  128758. * @param centerMesh The mesh to be center of explosion.
  128759. */
  128760. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  128761. private _setCenterMesh;
  128762. /**
  128763. * Get class name
  128764. * @returns "MeshExploder"
  128765. */
  128766. getClassName(): string;
  128767. /**
  128768. * "Exploded meshes"
  128769. * @returns Array of meshes with the centerMesh at index 0.
  128770. */
  128771. getMeshes(): Array<Mesh>;
  128772. /**
  128773. * Explodes meshes giving a specific direction
  128774. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  128775. */
  128776. explode(direction?: number): void;
  128777. }
  128778. }
  128779. declare module BABYLON {
  128780. /**
  128781. * Class used to help managing file picking and drag'n'drop
  128782. */
  128783. export class FilesInput {
  128784. /**
  128785. * List of files ready to be loaded
  128786. */
  128787. static readonly FilesToLoad: {
  128788. [key: string]: File;
  128789. };
  128790. /**
  128791. * Callback called when a file is processed
  128792. */
  128793. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  128794. private _engine;
  128795. private _currentScene;
  128796. private _sceneLoadedCallback;
  128797. private _progressCallback;
  128798. private _additionalRenderLoopLogicCallback;
  128799. private _textureLoadingCallback;
  128800. private _startingProcessingFilesCallback;
  128801. private _onReloadCallback;
  128802. private _errorCallback;
  128803. private _elementToMonitor;
  128804. private _sceneFileToLoad;
  128805. private _filesToLoad;
  128806. /**
  128807. * Creates a new FilesInput
  128808. * @param engine defines the rendering engine
  128809. * @param scene defines the hosting scene
  128810. * @param sceneLoadedCallback callback called when scene is loaded
  128811. * @param progressCallback callback called to track progress
  128812. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  128813. * @param textureLoadingCallback callback called when a texture is loading
  128814. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  128815. * @param onReloadCallback callback called when a reload is requested
  128816. * @param errorCallback callback call if an error occurs
  128817. */
  128818. 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);
  128819. private _dragEnterHandler;
  128820. private _dragOverHandler;
  128821. private _dropHandler;
  128822. /**
  128823. * Calls this function to listen to drag'n'drop events on a specific DOM element
  128824. * @param elementToMonitor defines the DOM element to track
  128825. */
  128826. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  128827. /**
  128828. * Release all associated resources
  128829. */
  128830. dispose(): void;
  128831. private renderFunction;
  128832. private drag;
  128833. private drop;
  128834. private _traverseFolder;
  128835. private _processFiles;
  128836. /**
  128837. * Load files from a drop event
  128838. * @param event defines the drop event to use as source
  128839. */
  128840. loadFiles(event: any): void;
  128841. private _processReload;
  128842. /**
  128843. * Reload the current scene from the loaded files
  128844. */
  128845. reload(): void;
  128846. }
  128847. }
  128848. declare module BABYLON {
  128849. /**
  128850. * Defines the root class used to create scene optimization to use with SceneOptimizer
  128851. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128852. */
  128853. export class SceneOptimization {
  128854. /**
  128855. * Defines the priority of this optimization (0 by default which means first in the list)
  128856. */
  128857. priority: number;
  128858. /**
  128859. * Gets a string describing the action executed by the current optimization
  128860. * @returns description string
  128861. */
  128862. getDescription(): string;
  128863. /**
  128864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128865. * @param scene defines the current scene where to apply this optimization
  128866. * @param optimizer defines the current optimizer
  128867. * @returns true if everything that can be done was applied
  128868. */
  128869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128870. /**
  128871. * Creates the SceneOptimization object
  128872. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128873. * @param desc defines the description associated with the optimization
  128874. */
  128875. constructor(
  128876. /**
  128877. * Defines the priority of this optimization (0 by default which means first in the list)
  128878. */
  128879. priority?: number);
  128880. }
  128881. /**
  128882. * Defines an optimization used to reduce the size of render target textures
  128883. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128884. */
  128885. export class TextureOptimization extends SceneOptimization {
  128886. /**
  128887. * Defines the priority of this optimization (0 by default which means first in the list)
  128888. */
  128889. priority: number;
  128890. /**
  128891. * 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
  128892. */
  128893. maximumSize: number;
  128894. /**
  128895. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128896. */
  128897. step: number;
  128898. /**
  128899. * Gets a string describing the action executed by the current optimization
  128900. * @returns description string
  128901. */
  128902. getDescription(): string;
  128903. /**
  128904. * Creates the TextureOptimization object
  128905. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128906. * @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
  128907. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128908. */
  128909. constructor(
  128910. /**
  128911. * Defines the priority of this optimization (0 by default which means first in the list)
  128912. */
  128913. priority?: number,
  128914. /**
  128915. * 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
  128916. */
  128917. maximumSize?: number,
  128918. /**
  128919. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  128920. */
  128921. step?: number);
  128922. /**
  128923. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128924. * @param scene defines the current scene where to apply this optimization
  128925. * @param optimizer defines the current optimizer
  128926. * @returns true if everything that can be done was applied
  128927. */
  128928. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128929. }
  128930. /**
  128931. * Defines an optimization used to increase or decrease the rendering resolution
  128932. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128933. */
  128934. export class HardwareScalingOptimization extends SceneOptimization {
  128935. /**
  128936. * Defines the priority of this optimization (0 by default which means first in the list)
  128937. */
  128938. priority: number;
  128939. /**
  128940. * Defines the maximum scale to use (2 by default)
  128941. */
  128942. maximumScale: number;
  128943. /**
  128944. * Defines the step to use between two passes (0.5 by default)
  128945. */
  128946. step: number;
  128947. private _currentScale;
  128948. private _directionOffset;
  128949. /**
  128950. * Gets a string describing the action executed by the current optimization
  128951. * @return description string
  128952. */
  128953. getDescription(): string;
  128954. /**
  128955. * Creates the HardwareScalingOptimization object
  128956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  128957. * @param maximumScale defines the maximum scale to use (2 by default)
  128958. * @param step defines the step to use between two passes (0.5 by default)
  128959. */
  128960. constructor(
  128961. /**
  128962. * Defines the priority of this optimization (0 by default which means first in the list)
  128963. */
  128964. priority?: number,
  128965. /**
  128966. * Defines the maximum scale to use (2 by default)
  128967. */
  128968. maximumScale?: number,
  128969. /**
  128970. * Defines the step to use between two passes (0.5 by default)
  128971. */
  128972. step?: number);
  128973. /**
  128974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128975. * @param scene defines the current scene where to apply this optimization
  128976. * @param optimizer defines the current optimizer
  128977. * @returns true if everything that can be done was applied
  128978. */
  128979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128980. }
  128981. /**
  128982. * Defines an optimization used to remove shadows
  128983. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  128984. */
  128985. export class ShadowsOptimization extends SceneOptimization {
  128986. /**
  128987. * Gets a string describing the action executed by the current optimization
  128988. * @return description string
  128989. */
  128990. getDescription(): string;
  128991. /**
  128992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  128993. * @param scene defines the current scene where to apply this optimization
  128994. * @param optimizer defines the current optimizer
  128995. * @returns true if everything that can be done was applied
  128996. */
  128997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  128998. }
  128999. /**
  129000. * Defines an optimization used to turn post-processes off
  129001. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129002. */
  129003. export class PostProcessesOptimization extends SceneOptimization {
  129004. /**
  129005. * Gets a string describing the action executed by the current optimization
  129006. * @return description string
  129007. */
  129008. getDescription(): string;
  129009. /**
  129010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129011. * @param scene defines the current scene where to apply this optimization
  129012. * @param optimizer defines the current optimizer
  129013. * @returns true if everything that can be done was applied
  129014. */
  129015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129016. }
  129017. /**
  129018. * Defines an optimization used to turn lens flares off
  129019. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129020. */
  129021. export class LensFlaresOptimization extends SceneOptimization {
  129022. /**
  129023. * Gets a string describing the action executed by the current optimization
  129024. * @return description string
  129025. */
  129026. getDescription(): string;
  129027. /**
  129028. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129029. * @param scene defines the current scene where to apply this optimization
  129030. * @param optimizer defines the current optimizer
  129031. * @returns true if everything that can be done was applied
  129032. */
  129033. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129034. }
  129035. /**
  129036. * Defines an optimization based on user defined callback.
  129037. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129038. */
  129039. export class CustomOptimization extends SceneOptimization {
  129040. /**
  129041. * Callback called to apply the custom optimization.
  129042. */
  129043. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129044. /**
  129045. * Callback called to get custom description
  129046. */
  129047. onGetDescription: () => string;
  129048. /**
  129049. * Gets a string describing the action executed by the current optimization
  129050. * @returns description string
  129051. */
  129052. getDescription(): string;
  129053. /**
  129054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129055. * @param scene defines the current scene where to apply this optimization
  129056. * @param optimizer defines the current optimizer
  129057. * @returns true if everything that can be done was applied
  129058. */
  129059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129060. }
  129061. /**
  129062. * Defines an optimization used to turn particles off
  129063. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129064. */
  129065. export class ParticlesOptimization extends SceneOptimization {
  129066. /**
  129067. * Gets a string describing the action executed by the current optimization
  129068. * @return description string
  129069. */
  129070. getDescription(): string;
  129071. /**
  129072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129073. * @param scene defines the current scene where to apply this optimization
  129074. * @param optimizer defines the current optimizer
  129075. * @returns true if everything that can be done was applied
  129076. */
  129077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129078. }
  129079. /**
  129080. * Defines an optimization used to turn render targets off
  129081. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129082. */
  129083. export class RenderTargetsOptimization extends SceneOptimization {
  129084. /**
  129085. * Gets a string describing the action executed by the current optimization
  129086. * @return description string
  129087. */
  129088. getDescription(): string;
  129089. /**
  129090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129091. * @param scene defines the current scene where to apply this optimization
  129092. * @param optimizer defines the current optimizer
  129093. * @returns true if everything that can be done was applied
  129094. */
  129095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129096. }
  129097. /**
  129098. * Defines an optimization used to merge meshes with compatible materials
  129099. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129100. */
  129101. export class MergeMeshesOptimization extends SceneOptimization {
  129102. private static _UpdateSelectionTree;
  129103. /**
  129104. * Gets or sets a boolean which defines if optimization octree has to be updated
  129105. */
  129106. /**
  129107. * Gets or sets a boolean which defines if optimization octree has to be updated
  129108. */
  129109. static UpdateSelectionTree: boolean;
  129110. /**
  129111. * Gets a string describing the action executed by the current optimization
  129112. * @return description string
  129113. */
  129114. getDescription(): string;
  129115. private _canBeMerged;
  129116. /**
  129117. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129118. * @param scene defines the current scene where to apply this optimization
  129119. * @param optimizer defines the current optimizer
  129120. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129121. * @returns true if everything that can be done was applied
  129122. */
  129123. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129124. }
  129125. /**
  129126. * Defines a list of options used by SceneOptimizer
  129127. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129128. */
  129129. export class SceneOptimizerOptions {
  129130. /**
  129131. * Defines the target frame rate to reach (60 by default)
  129132. */
  129133. targetFrameRate: number;
  129134. /**
  129135. * Defines the interval between two checkes (2000ms by default)
  129136. */
  129137. trackerDuration: number;
  129138. /**
  129139. * Gets the list of optimizations to apply
  129140. */
  129141. optimizations: SceneOptimization[];
  129142. /**
  129143. * Creates a new list of options used by SceneOptimizer
  129144. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129145. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129146. */
  129147. constructor(
  129148. /**
  129149. * Defines the target frame rate to reach (60 by default)
  129150. */
  129151. targetFrameRate?: number,
  129152. /**
  129153. * Defines the interval between two checkes (2000ms by default)
  129154. */
  129155. trackerDuration?: number);
  129156. /**
  129157. * Add a new optimization
  129158. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129159. * @returns the current SceneOptimizerOptions
  129160. */
  129161. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129162. /**
  129163. * Add a new custom optimization
  129164. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129165. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129166. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129167. * @returns the current SceneOptimizerOptions
  129168. */
  129169. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129170. /**
  129171. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129172. * @param targetFrameRate defines the target frame rate (60 by default)
  129173. * @returns a SceneOptimizerOptions object
  129174. */
  129175. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129176. /**
  129177. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129178. * @param targetFrameRate defines the target frame rate (60 by default)
  129179. * @returns a SceneOptimizerOptions object
  129180. */
  129181. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129182. /**
  129183. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129184. * @param targetFrameRate defines the target frame rate (60 by default)
  129185. * @returns a SceneOptimizerOptions object
  129186. */
  129187. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129188. }
  129189. /**
  129190. * Class used to run optimizations in order to reach a target frame rate
  129191. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129192. */
  129193. export class SceneOptimizer implements IDisposable {
  129194. private _isRunning;
  129195. private _options;
  129196. private _scene;
  129197. private _currentPriorityLevel;
  129198. private _targetFrameRate;
  129199. private _trackerDuration;
  129200. private _currentFrameRate;
  129201. private _sceneDisposeObserver;
  129202. private _improvementMode;
  129203. /**
  129204. * Defines an observable called when the optimizer reaches the target frame rate
  129205. */
  129206. onSuccessObservable: Observable<SceneOptimizer>;
  129207. /**
  129208. * Defines an observable called when the optimizer enables an optimization
  129209. */
  129210. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129211. /**
  129212. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129213. */
  129214. onFailureObservable: Observable<SceneOptimizer>;
  129215. /**
  129216. * Gets a boolean indicating if the optimizer is in improvement mode
  129217. */
  129218. readonly isInImprovementMode: boolean;
  129219. /**
  129220. * Gets the current priority level (0 at start)
  129221. */
  129222. readonly currentPriorityLevel: number;
  129223. /**
  129224. * Gets the current frame rate checked by the SceneOptimizer
  129225. */
  129226. readonly currentFrameRate: number;
  129227. /**
  129228. * Gets or sets the current target frame rate (60 by default)
  129229. */
  129230. /**
  129231. * Gets or sets the current target frame rate (60 by default)
  129232. */
  129233. targetFrameRate: number;
  129234. /**
  129235. * Gets or sets the current interval between two checks (every 2000ms by default)
  129236. */
  129237. /**
  129238. * Gets or sets the current interval between two checks (every 2000ms by default)
  129239. */
  129240. trackerDuration: number;
  129241. /**
  129242. * Gets the list of active optimizations
  129243. */
  129244. readonly optimizations: SceneOptimization[];
  129245. /**
  129246. * Creates a new SceneOptimizer
  129247. * @param scene defines the scene to work on
  129248. * @param options defines the options to use with the SceneOptimizer
  129249. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129250. * @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)
  129251. */
  129252. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129253. /**
  129254. * Stops the current optimizer
  129255. */
  129256. stop(): void;
  129257. /**
  129258. * Reset the optimizer to initial step (current priority level = 0)
  129259. */
  129260. reset(): void;
  129261. /**
  129262. * Start the optimizer. By default it will try to reach a specific framerate
  129263. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129264. */
  129265. start(): void;
  129266. private _checkCurrentState;
  129267. /**
  129268. * Release all resources
  129269. */
  129270. dispose(): void;
  129271. /**
  129272. * Helper function to create a SceneOptimizer with one single line of code
  129273. * @param scene defines the scene to work on
  129274. * @param options defines the options to use with the SceneOptimizer
  129275. * @param onSuccess defines a callback to call on success
  129276. * @param onFailure defines a callback to call on failure
  129277. * @returns the new SceneOptimizer object
  129278. */
  129279. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129280. }
  129281. }
  129282. declare module BABYLON {
  129283. /**
  129284. * Class used to serialize a scene into a string
  129285. */
  129286. export class SceneSerializer {
  129287. /**
  129288. * Clear cache used by a previous serialization
  129289. */
  129290. static ClearCache(): void;
  129291. /**
  129292. * Serialize a scene into a JSON compatible object
  129293. * @param scene defines the scene to serialize
  129294. * @returns a JSON compatible object
  129295. */
  129296. static Serialize(scene: Scene): any;
  129297. /**
  129298. * Serialize a mesh into a JSON compatible object
  129299. * @param toSerialize defines the mesh to serialize
  129300. * @param withParents defines if parents must be serialized as well
  129301. * @param withChildren defines if children must be serialized as well
  129302. * @returns a JSON compatible object
  129303. */
  129304. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129305. }
  129306. }
  129307. declare module BABYLON {
  129308. /**
  129309. * Class used to host texture specific utilities
  129310. */
  129311. export class TextureTools {
  129312. /**
  129313. * Uses the GPU to create a copy texture rescaled at a given size
  129314. * @param texture Texture to copy from
  129315. * @param width defines the desired width
  129316. * @param height defines the desired height
  129317. * @param useBilinearMode defines if bilinear mode has to be used
  129318. * @return the generated texture
  129319. */
  129320. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129321. }
  129322. }
  129323. declare module BABYLON {
  129324. /**
  129325. * This represents the different options available for the video capture.
  129326. */
  129327. export interface VideoRecorderOptions {
  129328. /** Defines the mime type of the video. */
  129329. mimeType: string;
  129330. /** Defines the FPS the video should be recorded at. */
  129331. fps: number;
  129332. /** Defines the chunk size for the recording data. */
  129333. recordChunckSize: number;
  129334. /** The audio tracks to attach to the recording. */
  129335. audioTracks?: MediaStreamTrack[];
  129336. }
  129337. /**
  129338. * This can help with recording videos from BabylonJS.
  129339. * This is based on the available WebRTC functionalities of the browser.
  129340. *
  129341. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129342. */
  129343. export class VideoRecorder {
  129344. private static readonly _defaultOptions;
  129345. /**
  129346. * Returns whether or not the VideoRecorder is available in your browser.
  129347. * @param engine Defines the Babylon Engine.
  129348. * @returns true if supported otherwise false.
  129349. */
  129350. static IsSupported(engine: Engine): boolean;
  129351. private readonly _options;
  129352. private _canvas;
  129353. private _mediaRecorder;
  129354. private _recordedChunks;
  129355. private _fileName;
  129356. private _resolve;
  129357. private _reject;
  129358. /**
  129359. * True when a recording is already in progress.
  129360. */
  129361. readonly isRecording: boolean;
  129362. /**
  129363. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129364. * @param engine Defines the BabylonJS Engine you wish to record.
  129365. * @param options Defines options that can be used to customize the capture.
  129366. */
  129367. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129368. /**
  129369. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129370. */
  129371. stopRecording(): void;
  129372. /**
  129373. * Starts recording the canvas for a max duration specified in parameters.
  129374. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129375. * If null no automatic download will start and you can rely on the promise to get the data back.
  129376. * @param maxDuration Defines the maximum recording time in seconds.
  129377. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129378. * @return A promise callback at the end of the recording with the video data in Blob.
  129379. */
  129380. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129381. /**
  129382. * Releases internal resources used during the recording.
  129383. */
  129384. dispose(): void;
  129385. private _handleDataAvailable;
  129386. private _handleError;
  129387. private _handleStop;
  129388. }
  129389. }
  129390. declare module BABYLON {
  129391. /**
  129392. * Class containing a set of static utilities functions for screenshots
  129393. */
  129394. export class ScreenshotTools {
  129395. /**
  129396. * Captures a screenshot of the current rendering
  129397. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129398. * @param engine defines the rendering engine
  129399. * @param camera defines the source camera
  129400. * @param size This parameter can be set to a single number or to an object with the
  129401. * following (optional) properties: precision, width, height. If a single number is passed,
  129402. * it will be used for both width and height. If an object is passed, the screenshot size
  129403. * will be derived from the parameters. The precision property is a multiplier allowing
  129404. * rendering at a higher or lower resolution
  129405. * @param successCallback defines the callback receives a single parameter which contains the
  129406. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129407. * src parameter of an <img> to display it
  129408. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129409. * Check your browser for supported MIME types
  129410. */
  129411. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129412. /**
  129413. * Captures a screenshot of the current rendering
  129414. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129415. * @param engine defines the rendering engine
  129416. * @param camera defines the source camera
  129417. * @param size This parameter can be set to a single number or to an object with the
  129418. * following (optional) properties: precision, width, height. If a single number is passed,
  129419. * it will be used for both width and height. If an object is passed, the screenshot size
  129420. * will be derived from the parameters. The precision property is a multiplier allowing
  129421. * rendering at a higher or lower resolution
  129422. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129423. * Check your browser for supported MIME types
  129424. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129425. * to the src parameter of an <img> to display it
  129426. */
  129427. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129428. /**
  129429. * Generates an image screenshot from the specified camera.
  129430. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129431. * @param engine The engine to use for rendering
  129432. * @param camera The camera to use for rendering
  129433. * @param size This parameter can be set to a single number or to an object with the
  129434. * following (optional) properties: precision, width, height. If a single number is passed,
  129435. * it will be used for both width and height. If an object is passed, the screenshot size
  129436. * will be derived from the parameters. The precision property is a multiplier allowing
  129437. * rendering at a higher or lower resolution
  129438. * @param successCallback The callback receives a single parameter which contains the
  129439. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129440. * src parameter of an <img> to display it
  129441. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129442. * Check your browser for supported MIME types
  129443. * @param samples Texture samples (default: 1)
  129444. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129445. * @param fileName A name for for the downloaded file.
  129446. */
  129447. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129448. /**
  129449. * Generates an image screenshot from the specified camera.
  129450. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129451. * @param engine The engine to use for rendering
  129452. * @param camera The camera to use for rendering
  129453. * @param size This parameter can be set to a single number or to an object with the
  129454. * following (optional) properties: precision, width, height. If a single number is passed,
  129455. * it will be used for both width and height. If an object is passed, the screenshot size
  129456. * will be derived from the parameters. The precision property is a multiplier allowing
  129457. * rendering at a higher or lower resolution
  129458. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129459. * Check your browser for supported MIME types
  129460. * @param samples Texture samples (default: 1)
  129461. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129462. * @param fileName A name for for the downloaded file.
  129463. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129464. * to the src parameter of an <img> to display it
  129465. */
  129466. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129467. /**
  129468. * Gets height and width for screenshot size
  129469. * @private
  129470. */
  129471. private static _getScreenshotSize;
  129472. }
  129473. }
  129474. declare module BABYLON {
  129475. /**
  129476. * A cursor which tracks a point on a path
  129477. */
  129478. export class PathCursor {
  129479. private path;
  129480. /**
  129481. * Stores path cursor callbacks for when an onchange event is triggered
  129482. */
  129483. private _onchange;
  129484. /**
  129485. * The value of the path cursor
  129486. */
  129487. value: number;
  129488. /**
  129489. * The animation array of the path cursor
  129490. */
  129491. animations: Animation[];
  129492. /**
  129493. * Initializes the path cursor
  129494. * @param path The path to track
  129495. */
  129496. constructor(path: Path2);
  129497. /**
  129498. * Gets the cursor point on the path
  129499. * @returns A point on the path cursor at the cursor location
  129500. */
  129501. getPoint(): Vector3;
  129502. /**
  129503. * Moves the cursor ahead by the step amount
  129504. * @param step The amount to move the cursor forward
  129505. * @returns This path cursor
  129506. */
  129507. moveAhead(step?: number): PathCursor;
  129508. /**
  129509. * Moves the cursor behind by the step amount
  129510. * @param step The amount to move the cursor back
  129511. * @returns This path cursor
  129512. */
  129513. moveBack(step?: number): PathCursor;
  129514. /**
  129515. * Moves the cursor by the step amount
  129516. * If the step amount is greater than one, an exception is thrown
  129517. * @param step The amount to move the cursor
  129518. * @returns This path cursor
  129519. */
  129520. move(step: number): PathCursor;
  129521. /**
  129522. * Ensures that the value is limited between zero and one
  129523. * @returns This path cursor
  129524. */
  129525. private ensureLimits;
  129526. /**
  129527. * Runs onchange callbacks on change (used by the animation engine)
  129528. * @returns This path cursor
  129529. */
  129530. private raiseOnChange;
  129531. /**
  129532. * Executes a function on change
  129533. * @param f A path cursor onchange callback
  129534. * @returns This path cursor
  129535. */
  129536. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129537. }
  129538. }
  129539. declare module BABYLON {
  129540. /** @hidden */
  129541. export var blurPixelShader: {
  129542. name: string;
  129543. shader: string;
  129544. };
  129545. }
  129546. declare module BABYLON {
  129547. /** @hidden */
  129548. export var pointCloudVertexDeclaration: {
  129549. name: string;
  129550. shader: string;
  129551. };
  129552. }
  129553. // Mixins
  129554. interface Window {
  129555. mozIndexedDB: IDBFactory;
  129556. webkitIndexedDB: IDBFactory;
  129557. msIndexedDB: IDBFactory;
  129558. webkitURL: typeof URL;
  129559. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129560. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129561. WebGLRenderingContext: WebGLRenderingContext;
  129562. MSGesture: MSGesture;
  129563. CANNON: any;
  129564. AudioContext: AudioContext;
  129565. webkitAudioContext: AudioContext;
  129566. PointerEvent: any;
  129567. Math: Math;
  129568. Uint8Array: Uint8ArrayConstructor;
  129569. Float32Array: Float32ArrayConstructor;
  129570. mozURL: typeof URL;
  129571. msURL: typeof URL;
  129572. VRFrameData: any; // WebVR, from specs 1.1
  129573. DracoDecoderModule: any;
  129574. setImmediate(handler: (...args: any[]) => void): number;
  129575. }
  129576. interface HTMLCanvasElement {
  129577. requestPointerLock(): void;
  129578. msRequestPointerLock?(): void;
  129579. mozRequestPointerLock?(): void;
  129580. webkitRequestPointerLock?(): void;
  129581. /** Track wether a record is in progress */
  129582. isRecording: boolean;
  129583. /** Capture Stream method defined by some browsers */
  129584. captureStream(fps?: number): MediaStream;
  129585. }
  129586. interface CanvasRenderingContext2D {
  129587. msImageSmoothingEnabled: boolean;
  129588. }
  129589. interface MouseEvent {
  129590. mozMovementX: number;
  129591. mozMovementY: number;
  129592. webkitMovementX: number;
  129593. webkitMovementY: number;
  129594. msMovementX: number;
  129595. msMovementY: number;
  129596. }
  129597. interface Navigator {
  129598. mozGetVRDevices: (any: any) => any;
  129599. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129600. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129601. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129602. webkitGetGamepads(): Gamepad[];
  129603. msGetGamepads(): Gamepad[];
  129604. webkitGamepads(): Gamepad[];
  129605. }
  129606. interface HTMLVideoElement {
  129607. mozSrcObject: any;
  129608. }
  129609. interface Math {
  129610. fround(x: number): number;
  129611. imul(a: number, b: number): number;
  129612. }
  129613. interface WebGLRenderingContext {
  129614. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  129615. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  129616. vertexAttribDivisor(index: number, divisor: number): void;
  129617. createVertexArray(): any;
  129618. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  129619. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  129620. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  129621. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  129622. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  129623. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  129624. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  129625. // Queries
  129626. createQuery(): WebGLQuery;
  129627. deleteQuery(query: WebGLQuery): void;
  129628. beginQuery(target: number, query: WebGLQuery): void;
  129629. endQuery(target: number): void;
  129630. getQueryParameter(query: WebGLQuery, pname: number): any;
  129631. getQuery(target: number, pname: number): any;
  129632. MAX_SAMPLES: number;
  129633. RGBA8: number;
  129634. READ_FRAMEBUFFER: number;
  129635. DRAW_FRAMEBUFFER: number;
  129636. UNIFORM_BUFFER: number;
  129637. HALF_FLOAT_OES: number;
  129638. RGBA16F: number;
  129639. RGBA32F: number;
  129640. R32F: number;
  129641. RG32F: number;
  129642. RGB32F: number;
  129643. R16F: number;
  129644. RG16F: number;
  129645. RGB16F: number;
  129646. RED: number;
  129647. RG: number;
  129648. R8: number;
  129649. RG8: number;
  129650. UNSIGNED_INT_24_8: number;
  129651. DEPTH24_STENCIL8: number;
  129652. MIN: number;
  129653. MAX: number;
  129654. /* Multiple Render Targets */
  129655. drawBuffers(buffers: number[]): void;
  129656. readBuffer(src: number): void;
  129657. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  129658. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  129659. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  129660. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  129661. // Occlusion Query
  129662. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  129663. ANY_SAMPLES_PASSED: number;
  129664. QUERY_RESULT_AVAILABLE: number;
  129665. QUERY_RESULT: number;
  129666. }
  129667. interface WebGLProgram {
  129668. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  129669. }
  129670. interface EXT_disjoint_timer_query {
  129671. QUERY_COUNTER_BITS_EXT: number;
  129672. TIME_ELAPSED_EXT: number;
  129673. TIMESTAMP_EXT: number;
  129674. GPU_DISJOINT_EXT: number;
  129675. QUERY_RESULT_EXT: number;
  129676. QUERY_RESULT_AVAILABLE_EXT: number;
  129677. queryCounterEXT(query: WebGLQuery, target: number): void;
  129678. createQueryEXT(): WebGLQuery;
  129679. beginQueryEXT(target: number, query: WebGLQuery): void;
  129680. endQueryEXT(target: number): void;
  129681. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  129682. deleteQueryEXT(query: WebGLQuery): void;
  129683. }
  129684. interface WebGLUniformLocation {
  129685. _currentState: any;
  129686. }
  129687. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  129688. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  129689. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  129690. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129691. interface WebGLRenderingContext {
  129692. readonly RASTERIZER_DISCARD: number;
  129693. readonly DEPTH_COMPONENT24: number;
  129694. readonly TEXTURE_3D: number;
  129695. readonly TEXTURE_2D_ARRAY: number;
  129696. readonly TEXTURE_COMPARE_FUNC: number;
  129697. readonly TEXTURE_COMPARE_MODE: number;
  129698. readonly COMPARE_REF_TO_TEXTURE: number;
  129699. readonly TEXTURE_WRAP_R: number;
  129700. readonly HALF_FLOAT: number;
  129701. readonly RGB8: number;
  129702. readonly RED_INTEGER: number;
  129703. readonly RG_INTEGER: number;
  129704. readonly RGB_INTEGER: number;
  129705. readonly RGBA_INTEGER: number;
  129706. readonly R8_SNORM: number;
  129707. readonly RG8_SNORM: number;
  129708. readonly RGB8_SNORM: number;
  129709. readonly RGBA8_SNORM: number;
  129710. readonly R8I: number;
  129711. readonly RG8I: number;
  129712. readonly RGB8I: number;
  129713. readonly RGBA8I: number;
  129714. readonly R8UI: number;
  129715. readonly RG8UI: number;
  129716. readonly RGB8UI: number;
  129717. readonly RGBA8UI: number;
  129718. readonly R16I: number;
  129719. readonly RG16I: number;
  129720. readonly RGB16I: number;
  129721. readonly RGBA16I: number;
  129722. readonly R16UI: number;
  129723. readonly RG16UI: number;
  129724. readonly RGB16UI: number;
  129725. readonly RGBA16UI: number;
  129726. readonly R32I: number;
  129727. readonly RG32I: number;
  129728. readonly RGB32I: number;
  129729. readonly RGBA32I: number;
  129730. readonly R32UI: number;
  129731. readonly RG32UI: number;
  129732. readonly RGB32UI: number;
  129733. readonly RGBA32UI: number;
  129734. readonly RGB10_A2UI: number;
  129735. readonly R11F_G11F_B10F: number;
  129736. readonly RGB9_E5: number;
  129737. readonly RGB10_A2: number;
  129738. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  129739. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  129740. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  129741. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  129742. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  129743. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  129744. 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;
  129745. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  129746. readonly TRANSFORM_FEEDBACK: number;
  129747. readonly INTERLEAVED_ATTRIBS: number;
  129748. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  129749. createTransformFeedback(): WebGLTransformFeedback;
  129750. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  129751. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  129752. beginTransformFeedback(primitiveMode: number): void;
  129753. endTransformFeedback(): void;
  129754. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  129755. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129756. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129757. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  129758. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  129759. }
  129760. interface ImageBitmap {
  129761. readonly width: number;
  129762. readonly height: number;
  129763. close(): void;
  129764. }
  129765. interface WebGLQuery extends WebGLObject {
  129766. }
  129767. declare var WebGLQuery: {
  129768. prototype: WebGLQuery;
  129769. new(): WebGLQuery;
  129770. };
  129771. interface WebGLSampler extends WebGLObject {
  129772. }
  129773. declare var WebGLSampler: {
  129774. prototype: WebGLSampler;
  129775. new(): WebGLSampler;
  129776. };
  129777. interface WebGLSync extends WebGLObject {
  129778. }
  129779. declare var WebGLSync: {
  129780. prototype: WebGLSync;
  129781. new(): WebGLSync;
  129782. };
  129783. interface WebGLTransformFeedback extends WebGLObject {
  129784. }
  129785. declare var WebGLTransformFeedback: {
  129786. prototype: WebGLTransformFeedback;
  129787. new(): WebGLTransformFeedback;
  129788. };
  129789. interface WebGLVertexArrayObject extends WebGLObject {
  129790. }
  129791. declare var WebGLVertexArrayObject: {
  129792. prototype: WebGLVertexArrayObject;
  129793. new(): WebGLVertexArrayObject;
  129794. };
  129795. // Type definitions for WebVR API
  129796. // Project: https://w3c.github.io/webvr/
  129797. // Definitions by: six a <https://github.com/lostfictions>
  129798. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129799. interface VRDisplay extends EventTarget {
  129800. /**
  129801. * Dictionary of capabilities describing the VRDisplay.
  129802. */
  129803. readonly capabilities: VRDisplayCapabilities;
  129804. /**
  129805. * z-depth defining the far plane of the eye view frustum
  129806. * enables mapping of values in the render target depth
  129807. * attachment to scene coordinates. Initially set to 10000.0.
  129808. */
  129809. depthFar: number;
  129810. /**
  129811. * z-depth defining the near plane of the eye view frustum
  129812. * enables mapping of values in the render target depth
  129813. * attachment to scene coordinates. Initially set to 0.01.
  129814. */
  129815. depthNear: number;
  129816. /**
  129817. * An identifier for this distinct VRDisplay. Used as an
  129818. * association point in the Gamepad API.
  129819. */
  129820. readonly displayId: number;
  129821. /**
  129822. * A display name, a user-readable name identifying it.
  129823. */
  129824. readonly displayName: string;
  129825. readonly isConnected: boolean;
  129826. readonly isPresenting: boolean;
  129827. /**
  129828. * If this VRDisplay supports room-scale experiences, the optional
  129829. * stage attribute contains details on the room-scale parameters.
  129830. */
  129831. readonly stageParameters: VRStageParameters | null;
  129832. /**
  129833. * Passing the value returned by `requestAnimationFrame` to
  129834. * `cancelAnimationFrame` will unregister the callback.
  129835. * @param handle Define the hanle of the request to cancel
  129836. */
  129837. cancelAnimationFrame(handle: number): void;
  129838. /**
  129839. * Stops presenting to the VRDisplay.
  129840. * @returns a promise to know when it stopped
  129841. */
  129842. exitPresent(): Promise<void>;
  129843. /**
  129844. * Return the current VREyeParameters for the given eye.
  129845. * @param whichEye Define the eye we want the parameter for
  129846. * @returns the eye parameters
  129847. */
  129848. getEyeParameters(whichEye: string): VREyeParameters;
  129849. /**
  129850. * Populates the passed VRFrameData with the information required to render
  129851. * the current frame.
  129852. * @param frameData Define the data structure to populate
  129853. * @returns true if ok otherwise false
  129854. */
  129855. getFrameData(frameData: VRFrameData): boolean;
  129856. /**
  129857. * Get the layers currently being presented.
  129858. * @returns the list of VR layers
  129859. */
  129860. getLayers(): VRLayer[];
  129861. /**
  129862. * Return a VRPose containing the future predicted pose of the VRDisplay
  129863. * when the current frame will be presented. The value returned will not
  129864. * change until JavaScript has returned control to the browser.
  129865. *
  129866. * The VRPose will contain the position, orientation, velocity,
  129867. * and acceleration of each of these properties.
  129868. * @returns the pose object
  129869. */
  129870. getPose(): VRPose;
  129871. /**
  129872. * Return the current instantaneous pose of the VRDisplay, with no
  129873. * prediction applied.
  129874. * @returns the current instantaneous pose
  129875. */
  129876. getImmediatePose(): VRPose;
  129877. /**
  129878. * The callback passed to `requestAnimationFrame` will be called
  129879. * any time a new frame should be rendered. When the VRDisplay is
  129880. * presenting the callback will be called at the native refresh
  129881. * rate of the HMD. When not presenting this function acts
  129882. * identically to how window.requestAnimationFrame acts. Content should
  129883. * make no assumptions of frame rate or vsync behavior as the HMD runs
  129884. * asynchronously from other displays and at differing refresh rates.
  129885. * @param callback Define the eaction to run next frame
  129886. * @returns the request handle it
  129887. */
  129888. requestAnimationFrame(callback: FrameRequestCallback): number;
  129889. /**
  129890. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  129891. * Repeat calls while already presenting will update the VRLayers being displayed.
  129892. * @param layers Define the list of layer to present
  129893. * @returns a promise to know when the request has been fulfilled
  129894. */
  129895. requestPresent(layers: VRLayer[]): Promise<void>;
  129896. /**
  129897. * Reset the pose for this display, treating its current position and
  129898. * orientation as the "origin/zero" values. VRPose.position,
  129899. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  129900. * updated when calling resetPose(). This should be called in only
  129901. * sitting-space experiences.
  129902. */
  129903. resetPose(): void;
  129904. /**
  129905. * The VRLayer provided to the VRDisplay will be captured and presented
  129906. * in the HMD. Calling this function has the same effect on the source
  129907. * canvas as any other operation that uses its source image, and canvases
  129908. * created without preserveDrawingBuffer set to true will be cleared.
  129909. * @param pose Define the pose to submit
  129910. */
  129911. submitFrame(pose?: VRPose): void;
  129912. }
  129913. declare var VRDisplay: {
  129914. prototype: VRDisplay;
  129915. new(): VRDisplay;
  129916. };
  129917. interface VRLayer {
  129918. leftBounds?: number[] | Float32Array | null;
  129919. rightBounds?: number[] | Float32Array | null;
  129920. source?: HTMLCanvasElement | null;
  129921. }
  129922. interface VRDisplayCapabilities {
  129923. readonly canPresent: boolean;
  129924. readonly hasExternalDisplay: boolean;
  129925. readonly hasOrientation: boolean;
  129926. readonly hasPosition: boolean;
  129927. readonly maxLayers: number;
  129928. }
  129929. interface VREyeParameters {
  129930. /** @deprecated */
  129931. readonly fieldOfView: VRFieldOfView;
  129932. readonly offset: Float32Array;
  129933. readonly renderHeight: number;
  129934. readonly renderWidth: number;
  129935. }
  129936. interface VRFieldOfView {
  129937. readonly downDegrees: number;
  129938. readonly leftDegrees: number;
  129939. readonly rightDegrees: number;
  129940. readonly upDegrees: number;
  129941. }
  129942. interface VRFrameData {
  129943. readonly leftProjectionMatrix: Float32Array;
  129944. readonly leftViewMatrix: Float32Array;
  129945. readonly pose: VRPose;
  129946. readonly rightProjectionMatrix: Float32Array;
  129947. readonly rightViewMatrix: Float32Array;
  129948. readonly timestamp: number;
  129949. }
  129950. interface VRPose {
  129951. readonly angularAcceleration: Float32Array | null;
  129952. readonly angularVelocity: Float32Array | null;
  129953. readonly linearAcceleration: Float32Array | null;
  129954. readonly linearVelocity: Float32Array | null;
  129955. readonly orientation: Float32Array | null;
  129956. readonly position: Float32Array | null;
  129957. readonly timestamp: number;
  129958. }
  129959. interface VRStageParameters {
  129960. sittingToStandingTransform?: Float32Array;
  129961. sizeX?: number;
  129962. sizeY?: number;
  129963. }
  129964. interface Navigator {
  129965. getVRDisplays(): Promise<VRDisplay[]>;
  129966. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  129967. }
  129968. interface Window {
  129969. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  129970. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  129971. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  129972. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129973. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  129974. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  129975. }
  129976. interface Gamepad {
  129977. readonly displayId: number;
  129978. }
  129979. type XRSessionMode =
  129980. | "inline"
  129981. | "immersive-vr"
  129982. | "immersive-ar";
  129983. type XRReferenceSpaceType =
  129984. | "viewer"
  129985. | "local"
  129986. | "local-floor"
  129987. | "bounded-floor"
  129988. | "unbounded";
  129989. type XREnvironmentBlendMode =
  129990. | "opaque"
  129991. | "additive"
  129992. | "alpha-blend";
  129993. type XRVisibilityState =
  129994. | "visible"
  129995. | "visible-blurred"
  129996. | "hidden";
  129997. type XRHandedness =
  129998. | "none"
  129999. | "left"
  130000. | "right";
  130001. type XRTargetRayMode =
  130002. | "gaze"
  130003. | "tracked-pointer"
  130004. | "screen";
  130005. type XREye =
  130006. | "none"
  130007. | "left"
  130008. | "right";
  130009. interface XRSpace extends EventTarget {
  130010. }
  130011. interface XRRenderState {
  130012. depthNear?: number;
  130013. depthFar?: number;
  130014. inlineVerticalFieldOfView?: number;
  130015. baseLayer?: XRWebGLLayer;
  130016. }
  130017. interface XRInputSource {
  130018. handedness: XRHandedness;
  130019. targetRayMode: XRTargetRayMode;
  130020. targetRaySpace: XRSpace;
  130021. gripSpace: XRSpace | undefined;
  130022. gamepad: Gamepad | undefined;
  130023. profiles: Array<string>;
  130024. }
  130025. interface XRSession {
  130026. addEventListener: Function;
  130027. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130028. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130029. requestAnimationFrame: Function;
  130030. end(): Promise<void>;
  130031. renderState: XRRenderState;
  130032. inputSources: Array<XRInputSource>;
  130033. }
  130034. interface XRReferenceSpace extends XRSpace {
  130035. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130036. onreset: any;
  130037. }
  130038. interface XRFrame {
  130039. session: XRSession;
  130040. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130041. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130042. }
  130043. interface XRViewerPose extends XRPose {
  130044. views: Array<XRView>;
  130045. }
  130046. interface XRPose {
  130047. transform: XRRigidTransform;
  130048. emulatedPosition: boolean;
  130049. }
  130050. declare var XRWebGLLayer: {
  130051. prototype: XRWebGLLayer;
  130052. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130053. };
  130054. interface XRWebGLLayer {
  130055. framebuffer: WebGLFramebuffer;
  130056. framebufferWidth: number;
  130057. framebufferHeight: number;
  130058. getViewport: Function;
  130059. }
  130060. interface XRRigidTransform {
  130061. position: DOMPointReadOnly;
  130062. orientation: DOMPointReadOnly;
  130063. matrix: Float32Array;
  130064. inverse: XRRigidTransform;
  130065. }
  130066. interface XRView {
  130067. eye: XREye;
  130068. projectionMatrix: Float32Array;
  130069. transform: XRRigidTransform;
  130070. }
  130071. interface XRInputSourceChangeEvent {
  130072. session: XRSession;
  130073. removed: Array<XRInputSource>;
  130074. added: Array<XRInputSource>;
  130075. }